// /** * @package phptal.php */ class PHPTAL_Php_ElementWriter { public function __construct(PHPTAL_Php_CodeWriter $writer, PHPTAL_Php_Element $tag) { $this->_writer = $writer; $this->_tag = $tag; } public function writeHead() { if ($this->_tag->headFootDisabled) return; if ($this->_tag->headFootPrintCondition){ $this->_writer->doIf($this->_tag->headFootPrintCondition); } $this->_writer->pushHtml('<'.$this->_tag->name); $this->_writeAttributes(); if ($this->_tag->isEmptyNode()){ $this->_writer->pushHtml('/>'); } else { $this->_writer->pushHtml('>'); } if ($this->_tag->headFootPrintCondition){ $this->_writer->doEnd(); } } public function writeFoot() { if ($this->_tag->headFootDisabled) return; if ($this->_tag->isEmptyNode()) return; if ($this->_tag->headFootPrintCondition){ $this->_writer->doIf($this->_tag->headFootPrintCondition); } $this->_writer->pushHtml('_tag->name.'>'); if ($this->_tag->headFootPrintCondition){ $this->_writer->doEnd(); } } public function writeAttributes() { $fullreplaceRx = PHPTAL_Php_Attribute_TAL_Attributes::REGEX_FULL_REPLACE; foreach ($this->_tag->attributes as $key=>$value) { if (preg_match($fullreplaceRx, $value)){ $this->_writer->pushHtml($value); } /* else if (strpos('_writer->pushHtml(' '.$key.'="'); $this->_writer->pushRawHtml($value); $this->_writer->pushHtml('"'); } */ else { $this->_writer->pushHtml(' '.$key.'="'.$value.'"'); } } } private $_tag; private $_writer; } ?>