lp_list.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php //$id:$
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2006 Dokeos S.A.
  6. Copyright (c) 2004 Denes Nagy
  7. Copyright (c) 2003 University of Ghent (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * This file was origially the copy of document.php, but many modifications happened since then ;
  22. * the direct file view is not any more needed, if the user uploads a scorm zip file, a directory
  23. * will be automatically created for it, and the files will be uncompressed there for example ;
  24. *
  25. * @package dokeos.learnpath
  26. * @author Yannick Warnier <ywarnier@beeznest.org>
  27. ==============================================================================
  28. */
  29. /**
  30. * Script
  31. */
  32. if(empty($lp_controller_touched) || $lp_controller_touched!=1){
  33. header('location: lp_controller.php?action=list');
  34. }
  35. require_once('back_compat.inc.php');
  36. $courseDir = api_get_course_path().'/scorm';
  37. $baseWordDir = $courseDir;
  38. require_once('learnpathList.class.php');
  39. require_once('learnpath.class.php');
  40. require_once('learnpathItem.class.php');
  41. //$charset = 'UTF-8';
  42. //$charset = 'ISO-8859-1';
  43. /**
  44. * Display initialisation and security checks
  45. */
  46. //extra javascript functions for in html head:
  47. $htmlHeadXtra[] =
  48. "<script language='javascript' type='text/javascript'>
  49. function confirmation (name)
  50. {
  51. if (confirm(\" ".get_lang('AreYouSureToDelete')." \"+ name + \" ?\"))
  52. {return true;}
  53. else
  54. {return false;}
  55. }
  56. </script>";
  57. $nameTools = get_lang("Doc");
  58. event_access_tool(TOOL_LEARNPATH);
  59. if (! $is_allowed_in_course) api_not_allowed();
  60. /**
  61. * Display
  62. */
  63. Display::display_header($nameTools,"Path");
  64. //api_display_tool_title($nameTools);
  65. /*
  66. -----------------------------------------------------------
  67. Introduction section
  68. (editable by course admins)
  69. -----------------------------------------------------------
  70. */
  71. if($my_version=='1.8'){
  72. Display::display_introduction_section(TOOL_LEARNPATH);
  73. }else{
  74. api_introductionsection(TOOL_LEARNPATH);
  75. }
  76. if(api_is_allowed_to_edit())
  77. {
  78. /*--------------------------------------
  79. DIALOG BOX SECTION
  80. --------------------------------------*/
  81. if ($dialog_box)
  82. {
  83. Display::display_normal_message($dialog_box);
  84. }
  85. if (api_failure::get_last_failure())
  86. {
  87. Display::display_normal_message(api_failure::get_last_failure());
  88. }
  89. if($_REQUEST['action']=='add_lp' && !($new_lp_id>0)){
  90. require('lp_add.php');
  91. }
  92. include('content_makers.inc.php');
  93. echo '<a href="'.$_SERVER['PHP_SELF'].'?action=add_lp">'.
  94. '<img src="../img/wizard.gif" border="0" align="absmiddle" alt="scormbuilder">&nbsp;'.get_lang('_add_learnpath').
  95. '</a>' .
  96. str_repeat('&nbsp;',3).
  97. '<a href="../upload/index.php?curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/file_zip.gif" border="0" alt="scormbuilder" align="absmiddle">&nbsp;'.get_lang("UploadScorm").'</a>';
  98. if(api_get_setting('service_ppt2lp','active')==true)
  99. {
  100. echo str_repeat('&nbsp;',3).'<a href="../upload/upload_ppt.php?curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/powerpoint.gif" border="0" alt="scormbuilder" align="absmiddle">&nbsp;'.get_lang("PowerPointConvert").'</a>';
  101. }
  102. }
  103. echo '<table width="100%" border="0" cellspacing="2" class="data_table">';
  104. api_is_allowed_to_edit() ? $colspan = 9 : $colspan = 3;
  105. /*
  106. if ($curDirName) // if the $curDirName is empty, we're in the root point and we can't go to a parent dir
  107. {
  108. ?>
  109. <!-- parent dir -->
  110. <a href="<?php echo $_SERVER['PHP_SELF'].'?'.api_get_cidreq().'&openDir='.$cmdParentDir.'&subdirs=yes'; ?>">
  111. <img src="../img/parent.gif" border="0" align="absbottom" hspace="5" alt="parent" />
  112. <?php echo get_lang("Up"); ?></a>&nbsp;
  113. <?php
  114. }
  115. */
  116. if ($curDirPath)
  117. {
  118. if(substr($curDirPath,1,1)=='/'){
  119. $tmpcurDirPath=substr($curDirPath,1,strlen($curDirPath));
  120. }else{
  121. $tmpcurDirPath = $curDirPath;
  122. }
  123. ?>
  124. <!-- current dir name -->
  125. <tr>
  126. <td colspan="<?php echo $colspan ?>" align="left" bgcolor="#4171B5">
  127. <img src="../img/opendir.gif" align="absbottom" vspace="2" hspace="3" alt="open_dir" />
  128. <font color="#ffffff"><b><?php echo $tmpcurDirPath ?></b></font>
  129. </td>
  130. </tr>
  131. <?php
  132. }
  133. /* CURRENT DIRECTORY */
  134. echo '<tr>';
  135. echo '<th>'.get_lang("Name").'</th>'."\n" .
  136. '<th>'.get_lang("progress")."</th>\n";
  137. if (api_is_allowed_to_edit())
  138. {
  139. echo "<th>",get_lang("Description"),"</th>\n" .
  140. "<th>",get_lang("ExportShort"),"</th>\n",
  141. '<th>',get_lang("Modify"),"</th>\n";
  142. }
  143. echo "</tr>\n";
  144. /*--------------------------------------
  145. DISPLAY SCORM LIST
  146. --------------------------------------*/
  147. $list = new LearnpathList(api_get_user_id());
  148. $flat_list = $list->get_flat_list();
  149. //var_dump($flat_list);
  150. if (is_array($flat_list))
  151. {
  152. $counter = 0;
  153. foreach ($flat_list as $id => $details)
  154. {
  155. $counter++;
  156. if (($counter % 2)==0) { $oddclass="row_odd"; } else { $oddclass="row_even"; }
  157. $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
  158. $name = $details['lp_name'];
  159. $image='<img src="../img/kcmdf.gif" border="0" align="absmiddle" alt="scorm">'."\n";
  160. $dsp_line = '<tr align="center" class="'.$oddclass.'">'."\n" .
  161. '<td align="left" valign="top">' .
  162. '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_lp.'" '.$style.'>' .
  163. $image . '</a></div><a href="'.$url_start_lp.'" '.$style.'>' . $name . '</a>' .
  164. "</td>\n";
  165. //$dsp_desc='<td>'.$details['lp_desc'].'</td>'."\n";
  166. $dsp_desc = '';
  167. $dsp_export = '';
  168. $dsp_edit = '';
  169. $dsp_delete = '';
  170. $dsp_visible = '';
  171. //$dsp_progress = '<td>'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id,api_get_user_id()),'%').'</td>';
  172. //temporarily removed progress bar because of display problems
  173. $dsp_progress = '<td style="padding-top:1em;">'.learnpath::get_db_progress($id,api_get_user_id(),'both').'</td>';
  174. if(api_is_allowed_to_edit())
  175. {
  176. $dsp_desc = '<td valign="middle" style="color: grey; padding-top:1em;"><em>'.$details['lp_maker'].'</em> &nbsp;&nbsp; '.$details['lp_proximity'].' &nbsp;&nbsp; '.$details['lp_encoding'].'<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'">&nbsp;&nbsp;<img src="../img/edit.gif" border="0" title="'.get_lang('_edit_learnpath').'"></a></td>'."\n";
  177. $fileExtension=explode('.',$dspFileName);
  178. $fileExtension=strtolower($fileExtension[sizeof($fileExtension)-1]);
  179. /* export */
  180. //export not available for normal lps yet
  181. if($details['lp_type']==1){
  182. $dsp_export = '<td align="center">' .
  183. "<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  184. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  185. "</a>" .
  186. "";
  187. }elseif($details['lp_type']==2){
  188. $dsp_export = '<td align="center">' .
  189. "<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
  190. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  191. "</a>" .
  192. "";
  193. }else{
  194. $dsp_export = '<td align="center">' .
  195. //"<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  196. "<img src=\"../img/cd_gray.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  197. //"</a>" .
  198. "";
  199. }
  200. /* edit title and description */
  201. $dsp_edit = '<td align="center">';
  202. /* DELETE COMMAND */
  203. $dsp_delete = "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" " .
  204. "onClick=\"return confirmation('".addslashes($dspFileName)."');\">" .
  205. "<img src=\"../img/delete.gif\" border=\"0\" title=\"".get_lang('_delete_learnpath')."\" />" .
  206. "</a>";
  207. /* VISIBILITY COMMAND */
  208. if ($details['lp_visibility'] == "i")
  209. {
  210. $dsp_visible = "<a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=v\">" .
  211. "<img src=\"../img/invisible_LP_list.gif\" border=\"0\" title=\"".get_lang('_publish')."\" />" .
  212. "</a>" .
  213. "";
  214. }
  215. else
  216. {
  217. $dsp_visible = "<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=i'>" .
  218. "<img src=\"../img/visible_LP_list.gif\" border=\"0\" title=\"".get_lang('_no_publish')."\" />" .
  219. "</a>".
  220. "";
  221. }
  222. /* Default view mode settings (fullscreen/embedded) */
  223. if($details['lp_view_mode'] == 'fullscreen'){
  224. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  225. '<img src="../img/view_fullscreen.gif" border="0" alt="'.get_lang("ViewModeEmbedded").'" title="'.get_lang("ViewModeEmbedded").'"/>' .
  226. '</a>&nbsp;';
  227. }else{
  228. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  229. '<img src="../img/view_choose.gif" border="0" alt="'.get_lang("ViewModeFullScreen").'" title="'.get_lang("ViewModeFullScreen").'"/>' .
  230. '</a>&nbsp;';
  231. }
  232. /* Increase SCORM recording */
  233. if($details['lp_force_commit'] == 1){
  234. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  235. '<img src="../img/clock.gif" border="0" alt="Normal SCORM recordings" title="'.get_lang("MakeScormRecordingNormal").'"/>' .
  236. '</a>&nbsp;';
  237. }else{
  238. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  239. '<img src="../img/clock_gray.gif" border="0" alt="Extra SCORM recordings" title="'.get_lang("MakeScormRecordingExtra").'"/>' .
  240. '</a>&nbsp;';
  241. }
  242. if($details['lp_prevent_reinit']==1){
  243. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  244. '<img src="../img/kaboodleloop.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
  245. '</a>&nbsp;';
  246. }else{
  247. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  248. '<img src="../img/kaboodleloop_gray.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
  249. '</a>&nbsp;';
  250. }
  251. if($details['lp_type']==1){
  252. $dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=build&amp;lp_id='.$id.'"><img src="../img/wizard.gif" border="0" title="'.get_lang("Build").'"></a>&nbsp;';
  253. }else{
  254. $dsp_build = '<img src="../img/wizard_gray.gif" border="0" title="'.get_lang("build").'">&nbsp;';
  255. }
  256. if($details['lp_scorm_debug']==1){
  257. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  258. '<img src="../img/bug.gif" border="0" alt="'.get_lang("HideDebug").'" title="'.get_lang("HideDebug").'"/>' .
  259. '</a>&nbsp;';
  260. }else{
  261. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  262. '<img src="../img/bug_gray.gif" border="0" alt="'.get_lang("ShowDebug").'" title="'.get_lang("ShowDebug").'"/>' .
  263. '</a>&nbsp;';
  264. }
  265. } // end if($is_allowedToEdit)
  266. //echo $dsp_line.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible;
  267. //echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_default_view.$dsp_force_commit.$dsp_debug.$dsp_delete;
  268. echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_force_commit.$dsp_delete;
  269. echo "</tr>\n";
  270. } // end foreach ($flat_list)
  271. //TODO print some user-friendly message if counter is still = 0 to tell nothing can be displayd yet
  272. }// end if ( is_array($flat_list)
  273. echo "</table>";
  274. echo "<br/><br/>";
  275. /*
  276. ==============================================================================
  277. FOOTER
  278. ==============================================================================
  279. */
  280. Display::display_footer();
  281. ?>