CmsLayoutStylesheet
in package
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.
Tags
Table of Contents
Methods
- add_design() : mixed
- Add a design association for this stylesheet object
- add_media_type() : bool
- Add the specified media type to the list of media types for this stylesheet object media types are used with the \@media css rule
- delete() : mixed
- 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
- generate_unique_name() : mixed
- Generate a unique name for a stylesheet
- get_all() : mixed
- Load all stylesheet objects
- get_content() : string
- Get the content of this stylesheet object
- get_content_filename() : string
- Get the filename that will be used to read template contents from file.
- get_created() : int
- Get the data that this stylesheet object was first saved to the database
- get_description() : string
- Get the description of this stylesheet object
- get_designs() : array<string|int, mixed>
- Get the list of design id's (if any) that this stylesheet is associated with
- get_id() : int
- Get the unique id of this stylesheet will return null if this stylesheet has not yet been saved to the database.
- get_lock() : CmsLock
- Get a lock (if any exist) for this object
- get_media_query() : string
- Get the media query associated with this stylesheet
- get_media_types() : array<string|int, mixed>
- Get the media types associated with this stylesheet media types are used with the \@media css rule
- get_modified() : int
- Get the data that this stylesheet object was last saved to the database
- get_name() : string
- Get the name of this stylesheet
- has_content_file() : bool
- Does this template have an associated file.
- has_media_type() : bool
- Test if this stylesheet object has the specified media type media types are used with the \@media css rule
- is_loaded() : bool
- Test if the specific stylesheet (by name or id) is loaded
- load() : CmsLayoutStylesheet
- Load the specified stylesheet object
- load_bulk() : array<string|int, mixed>
- Load multiple stylesheets in an optimized fashion
- lock_expired() : bool
- Test if the current stylesheet object is locked by an expired lock.
- locked() : bool
- Test if the current object is locked.
- remove_design() : mixed
- Remove a design from the association list.
- save() : mixed
- Save this stylesheet to the database Objects are only saved if they are dirty (have been modified in some way, or have no id)
- set_content() : mixed
- Set the CSS content of this stylesheet object
- set_description() : mixed
- Set the description of this stylesheet object
- set_designs() : mixed
- Set the list of design id's that this stylesheet is associated with
- set_media_query() : mixed
- Set the media query associated with this stylesheet
- set_media_types() : mixed
- Absolutely set the list of media types for this stylesheet object media types are used with the \@media css rule
- set_name() : mixed
- Set the unique name of this stylesheet Stylesheet names must be unique throughout the system.
- validate() : mixed
- 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)
Methods
add_design()
Add a design association for this stylesheet object
public
add_design(mixed $a) : mixed
Parameters
- $a : mixed
-
An Instance of a CmsLayoutCollection object, or an integer design id, or a string design name
Tags
add_media_type()
Add the specified media type to the list of media types for this stylesheet object media types are used with the \@media css rule
public
add_media_type(string $str) : bool
Parameters
- $str : string
-
The media type name
Tags
Return values
booldelete()
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
public
delete() : mixed
This method triggers the DeleteStylesheetPre and DeleteStylesheetPost events
generate_unique_name()
Generate a unique name for a stylesheet
public
static generate_unique_name(string $prototype[, string $prefix = null ]) : mixed
Parameters
- $prototype : string
-
A prototype template name
- $prefix : string = null
-
An optional name prefix.
Tags
get_all()
Load all stylesheet objects
public
static get_all([bool $as_list = FALSE ]) : mixed
Parameters
- $as_list : bool = FALSE
-
a flag indicating the output format
Return values
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
get_content()
Get the content of this stylesheet object
public
get_content() : string
Return values
stringget_content_filename()
Get the filename that will be used to read template contents from file.
public
get_content_filename() : string
Tags
Return values
stringget_created()
Get the data that this stylesheet object was first saved to the database
public
get_created() : int
Return values
intget_description()
Get the description of this stylesheet object
public
get_description() : string
Return values
stringget_designs()
Get the list of design id's (if any) that this stylesheet is associated with
public
get_designs() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Array of integer design ids
get_id()
Get the unique id of this stylesheet will return null if this stylesheet has not yet been saved to the database.
public
get_id() : int
Return values
intget_lock()
Get a lock (if any exist) for this object
public
get_lock() : CmsLock
Return values
CmsLockget_media_query()
Get the media query associated with this stylesheet
public
get_media_query() : string
Tags
Return values
stringget_media_types()
Get the media types associated with this stylesheet media types are used with the \@media css rule
public
get_media_types() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>get_modified()
Get the data that this stylesheet object was last saved to the database
public
get_modified() : int
Return values
intget_name()
Get the name of this stylesheet
public
get_name() : string
Return values
stringhas_content_file()
Does this template have an associated file.
public
has_content_file() : bool
Tags
Return values
boolhas_media_type()
Test if this stylesheet object has the specified media type media types are used with the \@media css rule
public
has_media_type(string $str) : bool
Parameters
- $str : string
-
The media type name
Tags
Return values
boolis_loaded()
Test if the specific stylesheet (by name or id) is loaded
public
static is_loaded(mixed $id) : bool
Parameters
- $id : mixed
-
Either an integer stylesheet id, or a string stylesheet name
Return values
boolload()
Load the specified stylesheet object
public
static & load(mixed $a) : CmsLayoutStylesheet
Parameters
- $a : mixed
-
Either an integer stylesheet id, or a string stylesheet name.
Tags
Return values
CmsLayoutStylesheetload_bulk()
Load multiple stylesheets in an optimized fashion
public
static load_bulk(array<string|int, mixed> $ids[, bool $deep = true ]) : array<string|int, mixed>
This method does not throw exceptions if one requested id, or name does not exist.
Parameters
- $ids : array<string|int, mixed>
-
Array of integer stylesheet ids or an array of string stylesheet names.
- $deep : bool = true
-
wether or not to load associated data
Tags
Return values
array<string|int, mixed> —Array of CmsLayoutStylesheet objects
lock_expired()
Test if the current stylesheet object is locked by an expired lock.
public
lock_expired() : bool
If the object is not locked false is returned
Return values
boollocked()
Test if the current object is locked.
public
locked() : bool
Return values
boolremove_design()
Remove a design from the association list.
public
remove_design(mixed $a) : mixed
Parameters
- $a : mixed
-
An Instance of a CmsLayoutCollection object, or an integer design id, or a string design name
Tags
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)
public
save() : mixed
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
Tags
set_content()
Set the CSS content of this stylesheet object
public
set_content(string $str) : mixed
Parameters
- $str : string
Tags
set_description()
Set the description of this stylesheet object
public
set_description(string $str) : mixed
Parameters
- $str : string
set_designs()
Set the list of design id's that this stylesheet is associated with
public
set_designs(array<string|int, mixed> $x) : mixed
Parameters
- $x : array<string|int, mixed>
-
Array of integer design ids
Tags
set_media_query()
Set the media query associated with this stylesheet
public
set_media_query(string $str) : mixed
Parameters
- $str : string
Tags
set_media_types()
Absolutely set the list of media types for this stylesheet object media types are used with the \@media css rule
public
set_media_types(mixed $arr) : mixed
Parameters
- $arr : mixed
-
Either a string, or an array of strings.
set_name()
Set the unique name of this stylesheet Stylesheet names must be unique throughout the system.
public
set_name(string $str) : mixed
Parameters
- $str : string
Tags
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)
protected
validate() : mixed