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

Source for file introductionSection.inc.php

Documentation is available at introductionSection.inc.php

  1. <?php
  2.  
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2004-2005 Dokeos S.A.
  8.     Copyright (c) Bart Mollet, Hogeschool Gent
  9.  
  10.     For a full list of contributors, see "credits.txt".
  11.     The full license can be read in "license.txt".
  12.  
  13.     This program is free software; you can redistribute it and/or
  14.     modify it under the terms of the GNU General Public License
  15.     as published by the Free Software Foundation; either version 2
  16.     of the License, or (at your option) any later version.
  17.  
  18.     See the GNU General Public License for more details.
  19.  
  20.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  21.     Mail: info@dokeos.com
  22. ==============================================================================
  23. */
  24. /**
  25. ==============================================================================
  26.  * The INTRODUCTION MICRO MODULE is used to insert and edit
  27.  * an introduction section on a Dokeos Module. It can be inserted on any
  28.  * Dokeos Module, provided a connection to a course Database is already active.
  29.  *
  30.  * The introduction content are stored on a table called "introduction"
  31.  * in the course Database. Each module introduction has an Id stored on
  32.  * the table. It is this id that can make correspondance to a specific module.
  33.  *
  34.  * 'introduction' table description
  35.  *   id : int
  36.  *   intro_text :text
  37.  *
  38.  *
  39.  * usage :
  40.  *
  41.  * $moduleId = XX // specifying the module Id
  42.  * include(moduleIntro.inc.php);
  43. *
  44. *    @package dokeos.include
  45. ==============================================================================
  46. */
  47.  
  48.  
  49. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  50.  
  51. /*
  52. -----------------------------------------------------------
  53.     Constants and variables
  54. -----------------------------------------------------------
  55. */
  56. $TBL_INTRODUCTION Database::get_course_table(TABLE_TOOL_INTRO);
  57. $intro_editAllowed $is_allowed_to_edit;
  58.  
  59. global $charset;
  60. $intro_cmdEdit (empty($_GET['intro_cmdEdit'])?'':$_GET['intro_cmdEdit']);
  61. $intro_cmdUpdate (empty($_POST['intro_cmdUpdate'])?'':$_POST['intro_cmdUpdate']);
  62. $intro_cmdDel(empty($_GET['intro_cmdDel'])?'':$_GET['intro_cmdDel']);
  63. $intro_cmdAdd(empty($_GET['intro_cmdAdd'])?'':$_GET['intro_cmdAdd']);
  64.  
  65. $form new FormValidator('introduction_text');
  66. $renderer =$form->defaultRenderer();
  67. $renderer->setElementTemplate('<div style="width: 80%; margin: 0px auto;">{element}</div>');
  68.  
  69. $form->add_html_editor('intro_content',null,null,false);
  70. $form->addElement('submit','intro_cmdUpdate',get_lang('Ok'));
  71.  
  72. /*=========================================================
  73.   INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED)
  74.   ========================================================*/
  75.  
  76. if ($intro_editAllowed)
  77. {
  78.     /* Replace command */
  79.  
  80.     if$intro_cmdUpdate )
  81.     {
  82.         if$form->validate())
  83.         {
  84.             $form_values $form->exportValues();
  85.             $intro_content $form_values['intro_content'];
  86.  
  87.             if empty($intro_content) )
  88.             {
  89.                 $sql "REPLACE $TBL_INTRODUCTION SET id='$moduleId',intro_text='".mysql_real_escape_string($intro_content)."'";
  90.                 api_sql_query($sql,__FILE__,__LINE__);
  91.                 Display::display_confirmation_message(get_lang('IntroductionTextUpdated'),false);
  92.             }
  93.             else
  94.             {
  95.                 $intro_cmdDel true;    // got to the delete command
  96.             }
  97.         }
  98.         else
  99.         {
  100.         $intro_cmdEdit true;
  101.         }
  102.     }
  103.  
  104.     /* Delete Command */
  105.  
  106.     if($intro_cmdDel)
  107.     {
  108.         api_sql_query("DELETE FROM $TBL_INTRODUCTION WHERE id='".$moduleId."'",__FILE__,__LINE__);
  109.         Display::display_confirmation_message(get_lang('IntroductionTextDeleted'));
  110.     }
  111. }
  112.  
  113.  
  114. /*===========================================
  115.   INTRODUCTION MICRO MODULE - DISPLAY SECTION
  116.   ===========================================*/
  117.  
  118. /* Retrieves the module introduction text, if exist */
  119.  
  120. $sql "SELECT intro_text FROM $TBL_INTRODUCTION WHERE id='".$moduleId."'";
  121. $intro_dbQuery api_sql_query($sql,__FILE__,__LINE__);
  122. $intro_dbResult mysql_fetch_array($intro_dbQuery);
  123. $intro_content $intro_dbResult['intro_text'];
  124.  
  125. /* Determines the correct display */
  126.  
  127. if ($intro_cmdEdit || $intro_cmdAdd)
  128. {
  129.     $intro_dispDefault false;
  130.     $intro_dispForm true;
  131.     $intro_dispCommand false;
  132. }
  133. else
  134. {
  135.     $intro_dispDefault true;
  136.     $intro_dispForm false;
  137.  
  138.     if ($intro_editAllowed)
  139.     {
  140.         $intro_dispCommand true;
  141.     }
  142.     else
  143.     {
  144.         $intro_dispCommand false;
  145.     }
  146. }
  147.  
  148.  
  149. /* Executes the display */
  150.  
  151. if ($intro_dispForm)
  152. {
  153.     $default['intro_content'$intro_content;
  154.     $form->setDefaults($default);
  155.     echo '<div id="courseintro">';
  156.     $form->display();
  157.     echo '</div>';
  158. }
  159.  
  160. if ($intro_dispDefault)
  161. {
  162.     //$intro_content = make_clickable($intro_content); // make url in text clickable
  163.     $intro_content text_filter($intro_content)// parse [tex] codes
  164.     if (!empty($intro_content))
  165.     {
  166.         echo "<table align='center' style='width: 80%;'><tr><td>$intro_content</td></tr></table>";
  167.     }
  168. }
  169.  
  170. if ($intro_dispCommand)
  171. {
  172.     ifempty($intro_content) ) // displays "Add intro" Commands
  173.     {
  174.         echo    "<div id=\"courseintro\"><p>\n",
  175.                 "<a href=\"".api_get_self()."?intro_cmdAdd=1\">\n",get_lang('AddIntro'),"</a>\n",
  176.                 "</p>\n</div>";
  177.     }
  178.     else // displays "edit intro && delete intro" Commands
  179.     {
  180.         echo    "<div id=\"courseintro_icons\"><p>\n",
  181.                 "<a href=\"".api_get_self()."?intro_cmdEdit=1\"><img src=\"" api_get_path(WEB_CODE_PATH"img/edit.gif\" alt=\"",get_lang('Modify'),"\" border=\"0\" /></a>\n",
  182.                 "<a href=\"".api_get_self()."?intro_cmdDel=1\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\"><img src=\"" api_get_path(WEB_CODE_PATH"img/delete.gif\" alt=\"",get_lang('Delete'),"\" border=\"0\" /></a>\n",
  183.                 "</p>\n</div>";
  184.     }
  185. }
  186. ?>

Documentation generated on Thu, 12 Jun 2008 13:53:22 -0500 by phpDocumentor 1.4.1