diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php
index 97c137dcec..750995432e 100755
--- a/main/inc/lib/display.lib.php
+++ b/main/inc/lib/display.lib.php
@@ -1,656 +1,658 @@
, Ghent University
- * @param string $tool These are the constants that are used for indicating the tools.
- * @param array $editor_config Optional configuration settings for the online editor.
- * @return $tool return a string array list with the "define" in main_api.lib
- * @return html code for adding an introduction
- */
- public static function display_introduction_section($tool, $editor_config = null) {
- $is_allowed_to_edit = api_is_allowed_to_edit();
- $moduleId = $tool;
- if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
- require api_get_path(INCLUDE_PATH).'introductionSection.inc.php';
- }
- }
-
- /**
- * Displays a localised html file
- * tries to show the file "$full_file_name"."_".$language_interface.".html"
- * and if this does not exist, shows the file "$full_file_name".".html"
- * warning this public function defines a global
- * @param $full_file_name, the (path) name of the file, without .html
- * @return return a string with the path
- */
- public static function display_localised_html_file($full_file_name) {
- global $language_interface;
- $localised_file_name = $full_file_name.'_'.$language_interface.'.html';
- $default_file_name = $full_file_name.'.html';
- if (file_exists($localised_file_name)) {
- include $localised_file_name;
- } else {
- include ($default_file_name);
- }
- }
-
- /**
- * Display simple html header of table.
- * @deprecated
- */
- /*public static function display_table_header() {
- $bgcolor = 'bgcolor="white"';
- echo '
';
- return $bgcolor;
- }*/
-
- /**
- * Display html header of table with several options.
- *
- * @param $properties, array with elements, all of which have defaults
- * "width" - the table width, e.g. "100%", default is 85%
- * "class" - the class to use for the table, e.g. "class=\"data_table\""
- * "cellpadding" - the extra border in each cell, e.g. "8",default is 4
- * "cellspacing" - the extra space between cells, default = 0
- * @param column_header, array with the header elements.
- * @author Roan Embrechts
- * @version 1.01
- * @todo remove this function, is only use in user.php
- * @return return type string, bgcolor
- */
- public static function display_complex_table_header($properties, $column_header) {
- $width = $properties['width'];
- if (!isset($width)) {
- $width = '85%';
- }
- $class = $properties['class'];
- if (!isset($class)) {
- $class = 'class="data_table"';
- }
- $cellpadding = $properties['cellpadding'];
- if (!isset($cellpadding)) {
- $cellpadding = '4';
- }
- $cellspacing = $properties['cellspacing'];
- if (!isset ($cellspacing)) {
- $cellspacing = '0';
- }
- //... add more properties as you see fit
- //api_display_debug_info("Light grey is " . DOKEOSLIGHTGREY);
- $bgcolor = 'bgcolor="'.DOKEOSLIGHTGREY.'"';
- echo '
\n";
- if ($is_alternating) {
- if ($bgcolor == 'bgcolor="'.HTML_WHITE.'"') {
- $bgcolor = 'bgcolor="'.DOKEOSLIGHTGREY.'"';
- } elseif ($bgcolor == 'bgcolor="'.DOKEOSLIGHTGREY.'"') {
- $bgcolor = 'bgcolor="'.HTML_WHITE.'"';
- }
- }
- return $bgcolor;
- }
-
-
- /**
- * Displays a table
- * @param array $header Titles for the table header
- * each item in this array can contain 3 values
- * - 1st element: the column title
- * - 2nd element: true or false (column sortable?)
- * - 3th element: additional attributes for
- * th-tag (eg for column-width)
- * - 4the element: additional attributes for the td-tags
- * @param array $content 2D-array with the tables content
- * @param array $sorting_options Keys are:
- * 'column' = The column to use as sort-key
- * 'direction' = SORT_ASC or SORT_DESC
- * @param array $paging_options Keys are:
- * 'per_page_default' = items per page when switching from
- * full- list to per-page-view
- * 'per_page' = number of items to show per page
- * 'page_nr' = The page to display
- * @param array $query_vars Additional variables to add in the query-string
- * @param string The style that the table will show. You can set 'table' or 'grid'
- * @author bart.mollet@hogent.be
- */
- public static function display_sortable_table($header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $form_actions = array(), $style = 'table') {
- if (!class_exists('SortableTable')) {
- require_once 'sortabletable.class.php';
- }
- global $origin;
- $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
- $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
-
- $table = new SortableTableFromArray($content, $column, $default_items_per_page);
-
- if (is_array($query_vars)) {
- $table->set_additional_parameters($query_vars);
- }
- if ($style == 'table') {
- if (is_array($header) && count($header) > 0) {
- foreach ($header as $index => $header_item) {
- $table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
- }
- }
- $table->set_form_actions($form_actions);
- $table->display();
- } else {
- $table->display_grid();
- }
- }
-
- /**
- * Shows a nice grid
- * @param string grid name (important to create css)
- * @param array header content
- * @param array array with the information to show
- * @param array $paging_options Keys are:
- * 'per_page_default' = items per page when switching from
- * full- list to per-page-view
- * 'per_page' = number of items to show per page
- * 'page_nr' = The page to display
- * 'hide_navigation' = true to hide the navigation
- * @param array $query_vars Additional variables to add in the query-string
- * @param array $form actions Additional variables to add in the query-string
- * @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column
- * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
- */
-
- public static function display_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true) {
- echo self::return_sortable_grid($name, $header, $content, $paging_options, $query_vars, $form_actions, $visibility_options, $sort_data);
- }
-
- /**
- * Gets a nice grid in html string
- * @param string grid name (important to create css)
- * @param array header content
- * @param array array with the information to show
- * @param array $paging_options Keys are:
- * 'per_page_default' = items per page when switching from
- * full- list to per-page-view
- * 'per_page' = number of items to show per page
- * 'page_nr' = The page to display
- * 'hide_navigation' = true to hide the navigation
- * @param array $query_vars Additional variables to add in the query-string
- * @param array $form actions Additional variables to add in the query-string
- * @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column
- * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
- * @param bool true for sorting data or false otherwise
- * @return string html grid
- */
- public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true) {
- if (!class_exists('SortableTable')) {
- require_once 'sortabletable.class.php';
- }
- global $origin;
- $column = 0;
- $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
- $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
-
- if (is_array($query_vars)) {
- $table->set_additional_parameters($query_vars);
- }
- return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
- }
-
- /**
- * Displays a table with a special configuration
- * @param array $header Titles for the table header
- * each item in this array can contain 3 values
- * - 1st element: the column title
- * - 2nd element: true or false (column sortable?)
- * - 3th element: additional attributes for
- * th-tag (eg for column-width)
- * - 4the element: additional attributes for the td-tags
- * @param array $content 2D-array with the tables content
- * @param array $sorting_options Keys are:
- * 'column' = The column to use as sort-key
- * 'direction' = SORT_ASC or SORT_DESC
- * @param array $paging_options Keys are:
- * 'per_page_default' = items per page when switching from
- * full- list to per-page-view
- * 'per_page' = number of items to show per page
- * 'page_nr' = The page to display
- * @param array $query_vars Additional variables to add in the query-string
- * @param array $column_show Array of binaries 1= show columns 0. hide a column
- * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
- * i.e: $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
- * @param array $form_actions Set optional forms actions
- *
- * @author Julio Montoya
- */
- 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()) {
- if (!class_exists('SortableTable')) {
- require_once 'sortabletable.class.php';
- }
- global $origin;
- $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
- $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
-
- $table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page, 'tablename', $column_show, $column_order);
-
- if (is_array($query_vars)) {
- $table->set_additional_parameters($query_vars);
- }
- // Show or hide the columns header
- if (is_array($column_show)) {
- for ($i = 0; $i < count($column_show); $i++) {
- if (!empty($column_show[$i])) {
- $val0 = isset($header[$i][0]) ? $header[$i][0] : null;
- $val1 = isset($header[$i][1]) ? $header[$i][1] : null;
- $val2 = isset($header[$i][2]) ? $header[$i][2] : null;
- $val3 = isset($header[$i][3]) ? $header[$i][3] : null;
- $table->set_header($i, $val0, $val1, $val2, $val3);
- }
- }
- }
- $table->set_form_actions($form_actions);
- $table->display();
- }
-
- /**
- * Displays a normal message. It is recommended to use this public function
- * to display any normal information messages.
- *
- * @author Roan Embrechts
- * @param string $message - include any additional html
- * tags if you need them
- * @param bool Filter (true) or not (false)
- * @return void
- */
- public static function display_normal_message($message, $filter = true) {
- if ($filter) {
- // Filter message
- $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
- }
- if (!headers_sent()) {
- echo '
- '; // TODO: There is no "default.css" file in this location.
- }
- echo '
';
- }
-
- /**
- * Displays an warning message. Use this if you want to draw attention to something
- * This can also be used for instance with the hint in the exercises
- *
- * @author Patrick Cool , Ghent University
- * @param string $message
- * @param bool Filter (true) or not (false)
- * @return void
- */
- public static function display_warning_message($message, $filter = true) {
- if ($filter){
- // Filter message
- $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
- }
- if (!headers_sent()) {
- echo '
- '; // TODO: There is no "default.css" file in this location.
- }
- echo '
';
- }
-
- /**
- * Displays an error message. It is recommended to use this public function if an error occurs
- *
- * @author Hugues Peeters
- * @author Roan Embrechts
- * @author Patrick Cool , Ghent University
- * @param string $message - include any additional html
- * tags if you need them
- * @param bool Filter (true) or not (false)
- * @return void
- */
- public static function display_error_message ($message, $filter = true) {
- if($filter){
- // Filter message
- $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
- }
- if (!headers_sent()) {
- echo '
- '; // TODO: There is no "default.css" file in this location.
- }
- echo '
';
- }
- /**
- * Returns a div html string with
- */
- public function return_message($message, $type='normal', $filter = true) {
- if ($filter) {
- $message = Security::remove_XSS($message);
- }
+
+ private function __construct() {
+
+ }
+
+ /**
+ * Displays the tool introduction of a tool.
+ *
+ * @author Patrick Cool , Ghent University
+ * @param string $tool These are the constants that are used for indicating the tools.
+ * @param array $editor_config Optional configuration settings for the online editor.
+ * @return $tool return a string array list with the "define" in main_api.lib
+ * @return html code for adding an introduction
+ */
+ public static function display_introduction_section($tool, $editor_config = null) {
+ $is_allowed_to_edit = api_is_allowed_to_edit();
+ $moduleId = $tool;
+ if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
+ require api_get_path(INCLUDE_PATH).'introductionSection.inc.php';
+ }
+ }
+
+ /**
+ * Displays a localised html file
+ * tries to show the file "$full_file_name"."_".$language_interface.".html"
+ * and if this does not exist, shows the file "$full_file_name".".html"
+ * warning this public function defines a global
+ * @param $full_file_name, the (path) name of the file, without .html
+ * @return return a string with the path
+ */
+ public static function display_localised_html_file($full_file_name) {
+ global $language_interface;
+ $localised_file_name = $full_file_name.'_'.$language_interface.'.html';
+ $default_file_name = $full_file_name.'.html';
+ if (file_exists($localised_file_name)) {
+ include $localised_file_name;
+ } else {
+ include ($default_file_name);
+ }
+ }
+
+ /**
+ * Display simple html header of table.
+ * @deprecated
+ */
+ /*public static function display_table_header() {
+ $bgcolor = 'bgcolor="white"';
+ echo '
';
+ return $bgcolor;
+ }*/
+
+ /**
+ * Display html header of table with several options.
+ *
+ * @param $properties, array with elements, all of which have defaults
+ * "width" - the table width, e.g. "100%", default is 85%
+ * "class" - the class to use for the table, e.g. "class=\"data_table\""
+ * "cellpadding" - the extra border in each cell, e.g. "8",default is 4
+ * "cellspacing" - the extra space between cells, default = 0
+ * @param column_header, array with the header elements.
+ * @author Roan Embrechts
+ * @version 1.01
+ * @todo remove this function, is only use in user.php
+ * @return return type string, bgcolor
+ */
+ public static function display_complex_table_header($properties, $column_header) {
+ $width = $properties['width'];
+ if (!isset($width)) {
+ $width = '85%';
+ }
+ $class = $properties['class'];
+ if (!isset($class)) {
+ $class = 'class="data_table"';
+ }
+ $cellpadding = $properties['cellpadding'];
+ if (!isset($cellpadding)) {
+ $cellpadding = '4';
+ }
+ $cellspacing = $properties['cellspacing'];
+ if (!isset ($cellspacing)) {
+ $cellspacing = '0';
+ }
+ //... add more properties as you see fit
+ //api_display_debug_info("Light grey is " . DOKEOSLIGHTGREY);
+ $bgcolor = 'bgcolor="'.DOKEOSLIGHTGREY.'"';
+ echo '
\n";
+ if ($is_alternating) {
+ if ($bgcolor == 'bgcolor="'.HTML_WHITE.'"') {
+ $bgcolor = 'bgcolor="'.DOKEOSLIGHTGREY.'"';
+ } elseif ($bgcolor == 'bgcolor="'.DOKEOSLIGHTGREY.'"') {
+ $bgcolor = 'bgcolor="'.HTML_WHITE.'"';
+ }
+ }
+ return $bgcolor;
+ }
+
+ /**
+ * Displays a table
+ * @param array $header Titles for the table header
+ * each item in this array can contain 3 values
+ * - 1st element: the column title
+ * - 2nd element: true or false (column sortable?)
+ * - 3th element: additional attributes for
+ * th-tag (eg for column-width)
+ * - 4the element: additional attributes for the td-tags
+ * @param array $content 2D-array with the tables content
+ * @param array $sorting_options Keys are:
+ * 'column' = The column to use as sort-key
+ * 'direction' = SORT_ASC or SORT_DESC
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param string The style that the table will show. You can set 'table' or 'grid'
+ * @author bart.mollet@hogent.be
+ */
+ public static function display_sortable_table($header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $form_actions = array(), $style = 'table') {
+ if (!class_exists('SortableTable')) {
+ require_once 'sortabletable.class.php';
+ }
+ global $origin;
+ $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
+ $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
+
+ $table = new SortableTableFromArray($content, $column, $default_items_per_page);
+
+ if (is_array($query_vars)) {
+ $table->set_additional_parameters($query_vars);
+ }
+ if ($style == 'table') {
+ if (is_array($header) && count($header) > 0) {
+ foreach ($header as $index => $header_item) {
+ $table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
+ }
+ }
+ $table->set_form_actions($form_actions);
+ $table->display();
+ } else {
+ $table->display_grid();
+ }
+ }
+
+ /**
+ * Shows a nice grid
+ * @param string grid name (important to create css)
+ * @param array header content
+ * @param array array with the information to show
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * 'hide_navigation' = true to hide the navigation
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param array $form actions Additional variables to add in the query-string
+ * @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column
+ * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
+ */
+ public static function display_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true) {
+ echo self::return_sortable_grid($name, $header, $content, $paging_options, $query_vars, $form_actions, $visibility_options, $sort_data);
+ }
+
+ /**
+ * Gets a nice grid in html string
+ * @param string grid name (important to create css)
+ * @param array header content
+ * @param array array with the information to show
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * 'hide_navigation' = true to hide the navigation
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param array $form actions Additional variables to add in the query-string
+ * @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column
+ * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
+ * @param bool true for sorting data or false otherwise
+ * @return string html grid
+ */
+ public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true) {
+ if (!class_exists('SortableTable')) {
+ require_once 'sortabletable.class.php';
+ }
+ global $origin;
+ $column = 0;
+ $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
+ $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
+
+ if (is_array($query_vars)) {
+ $table->set_additional_parameters($query_vars);
+ }
+ return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
+ }
+
+ /**
+ * Displays a table with a special configuration
+ * @param array $header Titles for the table header
+ * each item in this array can contain 3 values
+ * - 1st element: the column title
+ * - 2nd element: true or false (column sortable?)
+ * - 3th element: additional attributes for
+ * th-tag (eg for column-width)
+ * - 4the element: additional attributes for the td-tags
+ * @param array $content 2D-array with the tables content
+ * @param array $sorting_options Keys are:
+ * 'column' = The column to use as sort-key
+ * 'direction' = SORT_ASC or SORT_DESC
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param array $column_show Array of binaries 1= show columns 0. hide a column
+ * @param array $column_order An array of integers that let us decide how the columns are going to be sort.
+ * i.e: $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column
+ * @param array $form_actions Set optional forms actions
+ *
+ * @author Julio Montoya
+ */
+ 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()) {
+ if (!class_exists('SortableTable')) {
+ require_once 'sortabletable.class.php';
+ }
+ global $origin;
+ $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0;
+ $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
+
+ $table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page, 'tablename', $column_show, $column_order);
+
+ if (is_array($query_vars)) {
+ $table->set_additional_parameters($query_vars);
+ }
+ // Show or hide the columns header
+ if (is_array($column_show)) {
+ for ($i = 0; $i < count($column_show); $i++) {
+ if (!empty($column_show[$i])) {
+ $val0 = isset($header[$i][0]) ? $header[$i][0] : null;
+ $val1 = isset($header[$i][1]) ? $header[$i][1] : null;
+ $val2 = isset($header[$i][2]) ? $header[$i][2] : null;
+ $val3 = isset($header[$i][3]) ? $header[$i][3] : null;
+ $table->set_header($i, $val0, $val1, $val2, $val3);
+ }
+ }
+ }
+ $table->set_form_actions($form_actions);
+ $table->display();
+ }
+
+ /**
+ * Displays a normal message. It is recommended to use this public function
+ * to display any normal information messages.
+ *
+ * @author Roan Embrechts
+ * @param string $message - include any additional html
+ * tags if you need them
+ * @param bool Filter (true) or not (false)
+ * @return void
+ */
+ public static function display_normal_message($message, $filter = true) {
+ if ($filter) {
+ // Filter message
+ $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
+ }
+ if (!headers_sent()) {
+ echo '
+ '; // TODO: There is no "default.css" file in this location.
+ }
+ echo '
';
+ }
+
+ /**
+ * Displays an warning message. Use this if you want to draw attention to something
+ * This can also be used for instance with the hint in the exercises
+ *
+ * @author Patrick Cool , Ghent University
+ * @param string $message
+ * @param bool Filter (true) or not (false)
+ * @return void
+ */
+ public static function display_warning_message($message, $filter = true) {
+ if ($filter){
+ // Filter message
+ $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
+ }
+ if (!headers_sent()) {
+ echo '
+ '; // TODO: There is no "default.css" file in this location.
+ }
+ echo '
';
+ }
+
+ /**
+ * Displays an error message. It is recommended to use this public function if an error occurs
+ *
+ * @author Hugues Peeters
+ * @author Roan Embrechts
+ * @author Patrick Cool , Ghent University
+ * @param string $message - include any additional html
+ * tags if you need them
+ * @param bool Filter (true) or not (false)
+ * @return void
+ */
+ public static function display_error_message ($message, $filter = true) {
+ if($filter){
+ // Filter message
+ $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
+ }
+ if (!headers_sent()) {
+ echo '
+ '; // TODO: There is no "default.css" file in this location.
+ }
+ echo '
';
+ }
+
+ /**
+ * Returns a div html string with
+ */
+ public function return_message($message, $type='normal', $filter = true) {
+ if ($filter) {
+ $message = Security::remove_XSS($message);
+ }
switch($type) {
case 'warning':
- $class = 'warning-message';
+ $class = 'warning-message';
case 'error':
$class = 'error-message';
case 'normal':
$class = '';
case 'confirmation-message':
- $class = '';
+ $class = '';
default:
- $class = 'normal-message';
+ $class = 'normal-message';
return self::div($message, array('class'=>$class));
- }
- }
-
- /**
- * Returns an encrypted mailto hyperlink
- *
- * @param - $email (string) - e-mail
- * @param - $text (string) - clickable text
- * @param - $style_class (string) - optional, class from stylesheet
- * @return - encrypted mailto hyperlink
- */
- public static function encrypted_mailto_link ($email, $clickable_text = null, $style_class = '') {
- if (is_null($clickable_text)) {
- $clickable_text = $email;
- }
- // "mailto:" already present?
- if (substr($email, 0, 7) != 'mailto:') {
- $email = 'mailto:'.$email;
- }
- // Class (stylesheet) defined?
- if ($style_class != '') {
- $style_class = ' class="'.$style_class.'"';
- }
- // Encrypt email
- $hmail = '';
- for ($i = 0; $i < strlen($email); $i ++) {
- $hmail .= ''.ord($email {
- $i }).';';
- }
- // Encrypt clickable text if @ is present
- if (strpos($clickable_text, '@')) {
- for ($i = 0; $i < strlen($clickable_text); $i ++) {
- $hclickable_text .= ''.ord($clickable_text {
- $i }).';';
- }
- } else {
- $hclickable_text = @htmlspecialchars($clickable_text, ENT_QUOTES, api_get_system_encoding());
- }
- // Return encrypted mailto hyperlink
- return ''.$hclickable_text.'';
- }
-
- /**
- * Creates a hyperlink to the platform homepage.
- * @param string $name, the visible name of the hyperlink, default is sitename
- * @return string with html code for hyperlink
- */
- public static function get_platform_home_link_html($name = '') {
- if ($name == '') {
- $name = api_get_setting('siteName');
- }
- return ''.$name.'';
- }
-
- /**
- * Displays the page header
- * @param string The name of the page (will be showed in the page title)
- * @param string Optional help file name
- */
- public static function display_header($tool_name ='', $help = null) {
- $nameTools = $tool_name;
- global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
- global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $clarolineRepositoryWeb, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
- global $menu_navigation;
- require api_get_path(INCLUDE_PATH).'header.inc.php';
- }
-
- /**
- * Displays the reduced page header (without banner)
- */
- public static function display_reduced_header () {
- global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
- global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $clarolineRepositoryWeb, $text_dir, $plugins, $_user, $rootAdminWeb, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface;
- global $menu_navigation;
- require api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
- }
-
- /**
- * Display the page footer
- */
- public static function display_footer () {
- global $_plugins;
- require api_get_path(INCLUDE_PATH).'footer.inc.php';
- }
-
- /**
- * Prints an ';
}
- }
- $html .= '';
+ }
+ $html .= '';
return $html;
}
-
+
/**
- * Creates a tab menu
+ * Creates a tab menu
* Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css in the $htmlHeadXtra variable before the display_header
* Add this script
- * @example
+ * @example
*
* @param array list of the tab titles
* @param array content that will be showed
* @param string the id of the container of the tab in the example "tabs"
- * @param array attributes for the ul
- *
+ * @param array attributes for the ul
+ *
*/
public static function tabs($header_list, $content_list, $id = 'tabs', $ul_attributes = array()) {
-
+
if (empty($header_list) || count($header_list) == 0 ) {
- return '';
- }
-
- $lis = '';
+ return '';
+ }
+
+ $lis = '';
$i = 1;
foreach ($header_list as $item) {
-
+
$item =self::tag('a', $item, array('href'=>'#'.$id.'-'.$i));
- $lis .=self::tag('li', $item, $ul_attributes);
+ $lis .=self::tag('li', $item, $ul_attributes);
$i++;
}
$ul = self::tag('ul',$lis);
-
+
$i = 1;
$divs = '';
- foreach ($content_list as $content) {
- $content = self::tag('p',$content);
- $divs .=self::tag('div', $content, array('id'=>$id.'-'.$i));
+ foreach ($content_list as $content) {
+ $content = self::tag('p',$content);
+ $divs .=self::tag('div', $content, array('id'=>$id.'-'.$i));
$i++;
- }
+ }
$main_div = self::tag('div',$ul.$divs, array('id'=>$id));
- return $main_div ;
+ return $main_div ;
}
-
+
/**
* In order to display a grid using jqgrid you have to:
* @example
- * After your Display::display_header function you have to add the nex javascript code: *
- *
* //Then you have to call the grid_html
* echo Display::grid_html('my_grid_name');
* As you can see both function use the same "my_grid_name" this is very important otherwise nothing will work
- *
+ *
* @param string the div id, this value must be the same with the first parameter of Display::grid_js()
* @return string html
- *
+ *
*/
public static function grid_html($div_id){
- $table = self::tag('table','',array('id'=>$div_id));
+ $table = self::tag('table','',array('id'=>$div_id));
$table .= self::tag('div','',array('id'=>$div_id.'_pager'));
- return $table;
+ return $table;
}
-
- /**
- * This is a wrapper to use the jqgrid in Chamilo. For the other jqgrid options visit http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
+
+ /**
+ * This is a wrapper to use the jqgrid in Chamilo. For the other jqgrid options visit http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
* This function need to be in the ready jquery function example --> $(function() { }
* In order to work this function needs the Display::grid_html function with the same div id
- *
+ *
* @param string div id
* @param string url where the jqgrid will ask for data (if datatype = json)
- * @param array Visible columns (you should use get_lang). An array in which we place the names of the columns.
- * This is the text that appears in the head of the grid (Header layer).
- * Example: colname {name:'date', index:'date', width:120, align:'right'},
- * @param array the column model : Array which describes the parameters of the columns.This is the most important part of the grid.
+ * @param array Visible columns (you should use get_lang). An array in which we place the names of the columns.
+ * This is the text that appears in the head of the grid (Header layer).
+ * Example: colname {name:'date', index:'date', width:120, align:'right'},
+ * @param array the column model : Array which describes the parameters of the columns.This is the most important part of the grid.
* For a full description of all valid values see colModel API. See the url above.
* @param array extra parameters
* @param array data that will be loaded
- * @return string the js code
- *
+ * @return string the js code
+ *
*/
public static function grid_js($div_id, $url, $column_names, $column_model, $extra_params, $data = array(), $formatter = '', $width_fix = false) {
$obj = new stdClass();
-
+
if (!empty($url))
$obj->url = $url;
-
- $obj->colNames = $column_names;
+
+ $obj->colNames = $column_names;
$obj->colModel = $column_model;
$obj->pager = $div_id.'_pager';
-
+
$obj->datatype = 'json';
if (!empty($extra_params['datatype'])) {
$obj->datatype = $extra_params['datatype'];
}
-
+
//Row even odd style
$obj->altRows = true;
if (!empty($extra_params['altRows'])) {
$obj->altRows = $extra_params['altRows'];
}
-
+
if (!empty($extra_params['sortname'])) {
$obj->sortname = $extra_params['sortname'];
}
@@ -887,30 +888,30 @@ class Display {
if (!empty($extra_params['sortorder'])) {
$obj->sortorder = $extra_params['sortorder'];
}
-
+
if (!empty($extra_params['rowList'])) {
$obj->rowList = $extra_params['rowList'];
}
- //Sets how many records we want to view in the grid
+ //Sets how many records we want to view in the grid
$obj->rowNum = 20;
if (!empty($extra_params['rowNum'])) {
$obj->rowNum = $extra_params['rowNum'];
- }
-
- //height: 'auto',
-
+ }
+
+ //height: 'auto',
+
$obj->viewrecords = 'true';
-
+
if (!empty($extra_params['viewrecords']))
$obj->viewrecords = $extra_params['viewrecords'];
-
+
if (!empty($extra_params)) {
- foreach ($extra_params as $key=>$element){
- $obj->$key = $element;
+ foreach ($extra_params as $key=>$element){
+ $obj->$key = $element;
}
}
-
- //Adding static data
+
+ //Adding static data
if (!empty($data)) {
$data_var = $div_id.'_data';
$json.=' var '.$data_var.' = '.json_encode($data).';';
@@ -919,19 +920,19 @@ class Display {
$obj->data = $data_var;
$obj->datatype = 'local';
$json.="\n";
- }
-
+ }
+
$json_encode = json_encode($obj);
if (!empty($data)) {
//Converts the "data":"js_variable" to "data":js_variable othersiwe it will not work
- $json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode);
+ $json_encode = str_replace('"data":"'.$data_var.'"','"data":'.$data_var.'',$json_encode);
}
-
+
//Fixing true/false js values that doesn't need the ""
$json_encode = str_replace(':"true"',':true',$json_encode);
$json_encode = str_replace(':"false"',':false',$json_encode);
$json_encode = str_replace('"formatter":"action_formatter"','formatter:action_formatter',$json_encode);
-
+
if ($width_fix) {
if (is_numeric($width_fix)) {
$width_fix = intval($width_fix);
@@ -940,71 +941,70 @@ class Display {
}
//see BT#2020
$json .= "$(window).bind('resize', function() {
- $('#".$div_id."').setGridWidth($(window).width() - ".$width_fix.");
- }).trigger('resize');";
+ $('#".$div_id."').setGridWidth($(window).width() - ".$width_fix.");
+ }).trigger('resize');";
}
-
- //Creating the jqgrid element
+
+ //Creating the jqgrid element
$json .= '$("#'.$div_id.'").jqGrid(';
$json .= $json_encode;
$json .= ');';
-
+
$json.="\n";
-
- //Adding edit/delete icons
+
+ //Adding edit/delete icons
$json.=$formatter;
-
+
return $json;
-
+
/*
Real Example
$("#list_week").jqGrid({
url:'',
- datatype: 'json',
+ datatype: 'json',
colNames:['Week','Date','Course', 'LP'],
colModel :[
- {name:'week', index:'week', width:120, align:'right'},
+ {name:'week', index:'week', width:120, align:'right'},
{name:'date', index:'date', width:120, align:'right'},
- {name:'course', index:'course', width:150},
- {name:'lp', index:'lp', width:250}
+ {name:'course', index:'course', width:150},
+ {name:'lp', index:'lp', width:250}
],
pager: '#pager3',
rowNum:100,
- rowList:[10,20,30],
+ rowList:[10,20,30],
sortname: 'date',
sortorder: 'desc',
viewrecords: true,
- grouping:true,
- groupingView : {
+ grouping:true,
+ groupingView : {
groupField : ['week'],
groupColumnShow : [false],
groupText : ['Week {0} - {1} Item(s)']
- }
- }); */
+ }
+ }); */
}
-
+
public static function table($headers, $rows) {
/*
require_once api_get_path(LIBRARY_PATH).'pear/HTML/Table.php';
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
-
- //Course headers
+
+ //Course headers
foreach ($headers as $item) {
$table->setHeaderContents($row, $column, $item);
$column++;
- }
+ }
$row = 1;
$column = 0;
- foreach($rows as $content) {
+ foreach($rows as $content) {
$table->setCellContents($row, $column, $content);
$column++;
- }
+ }
return $table->toHtml();*/
}
-
/**
* Display dashboard link
*
@@ -1012,16 +1012,15 @@ class Display {
/*function display_dashboard_link() {
echo '
';
}*/
-
+
/**
* Show history sessions
*
@@ -1036,6 +1035,7 @@ class Display {
}
}
}*/
+
/**
* Returns the "what's new" icon notifications
*
@@ -1048,7 +1048,7 @@ class Display {
* @param array Course information array, containing at least elements 'db' and 'k'
* @return string The HTML link to be shown next to the course
*/
- function show_notification($my_course) {
+ function show_notification($my_course) {
$statistic_database = Database :: get_statistic_database();
$user_id = api_get_user_id();
$course_database = $my_course['db'];
@@ -1064,7 +1064,7 @@ class Display {
"WHERE access_cours_code = '".$my_course['k']."' ".
"AND access_user_id = '$user_id' AND access_session_id ='".$my_course['id_session']."'";
$resLastTrackInCourse = Database::query($sqlLastTrackInCourse);
-
+
$oldestTrackDate = $oldestTrackDateOrig = '3000-01-01 00:00:00';
while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
$lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
@@ -1076,7 +1076,7 @@ class Display {
//if there was no connexion to the course ever, then take the
// course creation date as a reference
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
- $sql = "SELECT course.creation_date ".
+ $sql = "SELECT course.creation_date ".
"FROM $course_table course ".
"WHERE course.code = '".$my_course['k']."'";
$res = Database::query($sql);
@@ -1105,27 +1105,27 @@ class Display {
while ($res && ($item_property = Database::fetch_array($res))) {
// First thing to check is if the user never entered the tool
// or if his last visit was earlier than the last modification.
- if ((!isset ($lastTrackInCourseDate[$item_property['tool']])
+ if ((!isset ($lastTrackInCourseDate[$item_property['tool']])
|| $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date'])
// Drop the tool elements that are part of a group that the
// user is not part of.
&& ((in_array($item_property['to_group_id'], $group_ids)
// Drop the dropbox, notebook and chat tools (we don't care)
- && ($item_property['tool'] != TOOL_DROPBOX
- && $item_property['tool'] != TOOL_NOTEBOOK
+ && ($item_property['tool'] != TOOL_DROPBOX
+ && $item_property['tool'] != TOOL_NOTEBOOK
&& $item_property['tool'] != TOOL_CHAT)
)
)
// Take only what's visible or invisible but where the user is a teacher or where the visibility is unset.
- && ($item_property['visibility'] == '1'
- || ($my_course['s'] == '1' && $item_property['visibility'] == '0')
- || !isset($item_property['visibility'])))
+ && ($item_property['visibility'] == '1'
+ || ($my_course['s'] == '1' && $item_property['visibility'] == '0')
+ || !isset($item_property['visibility'])))
{
// Also drop announcements and events that are not for the user or his group.
- if (($item_property['tool'] == TOOL_ANNOUNCEMENT
- || $item_property['tool'] == TOOL_CALENDAR_EVENT)
- && (($item_property['to_user_id'] != $user_id )
- && (!isset($item_property['to_group_id'])
+ if (($item_property['tool'] == TOOL_ANNOUNCEMENT
+ || $item_property['tool'] == TOOL_CALENDAR_EVENT)
+ && (($item_property['to_user_id'] != $user_id )
+ && (!isset($item_property['to_group_id'])
|| !in_array($item_property['to_group_id'], $group_ids)))) {
continue;
}
@@ -1137,11 +1137,11 @@ class Display {
}
// If it's a learning path, ensure it is currently visible to the user
if ($item_property['tool'] == TOOL_LEARNPATH) {
- require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
+ require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
if (!learnpath::is_lp_visible_for_student($item_property['ref'],$user_id, $my_course['k'])) {
- continue;
+ continue;
}
-
+
}
$notifications[$item_property['tool']] = $item_property;
}
@@ -1158,6 +1158,7 @@ class Display {
}
return $retvalue;
}
+
/**
* Displays a digest e.g. short summary of new agenda and announcements items.
* This used to be displayed in the right hand menu, but is now
@@ -1233,6 +1234,7 @@ class Display {
return $html;
}
} // End function display_digest
+
/**
* Get the session box details as an array
* @param int Session ID
@@ -1240,11 +1242,11 @@ class Display {
*/
function get_session_title_box($session_id) {
global $nosession;
-
+
if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
global $now, $date_start, $date_end;
}
-
+
$output = array();
if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
@@ -1261,7 +1263,7 @@ class Display {
$session = array();
$session['title'] = $session_info[2];
$session['coach'] = '';
-
+
if ($session_info['date_end'] == '0000-00-00' && $session_info['date_start'] == '0000-00-00') {
//$session['dates'] = Display::tag('i', get_lang('WithoutTimeLimits'));
$session['dates'] = '';
@@ -1273,7 +1275,7 @@ class Display {
$start = $stop = false;
$startt_buffer = $stop_buffer = '';
if ($session_info['date_start'] == '0000-00-00') {
- $session_info['date_start'] = '';
+ $session_info['date_start'] = '';
} else {
$start = true;
$start_buffer = $session_info['date_start'];
@@ -1284,14 +1286,14 @@ class Display {
} else {
$stop = true;
$stop_buffer = $session_info['date_end'];
- $session_info['date_end'] = get_lang('Until').' '.$session_info['date_end'];
+ $session_info['date_end'] = get_lang('Until').' '.$session_info['date_end'];
}
if ($start && $stop) {
- $session['dates'] = Display::tag('i', sprintf(get_lang('FromDateXToDateY'),$start_buffer, $stop_buffer));
+ $session['dates'] = Display::tag('i', sprintf(get_lang('FromDateXToDateY'),$start_buffer, $stop_buffer));
} else {
$session['dates'] = Display::tag('i', $session_info['date_start'].' '.$session_info['date_end']);
}
-
+
if ( api_get_setting('show_session_coach') === 'true' ) {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($session_info[1], $session_info[0]);
}