CmsLayoutStylesheet View code

A class to represent a stylesheet.

This class is capable of managing a single stylesheet, and has static methods for loading stylesheets from the database. Loaded stylesheets are cached in internal memory to ensure that the same stylesheet is not loaded twice for a request.

Stylesheets are (optionally) attached to designs (CmsLayoutCollection) see the {cms_stylesheet} plugin for more information.

package

CMS

license

GPL

since 2.0
author

Robert Campbell calguy1000@gmail.com

see

Methods

get_id() : integer

Get the unique id of this stylesheet will return null if this stylesheet has not yet been saved to the database.

Response

integer

get_name() : string

Get the name of this stylesheet

Response

string

set_name(string $str) 

Set the unique name of this stylesheet Stylesheet names must be unique throughout the system.

Arguments

string $str

get_content() : string

Get the content of this stylesheet object

Response

string

set_content(string $str) 

Set the CSS content of this stylesheet object

Arguments

string $str

get_description() : string

Get the description of this stylesheet object

Response

string

set_description(string $str) 

Set the description of this stylesheet object

Arguments

string $str

get_media_types() : array

Get the media types associated with this stylesheet media types are used with the \@media css rule

deprecated

Response

array

has_media_type(string $str) : boolean

Test if this stylesheet object has the specified media type media types are used with the \@media css rule

Arguments

string $str

The media type name

Response

boolean

add_media_type(string $str) : boolean

Add the specified media type to the list of media types for this stylesheet object media types are used with the \@media css rule

Arguments

string $str

The media type name

Response

boolean

set_media_types(mixed $arr) 

Absolutely set the list of media types for this stylesheet object media types are used with the \@media css rule

deprecated

Arguments

mixed $arr

Either a string, or an array of strings.

get_media_query() : string

Get the media query associated with this stylesheet

Response

string

set_media_query(string $str) 

Set the media query associated with this stylesheet

Arguments

string $str

get_created() : integer

Get the data that this stylesheet object was first saved to the database

Response

integer

get_modified() : integer

Get the data that this stylesheet object was last saved to the database

Response

integer

get_designs() : array

Get the list of design id's (if any) that this stylesheet is associated with

Response

array

Array of integer design ids

set_designs(array $x) 

Set the list of design id's that this stylesheet is associated with

Arguments

array $x

Array of integer design ids

add_design(mixed $a) 

Add a design association for this stylesheet object

Arguments

mixed $a

An Instance of a CmsLayoutCollection object, or an integer design id, or a string design name

remove_design(mixed $a) 

Remove a design from the association list.

Arguments

mixed $a

An Instance of a CmsLayoutCollection object, or an integer design id, or a string design name

validate() 

Validate this stylesheet object for suitability for saving to the database Stylesheet objects must have a valid name (only certain characters accepted, and must have at least some css content)

save() 

Save this stylesheet to the database Objects are only saved if they are dirty (have been modified in some way, or have no id)

This method sends events before and after saving. EditStylesheetPre is sent before an existing stylesheet is saved to the database EditStylesheetPost is sent after an existing stylesheet is saved to the database AddStylesheetPre is sent before a new stylesheet is saved to the database AddStylesheetPost is sent after a new stylesheet is saved to the database

delete() 

Delete this stylesheet object from the database This method deletes the appropriate records from the databas, deletes the id from this object, and marks the object as dirty so that it can be saved again

This method triggers the DeleteStylesheetPre and DeleteStylesheetPost events

get_lock() : \CmsLock

Get a lock (if any exist) for this object

Response

\CmsLock

locked() : boolean

Test if the current object is locked.

Response

boolean

lock_expired() : boolean

Test if the current stylesheet object is locked by an expired lock.

If the object is not locked false is returned

Response

boolean

load(mixed $a) : \CmsLayoutStylesheet

Load the specified stylesheet object

static

Arguments

mixed $a

Either an integer stylesheet id, or a string stylesheet name.

Response

\CmsLayoutStylesheet

load_bulk(array $ids, boolean $deep = true) : array

Load multiple stylesheets in an optimized fashion

static

This method does not throw exceptions if one requested id, or name does not exist.

Arguments

array $ids

Array of integer stylesheet ids or an array of string stylesheet names.

boolean $deep

wether or not to load associated data

Response

array

Array of CmsLayoutStylesheet objects

get_all(boolean $as_list = FALSE) : mixed

Load all stylesheet objects

static

Arguments

boolean $as_list

a flag indicating the output format

Response

mixed

If $as_list is true then the output will be an associated array of stylesheet id and stylesheet name suitable for use in an html select element otherwise, an array of CmsLayoutStylesheet objects is returned

is_loaded(mixed $id) : boolean

Test if the specific stylesheet (by name or id) is loaded

static

Arguments

mixed $id

Either an integer stylesheet id, or a string stylesheet name

Response

boolean

generate_unique_name(string $prototype, string $prefix = null) 

Generate a unique name for a stylesheet

static

Arguments

string $prototype

A prototype template name

string $prefix

An optional name prefix.

get_content_filename() : string

Get the filename that will be used to read template contents from file.

Response

string

has_content_file() : boolean

Does this template have an associated file.

Response

boolean