Browse Source

Fixing bug when changing visibility of tools in the course homepage when using custom icons see BT#4202

Julio Montoya 13 years ago
parent
commit
629f63dba4
2 changed files with 13 additions and 7 deletions
  1. 3 3
      main/inc/ajax/course_home.ajax.php
  2. 10 4
      main/inc/lib/display.lib.php

+ 3 - 3
main/inc/ajax/course_home.ajax.php

@@ -16,9 +16,9 @@ switch ($action) {
 			$tool_info = api_get_tool_information($_GET["id"]);
 			$tool_visibility   = $tool_info['visibility'];
 			$tool_image        = $tool_info['image'];
-			if (api_get_setting('homepage_view') != 'activity_big') {			
-                $new_image         = api_get_path(WEB_IMG_PATH).str_replace('.gif','_na.gif',$tool_image);
-                $tool_image        = api_get_path(WEB_IMG_PATH).$tool_image;    
+			if (api_get_setting('homepage_view') != 'activity_big') {			                    
+                $new_image        = Display::return_icon(str_replace('.gif','_na.gif',$tool_image), null, null, null, null, true);
+                $tool_image       = Display::return_icon($tool_image, null, null, null, null, true);
 			} else {
 			    $tool_image        = $tool_info['image'];
 			    $tool_image        = (substr($tool_info['image'], 0, strpos($tool_info['image'], '.'))).'.png';

+ 10 - 4
main/inc/lib/display.lib.php

@@ -555,7 +555,7 @@ 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) {
+    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);
@@ -568,6 +568,8 @@ class Display {
         if (isset($size)) {
             $size = intval($size);            
             $size_extra = $size.'/';
+        } else {
+            $size = ICON_SIZE_SMALL;
         }
         
         //Checking the theme icons folder example: main/css/chamilo/icons/XXX
@@ -578,8 +580,13 @@ class Display {
             $icon = $w_code_path.'img/icons/'.$size_extra.$image;
         } else {
             //Checking the img/ folder
-            $icon = $w_code_path.'img/'.$image;
-        }        
+            $icon = $w_code_path.'img/'.$image;            
+        }
+        
+        if ($return_only_path) {
+            return $icon;
+        }
+        
         $img = self::img($icon, $alt_text, $additional_attributes);
         if (SHOW_TEXT_NEAR_ICONS == true and !empty($alt_text)) {
             if ($show_text) {
@@ -602,7 +609,6 @@ class Display {
         // Sanitizing the parameter $image_path
         $image_path = Security::filter_img_path($image_path);
 
-        $attribute_list = '';
         // alt text = the image name if there is none provided (for XHTML compliance)
         if ($alt_text == '') {
             $alt_text = basename($image_path);