Browse Source

Minor - format code.

Julio Montoya 10 years ago
parent
commit
228a8c60a7
1 changed files with 142 additions and 48 deletions
  1. 142 48
      main/inc/lib/display.lib.php

+ 142 - 48
main/inc/lib/display.lib.php

@@ -2,7 +2,9 @@
 /* For licensing terms, see /license.txt */
 
 /**
- * This is a display library for Chamilo.
+ * Class Display
+ * Contains several public functions dealing with the display of
+ * table data, messages, help topics, ...
  *
  * Include/require it in your code to use its public functionality.
  * There are also several display public functions in the main api library.
@@ -12,18 +14,8 @@
  * Display::display_normal_message($message)
  *
  * @package chamilo.library
- */
-/**
- * Code
- */
-/**
- * Display class
- * contains several public functions dealing with the display of
- * table data, messages, help topics, ...
  *
- * @package chamilo.library
  */
-
 class Display
 {
     /* The main template*/
@@ -275,8 +267,28 @@ class Display
      * @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, $grid_class = array()) {
-        echo self::return_sortable_grid($name, $header, $content, $paging_options, $query_vars, $form_actions, $visibility_options, $sort_data, $grid_class);
+    public static function display_sortable_grid(
+        $name,
+        $header,
+        $content,
+        $paging_options = array(),
+        $query_vars = null,
+        $form_actions = array(),
+        $visibility_options = true,
+        $sort_data = true,
+        $grid_class = array()
+    ) {
+        echo self::return_sortable_grid(
+            $name,
+            $header,
+            $content,
+            $paging_options,
+            $query_vars,
+            $form_actions,
+            $visibility_options,
+            $sort_data,
+            $grid_class
+        );
     }
 
     /**
@@ -292,8 +304,9 @@ class 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 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
      * @param array grid classes
      * @return 	string   html grid
@@ -318,7 +331,14 @@ class Display
         if (is_array($query_vars)) {
             $table->set_additional_parameters($query_vars);
         }
-        return $table->display_simple_grid($visibility_options, $paging_options['hide_navigation'], $default_items_per_page, $sort_data, $grid_class);
+
+        return $table->display_simple_grid(
+            $visibility_options,
+            $paging_options['hide_navigation'],
+            $default_items_per_page,
+            $sort_data,
+            $grid_class
+        );
     }
 
     /**
@@ -347,7 +367,17 @@ class Display
      *
      * @author Julio Montoya
      */
-    public static function display_sortable_config_table($table_name, $header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $column_show = array(), $column_order = array(), $form_actions = array()) {
+    public static function display_sortable_config_table(
+        $table_name,
+        $header,
+        $content,
+        $sorting_options = array(),
+        $paging_options = array(),
+        $query_vars = null,
+        $column_show = array(),
+        $column_order = array(),
+        $form_actions = array()
+    ) {
         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;
@@ -380,7 +410,8 @@ class Display
      * @param bool	Filter (true) or not (false)
      * @return void
      */
-    public static function display_normal_message($message, $filter = true, $returnValue = false) {
+    public static function display_normal_message($message, $filter = true, $returnValue = false)
+    {
     	$message = self::return_message($message, 'normal', $filter);
         if ($returnValue) {
             return $message;
@@ -531,7 +562,8 @@ class Display
      * @param string  optional, class from stylesheet
      * @return string encrypted mailto hyperlink
      */
-    public static function icon_mailto_link ($email, $icon_file = "mail.png", $icon_size = 22, $style_class = '') {
+    public static function icon_mailto_link($email, $icon_file = "mail.png", $icon_size = 22, $style_class = '')
+    {
         // "mailto:" already present?
         if (substr($email, 0, 7) != 'mailto:') {
             $email = 'mailto:'.$email;
@@ -557,7 +589,8 @@ class Display
      *	@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 = '') {
+    public static function get_platform_home_link_html($name = '')
+    {
         if ($name == '') {
             $name = api_get_setting('siteName');
         }
@@ -569,9 +602,11 @@ class Display
     /**
      * Prints an <option>-list with all letters (A-Z).
      * @param char $selected_letter The letter that should be selected
-     * @todo This is English language specific implementation. It should be adapted for the other languages.
+     * @todo This is English language specific implementation.
+     * It should be adapted for the other languages.
      */
-    public static function get_alphabet_options($selected_letter = '') {
+    public static function get_alphabet_options($selected_letter = '')
+    {
         $result = '';
         for ($i = 65; $i <= 90; $i ++) {
             $letter = chr($i);
@@ -591,7 +626,8 @@ class Display
      * @param int   Default value
      * @return string HTML select options
      */
-    public static function get_numeric_options($min, $max, $selected_num = 0) {
+    public static function get_numeric_options($min, $max, $selected_num = 0)
+    {
         $result = '';
         for ($i = $min; $i <= $max; $i ++) {
             $result .= '<option value="'.$i.'"';
@@ -607,7 +643,8 @@ class Display
     /**
      * Shows the so-called "left" menu for navigating
      */
-    public static function show_course_navigation_menu($isHidden = false) {
+    public static function show_course_navigation_menu($isHidden = false)
+    {
         global $output_string_menu;
         global $_setting;
 
@@ -656,7 +693,12 @@ class Display
      * @param integer  The wanted width of the icon (to be looked for in the corresponding img/icons/ folder)
      * @return void
     */
-    public static function display_icon($image, $alt_text = '', $additional_attributes = array(), $size=null) {
+    public static function display_icon(
+        $image,
+        $alt_text = '',
+        $additional_attributes = array(),
+        $size = null
+    ) {
         echo self::return_icon($image, $alt_text, $additional_attributes, $size);
     }
 
@@ -674,7 +716,14 @@ class Display
      * @author Yannick Warnier 2011 Added size handler
      * @version Feb 2011
     */
-    public static function return_icon($image, $alt_text = '', $additional_attributes = array(), $size = ICON_SIZE_SMALL, $show_text = true, $return_only_path = false) {
+    public static function return_icon(
+        $image,
+        $alt_text = '',
+        $additional_attributes = array(),
+        $size = ICON_SIZE_SMALL,
+        $show_text = true,
+        $return_only_path = false
+    ) {
 
         $code_path   = api_get_path(SYS_CODE_PATH);
         $w_code_path = api_get_path(WEB_CODE_PATH);
@@ -723,8 +772,8 @@ class Display
      * @param array additional attributes (for instance height, width, onclick, ...)
      * @author Julio Montoya 2010
      */
-    public static function img($image_path, $alt_text = '', $additional_attributes = array()) {
-
+    public static function img($image_path, $alt_text = '', $additional_attributes = array())
+    {
         // Sanitizing the parameter $image_path
         $image_path = Security::filter_img_path($image_path);
 
@@ -753,7 +802,8 @@ class Display
      * @param array $additional_attributes (for instance height, width, onclick, ...)
      * @author Julio Montoya 2010
      */
-    public static function tag($tag, $content, $additional_attributes = array()) {
+    public static function tag($tag, $content, $additional_attributes = array())
+    {
         $attribute_list = '';
         // Managing the additional attributes
         if (!empty($additional_attributes) && is_array($additional_attributes)) {
@@ -774,7 +824,8 @@ class Display
     /**
      * Creates a URL anchor
      */
-    public static function url($name, $url, $extra_attributes = array()) {
+    public static function url($name, $url, $extra_attributes = array())
+    {
         if (!empty($url)) {
             $extra_attributes['href']= $url;
         }
@@ -783,15 +834,21 @@ class Display
 
     /**
      * Creates a div tag
+     *
+     * @param $content
+     * @param array $extra_attributes
+     * @return string
      */
-    public static function div($content, $extra_attributes = array()) {
+    public static function div($content, $extra_attributes = array())
+    {
         return self::tag('div', $content, $extra_attributes);
     }
 
     /**
      * Creates a span tag
      */
-    public static function span($content, $extra_attributes = array()) {
+    public static function span($content, $extra_attributes = array())
+    {
         return self::tag('span', $content, $extra_attributes);
     }
 
@@ -799,7 +856,8 @@ class Display
      * Displays an HTML input tag
      *
      */
-    public static function input($type, $name, $value, $extra_attributes = array()) {
+    public static function input($type, $name, $value, $extra_attributes = array())
+    {
          if (isset($type)) {
             $extra_attributes['type']= $type;
          }
@@ -812,7 +870,14 @@ class Display
         return self::tag('input', '', $extra_attributes);
     }
 
-    public static function button($name, $value, $extra_attributes = array()) {
+    /**
+     * @param $name
+     * @param $value
+     * @param array $extra_attributes
+     * @return string
+     */
+    public static function button($name, $value, $extra_attributes = array())
+    {
     	if (!empty($name)) {
     		$extra_attributes['name']= $name;
     	}
@@ -823,7 +888,14 @@ class Display
      * Displays an HTML select tag
      *
      */
-    public static function select($name, $values, $default = -1, $extra_attributes = array(), $show_blank_item = true, $blank_item_text = null) {
+    public static function select(
+        $name,
+        $values,
+        $default = -1,
+        $extra_attributes = array(),
+        $show_blank_item = true,
+        $blank_item_text = null
+    ) {
         $html = '';
         $extra = '';
         $default_id =  'id="'.$name.'" ';
@@ -872,7 +944,8 @@ class Display
 
     /**
      * Creates a tab menu
-     * Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css  in the $htmlHeadXtra variable before the display_header
+     * Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css
+     * in the $htmlHeadXtra variable before the display_header
      * Add this script
      * @example
              * <script>
@@ -886,8 +959,8 @@ class Display
      * @param   array   attributes for the ul
      *
      */
-    public static function tabs($header_list, $content_list, $id = 'tabs', $attributes = array(), $ul_attributes = array()) {
-
+    public static function tabs($header_list, $content_list, $id = 'tabs', $attributes = array(), $ul_attributes = array())
+    {
         if (empty($header_list) || count($header_list) == 0 ) {
             return '';
         }
@@ -913,7 +986,8 @@ class Display
         return $main_div ;
     }
 
-    public static function tabs_only_link($header_list, $selected = null) {
+    public static function tabs_only_link($header_list, $selected = null)
+    {
          $id = uniqid();
          $i = 1;
          $lis = null;
@@ -964,8 +1038,10 @@ class Display
     }
 
     /**
-     * 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() { <?php echo Display::grid_js('grid' ...); ?> }
+     * 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() { <?php echo Display::grid_js('grid' ...); ?> }
      * In order to work this function needs the Display::grid_html function with the same div id
      *
      * @param   string  $div_id div id
@@ -1130,8 +1206,8 @@ class Display
      * @param array $attributes
      * @return string
      */
-    public static function table($headers, $rows, $attributes = array()) {
-
+    public static function table($headers, $rows, $attributes = array())
+    {
     	if (empty($attributes)) {
     		$attributes['class'] = 'data_table';
         }
@@ -1321,7 +1397,8 @@ class Display
      *
      * @version 1.0
      */
-    public static function display_digest($toolsList, $digest, $orderKey, $courses) {
+    public static function display_digest($toolsList, $digest, $orderKey, $courses)
+    {
         $html = '';
         if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both)) {
             // // // LEVEL 1 // // //
@@ -1494,7 +1571,8 @@ class Display
 	 * @param	bool	add a div wrapper
 	 * @todo	use     templates
      **/
-    public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true) {
+    public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true)
+    {
 		$number_of_users_who_voted =  isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
 
 		$percentage =  isset($point_info['point_average']) ? $point_info['point_average'] : 0;
@@ -1653,7 +1731,12 @@ class Display
         return null;
     }
 
-    public static function badge_group($badge_list) {
+    /**
+     * @param array $badge_list
+     * @return string
+     */
+    public static function badge_group($badge_list)
+    {
         $html = '<div class="badge-group">';
         foreach ($badge_list as $badge) {
             $html .= $badge;
@@ -1662,6 +1745,11 @@ class Display
         return $html;
     }
 
+    /**
+     * @param string $content
+     * @param string $type
+     * @return string
+     */
     public static function label($content, $type = null) {
         $class = '';
         switch ($type) {
@@ -1691,6 +1779,10 @@ class Display
         return $html;
     }
 
+    /**
+     * @param array $items
+     * @return null|string
+     */
     public static function actions($items) {
         $html = null;
         if (!empty($items)) {
@@ -1712,14 +1804,16 @@ class Display
     /**
      * Prints a tooltip
      */
-    public static function tip($text, $tip)  {
+    public static function tip($text, $tip)
+    {
         if (empty($tip)) {
             return $text;
         }
         return self::span($text, array('class' => 'boot-tooltip', 'title' => strip_tags($tip)));
     }
 
-    public static function generate_accordion($items, $type = 'jquery', $id = null) {
+    public static function generate_accordion($items, $type = 'jquery', $id = null)
+    {
         $html = null;
         if (!empty($items)) {
             if (empty($id)) {