API - Resources\Resources
system\resources.php at line 11

Class Resources

Resources

public class Resources

Cotonti Resource control class
Copyright:
(c) Cotonti Team
License:
https://github.com/Cotonti/Cotonti/blob/master/License.txt

Constant Summary
final static str

bootstrap

final static str

ckeditor

final static str

jQuery

Field Summary
protected static mixed

$addedFiles

protected static array predefined aliases

$alias

protected static mixed

$cacheOn

protected static mixed

$consolidate

protected static string $dir Resources cache dir

$dir

protected static array footer Resources Registry

$footerRc

protected static bool header.php executed?

$headerComplete

protected static array header Resources Registry

$headerRc

protected static mixed

$isAdmin

protected static mixed

$minify

protected static array Resources Registry

$registry

protected static mixed

$skip_minification

Method Summary
static void

__init()

static bool

addFile(string path, string type, int order, string scope)

Puts a JS/CSS file into the header resource registry to be consolidated with other such resources and stored in cache.

protected static void

additionalFiles(mixed file)

static bool

addEmbed(string identifier, string code, string scope, string type, int order)

Puts a portion of embedded code into the header CSS/JS resource registry.

static void

render()

protected static void

consolidate()

Consolidate all resources and make single file

static void

renderFooter()

Render footer resources

static bool

linkFile(string path, string type, int order)

A shortcut for plain output of a link to a CSS/JS file in the header of the page

static bool

linkFileFooter(string path, string type, int order)

A shortcut to append a JavaScript or CSS file to the footer

static void

embed(string code, int order, string type)

A shortcut for plain output of an embedded stylesheet/javascript in the header of the page Example: Resources::embed(" alert('ssssss') "); Resources::embed(" .blablabla {color: #000000} ", 'css');

static void

embedFooter(string code, string type, int order)

A shortcut for plain output of an embedded stylesheet/javascript in the footer of the page Example: Resources::embedFooter(" alert('ssssss') ");

static string

minify(string code, string type)

JS/CSS minification function

static bool

setAlias(string newAlias, string value, bool canReWrite)

Set Resource alias

static void

getAlias(mixed aliasName)

Constant Detail

system\resources.php at line 21

bootstrap

public final static str bootstrap = '@bootstrap.js'

system\resources.php at line 22

ckeditor

public final static str ckeditor = '@ckeditor'

system\resources.php at line 20

jQuery

public final static str jQuery = '@jQuery'

Field Detail

system\resources.php at line 40

addedFiles

protected static mixed $addedFiles = array()

system\resources.php at line 17

alias

protected static array predefined aliases $alias = array(...)

system\resources.php at line 44

cacheOn

protected static mixed $cacheOn = false

system\resources.php at line 46

consolidate

protected static mixed $consolidate = false

system\resources.php at line 60

dir

protected static string $dir Resources cache dir $dir = ''

system\resources.php at line 33

footerRc

protected static array footer Resources Registry $footerRc = array()

system\resources.php at line 55

headerComplete

protected static bool header.php executed? $headerComplete = false

system\resources.php at line 38

headerRc

protected static array header Resources Registry $headerRc = array()

system\resources.php at line 48

isAdmin

protected static mixed $isAdmin = false

system\resources.php at line 50

minify

protected static mixed $minify = false

system\resources.php at line 28

registry

protected static array Resources Registry $registry = array()

system\resources.php at line 42

skip_minification

protected static mixed $skip_minification = false

Method Detail

system\resources.php at line 62

__init

public static void __init()

system\resources.php at line 104

addFile

public static bool addFile(string path, string type, int order, string scope)
Puts a JS/CSS file into the header resource registry to be consolidated with other such resources and stored in cache. It is recommened to use files instead of embedded code and use this method instead of Resources::addEmbed(). Use this way for any sort of static JavaScript or CSS linking. Do not put any private data in any of resource files - it is not secure. If you really need it, then use direct output instead.
Parameters:
path - Path to a *.js script or *.css stylesheet
order - Order priority number
scope - Resource scope. Scope is a selector of domain where resource is used. Valid scopes are: 'global' - global for entire site, will be included everywhere, this is the most static and persistent scope; 'guest' - for unregistered visitors only; 'user' - for registered members only; 'group_123' - for members of a specific group (maingrp), in this example of group with id=123. It is recommended to use 'global' scope whenever possible because it delivers best caching opportunities.
Returns:
Returns TRUE normally, FALSE is file was not found
Throws:
Exception

system\resources.php at line 162

additionalFiles

protected static void additionalFiles(mixed file)

system\resources.php at line 198

addEmbed

public static bool addEmbed(string identifier, string code, string scope, string type, int order)
Puts a portion of embedded code into the header CSS/JS resource registry. It is strongly recommended to use files for CSS/JS whenever possible and call Resources::AddFile() function for them instead of embedding code into the page and using this function. This function should be used for dynamically generated code, which cannot be stored in static files.
Parameters:
identifier - Alphanumeric identifier for the piece, used to control updates, etc.
code - Embedded stylesheet or script code
scope - Resource scope. See description of this parameter in Resources::AddFile() docs.
type - Resource type: 'js' or 'css'
order - Order priority number
Returns:
This function always returns TRUE
See Also:
Resources::AddFile()

system\resources.php at line 233

render

public static void render()

system\resources.php at line 310

consolidate

protected static void consolidate()
Consolidate all resources and make single file

system\resources.php at line 537

renderFooter

public static void renderFooter()
Render footer resources

system\resources.php at line 588

linkFile

public static bool linkFile(string path, string type, int order)
A shortcut for plain output of a link to a CSS/JS file in the header of the page
Parameters:
path - Stylesheet *.css or script *.js path/url
Returns:
Throws:
Exception

system\resources.php at line 630

linkFileFooter

public static bool linkFileFooter(string path, string type, int order)
A shortcut to append a JavaScript or CSS file to the footer
Parameters:
path - JavaScript or CSS file path
Returns:
Throws:
Exception

system\resources.php at line 678

embed

public static void embed(string code, int order, string type)
A shortcut for plain output of an embedded stylesheet/javascript in the header of the page Example: Resources::embed(" alert('ssssss') "); Resources::embed(" .blablabla {color: #000000} ", 'css');
Parameters:
code - Stylesheet or javascript code
type - Resource type: 'js' or 'css'

system\resources.php at line 697

embedFooter

public static void embedFooter(string code, string type, int order)
A shortcut for plain output of an embedded stylesheet/javascript in the footer of the page Example: Resources::embedFooter(" alert('ssssss') ");
Parameters:
code - Stylesheet or javascript code
type - Resource type: 'js' or 'css'

system\resources.php at line 712

minify

public static string minify(string code, string type)
JS/CSS minification function
Parameters:
code - Code to minify
type - Type: 'js' or 'css'
Returns:
Minified code

system\resources.php at line 734

setAlias

public static bool setAlias(string newAlias, string value, bool canReWrite)
Set Resource alias
Returns:

system\resources.php at line 747

getAlias

public static void getAlias(mixed aliasName)