Docs For Class Container

## 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

- tutorial: Container
- author: Walter A. Boring IV <waboring@newsblob.com>
- link: http://phphtmllib.sourceforge.net

Located in /ContainerClass.inc (line 39)

Direct descendents

Class | Description
--- | ---
XMLTagClass | This class is used for building and rendering an XML tag.
FormProcessor | This is the main engine for the processing
BaseWidget | this is the base widget class, that all widgets are based off of. It provides some basic members and methods
ContainerWidget | This is just to maintain compatibility with the 1.1.0 release of phphtmllib
XMLDocumentClass | This class lets you build a complete xml document and render it.

Method Summary
Container Container ()
void add (mixed $content)
void add_reference (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, int $output_debug)
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.

    function Container() {
            //We do the adding to the content var
            //here instead of calling $this->push()
            //to save some cpu cycles.
            $num = func_num_args();
            for ($i=0;$i<$num;$i++) {
                $arg = func_get_arg($i);
                array_push($this->_content, $arg);
            }
            $this->_data_count += $num;

            //set the flag bitmask
            $this->_set_flags();
        }

- tutorial: Constructor call

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.

    function add(  ) {
            $args = func_get_args();
            $num = 0;
            foreach( $args as $arg ) {
                $this->_content[] = $arg;
                $num++;
            }
            //keep track of how much data we have added.
            $this->_data_count += $num;
        }

- access: public
- tutorial: add Method

void add (mixed $content)

- mixed $content: - either string, or tag object.

Redefined in descendants as:

- OLtag::add() : add content onto content stack adds content to tag as a FIFO.
- TRtag::add() : add content onto content stack adds content to tag as a FIFO.
- ButtonPanel::add() : Push content onto the data object
- CSSContainer::add() : Only allow the adding of CSSBuilder
- DialogWidget::add() : Pushes a content into the data object
- FooterNav::add() : add an entry to the footer nav
- NavTable::add() : this function adds an entry to the navtable.
- TabList::add() : This public method adds a new tab to the table
- TextCSSNav::add() : this function adds a clickable link.
- TextNav::add() : this function adds a clickable link.
- VerticalCSSNavTable::add() : this function adds a clickable link.
- ErrorBoxWidget::add() : This method is used to add individual errors.
- XMLDocumentClass::add() : we override this class to make sure we push all content inside the local _xml_obj tag

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 (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.

Redefined in descendants as:

- OLtag::add_reference() : push content onto content stack
- TRtag::add_reference() : add content onto content stack
- XMLDocumentClass::add_reference() : we override this class to make sure we push all content inside the local _xml_obj tag

count_content (line 256)

counts the number of content objects

    function count_content( ) {
            return $this->_data_count;
        }

- access: public

int count_content ()
get_element (line 269)

get the nth element from content array

    function &get_element( $cell ) {
            return $this->_content[$cell];
        }

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

    function get_indent_flag() {
            return $this->_flags & _INDENT;
        }

boolean get_indent_flag ()
push (line 166)

Same as add().

NOTE: only exists for 1.1.x compatibility

    function push(  ) {
            $args = func_get_args();
            call_user_func_array( array(&$this, "add"), $args);
        }

- access: public
- deprecated:

void push (mixed $content)

- mixed $content: - either string, or tag object.

Redefined in descendants as:

- TRtag::push() : Same ass add()
- FooterNav::push() : add an entry to the footer nav.
- ImageThumbnailWidget::push()
- NavTable::push() : depricated version of add()
- TextCSSNav::push() : depricated version of add()
- TextNav::push() : depricated version of add()
- TreeNav::push()
- XMLDocumentClass::push() : Same as add().

push_reference (line 207)

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

    function push_reference( &$content ) {
            $this->add_reference( $content );
        }

- access: public

void push_reference (mixed &$content)

- mixed &$content: - a reference to some variable.

Redefined in descendants as:

- TRtag::push_reference() : Same ass add_reference()
- XMLDocumentClass::push_reference() : Same as add_reference NOTE : only exists for compatibility with 1.1.x

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.

    function render($indent_level=0, $output_debug=0) {
            $html = '';

            for ($x=0; $x<=$this->_data_count-1; $x++) {
                $item = &$this->_content[$x];
                if (method_exists($item, "render") ) {
                    if (($this->_flags & _COLLAPSE) && method_exists($item, "set_collapse")) {
                        $item->set_collapse(TRUE, FALSE);
                    }
                    $html .= $item->render($indent_level, $output_debug);
                } else {
                    if ($this->_flags & _COLLAPSE) {
                        $html .= $item;
                    } else {
                        $indent = $this->_render_indent($indent_level, $output_debug);
                        $html .= $indent.$item;
                        if ($this->_flags & _NEWLINEAFTERCONTENT) {
                            $html .= "\n";
                        }
                    }
                }
            }
            if ($this->_flags & _COLLAPSE) {
                $indent = $this->_render_indent($indent_level, $output_debug);
                if ($this->_flags & _NEWLINEAFTERCONTENT) {
                    if ($output_debug) {
                        $html = $indent . $html . "<br>\n";
                    } else {
                        $html = $indent . $html . "\n";
                    }
                } else {
                    $html = $indent . $html;
                }

            }
            return $html;
        }

- return: the raw html output.

string render (int $indent_level, int $output_debug)

- 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:

- XMLTagClass::render() : This function is responsible for rendering the tag and its contents
- HTMLTagClass::render() : Renders the tag, attributes, content and close tag.
- FormProcessor::render() : This method is called to render the form's html
- FormWizard::render() : This function renders the
- SVGGraph::render()
- ActiveTab::render()
- ButtonPanel::render() : render the entire table.
- DialogWidget::render() : Creates a container with title,
- MessageBoxWidget::render() : We override the render function
- FooterNav::render() : render the code for this widget.
- ImageThumbnailWidget::render() : Render the entire widget. this includes the page offset links, as well as the thumbnails.
- InfoTable::render() : This function renders the object.
- NavTable::render() : Render the Navtable and its content.
- RoundTitleTable::render() : Render the Navtable and its content.
- TabControlWidget::render() : render the widget
- TabList::render() : The render method
- TextCSSNav::render() : function that will render the widget.
- TextNav::render() : function that will render the widget.
- TreeNav::render() : function that will render the widget.
- VerticalCSSNavTable::render() : function that will render the widget.
- DataList::render() : This function renders the final
- ProgressWidget::render() : Render the main layout of the bar.
- ProgressBoxWidget::render() : Render the box.
- ErrorBoxWidget::render() : This is called to generate the resulting html output
- XMLDocumentClass::render() : function that will render the XML Document.

reset_content (line 242)

destroy existing content and start with new content.

    function reset_content( ) {
            $this->_content = array();
            $this->_data_count = 0;
            $args = func_get_args();
            call_user_func_array( array(&$this, "add"), $args);
        }

- access: public

void reset_content (mixed $content)

- mixed $content: can be tag object, or raw (string).

Redefined in descendants as:

- XMLDocumentClass::reset_content() : we override this class to make sure we push all content inside the local _xml_obj tag

set_collapse (line 332)

This function turns on the collapse flag

    function set_collapse($collapse=TRUE, $indent=TRUE) {
            if ($collapse) {
                $this->_flags |= _COLLAPSE;
            } else {
                $this->_flags &= ~_COLLAPSE;
            }

            if (!$indent) {
                $this->set_indent_flag($indent);
                $this->_flags &= ~_NEWLINEAFTERCONTENT;
            }
        }

- tutorial: Collapse

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:

- XMLTagClass::set_collapse() : This function turns on the collapse flag

set_indent_flag (line 299)

function to set the indent flag

    function set_indent_flag( $flag ) {
            if ($flag) {
                $this->_flags |= _INDENT;
            } else {
                $this->_flags &= ~_INDENT;
            }
        }

- access: public

void set_indent_flag (boolean $flag)

- boolean $flag: TRUE or FALSE

Documentation generated on Thu, 1 Sep 2005 17:05:34 -0700 by phpDocumentor 1.3.0RC3