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 out ($stack_name, $format=null)
static scripts ($element, $attrib=null, $wrapper= '%s')
static styles ($element, $typename=null, $props=array())
static dependent ($dependent, $dependson)
static load_stackitems ()
static action_register_stackitems ()

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 32 of file stack.php.


Member Function Documentation

static Stack::action_register_stackitems (  )  [static]

Register CSS and script that can be added to the Stacks.

Definition at line 355 of file stack.php.

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 137 of file stack.php.

Referenced by FormControlFacet::_extend(), Theme::act_display(), Menus::action_admin_header(), CoreDashModules::action_admin_header(), Monolith::action_admin_header(), Theme::action_template_footer_9(), Theme::action_template_header_9(), Theme::add_script(), Theme::add_style(), AdminGroupsHandler::get_group(), AdminPostsHandler::post_posts(), 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 119 of file stack.php.

Referenced by get_named_stack().

static Stack::dependent ( dependent,
dependson 
) [static]

Make a stack's dependencies be provided by another stack

Parameters:
string $dependent The name of a stack that should be made to depend on another stack
string $dependson The name of the stack that the dependent stack should depend on

Definition at line 334 of file stack.php.

Referenced by Theme::theme_footer().

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 99 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 59 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 76 of file stack.php.

static Stack::load_stackitems (  )  [static]

Allow plugins to register StackItems that can be added to Stacks later Initialize this class for plugin behavior so it can add system default StackItems

Definition at line 346 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 257 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,
attrib = null,
wrapper = '%s' 
) [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
mixed $attrib Additional attributes, like 'defer' or 'async' allowed for <script src="..."> tags
string $wrapper An sprintf formatting string in which to output the script tag, for IE conditional comments
Returns:
string The resulting script tag

Definition at line 270 of file stack.php.

static Stack::styles ( element,
typename = null,
props = array() 
) [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
string $props Additional properties of the style tag output
Returns:
string The resulting style or link tag

Definition at line 293 of file stack.php.


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