Static Public Member Functions

Stack Class Reference

List of all members.

Static Public Member Functions

static get_named_stack ($stack_name)
static has ($stack_name, $value_name)
static get_item ($stack_name, $value_name, $default_value=null)
static create_stack ($stack_name)
static add ($stack_name, $value, $value_name=null, $after=null)
static remove ($stack_name, $value_name=null)
static get_sorted_stack ($stack_name)
static sort_stack_cmp ($a, $b)
static get ($stack_name, $format=null)
static out ($stack_name, $format=null)
static scripts ($element)
static styles ($element, $typename)

Detailed Description

Habari Stack Class

This class allows Habari to accumulate a group of unique values that can be output using a specific formatting string. This is useful for collecting a set of unique javascript references to output and then insert them at a specific point on the page.

// Add jquery to the javascript stack: Stack::add( 'template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery' );

// Add stylesheet to theme_stylesheet stack with media type Stack::add( 'template_stylesheet', array( Site::get_url('theme') . '/style.css', 'screen' ), 'style' );

// Output the javascript stack: Stack::out( 'template_header_javascript', '<script src="%s" type="text/javascript"></script>' );

// Output the theme_stylesheet stack: Stack::out( 'template_stylesheet', '<link rel="stylesheet" type="text/css" href="%s" media="%s">' );

Definition at line 30 of file stack.php.


Member Function Documentation

static Stack::add ( stack_name,
value,
value_name = null,
after = null 
) [static]

Add a value to a stack

Parameters:
string $stack_name The name of the stack
mixed $value The value to add
string $value_name The name of the value to add
string $after The name of the stack element to insert this new element after
Returns:
array The stack that was added to

Definition at line 134 of file stack.php.

Referenced by Theme::act_display(), ViddlerSilo::action_init(), Theme::add_script(), Theme::add_style(), K2::add_template_vars(), AdminGroupsHandler::get_group(), AdminHandler::setup_admin_theme(), AdminHandler::setup_stacks(), and Theme::theme_header().

static Stack::create_stack ( stack_name  )  [static]

Creates and retreives a named stack instance

Parameters:
string $stack_name The name of the stack to create and return
Returns:
array The created stack

Definition at line 116 of file stack.php.

Referenced by get_named_stack().

static Stack::get ( stack_name,
format = null 
) [static]

Returns all of the values of the stack

Parameters:
string $stack_name The name of the stack to output
mixed $format A printf-style formatting string or callback used to output each stack element

Definition at line 216 of file stack.php.

Referenced by out(), Theme::theme_footer(), and Theme::theme_header().

static Stack::get_item ( stack_name,
value_name,
default_value = null 
) [static]

Get a single item from a given stack.

Parameters:
string $stack_name The name of the stack to fetch an item from.
string $value The item to fetch.
mixed $default_value The default value to return if the item does not exist in the stack.
Returns:
mixed The item, or $default_value if it does not exist.

Definition at line 96 of file stack.php.

static Stack::get_named_stack ( stack_name  )  [static]

Retreive a named stack instance

Parameters:
string $stack_name The name of the stack to return
Returns:
Stack The requested stack

Definition at line 56 of file stack.php.

Referenced by add(), get_item(), has(), remove(), and Theme::theme_body_class().

static Stack::has ( stack_name,
value_name 
) [static]

Check for the existence of a given stack item.

Parameters:
string $stack_name The name of the stack in which to check.
string $value The value to check for.
Returns:
boolean true if the item exists, false otherwise.

Definition at line 73 of file stack.php.

static Stack::out ( stack_name,
format = null 
) [static]

Outputs all of the values of the stack

Parameters:
string $stack_name The name of the stack to output
mixed $format A printf-style formatting string or callback used to output each stack element

Definition at line 240 of file stack.php.

static Stack::remove ( stack_name,
value_name = null 
) [static]

Remove a value to a stack

Parameters:
string $stack_name The name of the stack
string $value_name The name of the value to remove
Returns:
array The rest of the stack, post-remove

Definition at line 163 of file stack.php.

static Stack::scripts ( element  )  [static]

A callback for Stack::get() that outputs scripts as reference or inline depending on their content

Parameters:
string $element The script element in the stack
Returns:
string The resulting script tag

Definition at line 251 of file stack.php.

static Stack::styles ( element,
typename 
) [static]

A callback for Stack::get() that outputs styles as link or inline style tags depending on their content

Parameters:
string $element The style element in the stack
string $typename The media disposition of the content
Returns:
string The resulting style or link tag

Definition at line 269 of file stack.php.


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