[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_8-24508-g628a0c6

Rouslan Placella roccivic at users.sourceforge.net
Mon Dec 12 00:07:27 CET 2011


The branch, master has been updated
       via  628a0c646920787933c7e7231e8e5c3574625a12 (commit)
      from  e4bbd02eefa782f3d8b187deb43c661a67b6b1ec (commit)


- Log -----------------------------------------------------------------
commit 628a0c646920787933c7e7231e8e5c3574625a12
Author: Rouslan Placella <rouslan at placella.com>
Date:   Sun Dec 11 23:01:03 2011 +0000

    Speed up PMA_getImage()

-----------------------------------------------------------------------

Summary of changes:
 libraries/common.lib.php |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index fb1c307..62e49ff 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -118,22 +118,29 @@ function PMA_getIcon($icon, $alternate = '', $force_text = false)
  */
 function PMA_getImage($image, $alternate = '', $attributes = array())
 {
+    static $sprites; // cached list of available sprites (if any)
+
     $url       = '';
     $is_sprite = false;
     $alternate = htmlspecialchars($alternate);
 
-    // Check if we have the requested image as a sprite
-    //  and set $url accordingly
-    if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) {
-        include_once $_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php';
-        $sprites = PMA_sprites();
-        $class = str_replace(array('.gif','.png'), '', $image);
-        if (array_key_exists($class, $sprites)) {
-            $is_sprite = true;
-            $url = 'themes/dot.gif';
+    // If it's the first time this function is called
+    if (! isset($sprites)) {
+        // Try to load the list of sprites
+        if (is_readable($_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php')) {
+            include_once $_SESSION['PMA_Theme']->getPath() . '/sprites.lib.php';
+            $sprites = PMA_sprites();
         } else {
-            $url = $GLOBALS['pmaThemeImage'] . $image;
+            // No sprites are available for this theme
+            $sprites = array();
         }
+    }
+    // Check if we have the requested image as a sprite
+    //  and set $url accordingly
+    $class = str_replace(array('.gif','.png'), '', $image);
+    if (array_key_exists($class, $sprites)) {
+        $is_sprite = true;
+        $url = 'themes/dot.gif';
     } else {
         $url = $GLOBALS['pmaThemeImage'] . $image;
     }


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list