Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

1742 lines (1526 sloc) 208.231 kb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>API: phploader loader.php (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
<link rel="stylesheet" type="text/css" href="assets/api.css" />
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
<h3>phploader&nbsp; <span class="subtitle">1.0.0beta</span></h3>
<a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a>
&gt; <a href="./module_phploader.html" title="phploader">phploader</a>
&gt; loader.php (source view)
<form onsubmit="return false">
<div id="propertysearch">
Search: <input autocomplete="off" id="searchinput" />
<div id="searchresults">
&nbsp;
</div>
</div>
</form>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
<fieldset>
<legend>Filters</legend>
<span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
<span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
<span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
</fieldset>
</form>
<div id="srcout">
<style>
#doc3 .classopts { display:none; }
</style>
<div class="highlight"><pre><span class="cp">&lt;?PHP</span>
<span class="sd">/**</span>
<span class="sd"> * Copyright (c) 2009, Yahoo! Inc. All rights reserved.</span>
<span class="sd"> * Code licensed under the BSD License:</span>
<span class="sd"> * http://developer.yahoo.net/yui/license.html</span>
<span class="sd"> * version: 1.0.0b2</span>
<span class="sd"> */</span>
<span class="sd">/**</span>
<span class="sd"> * Used to specify JavaScript and CSS module requirements. It maintains a dependency</span>
<span class="sd"> * tree for these modules so when a module is requested, all of the other modules it </span>
<span class="sd"> * depends on are included as well. By default, the YUI Library is configured, and </span>
<span class="sd"> * other modules and their dependencies can be added via PHP.</span>
<span class="sd"> * @module phploader</span>
<span class="sd"> */</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_AFTER&#39;</span><span class="p">,</span> <span class="s1">&#39;after&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_BASE&#39;</span><span class="p">,</span> <span class="s1">&#39;base&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_CSS&#39;</span><span class="p">,</span> <span class="s1">&#39;css&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_DATA&#39;</span><span class="p">,</span> <span class="s1">&#39;DATA&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_DEPCACHE&#39;</span><span class="p">,</span> <span class="s1">&#39;depCache&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_DEBUG&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_EMBED&#39;</span><span class="p">,</span> <span class="s1">&#39;EMBED&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_FILTERS&#39;</span><span class="p">,</span> <span class="s1">&#39;filters&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_FULLPATH&#39;</span><span class="p">,</span> <span class="s1">&#39;fullpath&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_FULLJSON&#39;</span><span class="p">,</span> <span class="s1">&#39;FULLJSON&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_GLOBAL&#39;</span><span class="p">,</span> <span class="s1">&#39;global&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_JS&#39;</span><span class="p">,</span> <span class="s1">&#39;js&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_JSON&#39;</span><span class="p">,</span> <span class="s1">&#39;JSON&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_MODULES&#39;</span><span class="p">,</span> <span class="s1">&#39;modules&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SUBMODULES&#39;</span><span class="p">,</span> <span class="s1">&#39;submodules&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_EXPOUND&#39;</span><span class="p">,</span> <span class="s1">&#39;expound&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_NAME&#39;</span><span class="p">,</span> <span class="s1">&#39;name&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_OPTIONAL&#39;</span><span class="p">,</span> <span class="s1">&#39;optional&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_OVERRIDES&#39;</span><span class="p">,</span> <span class="s1">&#39;overrides&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_PATH&#39;</span><span class="p">,</span> <span class="s1">&#39;path&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_PKG&#39;</span><span class="p">,</span> <span class="s1">&#39;pkg&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_PREFIX&#39;</span><span class="p">,</span> <span class="s1">&#39;prefix&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_PROVIDES&#39;</span><span class="p">,</span> <span class="s1">&#39;provides&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_RAW&#39;</span><span class="p">,</span> <span class="s1">&#39;RAW&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_REPLACE&#39;</span><span class="p">,</span> <span class="s1">&#39;replace&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_REQUIRES&#39;</span><span class="p">,</span> <span class="s1">&#39;requires&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_ROLLUP&#39;</span><span class="p">,</span> <span class="s1">&#39;rollup&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SATISFIES&#39;</span><span class="p">,</span> <span class="s1">&#39;satisfies&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SEARCH&#39;</span><span class="p">,</span> <span class="s1">&#39;search&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SKIN&#39;</span><span class="p">,</span> <span class="s1">&#39;skin&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SKINNABLE&#39;</span><span class="p">,</span> <span class="s1">&#39;skinnable&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_SUPERSEDES&#39;</span><span class="p">,</span> <span class="s1">&#39;supersedes&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_TAGS&#39;</span><span class="p">,</span> <span class="s1">&#39;TAGS&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_TYPE&#39;</span><span class="p">,</span> <span class="s1">&#39;type&#39;</span><span class="p">);</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">&#39;YUI_URL&#39;</span><span class="p">,</span> <span class="s1">&#39;url&#39;</span><span class="p">);</span>
<span class="sd">/**</span>
<span class="sd"> * The YUI PHP loader base class which provides dynamic server-side loading for YUI</span>
<span class="sd"> * @class YAHOO_util_Loader</span>
<span class="sd"> * @namespace PHP</span>
<span class="sd"> */</span>
<span class="k">class</span> <span class="nc">YAHOO_util_Loader</span> <span class="p">{</span>
<span class="sd">/**</span>
<span class="sd"> * The base directory</span>
<span class="sd"> * @property base</span>
<span class="sd"> * @type string</span>
<span class="sd"> * @default http://yui.yahooapis.com/[YUI VERSION]/build/</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$base</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * A filter to apply to result urls. This filter will modify the default path for </span>
<span class="sd"> * all modules. The default path is the minified version of the files (e.g., event-min.js). </span>
<span class="sd"> * Changing the filter alows for picking up the unminified (raw) or debug sources.</span>
<span class="sd"> * The default set of valid filters are: YUI_DEBUG &amp; YUI_RAW</span>
<span class="sd"> * @property filter</span>
<span class="sd"> * @type string (e.g.) </span>
<span class="sd"> * @default empty string (minified vesion)</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$filter</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * An array of filters &amp; filter replacement rules. Used with $filter.</span>
<span class="sd"> * @property filters</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$filters</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * A list of modules to apply the filter to. If not supplied, all</span>
<span class="sd"> * modules will have any defined filters applied. Tip: Useful for debugging.</span>
<span class="sd"> * @property filterList</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default null</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$filterList</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Should we allow rollups</span>
<span class="sd"> * @property allowRollups</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default true</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$allowRollups</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Whether or not to load optional dependencies for the requested modules</span>
<span class="sd"> * @property loadOptional</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default false</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$loadOptional</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Force rollup modules to be sorted as moved to the top of</span>
<span class="sd"> * the stack when performing an automatic rollup. This has a very small performance consequence.</span>
<span class="sd"> * @property rollupsToTop</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default false</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$rollupsToTop</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * The first time we output a module type we allow automatic rollups, this</span>
<span class="sd"> * array keeps track of module types we have processed</span>
<span class="sd"> * @property processedModuleTypes</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$processedModuleTypes</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * All required modules</span>
<span class="sd"> * @property requests</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$requests</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * List of modules that have been been outputted via getLink() / getComboLink()</span>
<span class="sd"> * @property loaded</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$loaded</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * List of all modules superceded by the list of required modules </span>
<span class="sd"> * @property superceded</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$superceded</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * Keeps track of modules that were requested that are not defined</span>
<span class="sd"> * @property undefined</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$undefined</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * Used to determine if additional sorting of dependencies is required</span>
<span class="sd"> * @property dirty</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default true</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$dirty</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * List of sorted modules</span>
<span class="sd"> * @property sorted</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default null</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$sorted</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * List of modules the loader has aleady accounted for</span>
<span class="sd"> * @property accountedFor</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$accountedFor</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * The list of required skins</span>
<span class="sd"> * @property skins</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$skins</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * Contains the available module metadata</span>
<span class="sd"> * @property modules</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default YUI module metadata for the specified release</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$modules</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * The APC cache key</span>
<span class="sd"> * @property fullCacheKey</span>
<span class="sd"> * @type string</span>
<span class="sd"> * @default null</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$fullCacheKey</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * List of modules that have had their base pathes overridden</span>
<span class="sd"> * @property baseOverrides</span>
<span class="sd"> * @type array</span>
<span class="sd"> * @default</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$baseOverrides</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * Used to determine if we have an APC cache hit</span>
<span class="sd"> * @property cacheFound</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default false</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$cacheFound</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Used to delay caching of module data</span>
<span class="sd"> * @property delayCache</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default false</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$delayCache</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span>
<span class="cm">/* If the version is set, a querystring parameter is appended to the</span>
<span class="cm"> * end of all generated URLs. This is a cache busting hack for environments</span>
<span class="cm"> * that always use the same path for the current version of the library.</span>
<span class="cm"> * @property version</span>
<span class="cm"> * @type string</span>
<span class="cm"> * @default null</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$version</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="k">var</span> <span class="nv">$versionKey</span> <span class="o">=</span> <span class="s2">&quot;_yuiversion&quot;</span><span class="p">;</span>
<span class="cm">/* Holds the calculated skin definition</span>
<span class="cm"> * @property skin</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @default</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$skin</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="cm">/* Holds the module rollup metadata</span>
<span class="cm"> * @property rollupModules</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @default</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$rollupModules</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="cm">/* Holds global module information. Used for global dependency support.</span>
<span class="cm"> * Note: Does not appear to be in use by recent metadata. Might be deprecated?</span>
<span class="cm"> * @property globalModules</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @default</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$globalModules</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="cm">/* Holds information about what modules satisfy the requirements of others</span>
<span class="cm"> * @property satisfactionMap</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @default</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$satisfactionMap</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="cm">/* Holds a cached module dependency list</span>
<span class="cm"> * @property depCache</span>
<span class="cm"> * @type array</span>
<span class="cm"> * @default</span>
<span class="cm"> */</span>
<span class="k">var</span> <span class="nv">$depCache</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="sd">/**</span>
<span class="sd"> * Combined into a single request using the combo service to pontentially reduce the number of </span>
<span class="sd"> * http requests required. This option is not supported when loading custom modules.</span>
<span class="sd"> * @property combine</span>
<span class="sd"> * @type boolean</span>
<span class="sd"> * @default false</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$combine</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * The base path to the combo service. Uses the Yahoo! CDN service by default.</span>
<span class="sd"> * You do not have to set this property to use the combine option. YUI PHP Loader ships </span>
<span class="sd"> * with an intrinsic, lightweight combo-handler as well (see combo.php).</span>
<span class="sd"> * @property comboBase</span>
<span class="sd"> * @type string</span>
<span class="sd"> * @default http://yui.yahooapis.com/combo?</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$comboBase</span> <span class="o">=</span> <span class="s2">&quot;http://yui.yahooapis.com/combo?&quot;</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Holds the current combo url for the loaded CSS resources. This is </span>
<span class="sd"> * built with addToCombo and retrieved with getComboLink. Only used when the combine</span>
<span class="sd"> * is enabled.</span>
<span class="sd"> * @property cssComboLocation</span>
<span class="sd"> * @type string</span>
<span class="sd"> * @default null</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$cssComboLocation</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * Holds the current combo url for the loaded JavaScript resources. This is </span>
<span class="sd"> * built with addToCombo and retrieved with getComboLink. Only used when the combine</span>
<span class="sd"> * is enabled.</span>
<span class="sd"> * @property jsComboLocation</span>
<span class="sd"> * @type string</span>
<span class="sd"> * @default null</span>
<span class="sd"> */</span>
<span class="k">var</span> <span class="nv">$jsComboLocation</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="sd">/**</span>
<span class="sd"> * The YAHOO_util_Loader class constructor</span>
<span class="sd"> * @constructor</span>
<span class="sd"> * @param {string} yuiVersion Defines which version of YUI metadata to load</span>
<span class="sd"> * @param {string} cacheKey Unique APC cache key. This is combined with the YUI base</span>
<span class="sd"> * so that updates to YUI will force a new cache entry. However, if your custom config </span>
<span class="sd"> * changes, this key should be changed (otherwise the old values will be used until the cache expires).</span>
<span class="sd"> * @param {array} modules A list of custom modules</span>
<span class="sd"> * @param {boolean} noYUI Pass true if you do not want the YUI metadata</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">YAHOO_util_Loader</span><span class="p">(</span><span class="nv">$yuiVersion</span><span class="p">,</span> <span class="nv">$cacheKey</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$modules</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$noYUI</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$yuiVersion</span><span class="p">))</span> <span class="p">{</span>
<span class="k">die</span><span class="p">(</span><span class="s2">&quot;Error: The first parameter of YAHOO_util_Loader must specify which version of YUI to use!&quot;</span><span class="p">);</span>
<span class="p">}</span>
<span class="cm">/* </span>
<span class="cm"> * Include the metadata config file that corresponds to the requested YUI version</span>
<span class="cm"> * Note: we attempt to find a prebuilt config_{version}.php file which contains an associative array,</span>
<span class="cm"> * but if not available we&#39;ll attempt to find and parse the YUI json dependency file.</span>
<span class="cm"> */</span>
<span class="nv">$parentDir</span> <span class="o">=</span> <span class="nb">dirname</span><span class="p">(</span><span class="nb">dirname</span><span class="p">(</span><span class="k">__FILE__</span><span class="p">));</span>
<span class="nv">$phpConfigFile</span> <span class="o">=</span> <span class="nv">$parentDir</span> <span class="o">.</span> <span class="s1">&#39;/lib/meta/config_&#39;</span> <span class="o">.</span> <span class="nv">$yuiVersion</span> <span class="o">.</span> <span class="s1">&#39;.php&#39;</span><span class="p">;</span>
<span class="nv">$jsonConfigFile</span> <span class="o">=</span> <span class="nv">$parentDir</span> <span class="o">.</span> <span class="s1">&#39;/lib/meta/json_&#39;</span> <span class="o">.</span> <span class="nv">$yuiVersion</span> <span class="o">.</span> <span class="s1">&#39;.txt&#39;</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">file_exists</span><span class="p">(</span><span class="nv">$phpConfigFile</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nb">is_readable</span><span class="p">(</span><span class="nv">$phpConfigFile</span><span class="p">))</span> <span class="p">{</span>
<span class="k">require</span><span class="p">(</span><span class="nv">$phpConfigFile</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nb">file_exists</span><span class="p">(</span><span class="nv">$jsonConfigFile</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nb">is_readable</span><span class="p">(</span><span class="nv">$jsonConfigFile</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nb">function_exists</span><span class="p">(</span><span class="s1">&#39;json_encode&#39;</span><span class="p">))</span> <span class="p">{</span>
<span class="nv">$jsonConfigString</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="nv">$jsonConfigFile</span><span class="p">);</span>
<span class="nv">$inf</span> <span class="o">=</span> <span class="nx">json_decode</span><span class="p">(</span><span class="nv">$jsonConfigString</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
<span class="nv">$GLOBALS</span><span class="p">[</span><span class="s1">&#39;yui_current&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$inf</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">die</span><span class="p">(</span><span class="s2">&quot;Unable to find a suitable YUI metadata file!&quot;</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">global</span> <span class="nv">$yui_current</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">apcttl</span> <span class="o">=</span> <span class="m">0</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">curlAvail</span> <span class="o">=</span> <span class="nb">function_exists</span><span class="p">(</span><span class="s1">&#39;curl_exec&#39;</span><span class="p">);</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">apcAvail</span> <span class="o">=</span> <span class="nb">function_exists</span><span class="p">(</span><span class="s1">&#39;apc_fetch&#39;</span><span class="p">);</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">jsonAvail</span> <span class="o">=</span> <span class="nb">function_exists</span><span class="p">(</span><span class="s1">&#39;json_encode&#39;</span><span class="p">);</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">customModulesInUse</span> <span class="o">=</span> <span class="k">empty</span><span class="p">(</span><span class="nv">$modules</span><span class="p">)</span> <span class="o">?</span> <span class="k">false</span> <span class="o">:</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">base</span> <span class="o">=</span> <span class="nv">$yui_current</span><span class="p">[</span><span class="nx">YUI_BASE</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">comboDefaultVersion</span> <span class="o">=</span> <span class="nv">$yuiVersion</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">fullCacheKey</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="nv">$cache</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$cacheKey</span> <span class="o">&amp;&amp;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">apcAvail</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">fullCacheKey</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">base</span> <span class="o">.</span> <span class="nv">$cacheKey</span><span class="p">;</span>
<span class="nv">$cache</span> <span class="o">=</span> <span class="nx">apc_fetch</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">fullCacheKey</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$cache</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">cacheFound</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_MODULES</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_SKIN</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">rollupModules</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_ROLLUP</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">globalModules</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_GLOBAL</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_SATISFIES</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_DEPCACHE</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">filters</span> <span class="o">=</span> <span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_FILTERS</span><span class="p">];</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="c1">// set up the YUI info for the current version of the lib</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$noYUI</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span> <span class="o">=</span> <span class="nv">$yui_current</span><span class="p">[</span><span class="s1">&#39;moduleInfo&#39;</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$modules</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span> <span class="o">=</span> <span class="nb">array_merge_recursive</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">,</span> <span class="nv">$modules</span><span class="p">);</span>
<span class="p">}</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span> <span class="o">=</span> <span class="nv">$yui_current</span><span class="p">[</span><span class="nx">YUI_SKIN</span><span class="p">];</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">[</span><span class="s1">&#39;overrides&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">[</span><span class="nx">YUI_PREFIX</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;skin-&quot;</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">filters</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
<span class="nx">YUI_RAW</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
<span class="nx">YUI_SEARCH</span> <span class="o">=&gt;</span> <span class="s2">&quot;-min\.js&quot;</span><span class="p">,</span>
<span class="nx">YUI_REPLACE</span> <span class="o">=&gt;</span> <span class="s2">&quot;.js&quot;</span>
<span class="p">),</span>
<span class="nx">YUI_DEBUG</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
<span class="nx">YUI_SEARCH</span> <span class="o">=&gt;</span> <span class="s2">&quot;-min\.js&quot;</span><span class="p">,</span>
<span class="nx">YUI_REPLACE</span> <span class="o">=&gt;</span> <span class="s2">&quot;-debug.js&quot;</span>
<span class="p">)</span>
<span class="p">);</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$m</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_GLOBAL</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">globalModules</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">rollupModules</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$m</span><span class="p">;</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$sup</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">mapSatisfyingModule</span><span class="p">(</span><span class="nv">$sup</span><span class="p">,</span> <span class="nv">$name</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to update the APC cache</span>
<span class="sd"> * @method updateCache</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">updateCache</span><span class="p">()</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">fullCacheKey</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$cache</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_MODULES</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_SKIN</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_ROLLUP</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">rollupModules</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_GLOBAL</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">globalModules</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_DEPCACHE</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_SATISFIES</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span><span class="p">;</span>
<span class="nv">$cache</span><span class="p">[</span><span class="nx">YUI_FILTERS</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">filters</span><span class="p">;</span>
<span class="nx">apc_store</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">fullCacheKey</span><span class="p">,</span> <span class="nv">$cache</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">apcttl</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to load YUI and/or custom components</span>
<span class="sd"> * @method load</span>
<span class="sd"> * @param string $varname [, string $... ] List of component names</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">load</span><span class="p">()</span> <span class="p">{</span>
<span class="c1">//Expects N-number of named components to load </span>
<span class="nv">$args</span> <span class="o">=</span> <span class="nb">func_get_args</span><span class="p">();</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$args</span> <span class="k">as</span> <span class="nv">$arg</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loadSingle</span><span class="p">(</span><span class="nv">$arg</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to mark a module type as processed</span>
<span class="sd"> * @method setProcessedModuleType</span>
<span class="sd"> * @param string $moduleType</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">setProcessedModuleType</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="s1">&#39;ALL&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processedModuleTypes</span><span class="p">[</span><span class="nv">$moduleType</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to determine if a module type has been processed</span>
<span class="sd"> * @method hasProcessedModuleType</span>
<span class="sd"> * @param string $moduleType</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">hasProcessedModuleType</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="s1">&#39;ALL&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processedModuleTypes</span><span class="p">[</span><span class="nv">$moduleType</span><span class="p">]);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to specify modules that are already on the page that should not be loaded again</span>
<span class="sd"> * @method setLoaded</span>
<span class="sd"> * @param string $varname [, string $... ] List of module names</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">setLoaded</span><span class="p">()</span> <span class="p">{</span>
<span class="nv">$args</span> <span class="o">=</span> <span class="nb">func_get_args</span><span class="p">();</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$args</span> <span class="k">as</span> <span class="nv">$arg</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$arg</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loaded</span><span class="p">[</span><span class="nv">$arg</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$arg</span><span class="p">;</span>
<span class="nv">$mod</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$arg</span><span class="p">];</span>
<span class="nv">$sups</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getSuperceded</span><span class="p">(</span><span class="nv">$arg</span><span class="p">);</span>
<span class="c1">// accounting for by way of supersede</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$sups</span> <span class="k">as</span> <span class="nv">$supname</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loaded</span><span class="p">[</span><span class="nv">$supname</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$supname</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// prevent rollups for this module type</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">setProcessedModuleType</span><span class="p">(</span><span class="nv">$mod</span><span class="p">[</span><span class="nx">YUI_TYPE</span><span class="p">]);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$msg</span> <span class="o">=</span> <span class="s2">&quot;YUI_LOADER: undefined module name provided to setLoaded(): &quot;</span> <span class="o">.</span> <span class="nv">$arg</span><span class="p">;</span>
<span class="nb">error_log</span><span class="p">(</span><span class="nv">$msg</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Sets up skin for skinnable modules</span>
<span class="sd"> * @method skinSetup</span>
<span class="sd"> * @param string $name module name</span>
<span class="sd"> * @return {string}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">skinSetup</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$skinName</span> <span class="o">=</span> <span class="k">null</span><span class="p">;</span>
<span class="nv">$dep</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$dep</span> <span class="o">&amp;&amp;</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$dep</span><span class="p">[</span><span class="nx">YUI_SKINNABLE</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$s</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_OVERRIDES</span><span class="p">][</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_OVERRIDES</span><span class="p">][</span><span class="nv">$name</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$name2</span> <span class="o">=&gt;</span> <span class="nv">$over2</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$skinName</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">formatSkin</span><span class="p">(</span><span class="nv">$over2</span><span class="p">,</span> <span class="nv">$name</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$skinName</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">formatSkin</span><span class="p">(</span><span class="nv">$s</span><span class="p">[</span><span class="s2">&quot;defaultSkin&quot;</span><span class="p">],</span> <span class="nv">$name</span><span class="p">);</span>
<span class="p">}</span>
<span class="c1">// adding new skin module</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skins</span><span class="p">[]</span> <span class="o">=</span> <span class="nv">$skinName</span><span class="p">;</span>
<span class="nv">$skin</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">parseSkin</span><span class="p">(</span><span class="nv">$skinName</span><span class="p">);</span>
<span class="c1">// module-specific</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$skin</span><span class="p">[</span><span class="m">2</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$dep</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$skin</span><span class="p">[</span><span class="m">2</span><span class="p">]];</span>
<span class="nv">$package</span> <span class="o">=</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$dep</span><span class="p">[</span><span class="nx">YUI_PKG</span><span class="p">]))</span> <span class="o">?</span> <span class="nv">$dep</span><span class="p">[</span><span class="nx">YUI_PKG</span><span class="p">]</span> <span class="o">:</span> <span class="nv">$skin</span><span class="p">[</span><span class="m">2</span><span class="p">];</span>
<span class="nv">$path</span> <span class="o">=</span> <span class="nv">$package</span> <span class="o">.</span> <span class="s1">&#39;/&#39;</span> <span class="o">.</span> <span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_BASE</span><span class="p">]</span> <span class="o">.</span> <span class="nv">$skin</span><span class="p">[</span><span class="m">1</span><span class="p">]</span> <span class="o">.</span> <span class="s1">&#39;/&#39;</span> <span class="o">.</span> <span class="nv">$skin</span><span class="p">[</span><span class="m">2</span><span class="p">]</span> <span class="o">.</span> <span class="s1">&#39;.css&#39;</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$skinName</span><span class="p">]</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
<span class="s2">&quot;name&quot;</span> <span class="o">=&gt;</span> <span class="nv">$skinName</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">=&gt;</span> <span class="nx">YUI_CSS</span><span class="p">,</span>
<span class="s2">&quot;path&quot;</span> <span class="o">=&gt;</span> <span class="nv">$path</span><span class="p">,</span>
<span class="s2">&quot;after&quot;</span> <span class="o">=&gt;</span> <span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_AFTER</span><span class="p">]</span>
<span class="p">);</span>
<span class="c1">// rollup skin</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$path</span> <span class="o">=</span> <span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_BASE</span><span class="p">]</span> <span class="o">.</span> <span class="nv">$skin</span><span class="p">[</span><span class="m">1</span><span class="p">]</span> <span class="o">.</span> <span class="s1">&#39;/&#39;</span> <span class="o">.</span> <span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_PATH</span><span class="p">];</span>
<span class="nv">$newmod</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
<span class="s2">&quot;name&quot;</span> <span class="o">=&gt;</span> <span class="nv">$skinName</span><span class="p">,</span>
<span class="s2">&quot;type&quot;</span> <span class="o">=&gt;</span> <span class="nx">YUI_CSS</span><span class="p">,</span>
<span class="s2">&quot;path&quot;</span> <span class="o">=&gt;</span> <span class="nv">$path</span><span class="p">,</span>
<span class="s2">&quot;rollup&quot;</span> <span class="o">=&gt;</span> <span class="m">3</span><span class="p">,</span>
<span class="s2">&quot;after&quot;</span> <span class="o">=&gt;</span> <span class="nv">$s</span><span class="p">[</span><span class="nx">YUI_AFTER</span><span class="p">]</span>
<span class="p">);</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$skinName</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$newmod</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">rollupModules</span><span class="p">[</span><span class="nv">$skinName</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$newmod</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nv">$skinName</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Parses a module&#39;s skin. A modules skin is typically prefixed.</span>
<span class="sd"> * @method parseSkin</span>
<span class="sd"> * @param string $name the name of a module to parse</span>
<span class="sd"> * @return {array}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">parseSkin</span><span class="p">(</span><span class="nv">$moduleName</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span> <span class="nv">$moduleName</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">[</span><span class="nx">YUI_PREFIX</span><span class="p">]</span> <span class="p">)</span> <span class="o">===</span> <span class="m">0</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nb">explode</span><span class="p">(</span><span class="s1">&#39;-&#39;</span><span class="p">,</span> <span class="nv">$moduleName</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">null</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Add prefix to module skin</span>
<span class="sd"> * @method formatSkin</span>
<span class="sd"> * @param string $skin the skin name</span>
<span class="sd"> * @param string $moduleName the name of a module</span>
<span class="sd"> * @return {string} prefixed skin name</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">formatSkin</span><span class="p">(</span><span class="nv">$skin</span><span class="p">,</span> <span class="nv">$moduleName</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$prefix</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skin</span><span class="p">[</span><span class="nx">YUI_PREFIX</span><span class="p">];</span>
<span class="nv">$s</span> <span class="o">=</span> <span class="nv">$prefix</span> <span class="o">.</span> <span class="nv">$skin</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$moduleName</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$s</span> <span class="o">=</span> <span class="nv">$s</span> <span class="o">.</span> <span class="s1">&#39;-&#39;</span> <span class="o">.</span> <span class="nv">$moduleName</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nv">$s</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Loads the requested module</span>
<span class="sd"> * @method loadSingle</span>
<span class="sd"> * @param string $name the name of a module to load</span>
<span class="sd"> * @return {boolean}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">loadSingle</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$skin</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">parseSkin</span><span class="p">(</span><span class="nv">$name</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$skin</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">skins</span><span class="p">[]</span> <span class="o">=</span> <span class="nv">$name</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">dirty</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="k">return</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$this</span> <span class="o">-&gt;</span> <span class="na">undefined</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$name</span><span class="p">;</span>
<span class="k">return</span> <span class="k">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loaded</span><span class="p">[</span><span class="nv">$name</span><span class="p">])</span> <span class="o">||</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="c1">// skip</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">requests</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$name</span><span class="p">;</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">dirty</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to output each of the required script tags</span>
<span class="sd"> * @method script</span>
<span class="sd"> * @return {string}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">script</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tags</span><span class="p">(</span><span class="nx">YUI_JS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to output each of the required link tags</span>
<span class="sd"> * @method css</span>
<span class="sd"> * @return {string}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">css</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">tags</span><span class="p">(</span><span class="nx">YUI_CSS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to output each of the required html tags (i.e.) script or link</span>
<span class="sd"> * @method tags</span>
<span class="sd"> * @param {string} moduleType Type of html tag to return (i.e.) js or css. Default is both.</span>
<span class="sd"> * @param {boolean} skipSort</span>
<span class="sd"> * @return {string}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">tags</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processDependencies</span><span class="p">(</span><span class="nx">YUI_TAGS</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to embed the raw JavaScript inline</span>
<span class="sd"> * @method script_embed</span>
<span class="sd"> * @return {string} Returns the script tag(s) with the JavaScript inline</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">script_embed</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">embed</span><span class="p">(</span><span class="nx">YUI_JS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to embed the raw CSS </span>
<span class="sd"> * @method css_embed</span>
<span class="sd"> * @return {string} (e.g.) Returns the style tag(s) with the CSS inline</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">css_embed</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">embed</span><span class="p">(</span><span class="nx">YUI_CSS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to output each of the required html tags inline (i.e.) script and/or style</span>
<span class="sd"> * @method embed</span>
<span class="sd"> * @param {string} moduleType Type of html tag to return (i.e.) js or css. Default is both.</span>
<span class="sd"> * @param {boolean} skipSort</span>
<span class="sd"> * @return {string} Returns the style tag(s) with the CSS inline and/or the script tag(s) with the JavaScript inline</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">embed</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processDependencies</span><span class="p">(</span><span class="nx">YUI_EMBED</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to fetch an array of the required JavaScript components </span>
<span class="sd"> * @method script_data</span>
<span class="sd"> * @return {array} Returns an array of data about each of the identified JavaScript components</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">script_data</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">data</span><span class="p">(</span><span class="nx">YUI_JS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to fetch an array of the required CSS components</span>
<span class="sd"> * @method css_data</span>
<span class="sd"> * @return {array} Returns an array of data about each of the identified JavaScript components</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">css_data</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">data</span><span class="p">(</span><span class="nx">YUI_CSS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to output an Array which contains data about the required JavaScript &amp; CSS components</span>
<span class="sd"> * @method data</span>
<span class="sd"> * @param {string} moduleType Type of html tag to return (i.e.) js or css. Default is both.</span>
<span class="sd"> * @param {boolean} allowRollups</span>
<span class="sd"> * @param {boolean} skipSort</span>
<span class="sd"> * @return {string}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">data</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$allowRollups</span><span class="o">=</span><span class="k">false</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nv">$allowRollups</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">setProcessedModuleType</span><span class="p">(</span><span class="nv">$moduleType</span><span class="p">);</span>
<span class="p">}</span>
<span class="nv">$type</span> <span class="o">=</span> <span class="nx">YUI_DATA</span><span class="p">;</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processDependencies</span><span class="p">(</span><span class="nv">$type</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to fetch a JSON object with the required JavaScript components </span>
<span class="sd"> * @method script_json</span>
<span class="sd"> * @return {string} Returns a JSON object containing urls for each JavaScript component</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">script_json</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">json</span><span class="p">(</span><span class="nx">YUI_JS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to fetch a JSON object with the required CSS components</span>
<span class="sd"> * @method css_json</span>
<span class="sd"> * @return {string} Returns a JSON object containing urls for each CSS component</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">css_json</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">json</span><span class="p">(</span><span class="nx">YUI_CSS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to fetch a JSON object with the required JavaScript and CSS components</span>
<span class="sd"> * @method json</span>
<span class="sd"> * @param {string} moduleType</span>
<span class="sd"> * @param {boolean} allowRollups</span>
<span class="sd"> * @param {boolean} skipSort</span>
<span class="sd"> * @param {boolean} full</span>
<span class="sd"> * @return {string} Returns a JSON object with the required JavaScript and CSS components</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">json</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$allowRollups</span><span class="o">=</span><span class="k">false</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">,</span> <span class="nv">$full</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nv">$allowRollups</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">setProcessedModuleType</span><span class="p">(</span><span class="nv">$moduleType</span><span class="p">);</span>
<span class="p">}</span>
<span class="c1">// the original JSON output only sent the provides data, not the requires</span>
<span class="nv">$type</span> <span class="o">=</span> <span class="nx">YUI_JSON</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$full</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$type</span> <span class="o">=</span> <span class="nx">YUI_FULLJSON</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processDependencies</span><span class="p">(</span><span class="nv">$type</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to produce the raw JavaScript code inline without the actual script tags</span>
<span class="sd"> * @method script_raw</span>
<span class="sd"> * @return {string} Returns the raw JavaScript code inline without the actual script tags</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">script_raw</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">raw</span><span class="p">(</span><span class="nx">YUI_JS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to produce the raw CSS code inline without the actual style tags</span>
<span class="sd"> * @method css_raw</span>
<span class="sd"> * @return {string} Returns the raw CSS code inline without the actual style tags</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">css_raw</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">raw</span><span class="p">(</span><span class="nx">YUI_CSS</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to produce the raw Javacript and CSS code inline without the actual script or style tags</span>
<span class="sd"> * @method raw</span>
<span class="sd"> * @param {string} moduleType</span>
<span class="sd"> * @param {boolean} allowRollups</span>
<span class="sd"> * @param {boolean} skipSort</span>
<span class="sd"> * @return {string} Returns the raw JavaScript and/or CSS code inline without the actual style tags</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">raw</span><span class="p">(</span><span class="nv">$moduleType</span><span class="o">=</span><span class="k">null</span><span class="p">,</span> <span class="nv">$allowRollups</span><span class="o">=</span><span class="k">false</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">processDependencies</span><span class="p">(</span><span class="nx">YUI_RAW</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * General logging function. Writes a message to the PHP error log.</span>
<span class="sd"> * @method log</span>
<span class="sd"> * @param {string} msg Message to write</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">log</span><span class="p">(</span><span class="nv">$msg</span><span class="p">)</span> <span class="p">{</span>
<span class="nb">error_log</span><span class="p">(</span><span class="nv">$msg</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Markes a module as being accounted for. Used in dependency testing.</span>
<span class="sd"> * @method accountFor</span>
<span class="sd"> * @param {string} name Module to mark as being accounted for</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">accountFor</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$name</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$dep</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">];</span>
<span class="nv">$sups</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getSuperceded</span><span class="p">(</span><span class="nv">$name</span><span class="p">);</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$sups</span> <span class="k">as</span> <span class="nv">$supname</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// accounting for by way of supersede package</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span><span class="p">[</span><span class="nv">$supname</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used during dependecy processing to prune modules from the list of modules requiring further processing</span>
<span class="sd"> * @method prune</span>
<span class="sd"> * @param {array} deps List of module dependencies</span>
<span class="sd"> * @param {string} moduleType Type of modules to prune (i.e.) js or css</span>
<span class="sd"> * @return {array}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">prune</span><span class="p">(</span><span class="nv">$deps</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$moduleType</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$newdeps</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$deps</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$dep</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$dep</span><span class="p">[</span><span class="nx">YUI_TYPE</span><span class="p">]</span> <span class="o">==</span> <span class="nv">$moduleType</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$newdeps</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nv">$newdeps</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$deps</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Use to get a list of modules superseded by the given module name</span>
<span class="sd"> * @method getSuperceded</span>
<span class="sd"> * @param {string} name Module name</span>
<span class="sd"> * @return {array}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">getSuperceded</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$key</span> <span class="o">=</span> <span class="nx">YUI_SUPERSEDES</span> <span class="o">.</span> <span class="nv">$name</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">];</span>
<span class="p">}</span>
<span class="nv">$sups</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$m</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">];</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$supName</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$sups</span><span class="p">[</span><span class="nv">$supName</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$supName</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$supsups</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getSuperceded</span><span class="p">(</span><span class="nv">$supName</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">count</span><span class="p">(</span><span class="nv">$supsups</span><span class="p">)</span> <span class="o">&gt;</span> <span class="m">0</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$sups</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$sups</span><span class="p">,</span> <span class="nv">$supsups</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$sups</span><span class="p">;</span>
<span class="k">return</span> <span class="nv">$sups</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Identify dependencies for a give module name</span>
<span class="sd"> * @method getAllDependencies</span>
<span class="sd"> * @param {string} mname Module name</span>
<span class="sd"> * @param {boolean} loadOptional Load optional dependencies</span>
<span class="sd"> * @param {array} completed</span>
<span class="sd"> * @return {array}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">getAllDependencies</span><span class="p">(</span><span class="nv">$mname</span><span class="p">,</span> <span class="nv">$loadOptional</span><span class="o">=</span><span class="k">false</span><span class="p">,</span> <span class="nv">$completed</span><span class="o">=</span><span class="k">array</span><span class="p">())</span> <span class="p">{</span>
<span class="nv">$key</span> <span class="o">=</span> <span class="nx">YUI_REQUIRES</span> <span class="o">.</span> <span class="nv">$mname</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$loadOptional</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$key</span> <span class="o">.=</span> <span class="nx">YUI_OPTIONAL</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">];</span>
<span class="p">}</span>
<span class="nv">$m</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$mname</span><span class="p">];</span>
<span class="nv">$mProvides</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getProvides</span><span class="p">(</span><span class="nv">$mname</span><span class="p">);</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="c1">//Some modules pretend to be others (override if this is the case)</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$mname</span><span class="p">][</span><span class="nx">YUI_EXPOUND</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$completed</span><span class="p">[</span><span class="nv">$mname</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$completed</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$mname</span><span class="p">][</span><span class="nx">YUI_EXPOUND</span><span class="p">],</span> <span class="nv">$loadOptional</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="nv">$mname</span> <span class="o">=&gt;</span> <span class="k">true</span><span class="p">)));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">//Add any requirements defined on the module itself</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_REQUIRES</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$origreqs</span> <span class="o">=</span> <span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_REQUIRES</span><span class="p">];</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$origreqs</span> <span class="k">as</span> <span class="nv">$r</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$r</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$r</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$r</span><span class="p">,</span> <span class="nv">$loadOptional</span><span class="p">,</span> <span class="nv">$reqs</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">//Add any submodule requirements not provided by the rollups</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUBMODULES</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUBMODULES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$submodule</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$subreqs</span> <span class="o">=</span> <span class="nv">$submodule</span><span class="p">[</span><span class="nx">YUI_REQUIRES</span><span class="p">];</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$subreqs</span> <span class="k">as</span> <span class="nv">$sr</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$sr</span><span class="p">,</span> <span class="nv">$mProvides</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$sr</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span><span class="p">))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$sr</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$sr</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$sr</span><span class="p">,</span> <span class="nv">$loadOptional</span><span class="p">,</span> <span class="nv">$reqs</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">//Add any superseded requirements not provided by the rollup and/or rollup submodules</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$supersededModule</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$supersededModule</span><span class="p">][</span><span class="nx">YUI_REQUIRES</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$supersededModule</span><span class="p">][</span><span class="nx">YUI_REQUIRES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$supersededModuleReq</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$supersededModuleReq</span><span class="p">,</span> <span class="nv">$mProvides</span><span class="p">))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$supersededModuleReq</span><span class="p">]))</span>
<span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$supersededModuleReq</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$supersededModuleReq</span><span class="p">,</span> <span class="nv">$loadOptional</span><span class="p">,</span> <span class="nv">$reqs</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">//Add any submodule requirements not provided by the rollup or originally requested module</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$supersededModule</span><span class="p">][</span><span class="nx">YUI_SUBMODULES</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$supersededModule</span><span class="p">][</span><span class="nx">YUI_SUBMODULES</span><span class="p">]</span> <span class="k">as</span> <span class="nv">$supersededSubmodule</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$ssmProvides</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getProvides</span><span class="p">(</span><span class="nv">$supersededModule</span><span class="p">);</span>
<span class="nv">$supersededSubreqs</span> <span class="o">=</span> <span class="nv">$supersededSubmodule</span><span class="p">[</span><span class="nx">YUI_REQUIRES</span><span class="p">];</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$supersededSubreqs</span> <span class="k">as</span> <span class="nv">$ssr</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$ssr</span><span class="p">,</span> <span class="nv">$ssmProvides</span><span class="p">))</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$ssr</span><span class="p">]))</span>
<span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$ssr</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$ssr</span><span class="p">,</span> <span class="nv">$loadOptional</span><span class="p">,</span> <span class="nv">$reqs</span><span class="p">));</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$loadOptional</span> <span class="o">&amp;&amp;</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_OPTIONAL</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$o</span> <span class="o">=</span> <span class="nv">$m</span><span class="p">[</span><span class="nx">YUI_OPTIONAL</span><span class="p">];</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$o</span> <span class="k">as</span> <span class="nv">$opt</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$opt</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">depCache</span><span class="p">[</span><span class="nv">$key</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$reqs</span><span class="p">;</span>
<span class="k">return</span> <span class="nv">$reqs</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// @todo restore global dependency support</span>
<span class="k">function</span> <span class="nf">getGlobalDependencies</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">globalModules</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Returns true if the supplied $satisfied module is satisfied by the</span>
<span class="sd"> * supplied $satisfier module</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">moduleSatisfies</span><span class="p">(</span><span class="nv">$satisfied</span><span class="p">,</span> <span class="nv">$satisfier</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$satisfied</span> <span class="o">==</span> <span class="nv">$satisfier</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span><span class="p">[</span><span class="nv">$satisfied</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$satisfiers</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span><span class="p">[</span><span class="nv">$satisfied</span><span class="p">];</span>
<span class="k">return</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$satisfiers</span><span class="p">[</span><span class="nv">$satisfier</span><span class="p">]);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to override the base dir for specific set of modules (Note: not supported when using the combo service)</span>
<span class="sd"> * @method overrideBase</span>
<span class="sd"> * @param {string} base Base path (e.g.) 2.6.0/build</span>
<span class="sd"> * @param {array} modules Module names of which to override base</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">overrideBase</span><span class="p">(</span><span class="nv">$base</span><span class="p">,</span> <span class="nv">$modules</span><span class="p">)</span> <span class="p">{</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$modules</span> <span class="k">as</span> <span class="nv">$name</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$this</span><span class="o">-&gt;</span><span class="na">baseOverrides</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="nv">$base</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to determine if one module is satisfied by provided array of modules</span>
<span class="sd"> * @method listSatisfies</span>
<span class="sd"> * @param {string} satisfied Module name</span>
<span class="sd"> * @param {array} moduleList List of modules names</span>
<span class="sd"> * @return {boolean}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">listSatisfies</span><span class="p">(</span><span class="nv">$satisfied</span><span class="p">,</span> <span class="nv">$moduleList</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$moduleList</span><span class="p">[</span><span class="nv">$satisfied</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span><span class="p">[</span><span class="nv">$satisfied</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$satisfiers</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">satisfactionMap</span><span class="p">[</span><span class="nv">$satisfied</span><span class="p">];</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$satisfiers</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$moduleList</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Determine if rollup replacement threshold has been met</span>
<span class="sd"> * @method checkThreshold</span>
<span class="sd"> * @param {string} Module name</span>
<span class="sd"> * @param {array} moduleList List of modules names</span>
<span class="sd"> * @return {boolean}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">checkThreshold</span><span class="p">(</span><span class="nv">$module</span><span class="p">,</span> <span class="nv">$moduleList</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">count</span><span class="p">(</span><span class="nv">$moduleList</span><span class="p">)</span> <span class="o">&gt;</span> <span class="m">0</span> <span class="o">&amp;&amp;</span> <span class="nb">isset</span><span class="p">(</span><span class="nv">$module</span><span class="p">[</span><span class="nx">YUI_ROLLUP</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$matched</span> <span class="o">=</span> <span class="m">0</span><span class="p">;</span>
<span class="nv">$thresh</span> <span class="o">=</span> <span class="nv">$module</span><span class="p">[</span><span class="nx">YUI_ROLLUP</span><span class="p">];</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$moduleList</span> <span class="k">as</span> <span class="nv">$moduleName</span><span class="o">=&gt;</span><span class="nv">$moddef</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">in_array</span><span class="p">(</span><span class="nv">$moduleName</span><span class="p">,</span> <span class="nv">$module</span><span class="p">[</span><span class="nx">YUI_SUPERSEDES</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$matched</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="p">(</span><span class="nv">$matched</span> <span class="o">&gt;=</span> <span class="nv">$thresh</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="k">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="sd">/**</span>
<span class="sd"> * Used to sort dependencies in the proper order (Note: only call this if the loader is dirty)</span>
<span class="sd"> * @method sortDependencies</span>
<span class="sd"> * @param {string} Module name</span>
<span class="sd"> * @param {array} moduleList List of modules names</span>
<span class="sd"> * @return {boolean}</span>
<span class="sd"> */</span>
<span class="k">function</span> <span class="nf">sortDependencies</span><span class="p">(</span><span class="nv">$moduleType</span><span class="p">,</span> <span class="nv">$skipSort</span><span class="o">=</span><span class="k">false</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$reqs</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$top</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$bot</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$notdone</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$sorted</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="nv">$found</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
<span class="c1">// add global dependenices so they are included when calculating rollups</span>
<span class="nv">$globals</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getGlobalDependencies</span><span class="p">(</span><span class="nv">$moduleType</span><span class="p">);</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$globals</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$dep</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// get and store the full list of dependencies.</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">requests</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$name</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="nv">$dep</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">modules</span><span class="p">[</span><span class="nv">$name</span><span class="p">];</span>
<span class="nv">$newreqs</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">getAllDependencies</span><span class="p">(</span><span class="nv">$name</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loadOptional</span><span class="p">);</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$newreqs</span> <span class="k">as</span> <span class="nv">$newname</span><span class="o">=&gt;</span><span class="nv">$newval</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$newname</span><span class="p">]))</span> <span class="p">{</span>
<span class="nv">$reqs</span><span class="p">[</span><span class="nv">$newname</span><span class="p">]</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">// if we skip the sort, we just return the list that includes everything that</span>
<span class="c1">// was requested, all of their requirements, and global modules. This is</span>
<span class="c1">// filtered by module type if supplied</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$skipSort</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">prune</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">,</span> <span class="nv">$moduleType</span><span class="p">);</span>
<span class="p">}</span>
<span class="c1">// if we are sorting again after new modules have been requested, we</span>
<span class="c1">// do not rollup, and we can remove the accounted for modules</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">count</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span><span class="p">)</span> <span class="o">&gt;</span> <span class="m">0</span> <span class="o">||</span> <span class="nb">count</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">loaded</span><span class="p">)</span> <span class="o">&gt;</span> <span class="m">0</span><span class="p">)</span> <span class="p">{</span>
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">accountedFor</span> <span class="k">as</span> <span class="nv">$name</span><span class="o">=&gt;</span><span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$name</span><span class="p">]))</span> <span class="p">{</span>
<span class="nb">unset</span><span class="p">(</span><span class="nv">$reqs</span><span class="p">[</span><span class="nv">$name</span><span class="p">]);</span>
<span class="p">}</span>
<span class="p">}</span>