Yahoo! UI Library

phploader  1.0.0beta

Yahoo! UI Library > phploader > PHP.YAHOO_util_Loader
Search:
 
Filters

Class PHP.YAHOO_util_Loader

The YUI PHP loader base class which provides dynamic server-side loading for YUI

Constructor

PHP.YAHOO_util_Loader ( yuiVersion , cacheKey , modules , noYUI )
Parameters:
yuiVersion <string> Defines which version of YUI metadata to load
cacheKey <string> Unique APC cache key. This is combined with the YUI base so that updates to YUI will force a new cache entry. However, if your custom config changes, this key should be changed (otherwise the old values will be used until the cache expires).
modules <array> A list of custom modules
noYUI <boolean> Pass true if you do not want the YUI metadata

Properties

accountedFor - array

List of modules the loader has aleady accounted for

allowRollups - boolean

Should we allow rollups
Default Value: true

base - string

The base directory
Default Value: http://yui.yahooapis.com/[YUI VERSION]/build/

baseOverrides - array

List of modules that have had their base pathes overridden

cacheFound - boolean

Used to determine if we have an APC cache hit
Default Value: false

combine - boolean

Combined into a single request using the combo service to pontentially reduce the number of http requests required. This option is not supported when loading custom modules.
Default Value: false

comboBase - string

The base path to the combo service. Uses the Yahoo! CDN service by default. You do not have to set this property to use the combine option. YUI PHP Loader ships with an intrinsic, lightweight combo-handler as well (see combo.php).
Default Value: http://yui.yahooapis.com/combo?

cssComboLocation - string

Holds the current combo url for the loaded CSS resources. This is built with addToCombo and retrieved with getComboLink. Only used when the combine is enabled.
Default Value: null

delayCache - boolean

Used to delay caching of module data
Default Value: false

dirty - boolean

Used to determine if additional sorting of dependencies is required
Default Value: true

filter - string (e.g.)

A filter to apply to result urls. This filter will modify the default path for all modules. The default path is the minified version of the files (e.g., event-min.js). Changing the filter alows for picking up the unminified (raw) or debug sources. The default set of valid filters are: YUI_DEBUG & YUI_RAW
Default Value: empty string (minified vesion)

filterList - array

A list of modules to apply the filter to. If not supplied, all modules will have any defined filters applied. Tip: Useful for debugging.
Default Value: null

filters - array

An array of filters & filter replacement rules. Used with $filter.

fullCacheKey - string

The APC cache key
Default Value: null

jsComboLocation - string

Holds the current combo url for the loaded JavaScript resources. This is built with addToCombo and retrieved with getComboLink. Only used when the combine is enabled.
Default Value: null

loaded - array

List of modules that have been been outputted via getLink() / getComboLink()

loadOptional - boolean

Whether or not to load optional dependencies for the requested modules
Default Value: false

modules - array

Contains the available module metadata
Default Value: YUI module metadata for the specified release

processedModuleTypes - array

The first time we output a module type we allow automatic rollups, this array keeps track of module types we have processed

requests - array

All required modules

rollupsToTop - boolean

Force rollup modules to be sorted as moved to the top of the stack when performing an automatic rollup. This has a very small performance consequence.
Default Value: false

skins - array

The list of required skins

sorted - array

List of sorted modules
Default Value: null

superceded - array

List of all modules superceded by the list of required modules

undefined - array

Keeps track of modules that were requested that are not defined

Methods

accountFor

void accountFor ( name )
Markes a module as being accounted for. Used in dependency testing.
Parameters:
name <string> Module to mark as being accounted for
Returns: void

addToCombo

void addToCombo ( name , type )
Adds a module the combo collection for a specified resource type
Parameters:
name <string> The module name to add
type <string> Resource type (i.e.) YUI_JS or YUI_CSS
Returns: void

canJSON

canJSON ( )
Detects if environment supports JSON encode/decode

checkThreshold

boolean checkThreshold ( Module , moduleList )
Determine if rollup replacement threshold has been met
Parameters:
Module <string> name
moduleList <array> List of modules names
Returns: boolean

clearComboLink

void clearComboLink ( type )
Clears the combo url of already loaded modules for a specific resource type. Prevents duplicate loading of modules if the page makes multiple calls to tags, css, or script.
Parameters:
type <string> Resource type (i.e.) YUI_JS or YUI_CSS
Returns: void

css

string css ( )
Used to output each of the required link tags
Returns: string

css_data

array css_data ( )
Used to fetch an array of the required CSS components
Returns: array
Returns an array of data about each of the identified JavaScript components

css_embed

string css_embed ( )
Used to embed the raw CSS
Returns: string
(e.g.) Returns the style tag(s) with the CSS inline

css_json

string css_json ( )
Used to fetch a JSON object with the required CSS components
Returns: string
Returns a JSON object containing urls for each CSS component

css_raw

string css_raw ( )
Used to produce the raw CSS code inline without the actual style tags
Returns: string
Returns the raw CSS code inline without the actual style tags

data

string data ( moduleType , allowRollups , skipSort )
Used to output an Array which contains data about the required JavaScript & CSS components
Parameters:
moduleType <string> Type of html tag to return (i.e.) js or css. Default is both.
allowRollups <boolean>
skipSort <boolean>
Returns: string

embed

string embed ( moduleType , skipSort )
Used to output each of the required html tags inline (i.e.) script and/or style
Parameters:
moduleType <string> Type of html tag to return (i.e.) js or css. Default is both.
skipSort <boolean>
Returns: string
Returns the style tag(s) with the CSS inline and/or the script tag(s) with the JavaScript inline

formatSkin

string formatSkin ( string )
Add prefix to module skin
Parameters:
string <object> $skin the skin name
string <object> $moduleName the name of a module
Returns: string
prefixed skin name

getAllDependencies

array getAllDependencies ( mname , loadOptional , completed )
Identify dependencies for a give module name
Parameters:
mname <string> Module name
loadOptional <boolean> Load optional dependencies
completed <array>
Returns: array

getComboLink

string getComboLink ( type )
Retrieves the combo link or script include for the currently loaded modules of a specific resource type
Parameters:
type <string> Resource type (i.e.) YUI_JS or YUI_CSS
Returns: string
link or script include

getContent

string getContent ( name , type )
Retrieve the style or script node with embedded source for a given module name and resource type
Parameters:
name <string> The module name to fetch the source from
type <string> Resource type (i.e.) YUI_JS or YUI_CSS
Returns: string
style or script node with embedded source

getLink

string getLink ( name , type )
Retrieve the link or script include for a given module name and resource type
Parameters:
name <string> The module name to fetch the include for
type <string> Resource type (i.e.) YUI_JS or YUI_CSS
Returns: string
link or script include

getLoadedModules

array getLoadedModules ( )
Identifies what module(s) have been loaded via the load method and/or marked as loaded via the setLoaded method
Returns: array

getLoadedModulesAsJSON

json getLoadedModulesAsJSON ( )
Identifies what module(s) have been loaded via the load method and/or marked as loaded via the setLoaded method
Returns: json

getProvides

array getProvides ( name )
Identifies what module(s) are provided by a given module name (e.g.) yaho-dom-event provides yahoo, dom, and event
Parameters:
name <string> Module name
Returns: array

getRaw

string getRaw ( name )
Retrieve the raw source contents for a given module name
Parameters:
name <string> The module name you wish to fetch the source from
Returns: string
raw source

getRemoteContent

getRemoteContent ( url )
Retrieve the contents of a remote resource
Parameters:
url <string> URL to fetch data from

getSuperceded

array getSuperceded ( name )
Use to get a list of modules superseded by the given module name
Parameters:
name <string> Module name
Returns: array

getUrl

void getUrl ( name )
Retrieve the calculated url for the component in question
Parameters:
name <string> YUI component name
Returns: void

hasProcessedModuleType

void hasProcessedModuleType ( string )
Used to determine if a module type has been processed
Parameters:
string <object> $moduleType
Returns: void

json

string json ( moduleType , allowRollups , skipSort , full )
Used to fetch a JSON object with the required JavaScript and CSS components
Parameters:
moduleType <string>
allowRollups <boolean>
skipSort <boolean>
full <boolean>
Returns: string
Returns a JSON object with the required JavaScript and CSS components

listSatisfies

boolean listSatisfies ( satisfied , moduleList )
Used to determine if one module is satisfied by provided array of modules
Parameters:
satisfied <string> Module name
moduleList <array> List of modules names
Returns: boolean

load

void load ( string )
Used to load YUI and/or custom components
Parameters:
string <object> $varname [, string $... ] List of component names
Returns: void

loadSingle

boolean loadSingle ( string )
Loads the requested module
Parameters:
string <object> $name the name of a module to load
Returns: boolean

log

void log ( msg )
General logging function. Writes a message to the PHP error log.
Parameters:
msg <string> Message to write
Returns: void

overrideBase

void overrideBase ( base , modules )
Used to override the base dir for specific set of modules (Note: not supported when using the combo service)
Parameters:
base <string> Base path (e.g.) 2.6.0/build
modules <array> Module names of which to override base
Returns: void

parseSkin

array parseSkin ( string )
Parses a module's skin. A modules skin is typically prefixed.
Parameters:
string <object> $name the name of a module to parse
Returns: array

processDependencies

varies processDependencies ( outputType , moduleType , skipSort , showLoaded )
Used to process the dependency list and retrieve the actual CSS and/or JavaScript resources in requested output format (e.g.) json, link/script nodes, embeddable code, php array, etc.
Parameters:
outputType <string> the format you like the response to be in
moduleType <string> Type of module to return (i.e.) js or css
skipSort <boolean>
showLoaded <boolean>
Returns: varies
output format based on requested outputType

prune

array prune ( deps , moduleType )
Used during dependecy processing to prune modules from the list of modules requiring further processing
Parameters:
deps <array> List of module dependencies
moduleType <string> Type of modules to prune (i.e.) js or css
Returns: array

raw

string raw ( moduleType , allowRollups , skipSort )
Used to produce the raw Javacript and CSS code inline without the actual script or style tags
Parameters:
moduleType <string>
allowRollups <boolean>
skipSort <boolean>
Returns: string
Returns the raw JavaScript and/or CSS code inline without the actual style tags

script

string script ( )
Used to output each of the required script tags
Returns: string

script_data

array script_data ( )
Used to fetch an array of the required JavaScript components
Returns: array
Returns an array of data about each of the identified JavaScript components

script_embed

string script_embed ( )
Used to embed the raw JavaScript inline
Returns: string
Returns the script tag(s) with the JavaScript inline

script_json

string script_json ( )
Used to fetch a JSON object with the required JavaScript components
Returns: string
Returns a JSON object containing urls for each JavaScript component

script_raw

string script_raw ( )
Used to produce the raw JavaScript code inline without the actual script tags
Returns: string
Returns the raw JavaScript code inline without the actual script tags

setLoaded

void setLoaded ( string )
Used to specify modules that are already on the page that should not be loaded again
Parameters:
string <object> $varname [, string $... ] List of module names
Returns: void

setProcessedModuleType

void setProcessedModuleType ( string )
Used to mark a module type as processed
Parameters:
string <object> $moduleType
Returns: void

skinSetup

string skinSetup ( string )
Sets up skin for skinnable modules
Parameters:
string <object> $name module name
Returns: string

sortDependencies

boolean sortDependencies ( Module , moduleList )
Used to sort dependencies in the proper order (Note: only call this if the loader is dirty)
Parameters:
Module <string> name
moduleList <array> List of modules names
Returns: boolean

tags

string tags ( moduleType , skipSort )
Used to output each of the required html tags (i.e.) script or link
Parameters:
moduleType <string> Type of html tag to return (i.e.) js or css. Default is both.
skipSort <boolean>
Returns: string

updateCache

void updateCache ( )
Used to update the APC cache
Returns: void


Copyright © 2009 Yahoo! Inc. All rights reserved.