class Theme extends ConcreteObject implements JsonSerializable (View source)

A page's theme is a pointer to a directory containing templates, CSS files and optionally PHP includes, images and JavaScript files.

Themes inherit down the tree when a page is added, but can also be set at the site-wide level (thereby overriding any previous choices.).

Constants

E_THEME_INSTALLED

THEME_EXTENSION

FILENAME_TYPOGRAPHY_CSS

Properties

$error from  ConcreteObject
protected $pThemeName
protected $pThemeID
protected $pThemeDescription
protected $pThemeDirectory
protected $pThemeThumbnail
protected $pThemeHandle
protected $pThemeURL
protected $pThemeIsPreview
protected $pkgID
protected $stylesheetCachePath
protected $stylesheetCacheRelativePath
protected string|null|false $pThemeGridFrameworkHandle

The handle of the grid framework supported by this theme.

Methods

loadError($error)

No description

isError()

No description

getError()

No description

setPropertiesFromArray($arr)

No description

static 
camelcase($file)

No description

static 
uncamelcase($string)

No description

__construct()

No description

static Theme[]
getGlobalList()

Get the installed themes provided by packages.

static Theme[]
getLocalList()

Get the installed themes provided by the core.

static Theme[]
getListByPackage($pkg)

Get the installed themes provided by a package.

static Theme[]
getList(string|null $where = null)

Get the installed themes.

static string[]
getInstalledHandles()

Get the handles of all the installed themes.

providesAsset(string $assetType, string|false $assetHandle = null)

Mark an asset as provided by this theme.

requireAsset()

Mark an asset as reuired by this theme.

static Theme[]
getAvailableThemes(bool $filterInstalled = true)

Get the all the themes available in the /application/themes directory.

static Theme|null
getByFileHandle(string $handle, string $dir = DIR_FILES_THEMES, string $pkgHandle = '')

Get a theme from the file system.

bool
hasSkins()

Returns true if theme or user preset skins are available

bool
hasPresetSkins()

Checks the filesystem and returns true if custom skins are available for the theme.

getSkinDirectoryRecord()

No description

array
getPresetSkins()

No description

array
getCustomSkins()

No description

array
getSkins()

No description

bool
isThemeCustomizable()

No description

Customizer|null
getThemeCustomizer()

No description

SkinInterface|null
getThemeDefaultSkin()

Gets the default skin for this theme

SkinInterface|null
getSkinByIdentifier(string $skinIdentifier)

Returns a skin object when passed a string identifier

mixed|void
jsonSerialize()

No description

enablePreviewRequest() deprecated

No description

getThemeCustomizableStyleSheets() deprecated

Get all the customizable LESS stylesheets.

bool
isThemePreviewRequest() deprecated

No description

getStylesheetObject(string $stylesheet) deprecated

No description

string
getStylesheet(string $stylesheet) deprecated

No description

getThemeCustomStyleObject() deprecated

No description

static Theme|null
getByHandle(string $pThemeHandle)

Get an installed theme given its handle.

static Theme|null
getByID(int $pThemeID)

Get an installed theme given its ID.

static Theme|null
populateThemeQuery(string $where, array $args)

Get the instance representing an installed theme.

static Theme|null
add(string $pThemeHandle, Package|Package|null $pkg = null)

Install a theme given its handle.

File[]
getFilesInTheme()

Grab all files in theme that are PHP based (or html if we go that route) and then lists them out, by type, allowing people to install them as page type, etc.

static stdClass
getThemeNameAndDescription(string $dir, string $pThemeHandle, string $pkgHandle = '')

Get the theme details by reading a directory containing the theme.

export(SimpleXMLElement $node)

Export this theme by creating the XML nodes under the provided XML node.

static 
exportList(SimpleXMLElement $xml)

Export all the installed themes by creating the XML nodes under the provided XML node.

static Theme|null
install(string $dir, string $pThemeHandle, int|null $pkgID)

Install a theme.

DocumentationProviderInterface|null
getDocumentationProvider()

No description

ColorCollection|null
getColorCollection()

No description

hasColorCollection()

No description

bool
supportsThemeDocumentation()

Checks to see whether the capability of theme documentation exists for this theme.

Page|null
bool
hasThemeDocumentation()

Checks to see if theme documentation has been installed

array
getThemeDocumentationPages()

Returns an array of documentation pages for this theme

updateThemeCustomClass()

(Re)Scan the theme folder to check if it contains the page_theme.php file: if so, marks the theme as having a controller.

int|null
getThemeID()

Get the ID of the installed theme (if available).

string
getThemeName()

Get the (English) name of the theme.

string
getThemeDisplayName(string $format = 'html')

Get the localized name for this theme (escaped accordingly to $format).

int|null
getPackageID()

Get the ID of the package providing this theme (if available).

string|false|null
getPackageHandle()

Get the handle of the package providing this theme (if available).

hasCustomClass()

Returns whether a theme has a custom class.

string
getThemeHandle()

Get the handle of this theme.

string
getThemeDescription()

Get the (English) description of this theme.

string
getThemeDisplayDescription(string $format = 'html')

Get the localized description for this theme (escaped accordingly to $format).

string
getThemeDirectory()

Get the directory containing this theme.

string
getThemeURL()

Get the URL prefix of the assets provided by this theme.

string
getThemeEditorCSS()

Get the URL of the theme typography.css file.

setThemeURL(string $pThemeURL)

Set the URL prefix of the assets provided by this theme.

setThemeDirectory(string $pThemeDirectory)

Set the absolute path of the theme folder.

setThemeHandle(string $pThemeHandle)

Set the handle of this theme.

setStylesheetCachePath(string $path)

Set the absolute path of a directory where the CSS stylesheet files should be stored.

setStylesheetCacheRelativePath(string $path)

Set the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory.

string
getStylesheetCachePath()

Get the absolute path of a directory where the CSS stylesheet files should be stored.

string
getStylesheetCacheRelativePath()

Get the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory.

bool
isUninstallable()

Is this theme uninstallable?

Image
getThemeThumbnail()

Get the theme thumbnail image.

applyToSite(Site $site = null)

Apply this theme to all the pages of a site.

static Theme|null
getSiteTheme()

Get the theme for the current site.

uninstall()

Uninstall this theme.

registerAssets()

Register the assets provided by this theme.

bool
supportsGridFramework()

Does this theme support a grid framework?

supportsFeature(string $feature)

No description

getThemeGridFrameworkObject()

Get the grid framework supported by this theme.

string|null|false
getThemeGridFrameworkHandle()

Get the handle of the grid framework supported by this theme.

string[]
getThemeSupportedFeatures()

Get the handles of the features supported by this theme.

array
getThemeBlockClasses()

Get the theme-specific CSS classes for every block.

array
getThemeAreaClasses()

Get the theme-specific CSS classes for every area.

array
getThemeEditorClasses()

Get the theme-specific style names to be used in the rich text editor.

array
getThemeDefaultBlockTemplates()

Get the theme-specific templates for every block.

array
getThemeResponsiveImageMap()

Get the handles of the thumbnail types and related resolution breakpoint. Important: make sure to define these in proper ascending size order, otherwise you might get inconsistencies in certain aspects of the UI that refer to these image types.

Details

loadError($error)

No description

Parameters

$error

isError()

No description

getError()

No description

setPropertiesFromArray($arr)

No description

Parameters

$arr

static camelcase($file)

No description

Parameters

$file

static uncamelcase($string)

No description

Parameters

$string

__construct()

No description

static Theme[] getGlobalList()

Get the installed themes provided by packages.

Return Value

Theme[]

static Theme[] getLocalList()

Get the installed themes provided by the core.

Return Value

Theme[]

static Theme[] getListByPackage($pkg)

Get the installed themes provided by a package.

Parameters

$pkg

Return Value

Theme[]

static Theme[] getList(string|null $where = null)

Get the installed themes.

Parameters

string|null $where

a custom SQL criteria to filter the installed themes.

Return Value

Theme[]

static string[] getInstalledHandles()

Get the handles of all the installed themes.

Return Value

string[]

providesAsset(string $assetType, string|false $assetHandle = null)

Mark an asset as provided by this theme.

Parameters

string $assetType

E.g. 'css' or 'javascript' (or an asset group identifier like 'jquery/ui')

string|false $assetHandle

E.g. 'core/colorpicker'.

requireAsset()

Mark an asset as reuired by this theme.

Accepts the same arguments as \Concrete\Core\Http\ResponseAssetGroup::requireAsset().

static Theme[] getAvailableThemes(bool $filterInstalled = true)

Get the all the themes available in the /application/themes directory.

Parameters

bool $filterInstalled

true (default) to exclude the already installed themes, false to include them.

Return Value

Theme[]

static Theme|null getByFileHandle(string $handle, string $dir = DIR_FILES_THEMES, string $pkgHandle = '')

Get a theme from the file system.

Parameters

string $handle

the theme handle

string $dir

the parent directory that contains the theme directory

string $pkgHandle

the handle of the package providing the theme

Return Value

Theme|null

bool hasSkins()

Returns true if theme or user preset skins are available

Return Value

bool

bool hasPresetSkins()

Checks the filesystem and returns true if custom skins are available for the theme.

Return Value

bool

Record getSkinDirectoryRecord()

No description

Return Value

Record

array getPresetSkins()

No description

Return Value

array

array getCustomSkins()

No description

Return Value

array

array getSkins()

No description

Return Value

array

bool isThemeCustomizable()

No description

Return Value

bool

Customizer|null getThemeCustomizer()

No description

Return Value

Customizer|null

SkinInterface|null getThemeDefaultSkin()

Gets the default skin for this theme

Return Value

SkinInterface|null

SkinInterface|null getSkinByIdentifier(string $skinIdentifier)

Returns a skin object when passed a string identifier

Parameters

string $skinIdentifier

Return Value

SkinInterface|null

mixed|void jsonSerialize()

No description

Return Value

mixed|void

enablePreviewRequest() deprecated

deprecated but still required by the legacy theme customizer Set this instance to be a preview for the current request.

No description

Stylesheet[] getThemeCustomizableStyleSheets() deprecated

deprecated

Get all the customizable LESS stylesheets.

Return Value

Stylesheet[]

bool isThemePreviewRequest() deprecated

deprecated Is this instance a preview for the current request?

No description

Return Value

bool

Stylesheet getStylesheetObject(string $stylesheet) deprecated

deprecated Get a customizable LESS stylesheet given the stylesheed base file name.

No description

Parameters

string $stylesheet

Return Value

Stylesheet

string getStylesheet(string $stylesheet) deprecated

deprecated Look into the current CSS directory and return a fully compiled stylesheet when passed a LESS stylesheet. Also serves up custom value list values for the stylesheet if they exist.

No description

Parameters

string $stylesheet

The LESS stylesheet to compile

Return Value

string

The path to the stylesheet

CustomStyle|null getThemeCustomStyleObject() deprecated

deprecated Get a CustomStyle object for the theme if one exists.

No description

Return Value

CustomStyle|null

static Theme|null getByHandle(string $pThemeHandle)

Get an installed theme given its handle.

Parameters

string $pThemeHandle

Return Value

Theme|null

static Theme|null getByID(int $pThemeID)

Get an installed theme given its ID.

Parameters

int $pThemeID

Return Value

Theme|null

static protected Theme|null populateThemeQuery(string $where, array $args)

Get the instance representing an installed theme.

Parameters

string $where

the SQL part used in the SELECT query

array $args

the parameters of the SQL query

Return Value

Theme|null

static Theme|null add(string $pThemeHandle, Package|Package|null $pkg = null)

Install a theme given its handle.

Parameters

string $pThemeHandle

the handle of the theme to be installed.

Package|Package|null $pkg

Return Value

Theme|null

returns NULL if the directory containing the theme could not be found

Exceptions

Exception

File[] getFilesInTheme()

Grab all files in theme that are PHP based (or html if we go that route) and then lists them out, by type, allowing people to install them as page type, etc.

..

Return Value

File[]

static private stdClass getThemeNameAndDescription(string $dir, string $pThemeHandle, string $pkgHandle = '')

Get the theme details by reading a directory containing the theme.

Parameters

string $dir
string $pThemeHandle
string $pkgHandle

Return Value

stdClass

export(SimpleXMLElement $node)

Export this theme by creating the XML nodes under the provided XML node.

Parameters

SimpleXMLElement $node

static exportList(SimpleXMLElement $xml)

Export all the installed themes by creating the XML nodes under the provided XML node.

Parameters

SimpleXMLElement $xml

static protected Theme|null install(string $dir, string $pThemeHandle, int|null $pkgID)

Install a theme.

Parameters

string $dir
string $pThemeHandle
int|null $pkgID

Return Value

Theme|null

returns NULL if $dir does not exist

Exceptions

Exception

DocumentationProviderInterface|null getDocumentationProvider()

No description

Return Value

DocumentationProviderInterface|null

ColorCollection|null getColorCollection()

No description

Return Value

ColorCollection|null

hasColorCollection()

No description

bool supportsThemeDocumentation()

Checks to see whether the capability of theme documentation exists for this theme.

Return Value

bool

Page|null getThemeDocumentationParentPage()

No description

Return Value

Page|null

bool hasThemeDocumentation()

Checks to see if theme documentation has been installed

Return Value

bool

array getThemeDocumentationPages()

Returns an array of documentation pages for this theme

Return Value

array

updateThemeCustomClass()

(Re)Scan the theme folder to check if it contains the page_theme.php file: if so, marks the theme as having a controller.

int|null getThemeID()

Get the ID of the installed theme (if available).

Return Value

int|null

string getThemeName()

Get the (English) name of the theme.

Return Value

string

string getThemeDisplayName(string $format = 'html')

Get the localized name for this theme (escaped accordingly to $format).

Parameters

string $format

Escape the result in html format (if $format is 'html'); if $format is 'text' or any other value, the display name won't be escaped

Return Value

string

int|null getPackageID()

Get the ID of the package providing this theme (if available).

Return Value

int|null

string|false|null getPackageHandle()

Get the handle of the package providing this theme (if available).

Return Value

string|false|null

hasCustomClass()

Returns whether a theme has a custom class.

string getThemeHandle()

Get the handle of this theme.

Return Value

string

string getThemeDescription()

Get the (English) description of this theme.

Return Value

string

string getThemeDisplayDescription(string $format = 'html')

Get the localized description for this theme (escaped accordingly to $format).

Parameters

string $format

Escape the result in html format (if $format is 'html'); if $format is 'text' or any other value, the display name won't be escaped

Return Value

string

string getThemeDirectory()

Get the directory containing this theme.

Return Value

string

string getThemeURL()

Get the URL prefix of the assets provided by this theme.

Return Value

string

string getThemeEditorCSS()

Get the URL of the theme typography.css file.

Return Value

string

setThemeURL(string $pThemeURL)

Set the URL prefix of the assets provided by this theme.

Parameters

string $pThemeURL

setThemeDirectory(string $pThemeDirectory)

Set the absolute path of the theme folder.

Parameters

string $pThemeDirectory

setThemeHandle(string $pThemeHandle)

Set the handle of this theme.

Parameters

string $pThemeHandle

setStylesheetCachePath(string $path)

Set the absolute path of a directory where the CSS stylesheet files should be stored.

Parameters

string $path

setStylesheetCacheRelativePath(string $path)

Set the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory.

Parameters

string $path

string getStylesheetCachePath()

Get the absolute path of a directory where the CSS stylesheet files should be stored.

Return Value

string

string getStylesheetCacheRelativePath()

Get the path of a directory where the CSS stylesheet files should be stored, relative to the website root directory.

Return Value

string

bool isUninstallable()

Is this theme uninstallable?

Return Value

bool

Image getThemeThumbnail()

Get the theme thumbnail image.

Return Value

Image

applyToSite(Site $site = null)

Apply this theme to all the pages of a site.

Parameters

Site $site

if null, we'll use the current site.

static Theme|null getSiteTheme()

Get the theme for the current site.

Return Value

Theme|null

uninstall()

Uninstall this theme.

registerAssets()

Register the assets provided by this theme.

bool supportsGridFramework()

Does this theme support a grid framework?

Return Value

bool

supportsFeature(string $feature)

No description

Parameters

string $feature

GridFramework|null getThemeGridFrameworkObject()

Get the grid framework supported by this theme.

Return Value

GridFramework|null

string|null|false getThemeGridFrameworkHandle()

Get the handle of the grid framework supported by this theme.

Return Value

string|null|false

string[] getThemeSupportedFeatures()

Get the handles of the features supported by this theme.

Return Value

string[]

See also

Feature for a list of features
PageTheme::getThemeSupportedFeatures for an example

array getThemeBlockClasses()

Get the theme-specific CSS classes for every block.

Return Value

array

array keys are the block type handles, array values are a list of the CSS classes.

See also

PageTheme::getThemeBlockClasses for an example

array getThemeAreaClasses()

Get the theme-specific CSS classes for every area.

Return Value

array

array keys are the area names, array values are a list of the CSS classes.

See also

PageTheme::getThemeAreaClasses for an example

array getThemeEditorClasses()

Get the theme-specific style names to be used in the rich text editor.

Return Value

array

Every array item is an array with the keys 'title', 'menuClass', 'spanClass', 'forceBlock'.

See also

PageTheme::getThemeEditorClasses for an example

array getThemeDefaultBlockTemplates()

Get the theme-specific templates for every block.

Return Value

array

array keys are the block type handles, array values are a list of the block templates.

See also

PageTheme::getThemeDefaultBlockTemplates for an example

array getThemeResponsiveImageMap()

Get the handles of the thumbnail types and related resolution breakpoint. Important: make sure to define these in proper ascending size order, otherwise you might get inconsistencies in certain aspects of the UI that refer to these image types.

Return Value

array

See also

PageTheme::getThemeResponsiveImageMap for an example