Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Theme Class Reference

Themes are collections of views, layouts, helpers, scripts, styles and image files. More...

Inheritance diagram for P4Cms_Theme:
P4Cms_PackageAbstract P4Cms_Model P4Cms_ModelInterface

List of all members.

Public Member Functions

 getDoctype ()
 Get the doctype for this theme or the default if none has been specified.
 getLayoutsPath ()
 Get the path to this theme's layouts.
 getViewsPath ()
 Get the path to this theme's views.
 load ()
 Load the theme into the environment.

Static Public Member Functions

static fetchActive ()
 Fetch the active (currently loaded) theme.
static fetchDefault ()
 Fetch the default theme.
static hasActive ()
 Determine if there is an active (currently loaded) theme.
static reset ()
 Clear any package paths and active theme.

Public Attributes

const DEFAULT_DOCTYPE = 'XHTML1_STRICT'
const DEFAULT_THEME = 'default'
const PACKAGE_FILENAME = 'theme.ini'

Static Protected Attributes

static $_activeTheme = null
static $_fields
static $_idField = 'name'
static $_packagesPaths = array()

Detailed Description

Themes are collections of views, layouts, helpers, scripts, styles and image files.

Theme models are read-only.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

static P4Cms_Theme::fetchActive ( ) [static]

Fetch the active (currently loaded) theme.

Guaranteed to return the active theme model or throw an exception.

Returns:
P4Cms_Theme the currently active theme.
Exceptions:
P4Cms_Theme_Exceptionif there is no currently active theme.
    {
        if (!static::$_activeTheme || !static::$_activeTheme instanceof P4Cms_Theme) {
            throw new P4Cms_Theme_Exception("There is no active (currently loaded) theme.");
        }
        return static::$_activeTheme;
    }
static P4Cms_Theme::fetchDefault ( ) [static]

Fetch the default theme.

Guaranteed to return the default theme model or throw an exception.

Returns:
P4Cms_Theme the default theme.
Exceptions:
P4Cms_Model_NotFoundExceptionif the default theme can't be fetched.
    {
        return static::fetch(static::DEFAULT_THEME);
    }
P4Cms_Theme::getDoctype ( )

Get the doctype for this theme or the default if none has been specified.

Defaults to: 'XHTML1_STRICT'.

Returns:
string the doctype to use for this theme.
    {
        $info = $this->getPackageInfo();
        return isset($info['doctype']) ? (string) $info['doctype'] : self::DEFAULT_DOCTYPE;
    }
P4Cms_Theme::getLayoutsPath ( )

Get the path to this theme's layouts.

Returns:
string the path to the layout scripts.
    {
        return $this->getPath() . "/layouts";
    }
P4Cms_Theme::getViewsPath ( )

Get the path to this theme's views.

Returns:
string the path to the view scripts.
    {
        return $this->getPath() . "/views";
    }
static P4Cms_Theme::hasActive ( ) [static]

Determine if there is an active (currently loaded) theme.

Returns:
boolean true if there is an active theme.
    {
        try {
            static::fetchActive();
            return true;
        } catch (P4Cms_Theme_Exception $e) {
            return false;
        }
    }
P4Cms_Theme::load ( )

Load the theme into the environment.

Set the theme in the ViewRenderer. Add the path to the theme's helpers. Add stylesheets and javascripts to the view. Load any required dojo modules. Register any provided dojo modules.

    {
        // set this instance as the active theme.
        static::$_activeTheme = $this;

        $view = static::getView();

        // add the current theme's helpers path to the view.
        $view->addHelperPath($this->getPath() . '/helpers', 'Theme_Helper_');

        // add theme's layout scripts path.
        $view->addScriptPath($this->getLayoutsPath());

        // add theme's views path to the view
        $view->addScriptPath($this->getViewsPath());

        // set the (x)html document type.
        $view->doctype($this->getDoctype());

        // add theme meta, stylesheets and scripts to view.
        $this->_loadHtmlMeta();
        $this->_loadStylesheets();
        $this->_loadScripts();

        // load dojo components.
        $this->_loadDojo();
    }
static P4Cms_Theme::reset ( ) [static]

Clear any package paths and active theme.

Primarily used for testing.

    {
        static::clearPackagesPaths();
        static::$_activeTheme = null;
    }

Member Data Documentation

P4Cms_Theme::$_activeTheme = null [static, protected]
P4Cms_Theme::$_fields [static, protected]
Initial value:
 array(
        'name'              => array(
            'accessor'      => 'getName',
            'mutator'       => 'setName'
        ),
        'label'             => array(
            'accessor'      => 'getLabel',
            'readOnly'      => true
        ),
        'version'           => array(
            'accessor'      => 'getVersion',
            'readOnly'      => true
        ),
        'description'       => array(
            'accessor'      => 'getDescription',
            'readOnly'      => true
        ),
        'maintainerInfo'    => array(
            'accessor'      => 'getMaintainerInfo',
            'readOnly'      => true
        ),
        'tags'              => array(
            'accessor'      => 'getTags',
            'readOnly'      => true
        )
    )

Reimplemented from P4Cms_Model.

P4Cms_Theme::$_idField = 'name' [static, protected]

Reimplemented from P4Cms_Model.

P4Cms_Theme::$_packagesPaths = array() [static, protected]

Reimplemented from P4Cms_PackageAbstract.

const P4Cms_Theme::DEFAULT_DOCTYPE = 'XHTML1_STRICT'
const P4Cms_Theme::DEFAULT_THEME = 'default'
const P4Cms_Theme::PACKAGE_FILENAME = 'theme.ini'

Reimplemented from P4Cms_PackageAbstract.


The documentation for this class was generated from the following file: