Dokeos PHP Cross Reference Learning Management Systems

Source: /main/inc/lib/display.lib.php - 834 lines - 29639 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3  *    Display class
   4  *    contains several public functions dealing with the display of
   5  *    table data, messages, help topics, ...
   6  *
   7  *    @version 1.0.4
   8  *    @package dokeos.library
   9  */
  10  require_once  'sortabletable.class.php';
  11  class Display {
  12  	private function __construct() {
  13  
  14      }
  15      /**
  16      * Displays the tool introduction of a tool.
  17      *
  18      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  19      * @param string $tool These are the constants that are used for indicating the tools.
  20      * @param array $editor_config Optional configuration settings for the online editor.
  21      * @return $tool return a string array list with the "define" in main_api.lib
  22      * @return html code for adding an introduction
  23      */
  24  	public static function display_introduction_section ($tool, $editor_config = null) {
  25          $is_allowed_to_edit = api_is_allowed_to_edit();
  26          $moduleId = $tool;
  27          if (api_get_setting('enable_tool_introduction') == 'true' || $tool==TOOL_COURSE_HOMEPAGE)
  28          {
  29              include (api_get_path(INCLUDE_PATH)."introductionSection.inc.php");
  30          }
  31      }
  32  
  33      /**
  34      *    Displays a localised html file
  35      *    tries to show the file "$full_file_name"."_".$language_interface.".html"
  36      *    and if this does not exist, shows the file "$full_file_name".".html"
  37      *    warning this public function defines a global
  38      *    @param $full_file_name, the (path) name of the file, without .html
  39      *    @return return a string with the path
  40      */
  41  	public static function display_localised_html_file ($full_file_name) {
  42          global $language_interface;
  43          $localised_file_name = $full_file_name."_".$language_interface.".html";
  44          $default_file_name = $full_file_name.".html";
  45          if (file_exists($localised_file_name))
  46          {
  47              include ($localised_file_name);
  48          }
  49          else
  50          {
  51              include ($default_file_name); //default
  52          }
  53      }
  54  
  55      /**
  56      *    Display simple html header of table.
  57      */
  58  	public static function display_table_header () {
  59          $bgcolor = "bgcolor='white'";
  60          echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"85%\"><tbody>";
  61          return $bgcolor;
  62      }
  63  
  64      /**
  65       * Gets a nice grid in html string
  66       * @param string grid name (important to create css)
  67       * @param array header content
  68       * @param array array with the information to show
  69       * @param array $paging_options Keys are:
  70       *                     'per_page_default' = items per page when switching from
  71       *                                          full-    list to per-page-view
  72       *                     'per_page' = number of items to show per page
  73       *                     'page_nr' = The page to display
  74       *                     'hide_navigation' =  true to hide the navigation
  75       * @param array $query_vars Additional variables to add in the query-string
  76       * @param array $form actions Additional variables to add in the query-string
  77       * @param mixed An array with bool values to know which columns show. i.e: $vibility_options= array(true, false) we will only show the first column
  78       *                 Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
  79       * @param bool  true for sorting data or false otherwise
  80       * @return     string   html grid
  81       */
  82  	public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $vibility_options = true, $sort_data = true) {
  83          if (!class_exists('SortableTable')) {
  84              require_once  'sortabletable.class.php';
  85          }
  86          global $origin;
  87          $column =  0;
  88          $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
  89          $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
  90  
  91          if (is_array($query_vars)) {
  92              $table->set_additional_parameters($query_vars);
  93          }
  94          return $table->return_simple_grid($vibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
  95      }
  96  
  97      /**
  98      *    Display html header of table with several options.
  99      *
 100      *    @param $properties, array with elements, all of which have defaults
 101      *    "width" - the table width, e.g. "100%", default is 85%
 102      *    "class"     - the class to use for the table, e.g. "class=\"data_table\""
 103      *   "cellpadding"  - the extra border in each cell, e.g. "8",default is 4
 104      *   "cellspacing"  - the extra space between cells, default = 0
 105      *    @param column_header, array with the header elements.
 106      *    @author Roan Embrechts
 107      *    @version 1.01
 108      *    @return return type string, bgcolor
 109      */
 110  	public static function display_complex_table_header ($properties, $column_header) {
 111          $width = $properties["width"];
 112          if (!isset ($width))
 113              $width = "85%";
 114          $class = $properties["class"];
 115          if (!isset ($class))
 116              $class = "class=\"data_table\"";
 117          $cellpadding = $properties["cellpadding"];
 118          if (!isset ($cellpadding))
 119              $cellpadding = "4";
 120          $cellspacing = $properties["cellspacing"];
 121          if (!isset ($cellspacing))
 122              $cellspacing = "0";
 123          //... add more properties as you see fit
 124          //api_display_debug_info("Dokeos light grey is " . DOKEOSLIGHTGREY);
 125          $bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
 126          echo "<table $class border=\"0\" cellspacing=\"$cellspacing\" cellpadding=\"$cellpadding\" width=\"$width\">\n";
 127          echo "<thead><tr $bgcolor>";
 128          foreach ($column_header as $table_element)
 129          {
 130              echo "<th>".$table_element."</th>";
 131          }
 132          echo "</tr></thead>\n";
 133          echo "<tbody>\n";
 134          $bgcolor = "bgcolor='".HTML_WHITE."'";
 135          return $bgcolor;
 136      }
 137  
 138      /**
 139      *    Displays a table row.
 140      *
 141      *    @param $bgcolor the background colour for the table
 142      *    @param $table_row an array with the row elements
 143      *    @param $is_alternating true: the row colours alternate, false otherwise
 144      */
 145  	public static function display_table_row ($bgcolor, $table_row, $is_alternating = true) {
 146          echo "<tr $bgcolor>";
 147          foreach ($table_row as $table_element)
 148          {
 149              echo "<td>".$table_element."</td>";
 150          }
 151          echo "</tr>\n";
 152          if ($is_alternating)
 153          {
 154              if ($bgcolor == "bgcolor='".HTML_WHITE."'")
 155              {
 156                  $bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
 157              }
 158              else
 159              {
 160                  if ($bgcolor == "bgcolor='".DOKEOSLIGHTGREY."'")
 161                  {
 162                      $bgcolor = "bgcolor='".HTML_WHITE."'";
 163                  }
 164              }
 165          }
 166          return $bgcolor;
 167      }
 168  
 169      /**
 170      *    Displays a table row.
 171      *    This public function has more options and is easier to extend than display_table_row()
 172      *
 173      *    @param $properties, array with properties:
 174      *    ["bgcolor"] - the background colour for the table
 175      *    ["is_alternating"] - true: the row colours alternate, false otherwise
 176      *    ["align_row"] - an array with, per cell, left|center|right
 177      *    @todo add valign property
 178      */
 179  	public static function display_complex_table_row ($properties, $table_row) {
 180          $bgcolor = $properties["bgcolor"];
 181          $is_alternating = $properties["is_alternating"];
 182          $align_row = $properties["align_row"];
 183          echo "<tr $bgcolor>";
 184          $number_cells = count($table_row);
 185          for ($i = 0; $i < $number_cells; $i ++)
 186          {
 187              $cell_data = $table_row[$i];
 188              $cell_align = $align_row[$i];
 189              echo "<td align=\"$cell_align\">".$cell_data."</td>";
 190          }
 191          echo "</tr>\n";
 192          if ($is_alternating)
 193          {
 194              if ($bgcolor == "bgcolor='".HTML_WHITE."'")
 195                  $bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
 196              else
 197                  if ($bgcolor == "bgcolor='".DOKEOSLIGHTGREY."'")
 198                      $bgcolor = "bgcolor='".HTML_WHITE."'";
 199          }
 200          return $bgcolor;
 201      }
 202  
 203      /**
 204      *    display html footer of table
 205      */
 206  	public static function display_table_footer() {
 207          echo "</tbody></table>";
 208      }
 209  
 210      /**
 211       * Display a table
 212       * @param array $header Titles for the table header
 213       *                         each item in this array can contain 3 values
 214       *                         - 1st element: the column title
 215       *                         - 2nd element: true or false (column sortable?)
 216       *                         - 3th element: additional attributes for
 217       *                          th-tag (eg for column-width)
 218       *                         - 4the element: additional attributes for the td-tags
 219       * @param array $content 2D-array with the tables content
 220       * @param array $sorting_options Keys are:
 221       *                     'column' = The column to use as sort-key
 222       *                     'direction' = SORT_ASC or SORT_DESC
 223       * @param array $paging_options Keys are:
 224       *                     'per_page_default' = items per page when switching from
 225       *                                          full-    list to per-page-view
 226       *                     'per_page' = number of items to show per page
 227       *                     'page_nr' = The page to display
 228       * @param array $query_vars Additional variables to add in the query-string
 229       * @param string The style that the table will show. You can set 'table' or 'grid'  
 230       * @author bart.mollet@hogent.be
 231       */
 232  	public static function display_sortable_table ($header, $content, $sorting_options = array (), $paging_options = array (), $query_vars = null, $form_actions=array(), $style='table') {
 233          global $origin;
 234          $column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
 235          $default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
 236  
 237          $table = new SortableTableFromArray($content, $column, $default_items_per_page);
 238  
 239          if (is_array($query_vars)) {
 240              $table->set_additional_parameters($query_vars);
 241          }
 242          if ($style=='table') {
 243              if (is_array($header) && count($header)>0 ) {
 244                  foreach ($header as $index => $header_item) {
 245                      $table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
 246                  }
 247              }
 248              $table->set_form_actions($form_actions);    
 249              $table->display();            
 250          } else {
 251              $table->display_grid();    
 252          }        
 253      }
 254      /**
 255       * Shows a nice grid 
 256       * @param string grid name (important to create css)
 257       * @param array header content
 258       * @param array array with the information to show
 259       * @param array $paging_options Keys are:
 260       *                     'per_page_default' = items per page when switching from
 261       *                                          full-    list to per-page-view
 262       *                     'per_page' = number of items to show per page
 263       *                     'page_nr' = The page to display
 264       *                     'hide_navigation' =  true to hide the navigation
 265       * @param array $query_vars Additional variables to add in the query-string
 266       * @param array $form actions Additional variables to add in the query-string
 267       * @param mixed An array with bool values to know which columns show. i.e: $vibility_options= array(true, false) we will only show the first column
 268       *                 Can be also only a bool value. TRUE: show all columns, FALSE: show nothing 
 269       */
 270                   
 271  	public static function display_sortable_grid ($name, $header, $content, $paging_options = array (), $query_vars = null, $form_actions=array(), $vibility_options = true) {
 272          global $origin;
 273          $column =  0;
 274          $default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
 275          $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);        
 276          
 277          if (is_array($query_vars)) {
 278              $table->set_additional_parameters($query_vars);
 279          }        
 280          $table->display_simple_grid($vibility_options, $paging_options['hide_navigation']);        
 281      }
 282      
 283  
 284  
 285      /**
 286       * Display a table with a special configuration
 287       * @param array $header Titles for the table header
 288       *                         each item in this array can contain 3 values
 289       *                         - 1st element: the column title
 290       *                         - 2nd element: true or false (column sortable?)
 291       *                         - 3th element: additional attributes for
 292       *                          th-tag (eg for column-width)
 293       *                         - 4the element: additional attributes for the td-tags
 294       * @param array $content 2D-array with the tables content
 295       * @param array $sorting_options Keys are:
 296       *                     'column' = The column to use as sort-key
 297       *                     'direction' = SORT_ASC or SORT_DESC
 298       * @param array $paging_options Keys are:
 299       *                     'per_page_default' = items per page when switching from
 300       *                                          full-    list to per-page-view
 301       *                     'per_page' = number of items to show per page
 302       *                     'page_nr' = The page to display
 303       * @param array $query_vars Additional variables to add in the query-string
 304       * @param array $column_show Array of binaries 1= show columns 0. hide a column
 305       * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
 306       *                               i.e:  $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
 307       * @param array $form_actions Set optional forms actions
 308       *
 309       * @author Julio Montoya
 310       */
 311  
 312  	public static function display_sortable_config_table ($header, $content, $sorting_options = array (), $paging_options = array (), $query_vars = null, $column_show=array(),$column_order=array(),$form_actions=array()) {
 313          global $origin;
 314          $column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
 315          $default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
 316  
 317          $table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page,'tablename',$column_show,$column_order);
 318  
 319          if (is_array($query_vars)) {
 320              $table->set_additional_parameters($query_vars);
 321          }
 322          // show or hide the columns header
 323          if (is_array($column_show) )
 324          {
 325              for ($i=0;$i<count($column_show);$i++)
 326              {
 327                  if (!empty($column_show[$i]))
 328                  {
 329                      isset($header[$i][0])?$val0=$header[$i][0]:$val0=null;
 330                      isset($header[$i][1])?$val1=$header[$i][1]:$val1=null;
 331                      isset($header[$i][2])?$val2=$header[$i][2]:$val2=null;
 332                      isset($header[$i][3])?$val3=$header[$i][3]:$val3=null;
 333                      $table->set_header($i, $val0, $val1, $val2, $val3);
 334                  }
 335              }
 336          }
 337          $table->set_form_actions($form_actions);
 338          $table->display();
 339      }
 340  
 341  
 342      /**
 343      * Displays a normal message. It is recommended to use this public function
 344      * to display any normal information messages.
 345      *
 346      * @author Roan Embrechts
 347      * @param string $message - include any additional html
 348      *                          tags if you need them
 349      * @param bool    Filter (true) or not (false)
 350      * @return void
 351      */
 352  	public static function display_normal_message ($message,$filter=true) {
 353          global $charset;
 354          global $notification;
 355  
 356          // no feedback messages
 357          if (api_get_setting('display_feedback_messages') == 'false'){
 358              return false;
 359          }
 360  
 361          $notification[] = array('type'=>'normal','message'=>$message);
 362          if($filter) {
 363              //filter message
 364              $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
 365          }
 366          if (!headers_sent())
 367          {
 368              echo '
 369                          <style type="text/css" media="screen, projection">
 370                          /*<![CDATA[*/
 371                          @import "'.api_get_path(WEB_CODE_PATH).'css/default.css";
 372                          /*]]>*/
 373                          </style>';
 374          }
 375          echo '<div class="normal-message">';
 376          //Display :: display_icon('message_normal.gif', get_lang('InfoMessage'), array ('style' => 'float:left; margin-right:10px;'));
 377          /*
 378          get_lang('InfoMessage', array ('style' => 'float:left; margin-right:10px;'));
 379          */
 380          echo $message.'</div>';
 381      }
 382  
 383      /**
 384      * Displays an warning message. Use this if you want to draw attention to something
 385      * This can also be used for instance with the hint in the exercises
 386      *
 387      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 388      * @param string $message
 389      * @param bool    Filter (true) or not (false)
 390      * @return void
 391      */
 392  	public static function display_warning_message ($message, $filter=true, $force = false) {
 393          global $charset;
 394          global $notification;
 395  
 396          // no feedback messages
 397          if (api_get_setting('display_feedback_messages') == 'false' && $force === false){
 398              return false;
 399          }
 400  
 401          $notification[] = array('type'=>'warning','message'=>$message);
 402          if($filter){
 403              //filter message
 404              $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
 405          }
 406          if (!headers_sent())
 407          {
 408              echo '
 409                          <style type="text/css" media="screen, projection">
 410                          /*<![CDATA[*/
 411                          @import "'.api_get_path(WEB_CODE_PATH).'css/default.css";
 412                          /*]]>*/
 413                          </style>';
 414          }
 415          echo '<div class="warning-message rounded">';
 416          //Display :: display_icon('message_warning.png', get_lang('WarningMessage'), array ('style' => 'float:left; margin-right:10px;'));
 417          /*
 418          get_lang('WarningMessage', array ('style' => 'float:left; margin-right:10px;'));
 419          */
 420          echo $message.'</div>';
 421      }
 422  
 423      /**
 424      * Displays an confirmation message. Use this if something has been done successfully
 425      *
 426      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 427      * @param string $message
 428      * @param bool    Filter (true) or not (false)
 429      * @return void
 430      */
 431  	public static function display_confirmation_message ($message, $filter = true, $force = false) {
 432          global $charset;
 433          global $notification;
 434  
 435          // no feedback messages
 436                  // Always is necessary feedback, we are adding a lof code with divs(confirmation-message) and this is ugly when we have available a display function for make this, I added the force parameter that allow to use this function and avoid add more divs with class="confirmation-message"
 437          if (api_get_setting('display_feedback_messages') == 'false' && $force === false){
 438              return false;
 439          }
 440  
 441          $notification[] = array('type'=>'confirmation','message'=>$message);
 442          if($filter){
 443              //filter message
 444              $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
 445          }
 446          if (!headers_sent())
 447          {
 448              echo '
 449                          <style type="text/css" media="screen, projection">
 450                          /*<![CDATA[*/
 451                          @import "'.api_get_path(WEB_CODE_PATH).'css/default.css";
 452                          /*]]>*/
 453                          </style>';
 454          }
 455          echo '<div class="confirmation-message rounded">';
 456          //Display :: display_icon('message_confirmation.gif', get_lang('ConfirmationMessage'), array ('style' => 'float:left; margin-right:10px;margin-left:5px;'));
 457          /*
 458          get_lang('ConfirmationMessage', array ('style' => 'float:left; margin-right:10px;margin-left:5px;'));
 459          */
 460          echo $message.'</div>';
 461      }
 462  
 463      /**
 464      * Displays an error message. It is recommended to use this public function if an error occurs
 465      *
 466      * @author Hugues Peeters
 467      * @author Roan Embrechts
 468      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 469      * @param string $message - include any additional html
 470      *                          tags if you need them
 471      * @param bool    Filter (true) or not (false)
 472      * @return void
 473      */
 474  	public static function display_error_message ($message, $filter = true, $force = false) {
 475          global $charset;
 476          global $notification;
 477  
 478          // no feedback messages
 479          if (api_get_setting('display_feedback_messages') == 'false' && $force === false){
 480              return false;
 481          }
 482  
 483          $notification[] = array('type'=>'error','message'=>$message);
 484          if($filter){
 485              //filter message
 486              $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
 487          }
 488  
 489          if (!headers_sent())
 490          {
 491              echo '
 492                          <style type="text/css" media="screen, projection">
 493                          /*<![CDATA[*/
 494                          @import "'.api_get_path(WEB_CODE_PATH).'css/default.css";
 495                          /*]]>*/
 496                          </style>';
 497          }
 498          echo '<div class="error-message rounded">';
 499          //Display :: display_icon('message_error.png', get_lang('ErrorMessage'), array ('style' => 'float:left; margin-right:10px;'));
 500          /*
 501          get_lang('ErrorMessage', array ('style' => 'float:left; margin-right:10px;'));
 502          */
 503          echo $message.'</div>';
 504      }
 505      /**
 506       * Return an encrypted mailto hyperlink
 507       *
 508       * @param - $email (string) - e-mail
 509       * @param - $text (string) - clickable text
 510       * @param - $style_class (string) - optional, class from stylesheet
 511       * @return - encrypted mailto hyperlink
 512       */
 513  	public static function encrypted_mailto_link ($email, $clickable_text = null, $style_class = '') {
 514          global $charset;
 515          if (is_null($clickable_text))
 516          {
 517              $clickable_text = $email;
 518          }
 519          //mailto already present?
 520          if (substr($email, 0, 7) != 'mailto:') {
 521              $email = 'mailto:'.$email;
 522          }
 523          //class (stylesheet) defined?
 524          if ($style_class != '') {
 525              $style_class = ' class="'.$style_class.'"';
 526          }
 527          //encrypt email
 528          $hmail = '';
 529          for ($i = 0; $i < strlen($email); $i ++) {
 530              $hmail .= '&#'.ord($email {
 531              $i }).';';
 532          }
 533          //encrypt clickable text if @ is present
 534          if (strpos($clickable_text, '@')) {
 535  
 536              for ($i = 0; $i < strlen($clickable_text); $i ++) {
 537                  $hclickable_text .= '&#'.ord($clickable_text {
 538                  $i }).';';
 539              }
 540          } else {
 541              $hclickable_text = htmlspecialchars($clickable_text,ENT_QUOTES,$charset);
 542          }
 543  
 544          //return encrypted mailto hyperlink
 545          return '<a href="'.$hmail.'"'.$style_class.' name="clickable_email_link">'.$hclickable_text.'</a>';
 546      }
 547  
 548      /**
 549      *    Create a hyperlink to the platform homepage.
 550      *    @param string $name, the visible name of the hyperlink, default is sitename
 551      *    @return string with html code for hyperlink
 552      */
 553  	public static function get_platform_home_link_html ($name = '') {
 554          if ($name == '')
 555          {
 556              $name = api_get_setting('siteName');
 557          }
 558          return "<a href=\"".api_get_path(WEB_PATH)."index.php\">$name</a>";
 559      }
 560      /**
 561       * Display the page header
 562       * @param string The name of the page (will be showed in the page title)
 563       * @param string Optional help file name
 564       */
 565  	public static function display_header ($tool_name ='', $help = NULL) {
 566          $nameTools = $tool_name;
 567          global $_plugins,$lp_theme_css,$mycoursetheme,$user_theme,$platform_theme;
 568          global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $clarolineRepositoryWeb, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
 569          global $menu_navigation;
 570          global $help_content; 
 571          include (api_get_path(INCLUDE_PATH)."header.inc.php");
 572      }
 573      /**
 574       * Display the reduced page header (without banner)
 575       */
 576  	public static function display_reduced_header ($tool_name ='', $help = NULL) {
 577          global $_plugins,$lp_theme_css,$mycoursetheme,$user_theme,$platform_theme;
 578          global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $clarolineRepositoryWeb, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface;
 579          global $menu_navigation;
 580          include (api_get_path(INCLUDE_PATH)."reduced_header.inc.php");
 581      }
 582      /**
 583       * Display the page footer
 584       */
 585  	public static function display_footer () {
 586          global $dokeos_version; //necessary to have the value accessible in the footer
 587          global $_plugins;
 588          include (api_get_path(INCLUDE_PATH)."footer.inc.php");
 589      }
 590  
 591      /**
 592       * Print an <option>-list with all letters (A-Z).
 593       * @param char $selected_letter The letter that should be selected
 594       */
 595  	public static function get_alphabet_options ($selected_letter = '') {
 596          $result = '';
 597          for ($i = 65; $i <= 90; $i ++) {
 598              $letter = chr($i);
 599              $result .= '<option value="'.$letter.'"';
 600              if ($selected_letter == $letter) {
 601                  $result .= ' selected="selected"';
 602              }
 603              $result .= '>'.$letter.'</option>';
 604          }
 605          return $result;
 606      }
 607  
 608  	public static function get_numeric_options ($min,$max, $selected_num = 0) {
 609          $result = '';
 610          for ($i = $min; $i <= $max; $i ++) {
 611              $result .= '<option value="'.$i.'"';
 612              if (is_int($selected_num))
 613                  if ($selected_num == $i) {
 614                      $result .= ' selected="selected"';
 615                  }
 616              $result .= '>'.$i.'</option>';
 617          }
 618          return $result;
 619      }
 620  
 621      /**
 622      * Show the so-called "left" menu for navigating
 623      */
 624  	public static function show_course_navigation_menu ($isHidden = false) {
 625          global $output_string_menu;
 626          global $_setting;
 627  
 628          // check if the $_SERVER['REQUEST_URI'] contains already url parameters (thus a questionmark)
 629          if (!strstr($_SERVER['REQUEST_URI'], "?"))
 630          {
 631              $sourceurl = api_get_self()."?";
 632          }
 633          else
 634          {
 635              $sourceurl = $_SERVER['REQUEST_URI'];
 636          }
 637          $output_string_menu = "";
 638          if ($isHidden == "true" and $_SESSION["hideMenu"]) {
 639  
 640              $_SESSION["hideMenu"] = "hidden";
 641  
 642              $sourceurl = str_replace("&isHidden=true", "", $sourceurl);
 643              $sourceurl = str_replace("&isHidden=false", "", $sourceurl);
 644  
 645              $output_string_menu .= " <a href='".$sourceurl."&isHidden=false'>"."<img src=../../main/img/expand.gif alt='Show menu1' padding:'2px'/>"."</a>";
 646          }
 647          elseif ($isHidden == "false" and $_SESSION["hideMenu"])
 648          {
 649              $sourceurl = str_replace("&isHidden=true", "", $sourceurl);
 650              $sourceurl = str_replace("&isHidden=false", "", $sourceurl);
 651  
 652              $_SESSION["hideMenu"] = "shown";
 653              $output_string_menu .= "<div id='leftimg'><a href='".$sourceurl."&isHidden=true'>"."<img src=../../main/img/collapse.gif alt='Hide menu2' padding:'2px'/>"."</a></div>";
 654          }
 655          elseif ($_SESSION["hideMenu"])
 656          {
 657              if ($_SESSION["hideMenu"] == "shown") {
 658                  $output_string_menu .= "<div id='leftimg'><a href='".$sourceurl."&isHidden=true'>"."<img src='../../main/img/collapse.gif' alt='Hide menu3' padding:'2px'/>"."</a></div>";
 659              }
 660              if ($_SESSION["hideMenu"] == "hidden") {
 661                  $sourceurl = str_replace("&isHidden=true", "", $sourceurl);
 662                  $output_string_menu .= "<a href='".$sourceurl."&isHidden=false'>"."<img src='../../main/img/expand.gif' alt='Hide menu4' padding:'2px'/>"."</a>";
 663  
 664              }
 665          }
 666          elseif (!$_SESSION["hideMenu"])
 667          {
 668              $_SESSION["hideMenu"] = "shown";
 669              if (isset ($_cid))
 670              {
 671                  $output_string_menu .= "<div id='leftimg'><a href='".$sourceurl."&isHidden=true'>"."<img src='main/img/collapse.gif' alt='Hide menu5' padding:'2px'/>"."</a></div>";
 672              }
 673          }
 674      }
 675  
 676      /**
 677       * This public function displays an icon
 678       * @param string $image the filename of the file (in the main/img/ folder
 679       * @param string $alt_text the alt text (probably a language variable)
 680       * @param array additional attributes (for instance height, width, onclick, ...)
 681      */
 682  	public static function display_icon ($image, $alt_text = '', $additional_attributes = array ()) {
 683          echo Display::return_icon($image,$alt_text,$additional_attributes);
 684      }
 685  
 686      /**
 687       * This public function returns the htmlcode for an icon
 688       *
 689       * @param string $image the filename of the file (in the main/img/ folder
 690       * @param string $alt_text the alt text (probably a language variable)
 691       * @param array additional attributes (for instance height, width, onclick, ...)
 692       *
 693       * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 694       * @version October 2006
 695      */
 696  	public static function return_icon ($image,$alt_text='',$additional_attributes=array()) {
 697          $attribute_list = '';
 698          // alt text = the image if there is none provided (for XHTML compliance)
 699          if ($alt_text=='')
 700          {
 701              $alt_text=$image;
 702          }
 703  
 704          // managing the additional attributes
 705          if (!empty($additional_attributes) and is_array($additional_attributes))
 706          {
 707              $attribute_list='';
 708              foreach ($additional_attributes as $key=>$value)
 709              {
 710                  $attribute_list.=$key.'="'.$value.'" ';
 711              }
 712          }
 713          return '<img src="'.api_get_path(WEB_IMG_PATH).$image.'" alt="'.$alt_text.'"  title="'.$alt_text.'" '.$attribute_list.'  />';
 714      }
 715  
 716      /**
 717       * Ivan, 05-SEP-2009: Deprecated, see api_get_person_name().
 718       *
 719       * Display name and lastname in a specific order
 720       * @param string Firstname
 721       * @param string Lastname
 722       * @param string Title in the destination language (Dr, Mr, Miss, Sr, Sra, etc)
 723       * @param string Optional format string (e.g. '%t. %l, %f')
 724       * @author Carlos Vargas <carlos.vargas@dokeos.com>
 725       */
 726  	 public static function user_name($fname,$lname,$title='',$format=null) {
 727           if (empty($format)){
 728                   if (empty($fname) or empty($lname)) {
 729                       $user_name = $fname.$lname;
 730                   } else {
 731                       $user_name= $fname.' '.$lname;
 732                   }
 733           }     else {
 734               $find = array('%t','%f','%l');
 735              $repl = array($title,$fname,$lname);
 736              $user_name = str_replace($find,$repl,$format);
 737           }
 738            return $user_name;
 739       }
 740  
 741      /**
 742       * This function adds a css file to $htmlHeadXtra, which is in /main/inc/header.inc.php then used and added to the output
 743       *
 744       * @param string $cssfile: the full web path to the css file
 745       *
 746       * @since Dokeos 2.0
 747       * @since June 2010
 748       * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
 749       */
 750  	public static function css($cssfile){
 751          global $htmlHeadXtra;
 752  
 753          $htmlHeadXtra[] = '<link type="text/css" href="'.$cssfile.'" rel="stylesheet" />';
 754      }
 755  
 756      /**
 757       * This function adds a javascript file to $htmlHeadXtra, which is in /main/inc/header.inc.php then used and added to the output
 758       *
 759       * @param string $javascriptfile: the full web path to the javascript file
 760       *
 761       * @since Dokeos 2.0
 762       * @since June 2010
 763       * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
 764       */
 765  	public static function javascript($javascriptfile){
 766          global $htmlHeadXtra;
 767  
 768          $htmlHeadXtra[] = '<script type="text/javascript" src="'.$javascriptfile.'" language="javascript"></script>';
 769      }
 770      
 771      /**
 772       * Display a reduced header in tools
 773       */
 774  	public static function display_tool_header () {
 775          global $_plugins,$lp_theme_css,$mycoursetheme,$user_theme,$platform_theme;
 776          global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $clarolineRepositoryWeb, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface;
 777          global $menu_navigation;
 778          include (api_get_path(INCLUDE_PATH)."tool_header.inc.php");
 779      }
 780      
 781  	public static function display_tool_footer(){
 782          global $dokeos_version; //necessary to have the value accessible in the footer
 783          global $_plugins;
 784          include (api_get_path(INCLUDE_PATH)."tool_footer.inc.php");
 785      }
 786      
 787      /**
 788       * Render HTML for top actions in author tool  (icon + text) in:
 789       * 
 790       *         "author"             => main index author tool
 791       *         "content"
 792       *         "more_criteria"        => show more criteria to forms
 793       *         "page"
 794       *         "questions"
 795       *         "quiz"
 796       *         "scenario"
 797       *         "templates"
 798       * @deprecated this code is not used anymore
 799       * @param action - string - action to display
 800       * @since October 2010
 801       * @return string, html code
 802       */
 803  	public static function render_author_action($action = null)
 804      {
 805           if(empty($action))        return "";
 806  
 807           $text = ""; $icon = "";
 808           
 809           switch($action){
 810               case "author":            $icon = Display::return_icon('go_previous_32.png', get_lang("Author"));
 811                                       $text = get_lang("Author");
 812                                       break;
 813                                       
 814               case "content":            break;
 815               
 816               case "more_criteria":    $icon = Display::return_icon('navigation/plus.png', get_lang("SeeMoreOptions"));
 817                                       $text = get_lang("SeeMoreOptions");
 818                                       break;
 819                                       
 820               case "page":            break;
 821               case "questions":        break;
 822               case "quiz":            break;
 823               case "scenario":        break;
 824               case "templates":        break;
 825               
 826               default:        break;        
 827           }
 828           
 829           return $icon.$text;
 830           
 831      } 
 832  
 833  } //end class Display
 834  ?>

title

Description

title

Description

title

Description

title

title

Body