Class Container

Description

This class is nothing more then a

container widget. It lets you push data into it, and it will render each item indented properly so it works with the rest of the libs.

This is helpfull when you have a function that wants to return multiple Tag Objects or widgets. Just wrap them in this container and they will all get rendered with the current indentation level.

Base Class for phpHtmlLib

Located in /ContainerClass.inc (line 39)


	
			
Direct descendents
Class Description
FormProcessor This is the main engine for the processing
XMLDocumentClass This class lets you build a complete xml document and render it.
ContainerWidget This is just to maintain compatibility with the 1.1.0 release of phphtmllib
BaseWidget this is the base widget class, that all widgets are based off of. It provides some basic members and methods
XMLTagClass This class is used for building and rendering an XML tag.
Method Summary
Container Container ()
void add (mixed $content)
void add_reference ( &$content, mixed $content)
int count_content ()
mixed &get_element (int $cell)
boolean get_indent_flag ()
void push (mixed $content)
void push_reference (mixed &$content)
string render ([int $indent_level = 0], [int $output_debug = 0])
void reset_content (mixed $content)
void set_collapse ([boolean $collapse = TRUE], [boolean $indent = TRUE])
void set_indent_flag (boolean $flag)
Methods
Constructor Container (line 82)

The constructor.

This lets you pass in data that you want automatically added to the container. This works in the same manner as the push() method.

  1. function Container({
  2.         //We do the adding to the content var
  3.         //here instead of calling $this->push()
  4.         //to save some cpu cycles.
  5.         $num func_num_args();
  6.         for ($i=0;$i<$num;$i++{
  7.             $arg func_get_arg($i);
  8.             array_push($this->_content$arg);
  9.         }
  10.         $this->_data_count += $num;
  11.  
  12.         //set the flag bitmask
  13.         $this->_set_flags();
  14.     }

Container Container ()
add (line 185)

add content onto content stack

adds content to tag as a FIFO. You can have n number of parameters. each one will get added in succession to the content.

  1. function add(  {
  2.         $args func_get_args();
  3.         $num 0;
  4.         foreach$args as $arg {
  5.             $this->_content[$arg;
  6.             $num++;
  7.         }
  8.         //keep track of how much data we have added.
  9.         $this->_data_count += $num;
  10.     }

void add (mixed $content)
  • mixed $content: - either string, or tag object.

Redefined in descendants as:
add_reference (line 228)

Add content onto content stack so you can change the item later.

adds content to tag as a FIFO You can only add 1 element at a time, and it will be added as a reference. So you can't do push_reference("something");, since "something" is a static.

  • access: public
void add_reference ( &$content, mixed $content)
  • mixed $content: - either string, or tag object. the tag object gets stored as a reference to the original, so you can push it, then modify it later.
  • &$content

Redefined in descendants as:
count_content (line 256)

counts the number of content objects

  1. function count_content{
  2.         return $this->_data_count;
  3.     }

  • access: public
int count_content ()
get_element (line 269)

get the nth element from content array

  1. function &get_element$cell {
  2.         return $this->_content[$cell];
  3.     }

mixed &get_element (int $cell)
  • int $cell: the cell to get
get_indent_flag (line 316)

This flag gets the current value of the indent flag

  1. function get_indent_flag({
  2.         return $this->_flags _INDENT;
  3.     }

boolean get_indent_flag ()
push (line 166)

Same as add().

NOTE: only exists for 1.1.x compatibility

  1. function push(  {
  2.         $args func_get_args();
  3.         call_user_func_arrayarray(&$this"add")$args);
  4.     }

  • deprecated:
  • access: public
void push (mixed $content)
  • mixed $content: - either string, or tag object.

Redefined in descendants as:
push_reference (line 207)

Same as add_reference NOTE : only exists for compatibility with 1.1.x

  1. function push_reference&$content {
  2.         $this->add_reference$content );
  3.     }

  • deprecated:
  • access: public
void push_reference (mixed &$content)
  • mixed &$content: - a reference to some variable.

Redefined in descendants as:
render (line 114)

This function is compatible with the rest of the phpHtmllib API spec.

It just walks through each of the class' data and renders it with the appropriate indentation.

  1. function render($indent_level=0$output_debug=0{
  2.         $html '';
  3.         
  4.         for ($x=0$x<=$this->_data_count-1$x++{
  5.             $item &$this->_content[$x];
  6.             if (method_exists($item"render") ) {
  7.                 if (($this->_flags _COLLAPSE&& method_exists($item"set_collapse")) {
  8.                     $item->set_collapse(TRUEFALSE);
  9.                 }
  10.                 $html .= $item->render($indent_level$output_debug);
  11.             else {
  12.                 if ($this->_flags _COLLAPSE{
  13.                     $html .= $item;                    
  14.                 else {
  15.                     $indent $this->_render_indent($indent_level$output_debug);
  16.                     $html .= $indent.$item;
  17.                     if ($this->_flags _NEWLINEAFTERCONTENT{
  18.                         $html .= "\n";
  19.                     }
  20.                 }                
  21.             }
  22.         }
  23.         if ($this->_flags _COLLAPSE{
  24.             $indent $this->_render_indent($indent_level$output_debug);
  25.             if ($this->_flags _NEWLINEAFTERCONTENT{
  26.                 if ($output_debug{
  27.                     $html $indent $html "<br>\n";                    
  28.                 else {
  29.                     $html $indent $html "\n";
  30.                 }                
  31.             else {
  32.                 $html $indent $html;
  33.             }
  34.             
  35.         }
  36.         return $html;
  37.     }

  • return: the raw html output.
string render ([int $indent_level = 0], [int $output_debug = 0])
  • int $indent_level: - the indentation level for the container.
  • int $output_debug: - the output debug flag to maintain compatibility w/ the API.

Redefined in descendants as:
reset_content (line 242)

destroy existing content and start with new content.

  1. function reset_content{
  2.         $this->_content array();
  3.         $this->_data_count 0;
  4.         $args func_get_args();
  5.         call_user_func_arrayarray(&$this"add")$args);
  6.     }

  • access: public
void reset_content (mixed $content)
  • mixed $content: can be tag object, or raw (string).

Redefined in descendants as:
set_collapse (line 332)

This function turns on the collapse flag

  1. function set_collapse($collapse=TRUE$indent=TRUE{
  2.         if ($collapse{
  3.             $this->_flags |= _COLLAPSE;
  4.         else {
  5.             $this->_flags &= ~_COLLAPSE;
  6.         }
  7.         
  8.         if (!$indent{
  9.             $this->set_indent_flag($indent);
  10.             $this->_flags &= ~_NEWLINEAFTERCONTENT;
  11.         }        
  12.     }

void set_collapse ([boolean $collapse = TRUE], [boolean $indent = TRUE])
  • boolean $collapse: - the collapse flag
  • boolean $indent: - the indent flag DEFAULT: TRUE;

Redefined in descendants as:
set_indent_flag (line 299)

function to set the indent flag

  1. function set_indent_flag$flag {
  2.         if ($flag{
  3.             $this->_flags |= _INDENT;
  4.         else {
  5.             $this->_flags &= ~_INDENT;
  6.         }
  7.     }

  • access: public
void set_indent_flag (boolean $flag)
  • boolean $flag: TRUE or FALSE

Documentation generated on Fri, 28 Jan 2011 08:52:50 -0500 by phpDocumentor 1.4.3