<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>phploader/combo_functions.inc.php</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -21,7 +21,7 @@ on a remote combo-service.
     this file in the same location as loader.php.
     
     Note: If the phploader directory does not live in the webserver's root 
-    folder then modify the PATH_TO_LOADER variable in combo.php accordingly.
+    folder then modify the PATH_TO_LIB variable in combo.php accordingly.
     
 2. Download and extract each version of YUI you intend to support into
     the phploader/lib directory.</diff>
      <filename>INSTALL</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 &lt;?PHP
 include(&quot;./inc/config.inc&quot;);
 include(&quot;../phploader/loader.php&quot;);
-$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules
+$loader = new YAHOO_util_Loader($yuiCurrentVersion);
 
 //Specify YUI components to load
 $loader-&gt;load(&quot;calendar&quot;);</diff>
      <filename>examples/phploader-advanced_source.php</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@
         this file in the same location as loader.php.
 
         Note: If the phploader directory does not live in the webserver's root 
-        folder then modify the PATH_TO_LOADER variable in combo.php accordingly
+        folder then modify the PATH_TO_LIB variable accordingly
 
     2. Download and extract each version of YUI you intend to support into
         the phploader/lib directory.
@@ -26,23 +26,15 @@
         etc...
 */
 
+require &quot;./combo_functions.inc.php&quot;;
+
 //Web accessible path to the YUI PHP loader lib directory (Override as needed)
-define(&quot;PATH_TO_LOADER&quot;, server() . &quot;/phploader/lib/&quot;); 
+define(&quot;PATH_TO_LIB&quot;, server() . &quot;/phploader/lib/&quot;); 
 
 //APC Configuration
 define(&quot;APC_AVAIL&quot;, function_exists('apc_fetch') ? true : false);
 define(&quot;APC_TTL&quot;, 0);
 
-//server(): Computes the base URL of the current page (protocol, server, path)
-//credit: http://code.google.com/p/simple-php-framework/ (modified version of full_url), license: MIT
-function server()
-{
-    $s = getenv('HTTPS') ? '' : (getenv('HTTPS') == 'on') ? 's' : '';
-    $protocol = substr(strtolower(getenv('SERVER_PROTOCOL')), 0, strpos(strtolower(getenv('SERVER_PROTOCOL')), '/')) . $s;
-    $port = (getenv('SERVER_PORT') == '80') ? '' : (&quot;:&quot;.getenv('SERVER_PORT'));
-    return $protocol . &quot;://&quot; . getenv('HTTP_HOST') . $port;
-}
-
 $queryString = getenv('QUERY_STRING') ? urldecode(getenv('QUERY_STRING')) : '';
 if (isset($queryString) &amp;&amp; !empty($queryString)) {
     $yuiFiles    = explode(&quot;&amp;&quot;, $queryString);
@@ -50,7 +42,7 @@ if (isset($queryString) &amp;&amp; !empty($queryString)) {
     
     $cache = false;
     if (APC_AVAIL === true) {
-        $cache = apc_fetch('combo:'.$queryString);
+        //$cache = apc_fetch('combo:'.$queryString);
     }
     
     if ($cache) {
@@ -68,8 +60,15 @@ if (isset($queryString) &amp;&amp; !empty($queryString)) {
 
         include(&quot;./loader.php&quot;);
         $loader = new YAHOO_util_Loader($yuiVersion);
-        $base   = PATH_TO_LOADER . $yuiVersion . &quot;/build/&quot;;
-        $loader-&gt;base = $base;
+        $base   = PATH_TO_LIB . $yuiVersion . &quot;/build/&quot;;
+        $baseWithoutBuild = PATH_TO_LIB . $yuiVersion . &quot;/&quot;;
+        $loader-&gt;base = $base; 
+        
+        //Verify this version of the library exists locally
+        $localPathToBuild = &quot;../lib/&quot; . $yuiVersion . &quot;/build/&quot;;
+        if (file_exists($localPathToBuild) === false || is_readable($localPathToBuild ) === false) {
+            die('&lt;!-- Unable to locate the YUI build directory! --&gt;');
+        }
 
         //Detect and load the required components now
         $yuiComponents = array();
@@ -97,11 +96,30 @@ if (isset($queryString) &amp;&amp; !empty($queryString)) {
             }
             echo $rawScript;
         } else {
-            $rawCSS = $loader-&gt;css_raw();
-            //Handle image path corrections
-            $rawCSS = preg_replace('/((url\()(\w+)(.*);)/', '${2}'. $base . '${3}${4}', $rawCSS); // subdirs
-            $rawCSS = preg_replace('/(\.\.\/)+/', $base, $rawCSS); // relative pathes
-            $rawCSS = str_replace(&quot;url(/&quot;, &quot;url($base&quot;, $rawCSS); // url(/whatever)
+            $rawCSS = '';
+            $cssResourceList = $loader-&gt;css_data();
+            foreach ($cssResourceList[&quot;css&quot;] as $cssResource=&gt;$val) {
+                foreach($cssResourceList[&quot;css&quot;][$cssResource] as $key=&gt;$value) {
+                     $crtResourceBase = substr($key, 0, strrpos($key, &quot;/&quot;) + 1);
+                     $crtResourceContent = $loader-&gt;getRemoteContent($key);
+                     
+                     //Handle image path corrections (order is important)
+                     $crtResourceContent = preg_replace('/((url\()(\w+)(.*);)/', '${2}'. $crtResourceBase . '${3}${4}', $crtResourceContent); // subdirs (e.g) url(foo/foo.png)
+                     $crtResourceContent = preg_replace('/(url\([^\.\/]\))+/', $crtResourceBase, $crtResourceContent); // just filename (e.g.) url(picker_mask.png)
+                     $crtResourceContent = str_replace(&quot;url(/&quot;, &quot;url($crtResourceBase&quot;, $crtResourceContent); // slash filename (e.g.) url(/whatever)
+                     $crtResourceContent = preg_replace('/(\.\.\/)+/', $crtResourceBase, $crtResourceContent); // relative pathes (e.g.) url(../../foo.png)
+                     $crtResourceContent = preg_replace_callback(
+                                            '/AlphaImageLoader\(src=[\'&quot;](.*?)[\'&quot;]/',
+                                            'alphaImageLoaderPathCorrection',
+                                            $crtResourceContent
+                                           ); // AlphaImageLoader relative pathes (e.g.) AlphaImageLoader(src='../../foo.png')
+                     
+                     $rawCSS .= $crtResourceContent;
+                 }
+            }
+            
+            //Cleanup build path dups caused by relative pathes that already included the build directory
+            $rawCSS = str_replace(&quot;/build/build/&quot;, &quot;/build/&quot;, $rawCSS);
             
             if (APC_AVAIL === true) {
                 apc_store('combo:'.$queryString, $rawCSS, APC_TTL);</diff>
      <filename>phploader/combo.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3deb6935e97ad6d8a132ca4e1243dc035909cff9</id>
    </parent>
  </parents>
  <author>
    <name>Chad Auld</name>
    <email>chadauld@gmail.com</email>
  </author>
  <url>http://github.com/yui/phploader/commit/3c10b59b8c13ced74c2053262c4a6de1d3f7920e</url>
  <id>3c10b59b8c13ced74c2053262c4a6de1d3f7920e</id>
  <committed-date>2009-11-02T22:38:45-08:00</committed-date>
  <authored-date>2009-11-02T22:38:45-08:00</authored-date>
  <message>Better handling of CSS image path replacements within the local combo handler</message>
  <tree>f24ebc8f724bea8c8b2fa689b7a6332e3564c916</tree>
  <committer>
    <name>Chad Auld</name>
    <email>chadauld@gmail.com</email>
  </committer>
</commit>
