Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Doc and example cleanup. Fixing combo.php query string explode bug. M…

…odifying loader APC/Curl support checks. Adding support for APC to combo.php. Fixing most of the CSS relative image path issues with combo.php.
  • Loading branch information...
commit 5a52dbf376f4d360d90d4a33afbb6df95d45a116 1 parent af5528e
Chad Auld authored
7  CHANGES
@@ -3,3 +3,10 @@ ChangeLog
3 3
 
4 4
 1.0.0b1
5 5
     * Initial release
  6
+
  7
+1.0.0b2
  8
+    * Doc cleanup
  9
+    * Combo script incorrectly exploded the query string on & not &.
  10
+    * Modified APC/Curl support checks
  11
+    * Adding APC support for combo.php
  12
+    * Combo.php was not handling relative image path in the raw css.  Now converts to absolute paths.
7  INSTALL
@@ -15,21 +15,20 @@ Local Combo Handler Setup
15 15
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 16
 
17 17
 This feature will allow YUI PHP Loader to combine files without relying 
18  
-on a remote combo-service.  The key use case here would be someone 
19  
-writing their own website/application in PHP.
  18
+on a remote combo-service.
20 19
 
21 20
 1. The main endpoint for combo requests in this case is combo.php.  Place
22 21
     this file in the same location as loader.php.
23 22
     
24 23
     Note: If the phploader directory does not live in the webserver's root 
25  
-    folder then modify the $pathToYUILoader variable in combo.php accordingly
  24
+    folder then modify the PATH_TO_LOADER variable in combo.php accordingly.
26 25
     
27 26
 2. Download and extract each version of YUI you intend to support into
28 27
     the phploader/lib directory.
29 28
 
30 29
     A valid setup would look something like:
  30
+    htdocs/phploader/lib/2.8.0r4/build
31 31
     htdocs/phploader/lib/2.7.0/build
32  
-    htdocs/phploader/lib/2.6.0/build
33 32
     etc...
34 33
     
35 34
 3. Refer to usage documents and examples:
5  README
@@ -36,8 +36,9 @@ license.txt
36 36
     Open source license details.
37 37
 
38 38
 lib/meta
39  
-    Contains the YUI module dependency metadata.  The latest version is
40  
-    shipped with each release, but you can manually add additional version.
  39
+    Contains the YUI module dependency metadata (for versions 2 and 3).
  40
+    The latest version is shipped with each release, but you can manually
  41
+    add additional version.
41 42
 
42 43
 phploader/loader.php
43 44
     The main YUI PHP Loader class file
2  examples/index.html
@@ -59,7 +59,7 @@ <h1 class="firstContent">
59 59
                                     <li><a href='phploader-basic.php'>Using PHP Loader to Load the Calendar Control (Basic)</a>: This example demonstrates a simple implementation in which we bring in the YUI Calendar Control — and its JavaScript and CSS dependencies — using the PHP Loader Utility.</li>
60 60
                                     <li><a href='phploader-advanced.php'>Using PHP Loader to Load the Calendar Control (Advanced)</a>: This example demonstrates a more advanced implementation in which we bring in the YUI Calendar Control — and its JavaScript and CSS dependencies — using the PHP Loader Utility.  The major difference between this and the previous example is that the CSS and JavaScript are output via separate method calls allowing for more control/optimization.</li>
61 61
                                     <li><a href='phploader-custom-modules.php'>Adding Custom (Non-YUI) Content with PHP Loader</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows one simple way to pull in external content with PHP Loader.</li>
62  
-                                    <li><a href='phploader-custom-modules-with-yui.php'>Adding Custom Modules with YUI Dependencies</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows how to pull in external content that has dependancies on YUI components.</li>
  62
+                                    <li><a href='phploader-custom-modules-with-yui.php'>Adding Custom Modules with YUI Dependencies</a>: PHP Loader can be used to add YUI components to the page, but it can also be used to add other components that you create yourself (or that you pull from a third-party source). This example shows how to pull in external content that has dependencies on YUI components.</li>
63 63
                                     <li><a href='phploader-local-combo-handler.php'>Using the Local Combo Handler</a>: PHP Loader ships with intrinsic combo-handling support. This feature will allow PHP Loader to combine files without relying on a remote combo-service such as the one outlined <a href="http://developer.yahoo.com/yui/articles/hosting/?#combo">here</a>. It should also prove useful in environments where SSL is required and/or where including scripts from remote servers is prohibited.</li>
64 64
                                 </ul>
65 65
                             </div>                            
2  examples/phploader-advanced_source.php
... ...
@@ -1,7 +1,7 @@
1 1
 <?PHP
2 2
 include("./inc/config.inc");
3 3
 include("../phploader/loader.php");
4  
-$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
  4
+$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules
5 5
 
6 6
 //Specify YUI components to load
7 7
 $loader->load("calendar");
13  examples/phploader-basic.php
@@ -34,18 +34,19 @@
34 34
 </ol>
35 35
 <p>Here's what that looks like in terms of raw source &mdash; this is the full source code for this example: </p>
36 36
 <textarea name="code" class="php" cols="60" rows="1">
  37
+&lt;?PHP
  38
+include("loader.php");
  39
+$loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");
  40
+
  41
+//Specify YUI components to load
  42
+$loader->load("calendar");
  43
+?&gt;
37 44
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
38 45
 <html>
39 46
 <head>
40 47
 	<title>YUI PHP Loader Utility Basic Example: Loading YUI Calendar with the YUI PHP Loader Utility</title>
41 48
 
42 49
     &lt;?PHP
43  
-    include("loader.php");
44  
-    $loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");
45  
-    
46  
-    //Specify YUI components to load
47  
-    $loader->load("calendar");
48  
-    
49 50
 	//Output the CSS and JavaScript tags
50 51
     echo $loader->tags();
51 52
 	?&gt;
2  examples/phploader-basic_source.php
... ...
@@ -1,7 +1,7 @@
1 1
 <?PHP
2 2
 include("./inc/config.inc");
3 3
 include("../phploader/loader.php");
4  
-$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
  4
+$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules
5 5
 
6 6
 //Specify YUI components to load
7 7
 $loader->load("calendar");
44  examples/phploader-custom-modules-with-yui.php
@@ -28,29 +28,31 @@
28 28
 	<h2 class="first">Defining a Custom Module with YUI Component Dependencies</h2>
29 29
 
30 30
     <p>
31  
-    The YAHOO_util_Loader class constructor accepts three parameters:
  31
+    The YAHOO_util_Loader class constructor accepts four parameters:
32 32
     </p>
33 33
     <ol>
  34
+        <li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
34 35
         <li><strong>cacheKey</strong>: Unique name to use as the <a href="http://us.php.net/manual/en/book.apc.php">APC</a> cache key.  Module calculations 
35 36
         are cached for performance if the environment supports APC.</li>
36  
-        <li><strong>modules</strong>: A list of custom modules</li>
  37
+        <li><strong>modules</strong>: An array of custom modules</li>
37 38
         <li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
38 39
     </ol>
39 40
     
40 41
     <p>The <em>modules</em> parameter expects an associative array.  The array should consist of custom JavaScript and/or 
41  
-    CSS modules defined using the following format:</p>
  42
+    CSS modules.  The modules array format mirrors that of the YUI metadata included with PHP Loader.  Use the metadata in the lib/meta folder as
  43
+    a reference for determining all the possible options.  Below is an example of such an array:</p>
42 44
     
43 45
     <textarea name="code" class="php" cols="60" rows="1">
44  
-    $customConfig = array(
45  
-        "customJS" => array(
46  
-            "name" => 'customJS',
  46
+    $customModules = array(
  47
+        "JSONModule" => array(
  48
+            "name" => 'JSONModule',
47 49
             "type" => 'js', // 'js' or 'css'
48  
-            // "path" => 'path/to/file3.css', // includes base
49  
-            "fullpath" => '../assets/custom/data.js', // overrides path
50  
-            "global" => true, // globals are always loaded
51  
-            "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
52  
-            // "supersedes" => array (0 => 'something'), // if a rollup
53  
-            // "rollup" => 3 // the rollup threshold
  50
+            // "requires" => array('event', 'dom'),
  51
+            // "optional" => array('connection'),
  52
+            // "supersedes" => array('something'), // if a rollup
  53
+            // "rollup" => 3, // the rollup threshold
  54
+            // "path" => 'path/to/file.js', // includes base
  55
+            "fullpath" => 'http://www.json.org/json2.js' // overrides path
54 56
         )
55 57
     );
56 58
     </textarea>
@@ -76,31 +78,23 @@
76 78
 include("loader.php");
77 79
 
78 80
 //Create a custom module metadata set
79  
-$customConfig = array(
  81
+$customModules = array(
80 82
     "customJS" => array(
81 83
         "name" => 'customJS',
82 84
         "type" => 'js', // 'js' or 'css'
83  
-        // "path" => 'path/to/file3.css', // includes base
84 85
         "fullpath" => './assets/custom/data.js', // overrides path
85  
-        "global" => true, // globals are always loaded
86  
-        "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
87  
-        // "supersedes" => array (0 => 'something'), // if a rollup
88  
-        // "rollup" => 3 // the rollup threshold
  86
+        "requires" => array("event", "dom", "json")
89 87
     ),
90 88
     "customCSS" => array(
91 89
         "name" => 'customCSS',
92  
-        "type" => 'css', // 'js' or 'css'
93  
-        // "path" => 'path/to/file3.css', // includes base
94  
-        "fullpath" => './assets/custom/custom.css', // overrides path
95  
-        "global" => true, // globals are always loaded
96  
-        // "supersedes" => array (0 => 'something'), // if a rollup
97  
-        // "rollup" => 3 // the rollup threshold
  90
+        "type" => 'css',
  91
+        "fullpath" => './assets/custom/custom.css'
98 92
     )
99 93
 );
100 94
 
101 95
 //Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
102 96
 //Note: rand is used here to help cache bust the example
103  
-$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig);
  97
+$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules);
104 98
 $loader->load("customJS", "customCSS");
105 99
 ?&gt;
106 100
 
14  examples/phploader-custom-modules-with-yui_source.php
@@ -3,31 +3,23 @@
3 3
 include("../phploader/loader.php");
4 4
 
5 5
 //Create a custom module metadata set
6  
-$customConfig = array(
  6
+$customModules = array(
7 7
     "customJS" => array(
8 8
         "name" => 'customJS',
9 9
         "type" => 'js', // 'js' or 'css'
10  
-        // "path" => 'path/to/file3.css', // includes base
11 10
         "fullpath" => './assets/custom/data.js', // overrides path
12  
-        "global" => true, // globals are always loaded
13  
-        "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
14  
-        // "supersedes" => array (0 => 'something'), // if a rollup
15  
-        // "rollup" => 3 // the rollup threshold
  11
+        "requires" => array("event", "dom", "json")
16 12
     ),
17 13
     "customCSS" => array(
18 14
         "name" => 'customCSS',
19 15
         "type" => 'css', // 'js' or 'css'
20  
-        // "path" => 'path/to/file3.css', // includes base
21 16
         "fullpath" => './assets/custom/custom.css', // overrides path
22  
-        "global" => true, // globals are always loaded
23  
-        // "supersedes" => array (0 => 'something'), // if a rollup
24  
-        // "rollup" => 3 // the rollup threshold
25 17
     )
26 18
 );
27 19
 
28 20
 //Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
29 21
 //Note: rand is used here to help cache bust the example
30  
-$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig);
  22
+$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules);
31 23
 $loader->load("customJS", "customCSS");
32 24
 ?>
33 25
 
59  examples/phploader-custom-modules.php
@@ -27,36 +27,37 @@
27 27
 	<h2 class="first">Defining a Custom Module</h2>
28 28
 
29 29
     <p>
30  
-    The YAHOO_util_Loader class constructor accepts three parameters:
  30
+    The YAHOO_util_Loader class constructor accepts four parameters:
31 31
     </p>
32 32
     <ol>
  33
+        <li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
33 34
         <li><strong>cacheKey</strong>: Unique name to use as the <a href="http://us.php.net/manual/en/book.apc.php">APC</a> cache key.  Module calculations 
34 35
         are cached for performance if the environment supports APC.</li>
35  
-        <li><strong>modules</strong>: A list of custom modules</li>
  36
+        <li><strong>modules</strong>: An array of custom modules</li>
36 37
         <li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
37 38
     </ol>
38 39
     
39 40
     <p>The <em>modules</em> parameter expects an associative array.  The array should consist of custom JavaScript and/or 
40  
-    CSS modules defined using the following format:</p>
  41
+    CSS modules.  The modules array format mirrors that of the YUI metadata included with PHP Loader.  Use the metadata in the lib/meta folder as
  42
+    a reference for determining all the possible options.  Below is an example of such an array:</p>
41 43
     
42 44
     <textarea name="code" class="php" cols="60" rows="1">
43  
-    $customConfig = array(
44  
-        "dcJson" => array(
45  
-            "name" => 'dcJson',
  45
+    $customModules = array(
  46
+        "JSONModule" => array(
  47
+            "name" => 'JSONModule',
46 48
             "type" => 'js', // 'js' or 'css'
  49
+            // "requires" => array('event', 'dom'),
  50
+            // "optional" => array('connection'),
  51
+            // "supersedes" => array('something'), // if a rollup
  52
+            // "rollup" => 3, // the rollup threshold
47 53
             // "path" => 'path/to/file.js', // includes base
48  
-            "fullpath" => 'http://www.json.org/json2.js', // overrides path
49  
-            // "requires" => array (0 => 'event', 1 => 'dom'),
50  
-            // "optional" => array (0 => 'connection'),
51  
-            // "global" => true, // globals are always loaded
52  
-            // "supersedes" => array (0 => 'something'), // if a rollup
53  
-            // "rollup" => 3 // the rollup threshold
  54
+            "fullpath" => 'http://www.json.org/json2.js' // overrides path
54 55
         )
55 56
     );
56 57
     </textarea>
57 58
     
58 59
     <p><strong>Note:</strong> The module names must be unique and should not conflict with any of the existing YUI 
59  
-    component names if you have chosen to leave the YUI metadata enabled.  To make a custom module dependant on an existing
  60
+    component names if you have chosen to leave the YUI metadata enabled.  To make a custom module dependent on an existing
60 61
     YUI module simply default a <em>requires</em> key/value pair that lists out the desired YUI components.</p>
61 62
 
62 63
     <h2>Simple Example with no YUI Dependencies</h2>
@@ -73,37 +74,29 @@
73 74
 include("loader.php");
74 75
 
75 76
 //Create a custom module metadata set
76  
-$customConfig = array(
77  
-    "dcJson" => array(
78  
-        "name" => 'dcJson',
  77
+$customModules = array(
  78
+    "JSONModule" => array(
  79
+        "name" => 'JSONModule',
79 80
         "type" => 'js', // 'js' or 'css'
80  
-        // "path" => 'path/to/file.js', // includes base
81  
-        "fullpath" => 'http://www.json.org/json2.js', // overrides path
82  
-        // "requires" => array (0 => 'event', 1 => 'dom'),
83  
-        // "optional" => array (0 => 'connection'),
84  
-        // "global" => true, // globals are always loaded
85  
-        // "supersedes" => array (0 => 'something'), // if a rollup
86  
-        // "rollup" => 3 // the rollup threshold
  81
+        "fullpath" => 'http://www.json.org/json2.js' // overrides path
87 82
     ),
88 83
     "customJS" => array(
89 84
         "name" => 'customJS',
90  
-        "type" => 'js', // 'js' or 'css'
91  
-        "fullpath" => './assets/custom/data.js', // overrides path
92  
-        "global" => true, // globals are always loaded
93  
-        "requires" => array (0 => 'dcJson')
  85
+        "type" => 'js',
  86
+        "fullpath" => './assets/custom/data.js',
  87
+        "requires" => array('JSONModule')
94 88
     ),
95 89
     "customCSS" => array(
96 90
         "name" => 'customCSS',
97  
-        "type" => 'css', // 'js' or 'css'
98  
-        "fullpath" => './assets/custom/custom.css', // overrides path
99  
-        "global" => true // globals are always loaded
  91
+        "type" => 'css',
  92
+        "fullpath" => './assets/custom/custom.css'
100 93
     )
101 94
 );
102 95
 
103 96
 //Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
104 97
 //Note: rand is used here to help cache bust the example
105  
-$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig, true);
106  
-$loader->load("dcJson", "customJS", "customCSS");
  98
+$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules, true);
  99
+$loader->load("JSONModule", "customJS", "customCSS");
107 100
 ?&gt;
108 101
 
109 102
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -170,7 +163,7 @@
170 163
     <li><strong>A custom module set is defined</strong></li>
171 164
     <li><strong>An instance of YUI PHP Loader is created:</strong> Our custom module set is passed to the Loader</li>
172 165
     <li><strong>YUI PHP Loader calculates the dependencies and order of our custom modules: </strong>The Loader knows 
173  
-    our <em>customJS</em> module is dependent on our <em>dcJson</em> module.</li>
  166
+    our <em>customJS</em> module is dependent on our <em>JSONModule</em> module.</li>
174 167
     <li><strong>YUI PHP Loader loads the modules and is used to output the CSS and JavaScript: </strong>The &lt;link&gt; 
175 168
     nodes are output in the document head and the &lt;script&gt; nodes are output just before the closing body node.  This 
176 169
     is in accordance with the best practice performance recommendations outlined <a href="http://developer.yahoo.com/performance/rules.html">here</a>.</li>
30  examples/phploader-custom-modules_source.php
@@ -3,37 +3,29 @@
3 3
 include("../phploader/loader.php");
4 4
 
5 5
 //Create a custom module metadata set
6  
-$customConfig = array(
7  
-    "dcJson" => array(
8  
-        "name" => 'dcJson',
  6
+$customModules = array(
  7
+    "JSONModule" => array(
  8
+        "name" => 'JSONModule',
9 9
         "type" => 'js', // 'js' or 'css'
10  
-        // "path" => 'path/to/file.js', // includes base
11  
-        "fullpath" => 'http://www.json.org/json2.js', // overrides path
12  
-        // "requires" => array (0 => 'event', 1 => 'dom'),
13  
-        // "optional" => array (0 => 'connection'),
14  
-        // "global" => true, // globals are always loaded
15  
-        // "supersedes" => array (0 => 'something'), // if a rollup
16  
-        // "rollup" => 3 // the rollup threshold
  10
+        "fullpath" => 'http://www.json.org/json2.js' // overrides path
17 11
     ),
18 12
     "customJS" => array(
19 13
         "name" => 'customJS',
20  
-        "type" => 'js', // 'js' or 'css'
21  
-        "fullpath" => './assets/custom/data.js', // overrides path
22  
-        "global" => true, // globals are always loaded
23  
-        "requires" => array (0 => 'dcJson')
  14
+        "type" => 'js',
  15
+        "fullpath" => './assets/custom/data.js',
  16
+        "requires" => array('JSONModule')
24 17
     ),
25 18
     "customCSS" => array(
26 19
         "name" => 'customCSS',
27  
-        "type" => 'css', // 'js' or 'css'
28  
-        "fullpath" => './assets/custom/custom.css', // overrides path
29  
-        "global" => true // globals are always loaded
  20
+        "type" => 'css',
  21
+        "fullpath" => './assets/custom/custom.css'
30 22
     )
31 23
 );
32 24
 
33 25
 //Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
34 26
 //Note: rand is used here to help cache bust the example
35  
-$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig, true);
36  
-$loader->load("dcJson", "customJS", "customCSS");
  27
+$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules, true);
  28
+$loader->load("JSONModule", "customJS", "customCSS");
37 29
 ?>
38 30
 
39 31
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4  examples/phploader-local-combo-handler.php
@@ -22,7 +22,7 @@
22 22
 
23 23
 <p>This example implements the <a href="http://developer.yahoo.com/yui/phploader/">YUI PHP Loader Utility</a> to load 
24 24
 the <a href="http://developer.yahoo.com/yui/calendar/">Calendar Control</a>.  This example is almost identical to the advanced example 
25  
-outlined <a href="phploader-advanced.html">here</a>.  The only major difference is that we are enabling the combo handling service and overriding the 
  25
+outlined <a href="phploader-advanced.php">here</a>.  The only major difference is that we are enabling the combo handling service and overriding the 
26 26
 default the combo service location.  By default when combo handling is requested YUI PHP Loader will serve files from Yahoo! 
27 27
 servers; see "<a href="http://developer.yahoo.com/yui/articles/hosting/">Serving YUI Files from Yahoo!</a>" for important information about this service.</p>
28 28
 
@@ -56,7 +56,7 @@
56 56
 
57 57
 <p>This example implements the <a href="http://developer.yahoo.com/yui/phploader/">YUI PHP Loader Utility</a> to load 
58 58
 the <a href="http://developer.yahoo.com/yui/calendar/">Calendar Control</a>.  This example is almost identical to the 
59  
-advanced example outlined <a href="phploader-advanced.html">here</a>.  The only major difference is that we are 
  59
+advanced example outlined <a href="phploader-advanced.php">here</a>.  The only major difference is that we are 
60 60
 enabling the combo handling service and overriding the default the combo service location.  By default when combo 
61 61
 handling is requested YUI PHP Loader will serve files from Yahoo! servers; see 
62 62
 "<a href="http://developer.yahoo.com/yui/articles/hosting/">Serving YUI Files from Yahoo!</a>" for important information 
2  index.php
@@ -61,7 +61,7 @@
61 61
   <div id="quicklinks">
62 62
       <h4>Quick Links:</h4>
63 63
       <ul>
64  
-        <li><a href="/yui/docs/module_phploader.html">API Documentation</a></li>
  64
+        <li><a href="api_docs/index.html">API Documentation</a></li>
65 65
         <li><a href="http://yuilibrary.com/downloads/">Download YUI PHP Loader</a> from YUILibrary.com: YUI PHP Loader is available from the YUI project website, but it is a separate download from the YUI JavaScript/CSS library.</li>
66 66
     </ul>
67 67
     </div>
95  phploader/combo.php
@@ -21,13 +21,17 @@
21 21
         the phploader/lib directory.
22 22
 
23 23
         A valid setup would look something like:
  24
+        htdocs/phploader/lib/2.8.0r4/build
24 25
         htdocs/phploader/lib/2.7.0/build
25  
-        htdocs/phploader/lib/2.6.0/build
26 26
         etc...
27 27
 */
28 28
 
29 29
 //Web accessible path to the YUI PHP loader lib directory (Override as needed)
30  
-define("PATH_TO_LOADER", server() . "/phploader/phploader/lib/");
  30
+define("PATH_TO_LOADER", server() . "/phploader/lib/"); 
  31
+
  32
+//APC Configuration
  33
+define("APC_AVAIL", function_exists('apc_fetch') ? true : false);
  34
+define("APC_TTL", 0);
31 35
 
32 36
 //server(): Computes the base URL of the current page (protocol, server, path)
33 37
 //credit: http://code.google.com/p/simple-php-framework/ (modified version of full_url), license: MIT
@@ -41,45 +45,70 @@ function server()
41 45
 
42 46
 $queryString = getenv('QUERY_STRING') ? urldecode(getenv('QUERY_STRING')) : '';
43 47
 if (isset($queryString) && !empty($queryString)) {
44  
-    $yuiFiles    = explode("&amp;", $queryString);
  48
+    $yuiFiles    = explode("&", $queryString);
45 49
     $contentType = strpos($yuiFiles[0], ".js") ? 'application/x-javascript' : ' text/css';
46 50
     
47  
-    //Use the first module to determine which version of the YUI meta info to load
48  
-    if (isset($yuiFiles) && !empty($yuiFiles)) {
49  
-        $metaInfo = explode("/", $yuiFiles[0]);
50  
-        $yuiVersion = $metaInfo[0];
  51
+    $cache = false;
  52
+    if (APC_AVAIL === true) {
  53
+        $cache = apc_fetch('combo:'.$queryString);
51 54
     }
52 55
     
53  
-    include("./loader.php");
54  
-    $loader = new YAHOO_util_Loader($yuiVersion);
55  
-    $base = PATH_TO_LOADER . $loader->comboDefaultVersion . "/build/"; //Defaults to current version
  56
+    if ($cache) {
  57
+        //Set cache headers and output cache content
  58
+        header("Cache-Control: max-age=315360000");
  59
+        header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
  60
+        header("Content-Type: " . $contentType);
  61
+        echo $cache;
  62
+    } else {
  63
+        //Use the first module to determine which version of the YUI meta info to load
  64
+        if (isset($yuiFiles) && !empty($yuiFiles)) {
  65
+            $metaInfo = explode("/", $yuiFiles[0]);
  66
+            $yuiVersion = $metaInfo[0];
  67
+        }
56 68
 
57  
-    //Detect and load the required components now
58  
-    $baseOverrides = array();
59  
-    $yuiComponents = array();
60  
-    foreach($yuiFiles as $yuiFile) {
61  
-        $parts = explode("/", $yuiFile);
62  
-        if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) {
63  
-            //Add module to array for loading
64  
-            $yuiComponents[] = $parts[2];
65  
-        } else {
66  
-           die('<!-- Unable to determine module name! -->');
  69
+        include("./loader.php");
  70
+        $loader = new YAHOO_util_Loader($yuiVersion);
  71
+        $base   = PATH_TO_LOADER . $yuiVersion . "/build/";
  72
+        $loader->base = $base;
  73
+
  74
+        //Detect and load the required components now
  75
+        $yuiComponents = array();
  76
+        foreach($yuiFiles as $yuiFile) {
  77
+            $parts = explode("/", $yuiFile);
  78
+            if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) {
  79
+                //Add module to array for loading
  80
+                $yuiComponents[] = $parts[2];
  81
+            } else {
  82
+               die('<!-- Unable to determine module name! -->');
  83
+            }
67 84
         }
68  
-    }
69  
-    
70  
-    //Load the components
71  
-    call_user_func_array(array($loader, 'load'), $yuiComponents);
72 85
 
73  
-    //Set cache headers and output raw file content
74  
-    header("Cache-Control: max-age=315360000");
75  
-    header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
76  
-    header("Content-Type: " . $contentType);
77  
-    if ($contentType == "application/x-javascript") {
78  
-        echo $loader->script_raw();
79  
-    } else {
80  
-        echo $loader->css_raw();
  86
+        //Load the components
  87
+        call_user_func_array(array($loader, 'load'), $yuiComponents);
  88
+
  89
+        //Set cache headers and output raw file content
  90
+        header("Cache-Control: max-age=315360000");
  91
+        header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
  92
+        header("Content-Type: " . $contentType);
  93
+        if ($contentType == "application/x-javascript") {
  94
+            $rawScript = $loader->script_raw();
  95
+            if (APC_AVAIL === true) {
  96
+                apc_store('combo:'.$queryString, $rawScript, APC_TTL);
  97
+            }
  98
+            echo $rawScript;
  99
+        } else {
  100
+            $rawCSS = $loader->css_raw();
  101
+            //Handle image path corrections
  102
+            $rawCSS = preg_replace('/((url\()(\w+)(.*);)/', '${2}'. $base . '${3}${4}', $rawCSS); // subdirs
  103
+            $rawCSS = preg_replace('/(\.\.\/)+/', $base, $rawCSS); // relative pathes
  104
+            $rawCSS = str_replace("url(/", "url($base", $rawCSS); // url(/whatever)
  105
+            
  106
+            if (APC_AVAIL === true) {
  107
+                apc_store('combo:'.$queryString, $rawCSS, APC_TTL);
  108
+            }
  109
+            echo $rawCSS;
  110
+        }
81 111
     }
82  
-    
83 112
 } else {
84 113
     die('<!-- No YUI modules defined! -->');
85 114
 }
35  phploader/loader.php
@@ -69,7 +69,8 @@ class YAHOO_util_Loader {
69 69
     var $target = "";
70 70
 
71 71
     /**
72  
-    * Combined into a single request using the combo service to pontentially reduce the number of http requests required.
  72
+    * Combined into a single request using the combo service to pontentially reduce the number of 
  73
+    * http requests required.  This option is not supported when loading custom modules.
73 74
     * @property combine
74 75
     * @type boolean
75 76
     * @default false
@@ -224,9 +225,9 @@ function YAHOO_util_Loader($yuiVersion, $cacheKey=null, $modules=null, $noYUI=fa
224 225
         $this->curlAvail  = function_exists('curl_exec');
225 226
         $this->apcAvail   = function_exists('apc_fetch');
226 227
         $this->jsonAvail  = function_exists('json_encode');
227  
-        $this->embedAvail = ($this->curlAvail && $this->apcAvail);
  228
+        $this->customModulesInUse = empty($modules) ? false : true;
228 229
         $this->base = $yui_current[YUI_BASE];
229  
-        $this->comboDefaultVersion = $yuiVersion; //(ex) 2.7.0
  230
+        $this->comboDefaultVersion = $yuiVersion; //$customModules
230 231
         $this->fullCacheKey = null;
231 232
         $cache = null;
232 233
 
@@ -866,9 +867,6 @@ function sortDependencies($moduleType, $skipSort=false) {
866 867
             $reqs[$name] = true;
867 868
         }
868 869
 
869  
-        //print_r($this->requests);
870  
-        //return;
871  
-
872 870
         // get and store the full list of dependencies.
873 871
         foreach ($this->requests as $name=>$val) {
874 872
             $reqs[$name] = true;
@@ -1208,8 +1206,8 @@ function processDependencies($outputType, $moduleType, $skipSort=false, $showLoa
1208 1206
                         $item[YUI_OPTIONAL] = $dep[YUI_OPTIONAL];
1209 1207
                         break;
1210 1208
                     case YUI_TAGS:
1211  
-                    default: 
1212  
-                        if ($this->combine === true) {
  1209
+                    default:
  1210
+                        if ($this->combine === true && $this->customModulesInUse === false) {
1213 1211
                             $this->addToCombo($name, $dep[YUI_TYPE]);
1214 1212
                             $html = $this->getComboLink($dep[YUI_TYPE]);
1215 1213
                         } else {
@@ -1306,8 +1304,11 @@ function getUrl($name) {
1306 1304
     * @return
1307 1305
     */
1308 1306
     function getRemoteContent($url) {
1309  
-
1310  
-        $remote_content = apc_fetch($url);
  1307
+        
  1308
+        $remote_content = null;
  1309
+        if ($this->apcAvail === true) {
  1310
+            $remote_content = apc_fetch($url);
  1311
+        }        
1311 1312
 
1312 1313
         if (!$remote_content) {
1313 1314
 
@@ -1330,7 +1331,9 @@ function getRemoteContent($url) {
1330 1331
             //$this->log("CONTENT: " . $remote_content);
1331 1332
 
1332 1333
             // save the contents of the remote url for 30 minutes
1333  
-            apc_store($url, $remote_content, $this->apcttl);
  1334
+            if ($this->apcAvail === true) {
  1335
+                apc_store($url, $remote_content, $this->apcttl);
  1336
+            }
1334 1337
 
1335 1338
             curl_close ($ch);
1336 1339
         }
@@ -1338,9 +1341,9 @@ function getRemoteContent($url) {
1338 1341
         return $remote_content;
1339 1342
     }
1340 1343
 
1341  
-    function getRaw($name) {
1342  
-        if (!$this->embedAvail) {
1343  
-            return "cURL and/or APC was not detected, so the content can't be embedded";
  1344
+    function getRaw($name) {        
  1345
+        if(!$this->curlAvail) {
  1346
+            return "<!--// cURL was not detected, so the content cannot be fetched -->";
1344 1347
         }
1345 1348
 
1346 1349
         $url = $this->getUrl($name);
@@ -1349,8 +1352,8 @@ function getRaw($name) {
1349 1352
 
1350 1353
     function getContent($name, $type) {
1351 1354
 
1352  
-        if(!$this->embedAvail) {
1353  
-            return "<!--// cURL was not detected, so the content can't be embedded -->" . $this->getLink($name, $type);
  1355
+        if(!$this->curlAvail) {
  1356
+            return "<!--// cURL was not detected, so the content cannot be fetched/embedded -->" . $this->getLink($name, $type);
1354 1357
         }
1355 1358
 
1356 1359
         $url = $this->getUrl($name);

0 notes on commit 5a52dbf

Please sign in to comment.
Something went wrong with that request. Please try again.