Source for file Tag.php

Documentation is available at Tag.php

  1. <?php
  2.  
  3. /**
  4.  * Abstract class of a tag token (start, end or empty), and its behavior.
  5.  */
  6. {
  7.     /**
  8.      * Static bool marker that indicates the class is a tag.
  9.      * 
  10.      * This allows us to check objects with <tt>!empty($obj->is_tag)</tt>
  11.      * without having to use a function call <tt>is_a()</tt>.
  12.      */
  13.     public $is_tag = true;
  14.     
  15.     /**
  16.      * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
  17.      * 
  18.      * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
  19.      *  be lower-casing them, but these tokens cater to HTML tags, which are
  20.      *  insensitive.
  21.      */
  22.     public $name;
  23.     
  24.     /**
  25.      * Associative array of the tag's attributes.
  26.      */
  27.     public $attr = array();
  28.     
  29.     /**
  30.      * Non-overloaded constructor, which lower-cases passed tag name.
  31.      * 
  32.      * @param $name String name.
  33.      * @param $attr Associative array of attributes.
  34.      */
  35.     public function __construct($name$attr array()$line null{
  36.         $this->name = ctype_lower($name$name strtolower($name);
  37.         foreach ($attr as $key => $value{
  38.             // normalization only necessary when key is not lowercase
  39.             if (!ctype_lower($key)) {
  40.                 $new_key strtolower($key);
  41.                 if (!isset($attr[$new_key])) {
  42.                     $attr[$new_key$attr[$key];
  43.                 }
  44.                 if ($new_key !== $key{
  45.                     unset($attr[$key]);
  46.                 }
  47.             }
  48.         }
  49.         $this->attr = $attr;
  50.         $this->line = $line;
  51.     }
  52. }

Documentation generated on Thu, 19 Jun 2008 18:50:23 -0400 by phpDocumentor 1.4.2