Dokeos PHP Cross Reference Learning Management Systems

Source: /main/newscorm/lp_edit.php - 311 lines - 14595 bytes - Summary - Text - Print

Description: Learning Path Script allowing simple edition of learnpath information (title, description, etc)

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  
   4  /**
   5   * Learning Path
   6   * Script allowing simple edition of learnpath information (title, description, etc)
   7   * @package dokeos.learnpath
   8   * @author Yannick Warnier
   9   */
  10  
  11  // including additional libraries
  12  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  13  require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  14  
  15  // we set the encoding of the lp
  16  if (!empty($_SESSION['oLP']->encoding)) {
  17      $charset = $_SESSION['oLP']->encoding;
  18      // Check if we have a valid api encoding
  19      $valid_encodings = api_get_valid_encodings();
  20      $has_valid_encoding = false;
  21      foreach ($valid_encodings as $valid_encoding) {
  22        if (strcasecmp($charset,$valid_encoding) == 0) {
  23          $has_valid_encoding = true;
  24        }
  25      }
  26      // If the scorm packages has not a valid charset, i.e : UTF-16 we are displaying
  27      if ($has_valid_encoding === false) {
  28        $charset = api_get_system_encoding();
  29      }
  30  } else {
  31      $charset = api_get_system_encoding();
  32  }
  33  if (empty($charset)) {
  34      $charset = 'ISO-8859-1';
  35  }
  36  
  37  $show_description_field = false; //for now
  38  $nameTools = get_lang("Doc");
  39  event_access_tool(TOOL_LEARNPATH);
  40  if (! $is_allowed_in_course) api_not_allowed();
  41  
  42  if (isset($_SESSION['gradebook'])){
  43      $gradebook=    $_SESSION['gradebook'];
  44  }
  45  
  46  if (!empty($gradebook) && $gradebook=='view') {
  47      $interbreadcrumb[]= array (
  48              'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  49              'name' => get_lang('Gradebook')
  50          );
  51  }
  52  $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  53  $interbreadcrumb[]= array ("url"=>api_get_self()."?action=admin_view&lp_id=$learnpath_id", "name" => $_SESSION['oLP']->get_name());
  54  
  55  Display::display_tool_header(null,'Path');
  56  
  57  $author_lang_var = api_convert_encoding(get_lang('Author'), $charset, api_get_system_encoding());
  58  $content_lang_var = api_convert_encoding(get_lang('Content'), $charset, api_get_system_encoding());
  59  $scenario_lang_var = api_convert_encoding(get_lang('Scenario'), $charset, api_get_system_encoding());
  60  $publication_lang_var = api_convert_encoding(get_lang('Publication'), $charset, api_get_system_encoding());
  61  $export_lang_var = api_convert_encoding(get_lang('Export'), $charset, api_get_system_encoding());
  62  
  63  // actions link
  64  echo '<div class="actions">';
  65  $gradebook = Security::remove_XSS($_GET['gradebook']);
  66  echo '<a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '">' . Display::return_icon('pixel.gif', $author_lang_var, array('class' => 'toolactionplaceholdericon toolactionback')).$author_lang_var . '</a>';
  67  echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display::return_icon('pixel.gif', $content_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorcontent')).$content_lang_var . '</a>';
  68  echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&gradebook=&action=admin_view&lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display::return_icon('pixel.gif', $scenario_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorscenario')).$scenario_lang_var . '</a>';
  69  echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&gradebook=&action=edit&lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display::return_icon('pixel.gif', $publication_lang_var, array('class' => 'toolactionplaceholdericon toolsettings')).$publication_lang_var . '</a>';
  70  /*   Export  */
  71  if($_SESSION['oLP']->get_type()==1){
  72      $dsp_disk =
  73          "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=".$_SESSION['oLP']->lp_id ."'>" .Display::return_icon('pixel.gif', $export_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorexport')).$export_lang_var.
  74          "</a>";
  75  }elseif($_SESSION['oLP']->get_type()==2){
  76      $dsp_disk =
  77          "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=".$_SESSION['oLP']->lp_id ."&export_name=".replace_dangerous_char($_SESSION['oLP']->get_name(),'strict').".zip'>" .Display::return_icon('pixel.gif', $export_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorexport')).$export_lang_var.
  78          "</a>";
  79  }
  80  echo $dsp_disk;
  81  echo '</div>';
  82  
  83  $defaults=array();
  84  $form = new FormValidator('form1', 'post', 'lp_controller.php?'.api_get_cidreq());
  85  
  86  $editlpsettings_lang_var = api_convert_encoding(get_lang('EditLPSettings'), $charset, api_get_system_encoding());
  87  
  88  // form title
  89  $form->addElement('header',null, $editlpsettings_lang_var);
  90  
  91  //Title
  92  $title_lang_var = api_convert_encoding(get_lang('_title'), $charset, api_get_system_encoding());
  93  $form->addElement('text', 'lp_name', api_ucfirst($title_lang_var),array('size'=>43));
  94  $form->applyFilter('lp_name', 'html_filter');
  95  $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
  96  
  97  //Metadata
  98  //$clean_scorm_id=Security::remove_XSS($_GET['lp_id']);
  99  //$metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Scorm.'.$clean_scorm_id).'">'.get_lang('AddMetadata').'</a>';
 100  //$form->addElement('static',null,get_lang('Metadata'),$metadata_link);
 101  
 102  //Encoding
 103  $charset_lang_var = api_convert_encoding(get_lang('Charset'), $charset, api_get_system_encoding());
 104  $encoding_select = &$form->addElement('select', 'lp_encoding', $charset_lang_var);
 105  $encodings = array('UTF-8','ISO-8859-1','ISO-8859-15','cp1251','cp1252','KOI8-R','BIG5','GB2312','Shift_JIS','EUC-JP');
 106  foreach($encodings as $encoding){
 107      if (api_equal_encodings($encoding, $_SESSION['oLP']->encoding)) {
 108            $s_selected_encoding = $encoding;
 109        }
 110        $encoding_select->addOption($encoding,$encoding);
 111  }
 112  
 113  
 114  //Origin
 115  $origin_lang_var = api_convert_encoding(get_lang('Origin'), $charset, api_get_system_encoding());
 116  $origin_select = &$form->addElement('select', 'lp_maker', $origin_lang_var);
 117  $lp_orig = $_SESSION['oLP']->get_maker();
 118  
 119  include ('content_makers.inc.php');
 120  foreach($content_origins as $origin){
 121      if($lp_orig == $origin){
 122          $s_selected_origin = $origin;
 123      }
 124      $origin = api_convert_encoding($origin, $charset, api_get_system_encoding());
 125      $origin_select->addOption($origin,$origin);
 126  }
 127  
 128  
 129  //Content proximity
 130  $contprox_lang_var = api_convert_encoding(get_lang('ContentProximity'), $charset, api_get_system_encoding());
 131  $local_lang_var = api_convert_encoding(get_lang('Local'), $charset, api_get_system_encoding());
 132  $remote_lang_var = api_convert_encoding(get_lang('Remote'), $charset, api_get_system_encoding());
 133  $content_proximity_select = &$form->addElement('select', 'lp_proximity', $contprox_lang_var);
 134  $lp_prox = $_SESSION['oLP']->get_proximity();
 135  if($lp_prox != 'local'){
 136      $s_selected_proximity = 'remote';
 137  }else{
 138      $s_selected_proximity = 'local';
 139  }
 140  $content_proximity_select->addOption($local_lang_var, 'local');
 141  $content_proximity_select->addOption($remote_lang_var, 'remote');
 142  
 143  
 144  if (api_get_setting('allow_course_theme') == 'true')
 145  {
 146      $mycourselptheme=api_get_course_setting('allow_learning_path_theme');
 147      $theme_lang_var = api_convert_encoding(get_lang('Theme'), $charset, api_get_system_encoding());
 148      if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1)
 149      {
 150          //LP theme picker
 151          $theme_select = &$form->addElement('select_theme', 'lp_theme', $theme_lang_var);
 152          $form->applyFilter('lp_theme', 'trim');
 153  
 154          $s_theme = $_SESSION['oLP']->get_theme();
 155          $theme_select ->setSelected($s_theme); //default
 156      }
 157  }
 158  
 159  // Course interface
 160  $dfcourseint_lang_var = api_convert_encoding(get_lang('LpSelectDefaultCourseInterface'), $charset, api_get_system_encoding());
 161  $lpdfmode_lang_var = api_convert_encoding(get_lang('LpDefaultMode'), $charset, api_get_system_encoding());
 162  $lpoldmode_lang_var = api_convert_encoding(get_lang('LpOldInterfaceMode'), $charset, api_get_system_encoding());
 163  $lpnewmode_lang_var = api_convert_encoding(get_lang('LpNewInterfaceMode'), $charset, api_get_system_encoding());
 164  $course_interface_select = &$form->addElement('select', 'lp_interface', $dfcourseint_lang_var);
 165  $lp_interfaz = $_SESSION['oLP']->get_course_interface();
 166  if($lp_interfaz == 0){
 167      $s_selected_lp_interfaz = '0';
 168  }elseif($lp_interfaz == 2) {
 169      $s_selected_lp_interfaz = '2';
 170  }else{
 171      $s_selected_lp_interfaz = '1';
 172  }
 173  $course_interface_select->addOption($lpdfmode_lang_var, '0');
 174  $course_interface_select->addOption($lpoldmode_lang_var, '1');
 175  $course_interface_select->addOption($lpnewmode_lang_var, '2');
 176  //Author
 177  //$form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size'=>80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px') );
 178  $author_lang_var = api_convert_encoding(get_lang('Author'), $charset, api_get_system_encoding());
 179  $form->addElement('text', 'lp_author', $author_lang_var, '');
 180  $form->applyFilter('lp_author', 'html_filter');
 181  
 182  // LP image
 183  $form->add_progress_bar();
 184  if( strlen($_SESSION['oLP']->get_preview_image() ) > 0)
 185  {
 186      $imagepreview_lang_var = api_convert_encoding(get_lang('ImagePreview'), $charset, api_get_system_encoding());
 187      $delimage_lang_var = api_convert_encoding(get_lang('DelImage'), $charset, api_get_system_encoding());
 188  
 189      $show_preview_image='<img src='.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image().'>';
 190      $div = '<div class="row">
 191      <div class="label">'.$imagepreview_lang_var.'</div>
 192      <div class="formw">
 193      '.$show_preview_image.'
 194      </div>
 195      </div>';
 196      $form->addElement('html', $div .'<br/>');
 197      $form->addElement('checkbox', 'remove_picture', null, $delimage_lang_var);
 198  }
 199  $updateimage_lang_var = api_convert_encoding(get_lang('UpdateImage'), $charset, api_get_system_encoding());
 200  $addimage_lang_var = api_convert_encoding(get_lang('AddImage'), $charset, api_get_system_encoding());
 201  
 202  $form->addElement('file', 'lp_preview_image', ($_SESSION['oLP']->get_preview_image() != '' ? $updateimage_lang_var : $addimage_lang_var));
 203  
 204  $imgresize_lang_var = api_convert_encoding(get_lang('ImageWillResizeMsg'), $charset, api_get_system_encoding());
 205  $form->addElement('static', null, null, $imgresize_lang_var);
 206  
 207  
 208  if($_SESSION['oLP']->type == '3')
 209  { // then an update of source exists
 210      $updateaicc_lang_var = api_convert_encoding(get_lang('UpdateAiccSource'), $charset, api_get_system_encoding());
 211      $form->addElement('file', 'lp_update_source', $updateaicc_lang_var);
 212  }
 213  
 214  /*
 215  $form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'mimetype', array('image/gif', 'image/jpeg', 'image/png'));
 216  */
 217  $onlyimages_lang_var = api_convert_encoding(get_lang('OnlyImagesAllowed'), $charset, api_get_system_encoding());
 218  $form->addRule('lp_preview_image', $onlyimages_lang_var, 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
 219  
 220  // Search terms (only if search is activated)
 221  if (api_get_setting('search_enabled') === 'true' && extension_loaded('xapian'))
 222  {
 223      $specific_fields = get_specific_field_list();
 224      foreach ($specific_fields as $specific_field) {
 225          $form -> addElement ('text', $specific_field['code'], $specific_field['name']);
 226          $filter = array('course_code'=> "'". api_get_course_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $_SESSION['oLP']->lp_id, 'tool_id' => '\''. TOOL_LEARNPATH .'\'');
 227          $values = get_specific_field_values_list($filter, array('value'));
 228          if ( !empty($values) ) {
 229              $arr_str_values = array();
 230              foreach ($values as $value) {
 231                  $arr_str_values[] = $value['value'];
 232              }
 233              $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
 234          }
 235      }
 236  }
 237  
 238  $showdebug_lang_var = api_convert_encoding(get_lang('ShowDebug'), $charset, api_get_system_encoding());
 239  $hidedebug_lang_var = api_convert_encoding(get_lang('HideDebug'), $charset, api_get_system_encoding());
 240  $selectDebug = &$form->addElement('select', 'enable_debug', $showdebug_lang_var);
 241  $selectDebug->addOption($showdebug_lang_var, 0);
 242  $selectDebug->addOption($hidedebug_lang_var, 1);
 243  
 244  //default values
 245  $content_proximity_select -> setSelected($s_selected_proximity);
 246  $origin_select -> setSelected($s_selected_origin);
 247  $course_interface_select->  setSelected($s_selected_lp_interfaz);
 248  $encoding_select -> setSelected($s_selected_encoding);
 249  $defaults['lp_name'] = Security::remove_XSS(api_convert_encoding($_SESSION['oLP']->get_name(), $charset, api_get_system_encoding()));
 250  $defaults['lp_author'] = Security::remove_XSS(api_convert_encoding($_SESSION['oLP']->get_author(), $charset, api_get_system_encoding()));
 251  $defaults['enable_debug'] = $_SESSION['oLP']->scorm_debug;
 252  
 253  //get the keyword
 254  $searchkey = new SearchEngineManager();
 255  $keyword = $searchkey->getKeyWord(TOOL_LEARNPATH, $_SESSION['oLP']->lp_id);
 256  
 257  $defaults['search_terms'] = $keyword;
 258  if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
 259      //TODO: include language file
 260      $form -> addElement('html','<input type="hidden" name="index_document" value="1"/>'.
 261       '<input type="hidden" name="language" value="' . api_get_setting('platformLanguage') . '"/>');
 262      $form-> addElement('textarea','search_terms',get_lang('SearchKeywords'),array('cols'=>65));
 263  }
 264  
 265  //Submit button
 266  $savelp_lang_var = api_convert_encoding(get_lang('SaveLPSettings'), $charset, api_get_system_encoding());
 267  $form->addElement('style_submit_button', 'Submit',$savelp_lang_var,'class="save"');
 268  //'<img src="'.api_get_path(WEB_IMG_PATH).'accept.png'.'" alt=""/>'
 269  
 270  //Hidden fields
 271  $form->addElement('hidden', 'action', 'update_lp');
 272  $form->addElement('hidden', 'lp_id', $_SESSION['oLP']->get_id());
 273  
 274  
 275  
 276  $form->setDefaults($defaults);
 277  echo '<div id="content_with_secondary_actions">';
 278  echo '<table style="width:100%"><tr><td style="width:70%" valign="top">';
 279      $form -> display();
 280  echo '</td><td style="width:30%" valign="top">
 281  <table style="text-align: left;padding-left:20px; width: 100%;" border="0" cellpadding="2" cellspacing="2">
 282    <tbody>
 283      <tr>
 284        <td style="vertical-align: top;">'.$lpnewmode_lang_var.'</td>
 285      </tr>
 286      <tr>
 287        <td style="vertical-align: top;">'.Display::return_icon('full_screen.png',$lpnewmode_lang_var).'</td>
 288      </tr>
 289      <tr>
 290        <td style="vertical-align: top;">'.$lpdfmode_lang_var.'</td>
 291      </tr>
 292      <tr>
 293        <td style="vertical-align: top;">'.Display::return_icon('dokeos_navigation.png',$lpdfmode_lang_var).'<br>
 294      </td>
 295      </tr>
 296      <tr>
 297        <td style="vertical-align: top;">'.$lpoldmode_lang_var.'</td>
 298      </tr>
 299      <tr>
 300        <td style="vertical-align: top;">'.Display::return_icon('table_of_contents.png',$lpoldmode_lang_var).'<br>
 301      </td>
 302      </tr>
 303    </tbody>
 304  </table>
 305  </td></tr></table>';
 306  echo '</div>';
 307  // Actions bar
 308  echo '<div class="actions">';
 309  echo '</div>';
 310  Display::display_footer();
 311  ?>

title

Description

title

Description

title

Description

title

title

Body