HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/TokenFactory.php
Go to the documentation of this file.
00001 <?php
00002 
00014 class HTMLPurifier_TokenFactory
00015 {
00016 
00021     // p stands for prototype
00022     private $p_start, $p_end, $p_empty, $p_text, $p_comment;
00023 
00027     public function __construct() {
00028         $this->p_start  = new HTMLPurifier_Token_Start('', array());
00029         $this->p_end    = new HTMLPurifier_Token_End('');
00030         $this->p_empty  = new HTMLPurifier_Token_Empty('', array());
00031         $this->p_text   = new HTMLPurifier_Token_Text('');
00032         $this->p_comment= new HTMLPurifier_Token_Comment('');
00033     }
00034 
00041     public function createStart($name, $attr = array()) {
00042         $p = clone $this->p_start;
00043         $p->__construct($name, $attr);
00044         return $p;
00045     }
00046 
00052     public function createEnd($name) {
00053         $p = clone $this->p_end;
00054         $p->__construct($name);
00055         return $p;
00056     }
00057 
00064     public function createEmpty($name, $attr = array()) {
00065         $p = clone $this->p_empty;
00066         $p->__construct($name, $attr);
00067         return $p;
00068     }
00069 
00075     public function createText($data) {
00076         $p = clone $this->p_text;
00077         $p->__construct($data);
00078         return $p;
00079     }
00080 
00086     public function createComment($data) {
00087         $p = clone $this->p_comment;
00088         $p->__construct($data);
00089         return $p;
00090     }
00091 
00092 }
00093 
00094 // vim: et sw=4 sts=4