From: tjhunt <tjhunt>
Date: Thu, 2 Jul 2009 09:28:19 +0000 (+0000)
Subject: output: MDL-19690 allow for .png or .gif in $OUTPUT->mod/old_icon_url
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3aaa27f4cd92beb099b1575ae62047c69be86351;p=moodle.git

output: MDL-19690 allow for .png or .gif in $OUTPUT->mod/old_icon_url
---

diff --git a/lib/outputlib.php b/lib/outputlib.php
index 3b4a933670..b085d3fe56 100644
--- a/lib/outputlib.php
+++ b/lib/outputlib.php
@@ -524,13 +524,21 @@ class pix_icon_finder implements icon_finder {
     /* Implement interface method. */
     public function old_icon_url($iconname) {
         global $CFG;
-        return $CFG->httpswwwroot . '/pix/' . $iconname . '.gif';
+        if (file_exists($CFG->dirroot . '/pix/' . $iconname . '.png')) {
+            return $CFG->httpswwwroot . '/pix/' . $iconname . '.png';
+        } else {
+            return $CFG->httpswwwroot . '/pix/' . $iconname . '.gif';
+        }
     }
 
     /* Implement interface method. */
     public function mod_icon_url($iconname, $module) {
         global $CFG;
-        return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.gif';
+        if (file_exists($CFG->dirroot . '/mod/' . $module . '/' . $iconname . '.png')) {
+            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.png';
+        } else {
+            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.gif';
+        }
     }
 }
 
@@ -556,13 +564,21 @@ class theme_icon_finder implements icon_finder {
     /* Implement interface method. */
     public function old_icon_url($iconname) {
         global $CFG;
-        return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.gif';
+        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/' . $iconname . '.png')) {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.png';
+        } else {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.gif';
+        }
     }
 
     /* Implement interface method. */
     public function mod_icon_url($iconname, $module) {
         global $CFG;
-        return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.gif';
+        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png')) {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png';
+        } else {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.gif';
+        }
     }
 }
 
@@ -594,8 +610,10 @@ class smartpix_icon_finder extends pix_icon_finder {
     /* Implement interface method. */
     public function old_icon_url($iconname) {
         foreach ($this->places as $dirroot => $urlroot) {
-            if (file_exists($dirroot . $iconname . '.gif')) {
-                return $iconname . $iconname . '.gif';
+            if (file_exists($dirroot . $iconname . '.png')) {
+                return $dirroot . $iconname . '.png';
+            } else if (file_exists($dirroot . $iconname . '.gif')) {
+                return $dirroot . $iconname . '.gif';
             }
         }
         return parent::old_icon_url($iconname);
@@ -604,11 +622,13 @@ class smartpix_icon_finder extends pix_icon_finder {
     /* Implement interface method. */
     public function mod_icon_url($iconname, $module) {
         foreach ($this->places as $dirroot => $urlroot) {
-            if (file_exists($dirroot . 'mod/' . $iconname . '.gif')) {
-                return $iconname . 'mod/' . $iconname . '.gif';
+            if (file_exists($dirroot . 'mod/' . $iconname . '.png')) {
+                return $dirroot . 'mod/' . $iconname . '.png';
+            } else if (file_exists($dirroot . 'mod/' . $iconname . '.gif')) {
+                return $dirroot . 'mod/' . $iconname . '.gif';
             }
         }
-        return parent::old_icon_url($iconname);
+        return parent::old_icon_url($iconname, $module);
     }
 }