index.php 12 KB

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