, 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)
{
include (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); //default
}
}
/**
* Display simple html header of table.
*/
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
* @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("Dokeos light grey is " . DOKEOSLIGHTGREY);
$bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
echo "
\n";
echo "
";
foreach ($column_header as $table_element)
{
echo "
".$table_element."
";
}
echo "
\n";
echo "\n";
$bgcolor = "bgcolor='".HTML_WHITE."'";
return $bgcolor;
}
/**
* Displays a table row.
*
* @param $bgcolor the background colour for the table
* @param $table_row an array with the row elements
* @param $is_alternating true: the row colours alternate, false otherwise
*/
public static function display_table_row ($bgcolor, $table_row, $is_alternating = true) {
echo "
";
foreach ($table_row as $table_element)
{
echo "
".$table_element."
";
}
echo "
\n";
if ($is_alternating)
{
if ($bgcolor == "bgcolor='".HTML_WHITE."'")
{
$bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
}
else
{
if ($bgcolor == "bgcolor='".DOKEOSLIGHTGREY."'")
{
$bgcolor = "bgcolor='".HTML_WHITE."'";
}
}
}
return $bgcolor;
}
/**
* Displays a table row.
* This public function has more options and is easier to extend than display_table_row()
*
* @param $properties, array with properties:
* ["bgcolor"] - the background colour for the table
* ["is_alternating"] - true: the row colours alternate, false otherwise
* ["align_row"] - an array with, per cell, left|center|right
* @todo add valign property
*/
public static function display_complex_table_row ($properties, $table_row) {
$bgcolor = $properties["bgcolor"];
$is_alternating = $properties["is_alternating"];
$align_row = $properties["align_row"];
echo "
\n";
if ($is_alternating)
{
if ($bgcolor == "bgcolor='".HTML_WHITE."'")
$bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
else
if ($bgcolor == "bgcolor='".DOKEOSLIGHTGREY."'")
$bgcolor = "bgcolor='".HTML_WHITE."'";
}
return $bgcolor;
}
/**
* display html footer of table
*/
public static function display_table_footer() {
echo "
";
}
/**
* Display 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: $vibility_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(), $vibility_options = 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);
}
echo $table->display_simple_grid($vibility_options, $paging_options['hide_navigation']);
}
/**
* 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: $vibility_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(), $vibility_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);
}
//var_dump($table->get_additional_url_paramstring());
return $table->display_simple_grid($vibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
}
/**
* Display 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;$iset_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) {
global $charset;
if($filter) {
//filter message
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
}
if (!headers_sent())
{
echo '
';
}
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) {
global $charset;
if($filter){
//filter message
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
}
if (!headers_sent())
{
echo '
';
}
echo '
';
}
/**
* Displays an confirmation message. Use this if something has been done successfully
*
* @author Patrick Cool , Ghent University
* @param string $message
* @param bool Filter (true) or not (false)
* @return void
*/
public static function display_confirmation_message ($message,$filter=true) {
global $charset;
if($filter){
//filter message
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
}
if (!headers_sent())
{
echo '
';
}
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) {
global $charset;
if($filter){
//filter message
$message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : $charset);
}
if (!headers_sent())
{
echo '
';
}
echo '