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)
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. |
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();
- }
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;
- }
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.
counts the number of content objects
- function count_content( ) {
- return $this->_data_count;
- }
get the nth element from content array
- function &get_element( $cell ) {
- return $this->_content[$cell];
- }
This flag gets the current value of the indent flag
- function get_indent_flag() {
- return $this->_flags & _INDENT;
- }
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);
- }
Same as add_reference NOTE : only exists for compatibility with 1.1.x
- function push_reference( &$content ) {
- $this->add_reference( $content );
- }
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;
- }
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);
- }
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;
- }
- }
function to set the indent flag
- function set_indent_flag( $flag ) {
- if ($flag) {
- $this->_flags |= _INDENT;
- } else {
- $this->_flags &= ~_INDENT;
- }
- }
Documentation generated on Thu, 1 Sep 2005 17:05:34 -0700 by phpDocumentor 1.3.0RC3