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