Class Stack

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.

  1.  // Add jquery to the javascript stack:
  2.  Stack::add'template_header_javascript'Site::get_url('scripts''/jquery.js''jquery' );
  3.  
  4.  // Add stylesheet to theme_stylesheet stack with media type
  5.  Stack::add'template_stylesheet'arraySite::get_url('theme''/style.css''screen' )'style' );
  6.  
  7.  // Output the javascript stack:
  8.  Stack::out'template_header_javascript''<script src="%s" type="text/javascript"></script>' );
  9.  
  10.  // Output the theme_stylesheet stack:
  11.  Stack::out'template_stylesheet''<link rel="stylesheet" type="text/css"  href="%s" media="%s">' );

Located in /system/classes/stack.php (line 27)


	
			
Method Summary
static array add (string $stack_name, mixed $value, [string $value_name = null])
static array create_stack (string $stack_name)
static void get (string $stack_name, [mixed $format = null])
static mixed get_item (string $stack_name,  $value_name, [mixed $default_value = null], string $value)
static Stack get_named_stack (string $stack_name)
static boolean has (string $stack_name,  $value_name, string $value)
static void out (string $stack_name, [mixed $format = null])
static array remove (string $stack_name, string $value_name)
Methods
static method add (line 125)

Add a value to a stack

  • return: The stack that was added to
  • access: public
static array add (string $stack_name, mixed $value, [string $value_name = null])
  • string $stack_name: The name of the stack
  • mixed $value: The value to add
  • string $value_name: The name of the value to add
static method create_stack (line 109)

Creates and retreives a named stack instance

  • return: The created stack
  • access: public
static array create_stack (string $stack_name)
  • string $stack_name: The name of the stack to create and return
static method get (line 155)

Returns all of the values of the stack

  • access: public
static void get (string $stack_name, [mixed $format = null])
  • 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
static method get_item (line 90)

Get a single item from a given stack.

  • return: The item, or $default_value if it does not exist.
  • access: public
static mixed get_item (string $stack_name,  $value_name, [mixed $default_value = null], string $value)
  • 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.
  • $value_name
static method get_named_stack (line 51)

Retreive a named stack instance

  • return: The requested stack
  • access: public
static Stack get_named_stack (string $stack_name)
  • string $stack_name: The name of the stack to return
static method has (line 68)

Check for the existence of a given stack item.

  • return: TRUE if the item exists, FALSE otherwise.
  • access: public
static boolean has (string $stack_name,  $value_name, string $value)
  • string $stack_name: The name of the stack in which to check.
  • string $value: The value to check for.
  • $value_name
static method out (line 179)

Outputs all of the values of the stack

  • access: public
static void out (string $stack_name, [mixed $format = null])
  • 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
static method remove (line 140)

Remove a value to a stack

  • return: The rest of the stack, post-remove
  • access: public
static array remove (string $stack_name, string $value_name)
  • string $stack_name: The name of the stack
  • string $value_name: The name of the value to remove

Documentation generated on Thu, 30 Oct 2008 20:31:27 +0100 by phpDocumentor 1.3.2