Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@cauld cauld authored
View
7 CHANGES
@@ -3,3 +3,10 @@ ChangeLog
1.0.0b1
* Initial release
+
+1.0.0b2
+ * Doc cleanup
+ * Combo script incorrectly exploded the query string on & not &.
+ * Modified APC/Curl support checks
+ * Adding APC support for combo.php
+ * Combo.php was not handling relative image path in the raw css. Now converts to absolute paths.
View
7 INSTALL
@@ -15,21 +15,20 @@ Local Combo Handler Setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This feature will allow YUI PHP Loader to combine files without relying
-on a remote combo-service. The key use case here would be someone
-writing their own website/application in PHP.
+on a remote combo-service.
1. The main endpoint for combo requests in this case is combo.php. Place
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 $pathToYUILoader variable in combo.php accordingly
+ folder then modify the PATH_TO_LOADER variable in combo.php accordingly.
2. Download and extract each version of YUI you intend to support into
the phploader/lib directory.
A valid setup would look something like:
+ htdocs/phploader/lib/2.8.0r4/build
htdocs/phploader/lib/2.7.0/build
- htdocs/phploader/lib/2.6.0/build
etc...
3. Refer to usage documents and examples:
View
5 README
@@ -36,8 +36,9 @@ license.txt
Open source license details.
lib/meta
- Contains the YUI module dependency metadata. The latest version is
- shipped with each release, but you can manually add additional version.
+ Contains the YUI module dependency metadata (for versions 2 and 3).
+ The latest version is shipped with each release, but you can manually
+ add additional version.
phploader/loader.php
The main YUI PHP Loader class file
View
2  examples/index.html
@@ -59,7 +59,7 @@ <h1 class="firstContent">
<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>
<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>
<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>
- <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>
+ <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>
<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>
</ul>
</div>
View
2  examples/phploader-advanced_source.php
@@ -1,7 +1,7 @@
<?PHP
include("./inc/config.inc");
include("../phploader/loader.php");
-$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
+$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules
//Specify YUI components to load
$loader->load("calendar");
View
13 examples/phploader-basic.php
@@ -34,18 +34,19 @@
</ol>
<p>Here's what that looks like in terms of raw source &mdash; this is the full source code for this example: </p>
<textarea name="code" class="php" cols="60" rows="1">
+&lt;?PHP
+include("loader.php");
+$loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");
+
+//Specify YUI components to load
+$loader->load("calendar");
+?&gt;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI PHP Loader Utility Basic Example: Loading YUI Calendar with the YUI PHP Loader Utility</title>
&lt;?PHP
- include("loader.php");
- $loader = new YAHOO_util_Loader("<?PHP echo($yuiCurrentVersion);?>");
-
- //Specify YUI components to load
- $loader->load("calendar");
-
//Output the CSS and JavaScript tags
echo $loader->tags();
?&gt;
View
2  examples/phploader-basic_source.php
@@ -1,7 +1,7 @@
<?PHP
include("./inc/config.inc");
include("../phploader/loader.php");
-$loader = new YAHOO_util_Loader($yuiCurrentVersion); //(ex) 2.7.0
+$loader = new YAHOO_util_Loader($yuiCurrentVersion); //$customModules
//Specify YUI components to load
$loader->load("calendar");
View
44 examples/phploader-custom-modules-with-yui.php
@@ -28,29 +28,31 @@
<h2 class="first">Defining a Custom Module with YUI Component Dependencies</h2>
<p>
- The YAHOO_util_Loader class constructor accepts three parameters:
+ The YAHOO_util_Loader class constructor accepts four parameters:
</p>
<ol>
+ <li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
<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
are cached for performance if the environment supports APC.</li>
- <li><strong>modules</strong>: A list of custom modules</li>
+ <li><strong>modules</strong>: An array of custom modules</li>
<li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
</ol>
<p>The <em>modules</em> parameter expects an associative array. The array should consist of custom JavaScript and/or
- CSS modules defined using the following format:</p>
+ 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
+ a reference for determining all the possible options. Below is an example of such an array:</p>
<textarea name="code" class="php" cols="60" rows="1">
- $customConfig = array(
- "customJS" => array(
- "name" => 'customJS',
+ $customModules = array(
+ "JSONModule" => array(
+ "name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
- // "path" => 'path/to/file3.css', // includes base
- "fullpath" => '../assets/custom/data.js', // overrides path
- "global" => true, // globals are always loaded
- "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ // "requires" => array('event', 'dom'),
+ // "optional" => array('connection'),
+ // "supersedes" => array('something'), // if a rollup
+ // "rollup" => 3, // the rollup threshold
+ // "path" => 'path/to/file.js', // includes base
+ "fullpath" => 'http://www.json.org/json2.js' // overrides path
)
);
</textarea>
@@ -76,31 +78,23 @@
include("loader.php");
//Create a custom module metadata set
-$customConfig = array(
+$customModules = array(
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
- // "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/data.js', // overrides path
- "global" => true, // globals are always loaded
- "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "requires" => array("event", "dom", "json")
),
"customCSS" => array(
"name" => 'customCSS',
- "type" => 'css', // 'js' or 'css'
- // "path" => 'path/to/file3.css', // includes base
- "fullpath" => './assets/custom/custom.css', // overrides path
- "global" => true, // globals are always loaded
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "type" => 'css',
+ "fullpath" => './assets/custom/custom.css'
)
);
//Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
//Note: rand is used here to help cache bust the example
-$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig);
+$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules);
$loader->load("customJS", "customCSS");
?&gt;
View
14 examples/phploader-custom-modules-with-yui_source.php
@@ -3,31 +3,23 @@
include("../phploader/loader.php");
//Create a custom module metadata set
-$customConfig = array(
+$customModules = array(
"customJS" => array(
"name" => 'customJS',
"type" => 'js', // 'js' or 'css'
- // "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/data.js', // overrides path
- "global" => true, // globals are always loaded
- "requires" => array (0 => 'event', 1 => 'dom', 2 => 'json'),
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "requires" => array("event", "dom", "json")
),
"customCSS" => array(
"name" => 'customCSS',
"type" => 'css', // 'js' or 'css'
- // "path" => 'path/to/file3.css', // includes base
"fullpath" => './assets/custom/custom.css', // overrides path
- "global" => true, // globals are always loaded
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
)
);
//Get a new YAHOO_util_Loader instance which includes our custom metadata along with the base YUI metadata
//Note: rand is used here to help cache bust the example
-$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig);
+$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules);
$loader->load("customJS", "customCSS");
?>
View
59 examples/phploader-custom-modules.php
@@ -27,36 +27,37 @@
<h2 class="first">Defining a Custom Module</h2>
<p>
- The YAHOO_util_Loader class constructor accepts three parameters:
+ The YAHOO_util_Loader class constructor accepts four parameters:
</p>
<ol>
+ <li><strong>yuiVersion</strong>: Version of YUI metadata to load</li>
<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
are cached for performance if the environment supports APC.</li>
- <li><strong>modules</strong>: A list of custom modules</li>
+ <li><strong>modules</strong>: An array of custom modules</li>
<li><strong>noYUI</strong>: Enable or disable the base YUI metadata</li>
</ol>
<p>The <em>modules</em> parameter expects an associative array. The array should consist of custom JavaScript and/or
- CSS modules defined using the following format:</p>
+ 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
+ a reference for determining all the possible options. Below is an example of such an array:</p>
<textarea name="code" class="php" cols="60" rows="1">
- $customConfig = array(
- "dcJson" => array(
- "name" => 'dcJson',
+ $customModules = array(
+ "JSONModule" => array(
+ "name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
+ // "requires" => array('event', 'dom'),
+ // "optional" => array('connection'),
+ // "supersedes" => array('something'), // if a rollup
+ // "rollup" => 3, // the rollup threshold
// "path" => 'path/to/file.js', // includes base
- "fullpath" => 'http://www.json.org/json2.js', // overrides path
- // "requires" => array (0 => 'event', 1 => 'dom'),
- // "optional" => array (0 => 'connection'),
- // "global" => true, // globals are always loaded
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "fullpath" => 'http://www.json.org/json2.js' // overrides path
)
);
</textarea>
<p><strong>Note:</strong> The module names must be unique and should not conflict with any of the existing YUI
- component names if you have chosen to leave the YUI metadata enabled. To make a custom module dependant on an existing
+ component names if you have chosen to leave the YUI metadata enabled. To make a custom module dependent on an existing
YUI module simply default a <em>requires</em> key/value pair that lists out the desired YUI components.</p>
<h2>Simple Example with no YUI Dependencies</h2>
@@ -73,37 +74,29 @@
include("loader.php");
//Create a custom module metadata set
-$customConfig = array(
- "dcJson" => array(
- "name" => 'dcJson',
+$customModules = array(
+ "JSONModule" => array(
+ "name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
- // "path" => 'path/to/file.js', // includes base
- "fullpath" => 'http://www.json.org/json2.js', // overrides path
- // "requires" => array (0 => 'event', 1 => 'dom'),
- // "optional" => array (0 => 'connection'),
- // "global" => true, // globals are always loaded
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "fullpath" => 'http://www.json.org/json2.js' // overrides path
),
"customJS" => array(
"name" => 'customJS',
- "type" => 'js', // 'js' or 'css'
- "fullpath" => './assets/custom/data.js', // overrides path
- "global" => true, // globals are always loaded
- "requires" => array (0 => 'dcJson')
+ "type" => 'js',
+ "fullpath" => './assets/custom/data.js',
+ "requires" => array('JSONModule')
),
"customCSS" => array(
"name" => 'customCSS',
- "type" => 'css', // 'js' or 'css'
- "fullpath" => './assets/custom/custom.css', // overrides path
- "global" => true // globals are always loaded
+ "type" => 'css',
+ "fullpath" => './assets/custom/custom.css'
)
);
//Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
//Note: rand is used here to help cache bust the example
-$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customConfig, true);
-$loader->load("dcJson", "customJS", "customCSS");
+$loader = new YAHOO_util_Loader('<?PHP echo($yuiCurrentVersion);?>', 'my_custom_config_'.rand(), $customModules, true);
+$loader->load("JSONModule", "customJS", "customCSS");
?&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -170,7 +163,7 @@
<li><strong>A custom module set is defined</strong></li>
<li><strong>An instance of YUI PHP Loader is created:</strong> Our custom module set is passed to the Loader</li>
<li><strong>YUI PHP Loader calculates the dependencies and order of our custom modules: </strong>The Loader knows
- our <em>customJS</em> module is dependent on our <em>dcJson</em> module.</li>
+ our <em>customJS</em> module is dependent on our <em>JSONModule</em> module.</li>
<li><strong>YUI PHP Loader loads the modules and is used to output the CSS and JavaScript: </strong>The &lt;link&gt;
nodes are output in the document head and the &lt;script&gt; nodes are output just before the closing body node. This
is in accordance with the best practice performance recommendations outlined <a href="http://developer.yahoo.com/performance/rules.html">here</a>.</li>
View
30 examples/phploader-custom-modules_source.php
@@ -3,37 +3,29 @@
include("../phploader/loader.php");
//Create a custom module metadata set
-$customConfig = array(
- "dcJson" => array(
- "name" => 'dcJson',
+$customModules = array(
+ "JSONModule" => array(
+ "name" => 'JSONModule',
"type" => 'js', // 'js' or 'css'
- // "path" => 'path/to/file.js', // includes base
- "fullpath" => 'http://www.json.org/json2.js', // overrides path
- // "requires" => array (0 => 'event', 1 => 'dom'),
- // "optional" => array (0 => 'connection'),
- // "global" => true, // globals are always loaded
- // "supersedes" => array (0 => 'something'), // if a rollup
- // "rollup" => 3 // the rollup threshold
+ "fullpath" => 'http://www.json.org/json2.js' // overrides path
),
"customJS" => array(
"name" => 'customJS',
- "type" => 'js', // 'js' or 'css'
- "fullpath" => './assets/custom/data.js', // overrides path
- "global" => true, // globals are always loaded
- "requires" => array (0 => 'dcJson')
+ "type" => 'js',
+ "fullpath" => './assets/custom/data.js',
+ "requires" => array('JSONModule')
),
"customCSS" => array(
"name" => 'customCSS',
- "type" => 'css', // 'js' or 'css'
- "fullpath" => './assets/custom/custom.css', // overrides path
- "global" => true // globals are always loaded
+ "type" => 'css',
+ "fullpath" => './assets/custom/custom.css'
)
);
//Get a new YAHOO_util_Loader instance which includes just our custom metadata (No YUI metadata)
//Note: rand is used here to help cache bust the example
-$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customConfig, true);
-$loader->load("dcJson", "customJS", "customCSS");
+$loader = new YAHOO_util_Loader($yuiCurrentVersion, 'my_custom_config_'.rand(), $customModules, true);
+$loader->load("JSONModule", "customJS", "customCSS");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
View
4 examples/phploader-local-combo-handler.php
@@ -22,7 +22,7 @@
<p>This example implements the <a href="http://developer.yahoo.com/yui/phploader/">YUI PHP Loader Utility</a> to load
the <a href="http://developer.yahoo.com/yui/calendar/">Calendar Control</a>. This example is almost identical to the advanced example
-outlined <a href="phploader-advanced.html">here</a>. The only major difference is that we are enabling the combo handling service and overriding the
+outlined <a href="phploader-advanced.php">here</a>. The only major difference is that we are enabling the combo handling service and overriding the
default the combo service location. By default when combo handling is requested YUI PHP Loader will serve files from Yahoo!
servers; see "<a href="http://developer.yahoo.com/yui/articles/hosting/">Serving YUI Files from Yahoo!</a>" for important information about this service.</p>
@@ -56,7 +56,7 @@
<p>This example implements the <a href="http://developer.yahoo.com/yui/phploader/">YUI PHP Loader Utility</a> to load
the <a href="http://developer.yahoo.com/yui/calendar/">Calendar Control</a>. This example is almost identical to the
-advanced example outlined <a href="phploader-advanced.html">here</a>. The only major difference is that we are
+advanced example outlined <a href="phploader-advanced.php">here</a>. The only major difference is that we are
enabling the combo handling service and overriding the default the combo service location. By default when combo
handling is requested YUI PHP Loader will serve files from Yahoo! servers; see
"<a href="http://developer.yahoo.com/yui/articles/hosting/">Serving YUI Files from Yahoo!</a>" for important information
View
2  index.php
@@ -61,7 +61,7 @@
<div id="quicklinks">
<h4>Quick Links:</h4>
<ul>
- <li><a href="/yui/docs/module_phploader.html">API Documentation</a></li>
+ <li><a href="api_docs/index.html">API Documentation</a></li>
<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>
</ul>
</div>
View
95 phploader/combo.php
@@ -21,13 +21,17 @@
the phploader/lib directory.
A valid setup would look something like:
+ htdocs/phploader/lib/2.8.0r4/build
htdocs/phploader/lib/2.7.0/build
- htdocs/phploader/lib/2.6.0/build
etc...
*/
//Web accessible path to the YUI PHP loader lib directory (Override as needed)
-define("PATH_TO_LOADER", server() . "/phploader/phploader/lib/");
+define("PATH_TO_LOADER", server() . "/phploader/lib/");
+
+//APC Configuration
+define("APC_AVAIL", function_exists('apc_fetch') ? true : false);
+define("APC_TTL", 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
@@ -41,45 +45,70 @@ function server()
$queryString = getenv('QUERY_STRING') ? urldecode(getenv('QUERY_STRING')) : '';
if (isset($queryString) && !empty($queryString)) {
- $yuiFiles = explode("&amp;", $queryString);
+ $yuiFiles = explode("&", $queryString);
$contentType = strpos($yuiFiles[0], ".js") ? 'application/x-javascript' : ' text/css';
- //Use the first module to determine which version of the YUI meta info to load
- if (isset($yuiFiles) && !empty($yuiFiles)) {
- $metaInfo = explode("/", $yuiFiles[0]);
- $yuiVersion = $metaInfo[0];
+ $cache = false;
+ if (APC_AVAIL === true) {
+ $cache = apc_fetch('combo:'.$queryString);
}
- include("./loader.php");
- $loader = new YAHOO_util_Loader($yuiVersion);
- $base = PATH_TO_LOADER . $loader->comboDefaultVersion . "/build/"; //Defaults to current version
+ if ($cache) {
+ //Set cache headers and output cache content
+ header("Cache-Control: max-age=315360000");
+ header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
+ header("Content-Type: " . $contentType);
+ echo $cache;
+ } else {
+ //Use the first module to determine which version of the YUI meta info to load
+ if (isset($yuiFiles) && !empty($yuiFiles)) {
+ $metaInfo = explode("/", $yuiFiles[0]);
+ $yuiVersion = $metaInfo[0];
+ }
- //Detect and load the required components now
- $baseOverrides = array();
- $yuiComponents = array();
- foreach($yuiFiles as $yuiFile) {
- $parts = explode("/", $yuiFile);
- if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) {
- //Add module to array for loading
- $yuiComponents[] = $parts[2];
- } else {
- die('<!-- Unable to determine module name! -->');
+ include("./loader.php");
+ $loader = new YAHOO_util_Loader($yuiVersion);
+ $base = PATH_TO_LOADER . $yuiVersion . "/build/";
+ $loader->base = $base;
+
+ //Detect and load the required components now
+ $yuiComponents = array();
+ foreach($yuiFiles as $yuiFile) {
+ $parts = explode("/", $yuiFile);
+ if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) {
+ //Add module to array for loading
+ $yuiComponents[] = $parts[2];
+ } else {
+ die('<!-- Unable to determine module name! -->');
+ }
}
- }
-
- //Load the components
- call_user_func_array(array($loader, 'load'), $yuiComponents);
- //Set cache headers and output raw file content
- header("Cache-Control: max-age=315360000");
- header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
- header("Content-Type: " . $contentType);
- if ($contentType == "application/x-javascript") {
- echo $loader->script_raw();
- } else {
- echo $loader->css_raw();
+ //Load the components
+ call_user_func_array(array($loader, 'load'), $yuiComponents);
+
+ //Set cache headers and output raw file content
+ header("Cache-Control: max-age=315360000");
+ header("Expires: " . date("D, j M Y H:i:s", strtotime("now + 10 years")) ." GMT");
+ header("Content-Type: " . $contentType);
+ if ($contentType == "application/x-javascript") {
+ $rawScript = $loader->script_raw();
+ if (APC_AVAIL === true) {
+ apc_store('combo:'.$queryString, $rawScript, APC_TTL);
+ }
+ echo $rawScript;
+ } else {
+ $rawCSS = $loader->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("url(/", "url($base", $rawCSS); // url(/whatever)
+
+ if (APC_AVAIL === true) {
+ apc_store('combo:'.$queryString, $rawCSS, APC_TTL);
+ }
+ echo $rawCSS;
+ }
}
-
} else {
die('<!-- No YUI modules defined! -->');
}
View
35 phploader/loader.php
@@ -69,7 +69,8 @@ class YAHOO_util_Loader {
var $target = "";
/**
- * Combined into a single request using the combo service to pontentially reduce the number of http requests required.
+ * Combined into a single request using the combo service to pontentially reduce the number of
+ * http requests required. This option is not supported when loading custom modules.
* @property combine
* @type boolean
* @default false
@@ -224,9 +225,9 @@ function YAHOO_util_Loader($yuiVersion, $cacheKey=null, $modules=null, $noYUI=fa
$this->curlAvail = function_exists('curl_exec');
$this->apcAvail = function_exists('apc_fetch');
$this->jsonAvail = function_exists('json_encode');
- $this->embedAvail = ($this->curlAvail && $this->apcAvail);
+ $this->customModulesInUse = empty($modules) ? false : true;
$this->base = $yui_current[YUI_BASE];
- $this->comboDefaultVersion = $yuiVersion; //(ex) 2.7.0
+ $this->comboDefaultVersion = $yuiVersion; //$customModules
$this->fullCacheKey = null;
$cache = null;
@@ -866,9 +867,6 @@ function sortDependencies($moduleType, $skipSort=false) {
$reqs[$name] = true;
}
- //print_r($this->requests);
- //return;
-
// get and store the full list of dependencies.
foreach ($this->requests as $name=>$val) {
$reqs[$name] = true;
@@ -1208,8 +1206,8 @@ function processDependencies($outputType, $moduleType, $skipSort=false, $showLoa
$item[YUI_OPTIONAL] = $dep[YUI_OPTIONAL];
break;
case YUI_TAGS:
- default:
- if ($this->combine === true) {
+ default:
+ if ($this->combine === true && $this->customModulesInUse === false) {
$this->addToCombo($name, $dep[YUI_TYPE]);
$html = $this->getComboLink($dep[YUI_TYPE]);
} else {
@@ -1306,8 +1304,11 @@ function getUrl($name) {
* @return
*/
function getRemoteContent($url) {
-
- $remote_content = apc_fetch($url);
+
+ $remote_content = null;
+ if ($this->apcAvail === true) {
+ $remote_content = apc_fetch($url);
+ }
if (!$remote_content) {
@@ -1330,7 +1331,9 @@ function getRemoteContent($url) {
//$this->log("CONTENT: " . $remote_content);
// save the contents of the remote url for 30 minutes
- apc_store($url, $remote_content, $this->apcttl);
+ if ($this->apcAvail === true) {
+ apc_store($url, $remote_content, $this->apcttl);
+ }
curl_close ($ch);
}
@@ -1338,9 +1341,9 @@ function getRemoteContent($url) {
return $remote_content;
}
- function getRaw($name) {
- if (!$this->embedAvail) {
- return "cURL and/or APC was not detected, so the content can't be embedded";
+ function getRaw($name) {
+ if(!$this->curlAvail) {
+ return "<!--// cURL was not detected, so the content cannot be fetched -->";
}
$url = $this->getUrl($name);
@@ -1349,8 +1352,8 @@ function getRaw($name) {
function getContent($name, $type) {
- if(!$this->embedAvail) {
- return "<!--// cURL was not detected, so the content can't be embedded -->" . $this->getLink($name, $type);
+ if(!$this->curlAvail) {
+ return "<!--// cURL was not detected, so the content cannot be fetched/embedded -->" . $this->getLink($name, $type);
}
$url = $this->getUrl($name);
Please sign in to comment.
Something went wrong with that request. Please try again.