Stud.IP  2.0 Revision 48548
 All Data Structures Namespaces Files Functions Variables Pages
Assets Class Reference
Collaboration diagram for Assets:
Collaboration graph

Static Public Member Functions

static set_assets_url ($url)
static url ($to= '')
static img ($source, $opt=array())
static image_path ($source)
static script ($atLeastOneArgument)
static javascript_path ($source)
static stylesheet ($atLeastOneArgument)
static stylesheet_path ($source)

Data Fields

const NUMBER_OF_ALIASES = 2

Static Public Attributes

static $dynamic
static $counter_cache

Member Function Documentation

static image_path (   $source)
static

Returns path to an image asset.

Example:

The src can be supplied as a...

full path, like "/my_images/image.gif"

file name, like "rss.png", that gets expanded to "/images/rss.png"

file name without extension, like "logo", that gets expanded to "/images/logo.gif"

Here is the caller graph for this function:

static img (   $source,
  $opt = array() 
)
static

Returns an image tag using options as html attributes on the tag, but with these special cases:

'alt' - If no alt text is given, the file name part of the $source is used (capitalized and without the extension)

  • 'size' - Supplied as "X@Y", so "30@45" becomes width="30" and height="45"

The source can be supplied as a...

  • full path, like "/my_images/image.gif"
  • file name, like "rss.png", that gets expanded to "/images/rss.png"
  • file name without extension, like "logo", that gets expanded to "/images/logo.png"

Here is the call graph for this function:

Here is the caller graph for this function:

static javascript_path (   $source)
static

Returns path to a javascript asset.

Example:

Assets::javascript_path('ajax') => /javascripts/ajax.js

Here is the caller graph for this function:

static script (   $atLeastOneArgument)
static

Returns a script include tag per source given as argument.

Examples:

Assets::script('prototype') => <script src="/javascript/prototype.js"></script>

Assets::script('common.javascript', '/elsewhere/cools') => <script src="/js/common.javascript"></script> <script src="/elsewhere/cools.js"></script>

Here is the call graph for this function:

static set_assets_url (   $url)
static

This method sets the URL to your assets.

Parameters
stringthe URL to the assets
Returns
void
static stylesheet (   $atLeastOneArgument)
static

Returns a css link tag per source given as argument.

Examples:

Assets::stylesheet('style') => <link href="/stylesheets/style.css" media="screen" rel="stylesheet">

Assets::stylesheet('style', array('media' => 'all')) => <link href="/stylesheets/style.css" media="all" rel="stylesheet">

Assets::stylesheet('random.styles', '/css/stylish') => <link href="/stylesheets/random.styles" media="screen" rel="stylesheet"> <link href="/css/stylish.css" media="screen" rel="stylesheet">

Here is the call graph for this function:

Here is the caller graph for this function:

static stylesheet_path (   $source)
static

Returns path to a stylesheet asset.

Example:

stylesheet_path('style') => /stylesheets/style.css

Here is the caller graph for this function:

static url (   $to = '')
static

This class method is an accessor to the URL "prefix" for all things "asset" Prepend the return value of this method to the relative path of the wanted static content.

Additionally if the ASSETS_URL contains the string 'd', it will be replaced with a random number between 0 and 3. If you passed an argument this number will not be random but specific to that argument thus being referentially transparent.

Example:

static ASSETS_URL

$ASSETS_URL = 'http://www.example.com/public/'; echo Assets::url() . 'javascripts/prototype.js' . "\n"; echo Assets::url('javascripts/prototype.js') . "\n";

output

http://www.example.com/public/javascripts/prototype.js http://www.example.com/public/javascripts/prototype.js

dynamic ASSETS_URL

$ASSETS_URL = 'http://www%d.example.com/public/'; echo Assets::url() . 'javascripts/prototype.js' . "\n"; echo Assets::url() . 'javascripts/prototype.js' . "\n"; echo Assets::url() . 'javascripts/prototype.js' . "\n"; echo Assets::url('javascripts/prototype.js') . "\n"; echo Assets::url('javascripts/prototype.js') . "\n"; echo Assets::url('javascripts/prototype.js') . "\n";

output

http://www0.example.com/public/javascripts/prototype.js http://www1.example.com/public/javascripts/prototype.js http://www2.example.com/public/javascripts/prototype.js http://www1.example.com/public/javascripts/prototype.js http://www1.example.com/public/javascripts/prototype.js http://www1.example.com/public/javascripts/prototype.js

Parameters
stringan optional suffix which is used to construct a number if ASSETS_URL is dynamic (contains 'd')
Returns
string the URL "prefix"

Field Documentation

$counter_cache
static
$dynamic
static
const NUMBER_OF_ALIASES = 2

The documentation for this class was generated from the following file: