Stud.IP  5.4
Assets Class Reference

Static Public Member Functions

static set_assets_path (string $path)
 
static set_assets_url ($url)
 
static url ($to='')
 
static path ($to='')
 
static img ($source, $opt=[])
 
static input ($source, $opt=[])
 
static image_path ($source, $respect_retina=false)
 
static script ($atLeastOneArgument)
 
static javascript_path ($source)
 
static stylesheet ($atLeastOneArgument)
 
static stylesheet_path ($source)
 

Data Fields

const NUMBER_OF_ALIASES = 2
 

Member Function Documentation

◆ image_path()

static image_path (   $source,
  $respect_retina = false 
)
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.png"

Note: This function should be private/depracated for the use in other scripts, as we would like to always generate the complete <image> oder <input> tag. Please use Assets::img or Assets::input instead.

◆ img()

static img (   $source,
  $opt = [] 
)
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"

Do not use this to render icons. Use the more appropiate class Icon for this.

◆ input()

static input (   $source,
  $opt = [] 
)
static

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

  • '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"

Do not use this to render icons. Use the more appropiate class Icon for this.

◆ javascript_path()

static javascript_path (   $source)
static

Returns path to a javascript asset.

Example:

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

◆ path()

static path (   $to = '')
static

This class method is an accessor to the path "prefix" for all things "asset"

◆ script()

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>

◆ set_assets_path()

static set_assets_path ( string  $path)
static

This method sets the URL to your assets.

Parameters
string$paththe path to the assets

◆ set_assets_url()

static set_assets_url (   $url)
static

This method sets the URL to your assets.

Parameters
stringthe URL to the assets
Returns
void

◆ stylesheet()

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">

◆ stylesheet_path()

static stylesheet_path (   $source)
static

Returns path to a stylesheet asset.

Example:

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

◆ url()

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

◆ NUMBER_OF_ALIASES

const NUMBER_OF_ALIASES = 2

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