lp_list.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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 '<table border="0" cellspacing="2" cellpadding="4">
  94. <tr>
  95. <td style="padding-bottom: 15px;">' .
  96. '<a href="'.$_SERVER['PHP_SELF'].'?action=add_lp">'.
  97. '<img src="../img/scormbuilder.gif" border="0" align="absmiddle" alt="scormbuilder">'.get_lang('_add_learnpath').
  98. '</a>' .
  99. str_repeat('&nbsp',10)."</td>".
  100. "<td>" .
  101. /*--------------------------------------
  102. UPLOAD SECTION - displays file upload box
  103. --------------------------------------*/
  104. '<form name="ext_upload" action="../upload/index.php" method="post">' .
  105. '<input type="hidden" name="curdirpath" value="/">' .
  106. '<input type="hidden" name="tool" value="'.TOOL_LEARNPATH.'">' .
  107. '<img src="../img/scormbuilder.gif" border="0" align="absmiddle" alt="scormbuilder" style="margin-top:-10px;">'.
  108. '<input type="submit" name="upload" value="Upload">' .
  109. '</form>'.
  110. "</td>" .
  111. "</tr>
  112. </table>";
  113. }
  114. echo '<table width="100%" border="0" cellspacing="2" class="data_table">';
  115. api_is_allowed_to_edit() ? $colspan = 9 : $colspan = 3;
  116. /*
  117. if ($curDirName) // if the $curDirName is empty, we're in the root point and we can't go to a parent dir
  118. {
  119. ?>
  120. <!-- parent dir -->
  121. <a href="<?php echo $_SERVER['PHP_SELF'].'?'.api_get_cidreq().'&openDir='.$cmdParentDir.'&subdirs=yes'; ?>">
  122. <img src="../img/parent.gif" border="0" align="absbottom" hspace="5" alt="parent" />
  123. <?php echo get_lang("Up"); ?></a>&nbsp;
  124. <?php
  125. }
  126. */
  127. if ($curDirPath)
  128. {
  129. if(substr($curDirPath,1,1)=='/'){
  130. $tmpcurDirPath=substr($curDirPath,1,strlen($curDirPath));
  131. }else{
  132. $tmpcurDirPath = $curDirPath;
  133. }
  134. ?>
  135. <!-- current dir name -->
  136. <tr>
  137. <td colspan="<?php echo $colspan ?>" align="left" bgcolor="#4171B5">
  138. <img src="../img/opendir.gif" align="absbottom" vspace="2" hspace="3" alt="open_dir" />
  139. <font color="#ffffff"><b><?php echo $tmpcurDirPath ?></b></font>
  140. </td>
  141. </tr>
  142. <?php
  143. }
  144. /* CURRENT DIRECTORY */
  145. echo '<tr bgcolor="'.$color2.'" align="center" valign="top">';
  146. echo '<td width="30%"><b>'.get_lang("Name").'</b></td>'."\n" .
  147. '<td width="10%"><b>'.get_lang("progress")."</b></td>\n";
  148. if (api_is_allowed_to_edit())
  149. {
  150. echo "<td><b>",get_lang("Description"),"</b></td>\n" .
  151. "<td><b>",get_lang("ExportShort"),"</b></td>\n",
  152. '<td width="25%"><b>',get_lang("Modify"),"</b></td>\n";
  153. }
  154. echo "</tr>\n";
  155. /*--------------------------------------
  156. DISPLAY SCORM LIST
  157. --------------------------------------*/
  158. $list = new LearnpathList(api_get_user_id());
  159. $flat_list = $list->get_flat_list();
  160. //var_dump($flat_list);
  161. if (is_array($flat_list))
  162. {
  163. $counter = 0;
  164. foreach ($flat_list as $id => $details)
  165. {
  166. $counter++;
  167. if (($counter % 2)==0) { $oddclass="row_odd"; } else { $oddclass="row_even"; }
  168. $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
  169. $name = $details['lp_name'];
  170. $image='<img src="../img/scorm_logo.gif" border="0" align="absmiddle" alt="scorm">'."\n";
  171. $dsp_line = '<tr align="center" class="'.$oddclass.'">'."\n" .
  172. '<td align="left" valign="middle">&nbsp;' .
  173. '<a href="'.$url_start_lp.'" '.$style.'>' .
  174. $image . '</a>&nbsp;<a href="'.$url_start_lp.'" '.$style.'>' . $name . '</a>' .
  175. "</td>\n";
  176. //$dsp_desc='<td>'.$details['lp_desc'].'</td>'."\n";
  177. $dsp_desc = '';
  178. $dsp_export = '';
  179. $dsp_edit = '';
  180. $dsp_delete = '';
  181. $dsp_visible = '';
  182. //$dsp_progress = '<td>'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id,api_get_user_id()),'%').'</td>';
  183. //temporarily removed progress bar because of display problems
  184. $dsp_progress = '<td style="padding-top:1em;">'.learnpath::get_db_progress($id,api_get_user_id(),'both').'</td>';
  185. if(api_is_allowed_to_edit())
  186. {
  187. $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'].'</td>'."\n";
  188. $fileExtension=explode('.',$dspFileName);
  189. $fileExtension=strtolower($fileExtension[sizeof($fileExtension)-1]);
  190. /* export */
  191. //export not available for normal lps yet
  192. if($details['lp_type']==1){
  193. $dsp_export = '<td align="center">' .
  194. //"<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  195. "<img src=\"../img/save_zip.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  196. //"</a>" .
  197. "";
  198. }elseif($details['lp_type']==2){
  199. $dsp_export = '<td align="center">' .
  200. "<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
  201. "<img src=\"../img/save_zip.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  202. "</a>" .
  203. "";
  204. }else{
  205. $dsp_export = '<td align="center">' .
  206. //"<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  207. "<img src=\"../img/save_zip.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  208. //"</a>" .
  209. "";
  210. }
  211. /* edit title and description */
  212. $dsp_edit = '<td align="center">' .
  213. '<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'"><img src="../img/edit.gif" border="0" title="'.get_lang('_edit_learnpath').'"></a>';
  214. /* DELETE COMMAND */
  215. $dsp_delete = "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" " .
  216. "onClick=\"return confirmation('".addslashes($dspFileName)."');\">" .
  217. "<img src=\"../img/delete.gif\" border=\"0\" title=\"".get_lang('_delete_learnpath')."\" />" .
  218. "</a>";
  219. /* VISIBILITY COMMAND */
  220. if ($details['lp_visibility'] == "i")
  221. {
  222. $dsp_visible = "<a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=v\">" .
  223. "<img src=\"../img/invisible.gif\" border=\"0\" title=\"".get_lang('_publish')."\" />" .
  224. "</a>" .
  225. "";
  226. }
  227. else
  228. {
  229. $dsp_visible = "<a href='".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=i'>" .
  230. "<img src=\"../img/visible.gif\" border=\"0\" title=\"".get_lang('_no_publish')."\" />" .
  231. "</a>".
  232. "";
  233. }
  234. /* Default view mode settings (fullscreen/embedded) */
  235. if($details['lp_view_mode'] == 'fullscreen'){
  236. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  237. '<img src="scorm_fullscreen.gif" border="0" alt="View mode: embedded" title="Make mode embedded"/>' .
  238. '</a>';
  239. }else{
  240. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  241. '<img src="scorm_embed.gif" border="0" alt="View mode: fullscreen" title="Make mode fullscreen"/>' .
  242. '</a>';
  243. }
  244. /* Increase SCORM recording */
  245. if($details['lp_force_commit'] == 1){
  246. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  247. '<img src="scorm_extra.gif" border="0" alt="Normal SCORM recordings" title="Make SCORM recordings normal"/>' .
  248. '</a>';
  249. }else{
  250. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  251. '<img src="scorm_normal.gif" border="0" alt="Extra SCORM recordings" title="Make SCORM recordings extra"/>' .
  252. '</a>';
  253. }
  254. if($details['lp_prevent_reinit']==1){
  255. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  256. '<img src="scorm_no_reinit.gif" border="0" alt="Allow reinit" title="Allow multiple attempts"/>' .
  257. '</a>';
  258. }else{
  259. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  260. '<img src="scorm_reinit.gif" border="0" alt="Prevent reinit" title="Prevent multiple attempts"/>' .
  261. '</a>';
  262. }
  263. if($details['lp_type']==1){
  264. $dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=build&amp;lp_id='.$id.'"><img src="scorm_build.gif" border="0" title="Build"></a>';
  265. }else{
  266. $dsp_build = '<img src="scorm_build_disabled.gif" border="0" title="Build">';
  267. }
  268. if($details['lp_scorm_debug']==1){
  269. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  270. '<img src="../img/info.gif" height="25px" width="25px" border="0" alt="Hide debug" title="Hide debug"/>' .
  271. '</a>';
  272. }else{
  273. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  274. '<img src="../img/info_na.gif" height="25px" width="25px" border="0" alt="Show debug" title="Show debug"/>' .
  275. '</a>';
  276. }
  277. } // end if($is_allowedToEdit)
  278. //echo $dsp_line.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible;
  279. echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible.$dsp_default_view.$dsp_force_commit.$dsp_build.$dsp_reinit.$dsp_debug;
  280. echo "</tr>\n";
  281. } // end foreach ($flat_list)
  282. //TODO print some user-friendly message if counter is still = 0 to tell nothing can be displayd yet
  283. }// end if ( is_array($flat_list)
  284. echo "</table>";
  285. echo "<br/><br/>";
  286. /*
  287. ==============================================================================
  288. FOOTER
  289. ==============================================================================
  290. */
  291. Display::display_footer();
  292. ?>