Quellcode durchsuchen

Fixing LP UI when editing a Chapter see #5593

Julio Montoya vor 12 Jahren
Ursprung
Commit
9567d2799d

+ 5 - 3
main/newscorm/learnpath.class.php

@@ -5615,7 +5615,7 @@ class learnpath {
     public function display_edit_item($item_id) {
         global $_course; // It will disappear.
         $course_id = api_get_course_int_id();
-        $return = '';
+        $return = '';        
         if (is_numeric($item_id)) {
             $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
             $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = ".$course_id." AND id = " . Database::escape_string($item_id);
@@ -7700,11 +7700,13 @@ class learnpath {
      * @param array $data
      * @return string
      */
-    public function display_item_small_form($item_type, $title = '', $data) {
-        $form = new FormValidator('small_form');
+    public function display_item_small_form($item_type, $title = '', $data = array()) {        
+        $url = api_get_self() . '?' .api_get_cidreq().'&action=edit_item&lp_id='.$this->lp_id;
+        $form = new FormValidator('small_form', 'post', $url);
         $form->addElement('header', $title);
         $form->addElement('text', 'title', get_lang('Title'));
         $form->addElement('button', 'submit_button', get_lang('Save'));
+        $form->addElement('hidden', 'id', $data['id']);
         $form->addElement('hidden', 'parent', $data['parent_item_id']);
         $form->addElement('hidden', 'previous', $data['previous_item_id']);        
         $form->setDefaults(array('title' => $data['title']));

+ 25 - 23
main/newscorm/lp_admin_view.php

@@ -21,9 +21,6 @@ api_protect_course_script();
 
 /* Libraries */
 
-// The main_api.lib.php, database.lib.php and display.lib.php
-// libraries are included by default.
-
 include 'learnpath_functions.inc.php';
 //include '../resourcelinker/resourcelinker.inc.php';
 include 'resourcelinker.inc.php';
@@ -36,7 +33,6 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 
 $tbl_lp      = Database::get_course_table(TABLE_LP_MAIN);
 $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
 
 $isStudentView  = (int) $_REQUEST['isStudentView'];
 $learnpath_id   = (int) $_REQUEST['lp_id'];
@@ -46,7 +42,7 @@ $submit			= $_POST['submit_button'];
 
 // Using the resource linker as a tool for adding resources to the learning path.
 if ($action == 'add' and $type == 'learnpathitem') {
-     $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
+     $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
 }
 if ((!$is_allowed_to_edit) || ($isStudentView)) {
     error_log('New LP - User not authorized in lp_admin_view.php');
@@ -87,24 +83,8 @@ if (isset($_REQUEST['updateaudio'])) {
 $show_learn_path = true;
 $lp_theme_css = $_SESSION['oLP']->get_theme();
 
-
-
 /* DISPLAY SECTION */
 
-switch ($_GET['action']) {
-    case 'edit_item':
-        if (isset($is_success) && $is_success === true) {
-            Display::display_confirmation_message(get_lang('LearnpathItemEdited'));
-        } else {
-            echo $_SESSION['oLP']->display_edit_item($_GET['id']);
-        }
-        break;
-    case 'delete_item':
-        if (isset($is_success) && $is_success === true) {
-            Display::display_confirmation_message(get_lang('LearnpathItemDeleted'));
-        }
-        break;
-}
 
 // POST action handling (uploading mp3, deleting mp3)
 if (isset($_POST['save_audio'])) {
@@ -187,8 +167,8 @@ if (isset($_POST['save_audio'])) {
     exit;
 }
 
-
 Display::display_header(null, 'Path');
+
 $suredel = trim(get_lang('AreYouSureToDelete'));
 
 ?>
@@ -303,7 +283,29 @@ function confirmation(name) {
 
 echo $_SESSION['oLP']->build_action_menu();
 
-echo $_SESSION['oLP']->overview();
+echo '<div class="row-fluid">';
+echo '<div class="span3">';
+echo $_SESSION['oLP']->return_new_tree(null, true); 
+echo '</div>';
+
+echo '<div class="span9">';
+switch ($_GET['action']) {
+    case 'edit_item':
+        if (isset($is_success) && $is_success === true) {
+            Display::display_confirmation_message(get_lang('LearnpathItemEdited'));
+        } else {
+            echo $_SESSION['oLP']->display_edit_item($_GET['id']);
+        }
+        break;
+    case 'delete_item':
+        if (isset($is_success) && $is_success === true) {
+            Display::display_confirmation_message(get_lang('LearnpathItemDeleted'));
+        }
+        break;
+}
+
+echo '</div>';
+echo '</div>';
 
 /* FOOTER */
 Display::display_footer();

+ 4 - 7
main/newscorm/lp_controller.php

@@ -404,13 +404,12 @@ switch ($action) {
                 //Updating the lp.modified_on
                 $_SESSION['oLP']->set_modified_on();
 
-                //$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites']);
                 // TODO: mp3 edit
                 $audio = array();
-                
-                if (isset($_FILES['mp3'])) $audio = $_FILES['mp3'];
-                
-                $_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites'], $audio, $_POST['maxTimeAllowed']);
+                if (isset($_FILES['mp3'])) {
+                    $audio = $_FILES['mp3'];
+                }
+                $_SESSION['oLP']->edit_item($_REQUEST['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites'], $audio, $_POST['maxTimeAllowed']);
 
                 if (isset($_POST['content_lp'])) {
                     $_SESSION['oLP']->edit_document($_course);
@@ -421,8 +420,6 @@ switch ($action) {
                 header('Location: '.$url);
                 exit;
             }
-        
-            
             if (isset($_GET['view']) && $_GET['view'] == 'build') {
                 require 'lp_edit_item.php';
             } else {

+ 6 - 8
main/newscorm/lp_edit_item.php

@@ -21,9 +21,6 @@ api_protect_course_script();
 
 /* Libraries */
 
-// The main_api.lib.php, database.lib.php and display.lib.php
-// libraries are included by default.
-
 include 'learnpath_functions.inc.php';
 //include '../resourcelinker/resourcelinker.inc.php';
 include 'resourcelinker.inc.php';
@@ -34,7 +31,7 @@ $language_file = 'learnpath';
 /* Header and action code */
 
 $htmlHeadXtra[] = '
-<script type="text/javascript">
+<script>
 
 function FCKeditor_OnComplete( editorInstance ) {
     document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
@@ -48,7 +45,9 @@ function InnerDialogLoaded() {
         var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
     }
     return B.ClickFrame();
-$};'.$_SESSION['oLP']->get_js_dropdown_array().'</script>';
+$};'.$_SESSION['oLP']->get_js_dropdown_array().'
+
+</script>';
 
 /* Constants and variables */
 
@@ -92,7 +91,7 @@ if (!empty($gradebook) && $gradebook == 'view') {
     $interbreadcrumb[] = array (
             'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
             'name' => get_lang('ToolGradebook')
-        );
+    );
 }
 $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
 $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
@@ -106,7 +105,7 @@ Display::display_header(get_lang('Edit'),'Path');
 $suredel = trim(get_lang('AreYouSureToDelete'));
 
 ?>
-<script type='text/javascript'>
+<script>
 /* <![CDATA[ */
 function stripslashes(str) {
     str=str.replace(/\\'/g,'\'');
@@ -131,7 +130,6 @@ function confirmation(name) {
 
 echo $_SESSION['oLP']->build_action_menu();
 
-
 echo '<div class="row-fluid">';
 echo '<div class="span3">';