dokeos-learnpath
[ class tree: dokeos-learnpath ] [ index: dokeos-learnpath ] [ all elements ]

Source for file lp_list.php

Documentation is available at lp_list.php

  1. <?php //$id:$
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004-2008 Dokeos SPRL
  7.     Copyright (c) 2004 Denes Nagy
  8.     Copyright (c) 2003 Ghent University (UGent)
  9.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10.  
  11.     For a full list of contributors, see "credits.txt".
  12.     The full license can be read in "license.txt".
  13.  
  14.     This program is free software; you can redistribute it and/or
  15.     modify it under the terms of the GNU General Public License
  16.     as published by the Free Software Foundation; either version 2
  17.     of the License, or (at your option) any later version.
  18.  
  19.     See the GNU General Public License for more details.
  20.  
  21.     Contact: Dokeos, rue du Corbeau, 108, B-1000 Brussels, Belgium, info@dokeos.com
  22. ==============================================================================
  23. */
  24. /**
  25. ==============================================================================
  26. * This file was origially the copy of document.php, but many modifications happened since then ;
  27. * the direct file view is not any more needed, if the user uploads a scorm zip file, a directory
  28. * will be automatically created for it, and the files will be uncompressed there for example ;
  29. *
  30. @package dokeos.learnpath
  31. @author Yannick Warnier <ywarnier@beeznest.org>
  32. ==============================================================================
  33. */
  34. /**
  35.  * Script
  36.  */
  37.  
  38. if(empty($lp_controller_touched|| $lp_controller_touched!=1){
  39.     header('location: lp_controller.php?action=list');
  40. }
  41.  
  42. require_once('back_compat.inc.php');
  43. $courseDir   api_get_course_path().'/scorm';
  44. $baseWordDir $courseDir;
  45. $display_progress_bar true;
  46.  
  47. require_once('learnpathList.class.php');
  48. require_once('learnpath.class.php');
  49. require_once('learnpathItem.class.php');
  50. //$charset = 'UTF-8';
  51. //$charset = 'ISO-8859-1';
  52.  
  53. /**
  54.  * Display initialisation and security checks
  55.  */
  56. //extra javascript functions for in html head:
  57. $htmlHeadXtra[=
  58. "<script language='javascript' type='text/javascript'>
  59.  
  60. function confirmation(name)
  61. {
  62.     if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." ?\"))
  63.         {return true;}
  64.     else
  65.         {return false;}
  66. }
  67. </script>";
  68. $nameTools get_lang(ucfirst(TOOL_LEARNPATH));
  69.  
  70. if ($is_allowed_in_courseapi_not_allowed();
  71.  
  72. /**
  73.  * Display
  74.  */
  75. Display::display_header($nameTools,"Path");
  76. //api_display_tool_title($nameTools);
  77.  
  78. /*
  79. -----------------------------------------------------------
  80.     Introduction section
  81.     (editable by course admins)
  82. -----------------------------------------------------------
  83. */
  84.  
  85. {
  86.  
  87.  
  88.   /*--------------------------------------
  89.     DIALOG BOX SECTION
  90.     --------------------------------------*/
  91.  
  92.   if ($dialog_box)
  93.   {
  94.     Display::display_normal_message($dialog_box);
  95.   }
  96.   {
  97.   }
  98.  
  99.   //include('content_makers.inc.php');
  100.   echo    '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add_lp">'.
  101.         '<img src="../img/wizard.gif" border="0" align="absmiddle" alt="scormbuilder">&nbsp;'.get_lang('_add_learnpath').
  102.         '</a>' .
  103.         str_repeat('&nbsp;',3).
  104.         '<a href="../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/file_zip.gif" border="0" alt="scormbuilder" align="absmiddle">&nbsp;'.get_lang("UploadScorm").'</a>';
  105.         if (api_get_setting('service_ppt2lp''active'== 'true')
  106.         {
  107.             echo  str_repeat('&nbsp;',3).'<a href="../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/powerpoint.gif" border="0" alt="scormbuilder" align="absmiddle">&nbsp;'.get_lang("PowerPointConvert").'</a>';
  108.                echo  str_repeat('&nbsp;',3).'<a href="../upload/upload_word.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/word.gif" border="0" alt="scormbuilder" align="absmiddle">&nbsp;'.get_lang("WordConvert").'</a>';
  109.         }
  110.             
  111.        
  112. }
  113.  
  114. echo '<table width="100%" border="0" cellspacing="2" class="data_table">';
  115. api_is_allowed_to_edit($colspan $colspan 3;
  116.  
  117. /*
  118. if ($curDirName) // if the $curDirName is empty, we're in the root point and we can't go to a parent dir
  119. {
  120.   ?>
  121.   <!-- parent dir -->
  122.   <a href="<?php echo api_get_self().'?'.api_get_cidreq().'&openDir='.$cmdParentDir.'&subdirs=yes'; ?>">
  123.   <img src="../img/parent.gif" border="0" align="absbottom" hspace="5" alt="parent" />
  124.   <?php echo get_lang("Up"); ?></a>&nbsp;
  125.   <?php
  126. }
  127. */
  128. if ($curDirPath)
  129. {
  130.   if(substr($curDirPath,1,1)=='/'){
  131.       $tmpcurDirPath=substr($curDirPath,1,strlen($curDirPath));
  132.   }else{
  133.       $tmpcurDirPath $curDirPath;
  134.   }
  135.   ?>
  136.   <!-- current dir name -->
  137.   <tr>
  138.     <td colspan="<?php echo $colspan ?>" align="left" bgcolor="#4171B5">
  139.       <img src="../img/opendir.gif" align="absbottom" vspace="2" hspace="3" alt="open_dir" />
  140.       <font color="#ffffff"><b><?php echo $tmpcurDirPath ?></b></font>
  141.     </td>
  142.   </tr>
  143.   <?php
  144. }
  145.  
  146. /* CURRENT DIRECTORY */
  147.  
  148. echo    '<tr>';
  149. echo    '<th>'.get_lang("Name").'</th>'."\n" .
  150.         '<th>'.get_lang("Progress")."</th>\n";
  151. {
  152.   echo '<th>'.get_lang("Description")."</th>\n" .
  153.           '<th>'.get_lang("ExportShort")."</th>\n" .
  154.         '<th>'.get_lang("Modify")."</th>\n" .
  155.         '<th>'.get_lang('Move')."</th>\n";
  156. }
  157.  
  158. echo        "</tr>\n";
  159.  
  160. /*--------------------------------------
  161.       DISPLAY SCORM LIST
  162.   --------------------------------------*/
  163. $list new LearnpathList(api_get_user_id());
  164. $flat_list $list->get_flat_list();
  165. $is_allowed_to_edit api_is_allowed_to_edit();
  166. $test_mode api_get_setting('server_type');
  167. $max count($flat_list);
  168. //var_dump($flat_list);
  169. if (is_array($flat_list))
  170. {
  171.     $counter 0;
  172.     $current 0;
  173.     foreach ($flat_list as $id => $details)
  174.     {
  175.         if(!$is_allowed_to_edit && $details['lp_visibility'== 0)
  176.         {
  177.             // This is a student and this path is invisible, skip
  178.             continue;        
  179.         }
  180.         $counter++;
  181.         if (($counter 2)==0$oddclass="row_odd"else $oddclass="row_even"}
  182.  
  183.         $url_start_lp 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
  184.         $name $details['lp_name'];
  185.         $image='<img src="../img/kcmdf.gif" border="0" align="absmiddle" alt="scorm">'."\n";
  186.         $dsp_line =    '<tr align="center" class="'.$oddclass.'">'."\n" .
  187.             '<td align="left" valign="top">' .
  188.             '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_lp.'" '.$style.'>' .
  189.             $image '</a></div><a href="'.$url_start_lp.'" '.$style.'>' $name '</a>' .
  190.             "</td>\n";
  191.         //$dsp_desc='<td>'.$details['lp_desc'].'</td>'."\n";
  192.         $dsp_desc '';
  193.  
  194.         $dsp_export '';
  195.         $dsp_edit '';
  196.         $dsp_edit_close '';
  197.         $dsp_delete '';
  198.         $dsp_visible '';
  199.         $dsp_default_view '';
  200.         $dsp_debug '';
  201.         $dsp_order '';
  202.         
  203.         // Select course theme    
  204.         if (!empty($platform_theme))
  205.         {    
  206.             $mystyle=$platform_theme;
  207.         }
  208.         
  209.         if (!empty($user_theme)) 
  210.         {     
  211.             $mystyle=$user_theme;
  212.         }        
  213.                 
  214.         if (!empty($mycoursetheme)) 
  215.         {     
  216.             $mystyle=$mycoursetheme;
  217.         }
  218.         
  219.         $lp_theme_css=$mystyle;
  220.         
  221.         
  222.         if($display_progress_bar)
  223.         {
  224.             $dsp_progress '<td>'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id,api_get_user_id()),'').'</td>';
  225.         }
  226.         else
  227.         {
  228.             $dsp_progress '<td style="padding-top:1em;">'.learnpath::get_db_progress($id,api_get_user_id(),'both').'</td>';
  229.         }
  230.         if($is_allowed_to_edit)
  231.         {
  232.             $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";
  233.             $fileExtension=explode('.',$dspFileName);
  234.             $fileExtension=strtolower($fileExtension[sizeof($fileExtension)-1]);
  235.  
  236.             /* export */
  237.             //export not available for normal lps yet
  238.             if($details['lp_type']==1){
  239.                 $dsp_export '<td align="center">' .
  240.                     "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>.
  241.                     "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  242.                     "</a>" .
  243.                     "";
  244.             }elseif($details['lp_type']==2){
  245.                 $dsp_export '<td align="center">' .
  246.                     "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
  247.                     "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  248.                     "</a>" .
  249.                     "";
  250.             }else{
  251.                 $dsp_export '<td align="center">' .
  252.                     //"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  253.                     "<img src=\"../img/cd_gray.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  254.                     //"</a>" .
  255.                     "";
  256.             }
  257.             /* edit title and description */
  258.  
  259.             $dsp_edit '<td align="center">';
  260.             $dsp_edit_close '</td>';
  261.             
  262.             /* DELETE COMMAND */
  263.             $dsp_delete "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" .
  264.             "onClick=\"return confirmation('".addslashes($dspFileName)."');\">" .
  265.             "<img src=\"../img/delete.gif\" border=\"0\" title=\"".get_lang('_delete_learnpath')."\" />" .
  266.             "</a>";
  267.  
  268.             /* VISIBILITY COMMAND */
  269.  
  270.             if ($details['lp_published'== "i")
  271.             {
  272.                 $dsp_publish =    "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=v\">.
  273.                 "<img src=\"../img/visible_LP_list.gif\" border=\"0\" title=\"".get_lang('_publish')."\" />" .
  274.                 "</a>" .
  275.                 "";
  276.             }
  277.             else
  278.             {
  279.                 $dsp_publish =    "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i'>.
  280.                 "<img src=\"../img/invisible_LP_list.gif\" border=\"0\" title=\"".get_lang('_no_publish')."\" />" .
  281.                 "</a>".
  282.                 "";
  283.             }
  284.             /* VISIBILITY COMMAND */
  285.  
  286.             if ($details['lp_visibility'== 0)
  287.             {
  288.                 $dsp_visible =    "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">.
  289.                 "<img src=\"../img/invisible.gif\" border=\"0\" title=\"".get_lang('Show')."\" />" .
  290.                 "</a>" .
  291.                 "";
  292.             }
  293.             else
  294.             {
  295.                 $dsp_visible =    "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>.
  296.                 "<img src=\"../img/visible.gif\" border=\"0\" title=\"".get_lang('Hide')."\" />" .
  297.                 "</a>".
  298.                 "";
  299.             }
  300.             /* Default view mode settings (fullscreen/embedded) */
  301.             if($details['lp_view_mode'== 'fullscreen'){
  302.                 $dsp_default_view '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  303.                         '<img src="../img/view_fullscreen.gif" border="0" alt="'.get_lang("ViewModeEmbedded").'" title="'.get_lang("ViewModeEmbedded").'"/>' .
  304.                         '</a>&nbsp;';
  305.             }else{
  306.                 $dsp_default_view '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  307.                         '<img src="../img/view_choose.gif" border="0" alt="'.get_lang("ViewModeFullScreen").'" title="'.get_lang("ViewModeFullScreen").'"/>' .
  308.                         '</a>&nbsp;';
  309.             }
  310.             /* Increase SCORM recording */
  311.             /*
  312.             if($details['lp_force_commit'] == 1){
  313.                 $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  314.                         '<img src="../img/clock.gif" border="0" alt="Normal SCORM recordings" title="'.get_lang("MakeScormRecordingNormal").'"/>' .
  315.                         '</a>&nbsp;';
  316.             }else{
  317.                 $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  318.                         '<img src="../img/clock_gray.gif" border="0" alt="Extra SCORM recordings" title="'.get_lang("MakeScormRecordingExtra").'"/>' .
  319.                         '</a>&nbsp;';
  320.             }
  321.             */
  322.             if($details['lp_prevent_reinit']==1){
  323.                 $dsp_reinit '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  324.                         '<img src="../img/kaboodleloop_gray.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
  325.                         '</a>&nbsp;';
  326.             }else{
  327.                 $dsp_reinit '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  328.                         '<img src="../img/kaboodleloop.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
  329.                         '</a>&nbsp;';
  330.             }
  331.             if($details['lp_type']==|| $details['lp_type']==2){
  332.                 $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;';
  333.             }else{
  334.                 $dsp_build '<img src="../img/wizard_gray.gif" border="0" title="'.get_lang("Build").'">&nbsp;';
  335.             }
  336.             if($test_mode == 'test' or api_is_course_admin())
  337.             {
  338.                 if($details['lp_scorm_debug']==1){
  339.                     $dsp_debug '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  340.                             '<img src="../img/bug.gif" border="0" alt="'.get_lang("HideDebug").'" title="'.get_lang("HideDebug").'"/>' .
  341.                             '</a>&nbsp;';
  342.                 }else{
  343.                     $dsp_debug '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  344.                             '<img src="../img/bug_gray.gif" border="0" alt="'.get_lang("ShowDebug").'" title="'.get_lang("ShowDebug").'"/>' .
  345.                             '</a>&nbsp;';
  346.                 }
  347.             }
  348.             if($details['lp_display_order'== && $max != 1)
  349.             {
  350.                 $dsp_order .= '<td><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">' .
  351.                         '<img src="../img/arrow_down_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  352.                         '</a><img src="../img/blanco.png" border="0" alt="" title="" /></td>';
  353.             }
  354.             elseif($current == $max-&& $max != 1//last element
  355.             {
  356.                 $dsp_order .= '<td><img src="../img/blanco.png" border="0" alt="" title="" /><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_up&lp_id='.$id.'">' .
  357.                         '<img src="../img/arrow_up_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  358.                         '</a></td>';
  359.             }
  360.             elseif($max == 1)
  361.             {
  362.                 $dsp_order '<td></td>';
  363.             }
  364.             else
  365.             {
  366.                 $dsp_order .= '<td><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">' .
  367.                         '<img src="../img/arrow_down_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  368.                         '</a>&nbsp;';
  369.                 $dsp_order .= '<a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_up&lp_id='.$id.'">' .
  370.                         '<img src="../img/arrow_up_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  371.                         '</a></td>';
  372.             }
  373.         }    // end if($is_allowedToEdit)
  374.         //echo $dsp_line.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible;
  375.         echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_publish.$dsp_reinit.$dsp_default_view.$dsp_force_commit.$dsp_debug.$dsp_delete.$dsp_close.$dsp_order;
  376.         //echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_force_commit.$dsp_delete;
  377.         echo    "</tr>\n";
  378.         $current ++//counter for number of elements treated
  379.     }    // end foreach ($flat_list)
  380.     //TODO print some user-friendly message if counter is still = 0 to tell nothing can be displayd yet
  381. }// end if ( is_array($flat_list)
  382. echo "</table>";
  383. echo "<br/><br/>";
  384. /*
  385. ==============================================================================
  386.   FOOTER
  387. ==============================================================================
  388. */
  389. ?>

Documentation generated on Thu, 12 Jun 2008 14:02:54 -0500 by phpDocumentor 1.4.1