From 243b2ed2d3af39fe25526f19f5305ec3f0fb2d68 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Mon, 12 Nov 2007 16:55:26 +0100 Subject: [PATCH] [svn r13663] allows to edit asset items (when it's html content) FS#2052 --- main/newscorm/learnpath.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 77abf08c5e..96ea4fb4a8 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -4244,11 +4244,10 @@ class learnpath { $res = api_sql_query($sql, __FILE__, __LINE__); $row = Database::fetch_array($res); - + switch($row['item_type']) { - case 'dokeos_chapter': case 'dir' : case 'asset' : - + case 'dokeos_chapter': case 'dir' : case 'asset' : case 'sco' : if(isset($_GET['view']) && $_GET['view'] == 'build') { $return .= $this->display_manipulate($item_id, $row['item_type']); @@ -4337,6 +4336,8 @@ class learnpath { $return .= $this->display_thread_form('edit', $item_id, $row); break; + + default:echo'sdv';break; } } @@ -5455,12 +5456,15 @@ function display_thread_form($action = 'add', $id = 0, $extra_info = '') */ function display_item_form($item_type, $title = '', $action = 'add', $id = 0, $extra_info = 'new') { + global $_course; + $tbl_lp_item = Database::get_course_table('lp_item'); if($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); $item_description = stripslashes($extra_info['description']); + $item_path = api_get_path(WEB_COURSE_PATH) . $_course['path'].'/scorm/'.$this->path.'/'.stripslashes($extra_info['path']); } else { @@ -5555,6 +5559,7 @@ function display_thread_form($action = 'add', $id = 0, $extra_info = '') } $parent_select -> setSelected($s_selected_parent); + } if(is_array($arrLP)) { reset($arrLP); } @@ -5602,6 +5607,16 @@ function display_thread_form($action = 'add', $id = 0, $extra_info = '') } + $extension = pathinfo($item_path, PATHINFO_EXTENSION); + if($item_type=='asset' && ($extension == 'html' || $extension == 'htm')) + { + $renderer = $form->defaultRenderer(); + $renderer->setElementTemplate('
      {label}
{element}','content_lp'); + $form->addElement('html_editor','content_lp',''); + $defaults["content_lp"]=file_get_contents($item_path); + } + + $form->addElement('hidden', 'type', 'dokeos_'.$item_type); $form->addElement('hidden', 'post_time', time()); @@ -5612,6 +5627,7 @@ function display_thread_form($action = 'add', $id = 0, $extra_info = '') return $form->return_form(); } + /** * Enter description here... * @@ -5716,7 +5732,7 @@ function display_thread_form($action = 'add', $id = 0, $extra_info = '') $item_title = ''; $item_description = ''; } - + $return = '
'; if($id != 0 && is_array($extra_info))