Class Theme

Description

A generic

  1. Theme
implementation. It should be sufficient just to extend it to create new fully fledged Themes.



A

  1. Theme
is a combination of two things: first, it stores a variety of reusable
  1. StyleCollections
and second, it offers a mechanism for printing an HTML web page.

Each
  1. Theme
has a set of style collections that correspond to each component type.

Each
  1. Theme
has a single component (could be container) that will be printed when
  1. printPage()
is called.

  • version: $Id: Theme.class.php,v 1.27 2007/09/04 20:25:21 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/GUIManager/Theme.class.php (line 29)

ThemeInterface
   |
   --Theme
Direct descendents
Class Description
MenuThemeAbstract This MenuTheme abstract class implements solely the
  1. addMenu
and
  1. getMenu
GenericTheme A very basic theme based on simple borders and colored blocks.
NiksTheme A very basic theme based on simple borders and colored blocks.
SimpleLinesTheme A very basic theme based on simple borders and colored blocks.
SimpleTheme A simple theme with rounded boxes.
SimpleTheme1 A very basic theme based on simple borders and colored blocks.
Variable Summary
Method Summary
Theme Theme (string $displayName, string $description)
void addGlobalStyle (ref $styleCollection)
void addStyleForComponentType (ref $styleCollection, integer $type, integer $index)
mixed exportRegisteredSP (integer $id)
string getCollectionClass ()
ref getComponent ()
string getCSS ([string $tabs = ""])
string getCustom ()
string getDescription ()
string getDisplayName ()
string getPostHTMLForComponentType (integer $type, integer $index)
string getPreHTMLForComponentType (integer $type, integer $index)
ref getRegisteredSP (integer $id)
ref getStyleCollection (string $selector)
ref getStylesForComponentType (integer $type, [integer $index = null])
string getTemplate ()
ref importRegisteredSP (integer $id, mixed $importData)
void printPage ()
integer registerSP (ref $sp, [optional $postImportMethod = NULL])
void removeStyleCollection (mixed $style, [ref $removeFromDatabase = false])
void setComponent (ref $component)
void setCustom (string $custom_lev)
void setDescription (string $description)
void setDisplayName (string $displayName)
void setId (string $id)
void setPostHTMLForComponentType (string $html, integer $type, integer $index)
void setPreHTMLForComponentType (string $html, integer $type, integer $index)
void setTemplate (string $template)
string _getAllStyles (ref $component, array $result)
Variables
object _component $_component (line 57)

The component of this Theme.

  • access: private
array $_componentPostHTML (line 117)

This array will store the post-HTML strings for the different component types. The first dimension is the component type. The second dimension is the index.

  • var: _componentPostHTML
  • access: private
array $_componentPreHTML (line 108)

This array will store the pre-HTML strings for the different component types. The first dimension is the component type. The second dimension is the index.

  • var: _componentPreHTML
  • access: private
array $_componentStyles (line 81)

An array storing style collections for the different component types. The first dimension is the component type. The second dimension is the index. The third dimension is the selector of the style collection.

  • var: _componentStyles
  • access: private
string $_description (line 50)

The description of this Theme.

  • var: _description
  • access: private
string $_displayName (line 43)

The display name of this Theme.

  • var: _displayName
  • access: private
array $_globalStyles (line 90)

An array storing global style collections. It is one-dimensional. The key is the selector of the style collection. The element is the style collection itself.

  • var: _globalStyles
  • access: private
string $_headJavascript = "" (line 71)
  • var: The javascript functions to put between <script> tags in the <head> section.
  • access: private
$id; $_id (line 36)
  • var: the id of the theme
  • since: 5/1/06
  • access: private
string $_pageTitle (line 64)

The page title.

  • var: _pageTitle
  • access: private
array $_postImportMethods (line 132)

This array stores the names of the methods that will be run after importing of registered

  1. StyleProperties
.

  • var: _postImportMethods
  • access: private
array $_registeredSPs (line 124)

This array stores all registered mutable

  1. StyleProperties
.

  • var: _registeredSPs
  • access: private
array $_styles (line 99)

This array combines

  1. _componentStyles
and
  1. _globalStyles
into one. The purpose is to avoid duplication of style collection and to provide an easy way to implement the
  1. getCSS()
method.

  • var: _styles
  • access: private
Methods
Constructor Theme (line 140)

The constructor.

  • access: public
Theme Theme (string $displayName, string $description)
  • string $displayName
  • string $description
addGlobalStyle (line 365)

Attaches to the Theme a style collection that will have a global effect on the page look and feel. For example, this could be a style collection affecting the

  1. body
HTML element.

  • access: public
void addGlobalStyle (ref $styleCollection)
  • ref $styleCollection: object styleCollection The style collection to attach.

Redefinition of:
ThemeInterface::addGlobalStyle()
Attaches to the Theme a style collection that will have a global effect on the page look and feel. For example, this could be a style collection affecting the
  1. body
HTML element.
addStyleForComponentType (line 469)

Registers the specified style collection with the given component type.

  • access: public
void addStyleForComponentType (ref $styleCollection, integer $type, integer $index)
  • ref $styleCollection: object styleCollection The style collection to add.
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index with which to register the style collection. For a description of the role of indices, see the documentation of
    1. getStylesForComponentType()
    .

Redefinition of:
ThemeInterface::addStyleForComponentType()
Registers the specified style collection with the given component type.
exportAllRegisteredSPs (line 839)

This method is like

  1. exportRegisteredSP
but exports all registered stlye properties at the same time. The output is an array whose elements are the inividual export data as returned by
  1. exportRegisteredSP
.

  • return: An array containing the export data for each registered
    1. StylePorperty
    . The indexes of the array are the ids of the style properties.
  • access: public
array exportAllRegisteredSPs ()

Redefinition of:
ThemeInterface::exportAllRegisteredSPs()
This method is like
  1. exportRegisteredSP
but exports all registered stlye properties at the same time. The output is an array whose elements are the inividual export data as returned by
  1. exportRegisteredSP
.
exportRegisteredSP (line 811)

This methods exports the content of a registered style property object. The output is implementation specific. The only requirement is that if the output of this method is passed as an input to

  1. importRegisteredSP()
, then the contents of the
  1. StyleProperty
should not change.

  • return: The contens of the
    1. StyleProperty
    . The output representation is implementation specific.
  • access: public
mixed exportRegisteredSP (integer $id)

Redefinition of:
ThemeInterface::exportRegisteredSP()
This methods exports the content of a registered style property object. The output is implementation specific. The only requirement is that if the output of this method is passed as an input to
  1. importRegisteredSP()
, then the contents of the
  1. StyleProperty
should not change.
getAllRegisteredSPs (line 901)

Returns all registered mutable style properties in an array whose indexes are the ids of the style properties (as returned by

  1. registerSP()
).

  • return: array An array containing all registered mutable
    1. StyleProperty
    objects.
  • access: public
ref getAllRegisteredSPs ()

Redefinition of:
ThemeInterface::getAllRegisteredSPs()
Returns all registered mutable style properties in an array whose indexes are the ids of the style properties (as returned by
  1. registerSP()
).
getCollectionClass (line 318)

Answers the class for constructing Style Collections for this theme

  • since: 5/30/06
  • access: public
string getCollectionClass ()
getComponent (line 643)

Returns the component of this

  1. Theme
.

  • return: object The component of this
    1. Theme
    .
  • access: public
ref getComponent ()

Redefinition of:
ThemeInterface::getComponent()
Returns the component of this
  1. Theme
.
getCSS (line 672)

Returns all CSS code: The CSS code for the Theme, the various component types, the theme component and all sub-components (if any). Theme styles should come first, followed by individual component's styles to allow the latter to take precedence.

  • return: CSS code.
  • access: public
string getCSS ([string $tabs = ""])
  • string $tabs: tabs This is a string (normally a bunch of tabs) that will be prepended to each text line. This argument is optional but its usage is highly recommended in order to produce a nicely formatted HTML output.

Redefinition of:
ThemeInterface::getCSS()
Returns all CSS code: The CSS code for the Theme, the various component types, the theme component and all sub-components (if any). Theme styles should come first, followed by individual component's styles to allow the latter to take precedence.
getCustom (line 277)

Answers the customization level for the theme

  • since: 4/26/06
  • access: public
string getCustom ()
getDescription (line 217)

Returns the description of this Theme.

  • return: The description of this Theme.
  • access: public
string getDescription ()

Redefinition of:
ThemeInterface::getDescription()
Returns the description of this Theme.
getDisplayName (line 195)

Returns the display name of this Theme.

  • return: The display name of this Theme.
  • access: public
string getDisplayName ()

Redefinition of:
ThemeInterface::getDisplayName()
Returns the display name of this Theme.
getGlobalStyles (line 385)

Answers the Style Collection that has global effects.

  • return: array global styles array
  • access: public
ref getGlobalStyles ()
getId (line 181)

Answers the id

  • since: 4/26/06
  • access: public
object HarmoniId getId ()
getPostHTMLForComponentType (line 606)

Returns the HTML string that needs to be printed after successful rendering of components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see

  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.

  • return: The HTML string.
  • access: public
string getPostHTMLForComponentType (integer $type, integer $index)
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index that will determine which HTML string to return If the given index is greater than the maximal registered index for the given component type, then the highest index availible will be used.

Redefinition of:
ThemeInterface::getPostHTMLForComponentType()
Returns the HTML string that needs to be printed after successful rendering of components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see
  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.
getPreHTMLForComponentType (line 535)

Returns the HTML string that needs to be printed before an attempt is made to render components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see

  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.

  • return: The HTML string.
  • access: public
string getPreHTMLForComponentType (integer $type, integer $index)
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index that will determine which HTML string to return If the given index is greater than the maximal registered index for the given component type, then the highest index availible will be used.

Redefinition of:
ThemeInterface::getPreHTMLForComponentType()
Returns the HTML string that needs to be printed before an attempt is made to render components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see
  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.
getRegisteredSP (line 790)

Returns a

previously registered by
  1. registerSP()
for the given id.

  • return: object A
    1. StylePorperty
    object.
  • access: public
ref getRegisteredSP (integer $id)
  • integer $id: id The id identifying which StyleProperty to return; as returned by
    1. registerSP()
    .

Redefinition of:
ThemeInterface::getRegisteredSP()
Returns a
previously registered by
  1. registerSP()
for the given id.
getStyleCollection (line 301)

Returns the StyleCollection with the given selector

  • return: object StyleCollection
  • access: public
ref getStyleCollection (string $selector)
  • string $selector: the selector of the StyleCollection
getStyleCollections (line 289)

Answers the _styles array

  • return: array
  • since: 4/26/06
  • access: public
ref getStyleCollections ()
getStylesForComponentType (line 422)

This method returns all style collections for the given component type and the given numeric index.



Each

  1. Theme
has a set of style collections that correspond to a combination of a component type and a numeric index. For example, the user can define two style collections for components of type BLOCK and index 1 and a totally different set of three style collections for componets of type MENU and index 2.

The index has no semantic meaning: you can think of the index as 'level' of the component. Alternatively, the index could serve as means of distinguishing between components with the same type. For example, a BLOCK component with index 2 will normally have a different set of style collections than a BLOCK component with index 1.

Another way of interpreting the index is drawing a parallel to the HTML headings <h1>, <h2>, <h3>, ..., where the lower the index, the more "prominent" the look of the component.

The style collections would be normally set by the
  1. setStyleForComponentType()
method in the Theme constructor.

  • return: array An array of Style Collections.
  • access: public
ref getStylesForComponentType (integer $type, [integer $index = null])
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index that will determine which style collections to return. If the given index is greater than the maximum registered index for the given component type, then the highest index availible will be used.

Redefinition of:
ThemeInterface::getStylesForComponentType()
This method returns all style collections for the given component type and the given numeric index.
getTemplate (line 253)

Answers the template

  • since: 4/26/06
  • access: public
string getTemplate ()
importRegisteredSP (line 862)

Imports the contents of a registered mutable

  1. StyleProperty
.

The input to this method should be an output obtained from calling

  1. exportRegisteredSP
on the same
  1. StyleProperty
.

  • return: object The updated
    1. StyleProperty
    object.
  • access: public
ref importRegisteredSP (integer $id, mixed $importData)

Redefinition of:
ThemeInterface::importRegisteredSP()
Imports the contents of a registered mutable
  1. StyleProperty
.
printPage (line 735)

Prints the HTML page.

  • access: public
void printPage ()

Redefinition of:
ThemeInterface::printPage()
Prints the HTML page.

Redefined in descendants as:
registerSP (line 764)

Adds the given StyleProperty to the internally maintained list of mutable

(updateable) style properties and assigns it an id. This method and the

  1. getRegisteredSP
method enable the user to quickly change the values of key Theme settings. For example, let us assume that Bob has created his own theme and he has added a global style collection for the main content block. Bob would like to allow the user to change the width property of that collection. In order to do so, Bob needs to call
  1. registerSP()
and pass the WidthSP object accordingly. This WidthSP object must be the same object that had been added to the aforementioned global style collection. The user now can call
  1. getRegisteredSP
with the id that was returned by
  1. registerSP
and access/modify the
  1. WidthSP
object.

  • return: An integer id assigned to the given style property. The id only meaningful within the context of this Theme (i.e. this is not a system wide unique id).
  • access: public
integer registerSP (ref $sp, [optional $postImportMethod = NULL])
  • ref $sp: object sp The StyleProperty object that will be registered as mutable within this Theme.
  • optional $postImportMethod: string postImportMethod This is the name of the method that will be called after this SP is imported (an optional argument). This can be useful in case other properties depend on the content of this property, but the user does not to export all of them.

Redefinition of:
ThemeInterface::registerSP()
Adds the given StyleProperty to the internally maintained list of mutable
removeStyleCollection (line 340)

removes the style collection from the theme, and the DB is called for

  • since: 5/16/06
  • access: public
void removeStyleCollection (mixed $style, [ref $removeFromDatabase = false])
  • ref $removeFromDatabase: object StyleCollection $style the style
setComponent (line 652)

Sets the component of this

  1. Theme
.

  • access: public
void setComponent (ref $component)
  • ref $component: object A component.

Redefinition of:
ThemeInterface::setComponent()
Sets the component of this
  1. Theme
.

Redefined in descendants as:
  • DobomodeTheme::setComponent() : Overloads the normal
    1. setComponent
    method - sets the Theme component to the wrapper component and adds the argument to the latter.
setCustom (line 266)

Sets the level of customization for the theme

  • since: 4/26/06
  • access: public
void setCustom (string $custom_lev)
  • string $custom_lev
setDescription (line 226)

Sets the description of this Theme.

  • access: public
void setDescription (string $description)
  • string $description: description The new description of this Theme.

Redefinition of:
ThemeInterface::setDescription()
Sets the description of this Theme.
setDisplayName (line 204)

Sets the display name of this Theme.

  • access: public
void setDisplayName (string $displayName)
  • string $displayName: displayName The new display name of this Theme.

Redefinition of:
ThemeInterface::setDisplayName()
Sets the display name of this Theme.
setId (line 166)

Sets the id

  • since: 4/26/06
  • access: public
void setId (string $id)
  • string $id
setPostHTMLForComponentType (line 580)

Sets the HTML string that needs to be printed after successful rendering of components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see

  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.

  • access: public
void setPostHTMLForComponentType (string $html, integer $type, integer $index)
  • string $html: html The HTML code to use.
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index with which to register the HTML string. For a description of the role of indices, see the documentation of
    1. getStylesForComponentType()
    .

Redefinition of:
ThemeInterface::setPostHTMLForComponentType()
Sets the HTML string that needs to be printed after successful rendering of components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see
  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.
setPreHTMLForComponentType (line 509)

Sets the HTML string that needs to be printed before an attempt is made to render components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see

  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.

  • access: public
void setPreHTMLForComponentType (string $html, integer $type, integer $index)
  • string $html: html The HTML code to use.
  • integer $type: type The type of the component. One of BLANK, HEADING, HEADER, FOOTER, BLOCK, MENU, MENU_ITEM_LINK_UNSELECTED, MENU_ITEM_LINK_SELECTED, MENU_ITEM_HEADING, OTHER.
  • integer $index: index The index with which to register the HTML string. For a description of the role of indices, see the documentation of
    1. getStylesForComponentType()
    .

Redefinition of:
ThemeInterface::setPreHTMLForComponentType()
Sets the HTML string that needs to be printed before an attempt is made to render components of the given type and index. Note: use of the PreHTML and PostHTML get/set methods is discouraged - use styles instead: see
  1. addStyleForComponentType()
and
  1. getStylesForComponentType()
.
setTemplate (line 242)

Sets the template

  • since: 4/26/06
  • access: public
void setTemplate (string $template)
  • string $template
_getAllStyles (line 706)

A private function that returns all style collections for the given component and any subcomponents it might have.

  • return: The CSS code.
  • access: public
string _getAllStyles (ref $component, array $result)
  • ref $component: object component The component to start at.
  • array $result: result This array will be recursively filled with all the style collections.

Inherited Methods

Inherited From ThemeInterface

ThemeInterface::addGlobalStyle()
ThemeInterface::addStyleForComponentType()
ThemeInterface::exportAllRegisteredSPs()
ThemeInterface::exportRegisteredSP()
ThemeInterface::getAllRegisteredSPs()
ThemeInterface::getComponent()
ThemeInterface::getCSS()
ThemeInterface::getDescription()
ThemeInterface::getDisplayName()
ThemeInterface::getGlobalStyle()
ThemeInterface::getPostHTMLForComponentType()
ThemeInterface::getPreHTMLForComponentType()
ThemeInterface::getRegisteredSP()
ThemeInterface::getStylesForComponentType()
ThemeInterface::importRegisteredSP()
ThemeInterface::printPage()
ThemeInterface::registerSP()
ThemeInterface::setComponent()
ThemeInterface::setDescription()
ThemeInterface::setDisplayName()
ThemeInterface::setPostHTMLForComponentType()
ThemeInterface::setPreHTMLForComponentType()

Documentation generated on Wed, 19 Sep 2007 10:27:18 -0400 by phpDocumentor 1.3.0RC3