Class XMLTagClass

Description

This class is used for building and rendering an XML tag.

This class is the base class for the HTMLTagClass.

This is part of the phphtmllib libraries released under the LGPL license.

Located in /XMLTagClass.inc (line 35)

Container
   |
   --XMLTagClass
Direct descendents
Class Description
XMLtag xml tag class
WMLTagClass Base class for all WML Tag classes.
SVGTagClass This overrides the WMLTagClass to define some methods that set some commonly used SVG tag attributes.
HTMLTagClass Base class for all HTML Tag classes.
Method Summary
XMLTagClass XMLTagClass (string $name, [array $attributes = array()], mixed 2)
string get_tag ()
mixed. get_tag_attribute (string $attribute)
string get_tag_name ()
void render ([int $indent_level = 0])
none reset_attributes ([array $attributes = array()])
none set_cdata_flag (boolean $flag)
none set_collapse ([boolean $collapse = TRUE], [boolean $indent = TRUE])
none set_newline_after_closetag (boolean $flag)
none set_newline_after_opentag (boolean $flag)
none set_tag_attribute (string $name, [mixed $value = NULL])
none set_tag_attributes ([array $attributes = array()])
void set_tag_name (string $name)
void _set_flags ()
Methods
Constructor XMLTagClass (line 71)

The constructor

  1. function XMLTagClass($name$attributes=array() ) {
  2.         $this->set_tag_name$name );
  3.         $this->set_tag_attributes$attributes );
  4.  
  5.         $num_args func_num_args();
  6.         for ($i=2;$i<$num_args;$i++{
  7.             $this->add(func_get_arg($i));
  8.         }
  9.  
  10.         $this->_set_flags();
  11.     }

XMLTagClass XMLTagClass (string $name, [array $attributes = array()], mixed 2)
  • mixed 2: - n items of content to add
  • string $name: - the tag name
  • array $attributes: - the attributes array can be in name => value or just value
get_tag (line 160)

This returns the tag declared for this class.

This should be used in favor of accessing the $this->_tag directly.

  1. function get_tag({
  2.         //for compatibility only
  3.         return $this->get_tag_name();
  4.     }

  • return: - the _tag var for this class.
string get_tag ()
get_tag_attribute (line 202)

This method allows you to get the value for a tag attribute.

  • return: FALSE if there is no attribute set.
mixed. get_tag_attribute (string $attribute)
  • string $attribute: the attribute you want to find
get_tag_name (line 147)

This method gets the name of the tag

  1. function get_tag_name({
  2.         return $this->_tag;
  3.     }

  • return: - the tag name
string get_tag_name ()
render (line 94)

This function is responsible for rendering the tag and its contents

  1. function render$indent_level={
  2.         
  3.         //try and guess the indentation flags
  4.         //based on the data
  5.         $this->_prepare_flags();
  6.  
  7.         //return $xml;
  8.         return $this->_render_open_tag$indent_level .
  9.                $this->_render_content$indent_level .
  10.                $this->_render_close_tag$indent_level );
  11.     }

void render ([int $indent_level = 0])
  • int $indent_level: - the current indentation level for the tag

Redefinition of:
Container::render()
This function is compatible with the rest of the phpHtmllib API spec.

Redefined in descendants as:
reset_attributes (line 220)

clear all attributes and start with new attributes

  1. function reset_attributes$attributes=array() ) {
  2.         $this->_attributes array();
  3.         $this->set_tag_attributes$attributes );
  4.     }

none reset_attributes ([array $attributes = array()])
  • array $attributes: Associative array of name="value" pairs of tag atributes. ie array("border"=>"0", "class"=>"hover");
set_cdata_flag (line 288)

This method turns on the automatic wrapping of the tag's content inside the CDATA wrapper for XML

  1. function set_cdata_flag($flag{
  2.         if ($flag{
  3.             $this->_flags |= _CDATACONTENTWRAP;
  4.             $this->set_collapse(TRUE);
  5.         else{
  6.             $this->_flags &= ~_CDATACONTENTWRAP;
  7.         }
  8.     }

none set_cdata_flag (boolean $flag)
  • boolean $flag: TRUE or FALSE
set_collapse (line 307)

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.         $this->set_newline_after_opentag(FALSE);
  9.         $this->set_indent_flag($indent);
  10.         if ($indent{
  11.             $this->set_newline_after_closetag(TRUE);
  12.         else {
  13.             $this->set_newline_after_closetag(FALSE);
  14.         }
  15.     }

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

Redefinition of:
Container::set_collapse()
This function turns on the collapse flag
set_newline_after_closetag (line 271)

set the newline_after_content flag

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

none set_newline_after_closetag (boolean $flag)
  • boolean $flag: TRUE or FALSE
set_newline_after_opentag (line 255)

set the newline_after_opentag flag

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

none set_newline_after_opentag (boolean $flag)
  • boolean $flag: TRUE or FALSE
set_tag_attribute (line 174)

add a single attribute (name="value")

  1. function set_tag_attribute$name$value=NULL {
  2.         if (!$value{
  3.             $value $name;
  4.         }
  5.         $this->_attributes[$name$value;
  6.     }

none set_tag_attribute (string $name, [mixed $value = NULL])
  • string $name: attribute name
  • mixed $value: the value.

Redefined in descendants as:
set_tag_attributes (line 191)

add multiple attributes (name="value")

  1. function set_tag_attributes$attributes=array() ) {
  2.         $this->_attributes array_merge($this->_attributes$attributes);
  3.     }

none set_tag_attributes ([array $attributes = array()])
  • array $attributes: Associative array of name="value" pairs of tag atributes. ie array("border"=>"0", "class"=>"hover");

Redefined in descendants as:
set_tag_name (line 136)

This method sets the name of the tag

  1. function set_tag_name$name {
  2.         $this->_tag $name;
  3.     }

void set_tag_name (string $name)
  • string $name: - the tag name

Inherited Methods

Inherited From Container

Container::Container()
Container::add()
Container::add_reference()
Container::count_content()
Container::get_element()
Container::get_indent_flag()
Container::push()
Container::push_reference()
Container::render()
Container::reset_content()
Container::set_collapse()
Container::set_indent_flag()

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