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

Source for file index.php

Documentation is available at index.php

  1. <?php // $Id: index.php 15189 2008-04-30 14:58:34Z elixir_inter $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004 Dokeos SPRL
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) Bart Mollet, Hogeschool Gent
  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 address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  22.     Mail: info@dokeos.com
  23. ==============================================================================
  24. */
  25. /**
  26. ==============================================================================
  27. *    This script edits the course description.
  28. *    This script is reserved for users with write access on the course.
  29. *
  30. *    @author Thomas Depraetere
  31. *    @author Hugues Peeters
  32. *    @author Christophe Gesché
  33. *    @author Olivier brouckaert
  34. *    @package dokeos.course_description
  35. ==============================================================================
  36. */
  37.  
  38. /*
  39. ==============================================================================
  40.         INIT SECTION
  41. ==============================================================================
  42. */
  43. // name of the language file that needs to be included
  44. $language_file array ('course_description''pedaSuggest''accessibility');
  45.  
  46. include ('../inc/global.inc.php');
  47. $this_section SECTION_COURSES;
  48.  
  49. include (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  50.  
  51. include_once(api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php');
  52. /*
  53. -----------------------------------------------------------
  54.     Header
  55. -----------------------------------------------------------
  56. */
  57.  
  58. //$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
  59.  
  60. if(isset($_GET['description_id']&& $_GET['description_id']==1$interbreadcrumb[array ("url" => "#""name" => get_lang('GeneralDescription'));
  61. if(isset($_GET['description_id']&& $_GET['description_id']==2$interbreadcrumb[array ("url" => "#""name" => get_lang('Objectives'));
  62. if(isset($_GET['description_id']&& $_GET['description_id']==3$interbreadcrumb[array ("url" => "#""name" => get_lang('Topics'));
  63. if(isset($_GET['description_id']&& $_GET['description_id']==4$interbreadcrumb[array ("url" => "#""name" => get_lang('Methodology'));
  64. if(isset($_GET['description_id']&& $_GET['description_id']==5$interbreadcrumb[array ("url" => "#""name" => get_lang('CourseMaterial'));
  65. if(isset($_GET['description_id']&& $_GET['description_id']==6$interbreadcrumb[array ("url" => "#""name" => get_lang('HumanAndTechnicalResources'));
  66. if(isset($_GET['description_id']&& $_GET['description_id']==7$interbreadcrumb[array ("url" => "#""name" => get_lang('Assessment'));
  67. if(isset($_GET['description_id']&& $_GET['description_id']==8$interbreadcrumb[array ("url" => "#""name" => get_lang('NewBloc'));
  68.  
  69. $nameTools get_lang('CourseProgram');
  70. Display :: display_header($nameTools'Description');
  71. //api_display_tool_title($nameTools);
  72.  
  73.  
  74.  
  75. /*
  76. -----------------------------------------------------------
  77.     Constants and variables
  78. -----------------------------------------------------------
  79. */
  80.  
  81. $tbl_course_description Database::get_course_table(TABLE_COURSE_DESCRIPTION);
  82. $show_description_list true;
  83. $show_peda_suggest true;
  84. define('ADD_BLOCK'8);
  85. // Default descriptions
  86. $default_description_titles array();
  87. $default_description_titles[1]get_lang('GeneralDescription');
  88. $default_description_titles[2]get_lang('Objectives');
  89. $default_description_titles[3]get_lang('Topics');
  90. $default_description_titles[4]get_lang('Methodology');
  91. $default_description_titles[5]get_lang('CourseMaterial');
  92. $default_description_titles[6]get_lang('HumanAndTechnicalResources');
  93. $default_description_titles[7]get_lang('Assessment');
  94. $default_description_icon array();
  95. $default_description_icon[1]api_get_path(WEB_IMG_PATH).'/edu_miscellaneous.gif';
  96. $default_description_icon[2]api_get_path(WEB_IMG_PATH).'/spire.gif';
  97. $default_description_icon[3]api_get_path(WEB_IMG_PATH).'/kcmdf_big.gif';
  98. $default_description_icon[4]api_get_path(WEB_IMG_PATH).'/misc.gif';
  99. $default_description_icon[5]api_get_path(WEB_IMG_PATH).'/laptop.gif';
  100. $default_description_icon[6]api_get_path(WEB_IMG_PATH).'/personal.gif';
  101. $default_description_icon[7]api_get_path(WEB_IMG_PATH).'/korganizer.gif';
  102. $default_description_icon[8]api_get_path(WEB_IMG_PATH).'/ktip.gif';
  103. $question array();
  104. $question[1]get_lang('GeneralDescriptionQuestions');
  105. $question[2]get_lang('ObjectivesQuestions');
  106. $question[3]get_lang('TopicsQuestions');
  107. $question[4]get_lang('MethodologyQuestions');
  108. $question[5]get_lang('CourseMaterialQuestions');
  109. $question[6]get_lang('HumanAndTechnicalResourcesQuestions');
  110. $question[7]get_lang('AssessmentQuestions');
  111. $information array();
  112. $information[1]get_lang('GeneralDescriptionInformation');
  113. $information[2]get_lang('ObjectivesInformation');
  114. $information[3]get_lang('TopicsInformation');
  115. $information[4]get_lang('MethodologyInformation');
  116. $information[5]get_lang('CourseMaterialInformation');
  117. $information[6]get_lang('HumanAndTechnicalResourcesInformation');
  118. $information[7]get_lang('AssessmentInformation');
  119. $default_description_title_editable array();
  120. $default_description_title_editable[1false;
  121. $default_description_title_editable[2true;
  122. $default_description_title_editable[3true;
  123. $default_description_title_editable[4true;
  124. $default_description_title_editable[5true;
  125. $default_description_title_editable[6true;
  126. $default_description_title_editable[7true;
  127.  
  128.  
  129. /*
  130. ==============================================================================
  131.         MAIN CODE
  132. ==============================================================================
  133. */
  134. $description_id = isset ($_REQUEST['description_id']intval($_REQUEST['description_id']null;
  135. if (api_is_allowed_to_edit(&& !is_null($description_id))
  136. {
  137.     // Delete a description block
  138.     if (isset ($_GET['action']&& $_GET['action'== 'delete')
  139.     {
  140.         $sql "DELETE FROM $tbl_course_description WHERE id='$description_id'";
  141.         api_sql_query($sql__FILE____LINE__);
  142.         Display :: display_confirmation_message(get_lang('CourseDescriptionDeleted'));
  143.     }
  144.     // Add or edit a description block
  145.     else
  146.     {
  147.         $sql "SELECT * FROM $tbl_course_description WHERE id='$description_id'";
  148.         $result api_sql_query($sql__FILE____LINE__);
  149.         if ($description mysql_fetch_array($result))
  150.         {
  151.             $default_description_titles[$description_id$description['title'];
  152.             $description_content $description['content'];
  153.         }
  154.         
  155.         $fck_attribute['Width''100%';
  156.         $fck_attribute['Height''225';
  157.         $fck_attribute['ToolbarSet''Middle';
  158.         
  159.         echo '
  160.         <style>
  161.         .row{
  162.             width:100%;
  163.         }
  164.         div.row div.label {
  165.             width: 60px;
  166.         }
  167.         
  168.         div.row div.formw {
  169.             width: 100%;
  170.         }
  171.         </style>';
  172.         
  173.         // Build the form
  174.         $form new FormValidator('course_description','POST','index.php','','style="width: 100%;"');
  175.         $form->addElement('hidden''description_id');
  176.         if (($description_id == ADD_BLOCK|| $default_description_title_editable[$description_id])
  177.         {
  178.             $form->add_textfield('title'get_lang('Title')truearray('style'=>'width: 350px;'));
  179.         }
  180.         
  181.         if (api_get_setting('wcag_anysurfer_public_pages')=='true'{
  182.             WCAG_rendering::prepare_admin_form($description_content$form);
  183.         else {
  184.             $form->add_html_editor('contentDescription'get_lang('Content'));
  185.         }
  186.         $form->addElement('submit'nullget_lang('Ok'));
  187.         // Set some default values
  188.         $default['title'$default_description_titles[$description_id];
  189.         $default['contentDescription'$description_content;
  190.         $default['description_id'$description_id;
  191.         if($description_id == ADD_BLOCK$default['description_id'ADD_BLOCK;
  192.         $form->setDefaults($default);
  193.         // If form validates: save the description block
  194.         if ($form->validate())
  195.         {
  196.             $description $form->exportValues();
  197.             if (api_get_setting('wcag_anysurfer_public_pages')=='true'{
  198.                 $content WCAG_Rendering::prepareXHTML();
  199.             else {
  200.                 $content $description['contentDescription'];
  201.             }
  202.             $title $description['title'];
  203.             if ($description['description_id'== ADD_BLOCK)
  204.             {
  205.                 $sql "SELECT MAX(id) FROM $tbl_course_description";
  206.                 $result api_sql_query($sql__FILE____LINE__);
  207.                 $sql "INSERT IGNORE INTO $tbl_course_description SET id = '".$description_id."', title = '".mysql_real_escape_string($title)."', content = '".mysql_real_escape_string($content)."'";
  208.                 api_sql_query($sql__FILE____LINE__);
  209.             }
  210.             else
  211.             {
  212.                 if (!$default_description_title_editable[$description_id])
  213.                 {
  214.                     $title $default_description_titles[$description_id];
  215.                 }
  216.                 $sql "DELETE FROM $tbl_course_description WHERE id = '".$description_id."'";
  217.                 api_sql_query($sql__FILE____LINE__);
  218.                 $sql "INSERT IGNORE INTO $tbl_course_description SET id = '".$description_id."', title = '".mysql_real_escape_string($title)."', content = '".mysql_real_escape_string($content)."'";
  219.                 api_sql_query($sql__FILE____LINE__);
  220.             }
  221.             Display :: display_confirmation_message(get_lang('CourseDescriptionUpdated'));
  222.         }
  223.         // Show the form
  224.         else
  225.         {
  226.             if ($show_peda_suggest)
  227.             {
  228.                 echo '<dl>';
  229.                 if (isset ($question[$description_id]))
  230.                 {
  231.                     echo '<dt><b>'.get_lang('QuestionPlan').'</b></dt>';
  232.                     echo '<dd>'.$question[$description_id].'</dd>';
  233.                 }
  234.                 if (isset ($information[$description_id]))
  235.                 {
  236.                     //echo '<dt><b>'.get_lang('Info2Say').'</b></dt>';
  237.                     //echo '<dd>'.$information[$description_id].'</dd>';
  238.                 }
  239.                 echo '</dl>';
  240.             }
  241.             if (api_get_setting('wcag_anysurfer_public_pages')=='true'{
  242.                 echo (WCAG_Rendering::editor_header());
  243.             }
  244.             $form->display();
  245.             if (api_get_setting('wcag_anysurfer_public_pages')=='true'{
  246.                 echo (WCAG_Rendering::editor_footer());
  247.             }
  248.             $show_description_list false;
  249.         }
  250.     }
  251. }
  252.  
  253. // Show the list of all description blocks
  254. if ($show_description_list)
  255. {
  256.     $sql "SELECT * FROM $tbl_course_description ORDER BY id";
  257.     $result api_sql_query($sql__FILE____LINE__);
  258.     $descriptions;
  259.     while ($description mysql_fetch_object($result))
  260.     {
  261.         $descriptions[$description->id$description;
  262.     }
  263.     if (api_is_allowed_to_edit())
  264.     {
  265.         echo '<div style="position: relative;width: 500px;">';
  266.         Display::display_normal_message(get_lang('CourseDescriptionIntro'),false);
  267.         echo "</div>";
  268.         $categories array ();
  269.         
  270.         foreach ($default_description_titles as $id => $title)
  271.         {
  272.             $categories[$id$title;
  273.         }
  274.         $categories[ADD_BLOCKget_lang('NewBloc');
  275.         
  276.         $i=1;
  277.         foreach ($categories as $id => $title){
  278.             if($i==|| $i==5){
  279.                 echo '<div style="padding-bottom: 5px;margin-bottom: 0px;">';
  280.             }
  281.             echo '<div style="float: left;width:150px; text-align:center; margin-right: 5px;">
  282.                     <a href="'.api_get_self().'?'.api_get_cidreq().'&description_id='.$id.'"><img src="'.$default_description_icon[$id].'" /><br>'.$title.'</a>
  283.                 </div>';
  284.             if($i==|| $i==8){
  285.                 echo '<div style="clear: both"></div></div>';
  286.             }
  287.             $i++;
  288.         }
  289.         
  290.         echo '<br>';
  291.     }
  292.     if (isset($descriptions&& count($descriptions0)
  293.     {
  294.         foreach ($descriptions as $id => $description)
  295.         {
  296.             echo '<hr noshade="noshade" size="1"/>';
  297.             echo '<div>';
  298.             if (api_is_allowed_to_edit())
  299.             {
  300.                 
  301.                 //delete
  302.                 echo '<a href="'.api_get_self().'?action=delete&amp;description_id='.$description->id.'" onclick="javascript:if(!confirm(\''.addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
  303.                 echo '<img src="../img/delete.gif" alt="'.get_lang("Delete").'" border="0" style="vertical-align:middle;float:right;margin:2px;" />';
  304.                 echo '</a> ';
  305.                 
  306.                 
  307.                 //edit
  308.                 echo '<a href="'.api_get_self().'?action=edit&amp;description_id='.$description->id.'">';
  309.                 echo '<img src="../img/edit.gif" alt="'.get_lang("Edit").'" border="0" style="vertical-align:middle;float:right;margin:2px;" />';
  310.                 echo '</a> ';
  311.             }
  312.             echo '<h3>'.$description->title.'</h3>';
  313.             echo '</div>';
  314.             echo text_filter($description->content);
  315.         }
  316.     }
  317.     else
  318.     {
  319.         echo '<br /><em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
  320.     }
  321. }
  322. /*
  323. ==============================================================================
  324.         FOOTER
  325. ==============================================================================
  326. */
  327. ?>

Documentation generated on Thu, 12 Jun 2008 13:49:14 -0500 by phpDocumentor 1.4.1