CMS Made Simple API

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
license

GPL

since
2.0
author

Robert Campbell calguy1000@gmail.com

see
CmsLayoutCollection

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_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
depcreated
Return values
bool

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

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
throws
CmsInvalidDataException
throws
CmsLogicException

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_filename()

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

public get_content_filename() : string
Tags
since
2.2
Return values
string

get_created()

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

public get_created() : int
Return values
int

get_description()

Get the description of this stylesheet object

public get_description() : string
Return values
string

get_designs()

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

public get_designs() : array<string|int, mixed>
Tags
see
CmsLayoutCollection
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
int

get_modified()

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

public get_modified() : int
Return values
int

has_content_file()

Does this template have an associated file.

public has_content_file() : bool
Tags
since
2.2
Return values
bool

has_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
depcreated
Return values
bool

is_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
bool

load_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
throws
CmsInvalidDataException
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
bool

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
throws
CmsSQLErrorException

set_description()

Set the description of this stylesheet object

public set_description(string $str) : mixed
Parameters
$str : string

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.

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
Tags
throws
CmsInvalidDataException

        
On this page

Search results