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


- Log -----------------------------------------------------------------
commit 628a0c646920787933c7e7231e8e5c3574625a12
Author: Rouslan Placella <[email protected]>
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

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Phpmyadmin-git mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-git

Reply via email to