Class midcom_helper__styleloader

Description

This class is responsible for all style management and replaces the old <[...]> syntax. It is instantiated by the MidCOM framework and accessible through the $midcom->style object.

The method show ($style) returns the style element $style for the current component:

It checks whether a style path is defined for the current component.

  • If there is a user defined style path, the element named $style in this path is returned,
  • otherwise the element "$style" is taken from the default style of the current component (/path/to/component/_style/$path).
(The default fallback is always the default style, e.g. if $style is not in the user defined style path)

To enable cross-style referencing and provide the opportunity to access any style element in the current sitegroup (not only the style that is set in the current page), "show" can be called with a full qualified style path (like "/mystyle/element1", while the current page's style may be set to "/yourstyle").

Note: To make sure sub-styles and elements included in styles are handled correctly, the old style tag <[...]> should not be used anymore, but should be replaced by something like this:

  1.  <?php midcom_show_style ("elementname")?>

Styleinheritance

The basic path the styleloader follows to find a styleelement is:

  1. Topic style -> if the current topic has a style set
  2. Inherited topic style -> if the topic inherits a style from another topic.
  3. Site-wide per-component default style -> if defined in MidCOM configuration key styleengine_default_styles
  4. Midgard style -> the style of the MidCOM component.
  5. The filestyle. This is usually the elements found in the components style directory.
Regarding nr. 4: It is possible to add extra filestyles if so is needed for example by a portalcomponent. This is done either using the append/prepend component_style functions or by setting it to another directory by calling (append|prepend)_styledir directly.

NB: This cannot happen after the $_MIDCOM->content() stage in midcom is called, i.e. you cannot change this in another styleelement or in a _show() function in a component.

  • todo: Document Style Inheritance

Located in /midcom.core/midcom/helper/_styleloader.php (line 63)


	
			
Variable Summary
mixed $object
array $_filedirs
mixed $_styledirs
Method Summary
midcom_helper__styleloader __construct ()
void append_component_styledir (string $component)
boolean append_styledir (dirname $dirname)
boolean enter_context (int $context)
array get_component_default_elements (string $component)
array get_nodes_using_style (string $style)
void get_style ()
int get_style_id_from_path (string $path, [ $rootstyle = 0], int $rootstyle_id)
string get_style_path_from_id (int $id)
boolean leave_context ()
void prepend_component_styledir (string $component)
boolean prepend_styledir (dirname $dirname)
boolean show (string $path, [array $guids = null])
mixed _getComponentSnippetdir (MidgardTopic $topic)
void _merge_styledirs (string $component_style)
Variables
mixed $object = null (line 142)

The actual Midgard style object

array $_filedirs = array() (line 93)

Path to filestyles.

mixed $_styledirs = array() (line 137)

The stack of directories to check for styles.

Methods
Constructor __construct (line 147)

Simple initialization

midcom_helper__styleloader __construct ()
add_database_head_elements (line 873)

Include all text/css attachments of current style to MidCOM headers

void add_database_head_elements ()
append_component_styledir (line 754)

append the styledir of a component to the queue of styledirs.

  • throws: midcom exception if directory does not exist.
void append_component_styledir (string $component)
  • string $component: componentname
append_styledir (line 738)

Function append styledir

Adds an extra styledirectory to check for stylelements at the end of the styledir queue.

  • return: true if directory appended
  • throws: midcom exception if directory does not exist.
boolean append_styledir (dirname $dirname)
  • dirname $dirname: path of styledirectory within midcom.
enter_context (line 816)

Switches the context (see dynamic load). Private variables $_context, $_topic and $_snippetdir are adjusted.

  • return: True on success, false on failure.
  • todo: check documentation
boolean enter_context (int $context)
  • int $context: The context to enter
get_component_default_elements (line 331)

List the default template elements shipped with a component

  • return: List of elements found indexed by the element name
array get_component_default_elements (string $component)
  • string $component: Component to look elements for
get_nodes_using_style (line 294)

Get list of topics using a particular style

  • return: List of folders
array get_nodes_using_style (string $style)
  • string $style: Style path
get_style (line 861)
void get_style ()
get_style_elements_and_nodes (line 440)
void get_style_elements_and_nodes ( $style)
  • $style
get_style_id_from_path (line 201)

Returns the id of the style described by $path.

Note: $path already includes the element name, so $path looks like "/rootstyle/style/style/element".

  • return: ID of the matching style or FALSE
  • todo: complete documentation
  • access: public
int get_style_id_from_path (string $path, [ $rootstyle = 0], int $rootstyle_id)
  • string $path: The path to retrieve
  • int $rootstyle_id: ???
  • $rootstyle
get_style_path_from_id (line 163)

Returns the path of the style described by $id.

  • return: Style path
  • access: public
string get_style_path_from_id (int $id)
  • int $id: Style id to look up path for
leave_context (line 843)

Switches the context (see dynamic load). Private variables $_context, $_topic and $_snippetdir are adjusted.

  • return: True on success, false on failure.
  • todo: check documentation
boolean leave_context ()
prepend_component_styledir (line 767)

prepend the styledir of a component

  • throws: midcom exception if directory does not exist.
void prepend_component_styledir (string $component)
  • string $component: componentname
prepend_styledir (line 780)

Function prepend styledir

  • return: true if directory appended
  • throws: midcom exception if directory does not exist.
boolean prepend_styledir (dirname $dirname)
  • dirname $dirname: path of styledirectory within midcom.
show (line 514)

Looks for a style element matching $path (either in a user defined style or the default style snippetdir) and displays/evaluates it.

  • return: True on success, false otherwise.
boolean show (string $path, [array $guids = null])
  • string $path: The style element to show.
  • array $guids: List of GUIDs included in this element display, if set will enable caching
_getComponentSnippetdir (line 716)

Gets the component styledir associated with the topics component.

  • return: the path to the components styledirectory.
mixed _getComponentSnippetdir (MidgardTopic $topic)
  • MidgardTopic $topic: the current componenttopic.
_getComponentStyle (line 654)

Gets the component style.

  • return: Database ID if the style to use in current view or FALSE
  • todo: Document
int _getComponentStyle (midcom_db_topic $topic)
_get_nodes_inheriting_style (line 260)
void _get_nodes_inheriting_style ( $node)
  • $node
_merge_styledirs (line 797)

This function merges the prepend and append styles with the componentstyle. This happens when the enter_context function is called.

You cannot change the style call stack after that (unless you call enter_context again of course).

void _merge_styledirs (string $component_style)
  • string $component_style: component style

Documentation generated on Fri, 10 Oct 2008 22:15:27 +0300 by phpDocumentor 1.4.2