X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/blobdiff_plain/d2c79885c79f02502a531c00d0d437c96e7c3a4d..715ddc41f45dcf4d64348fef69844618ad1abb3d:/src/HTML/Template/HIT.php diff --git a/src/HTML/Template/HIT.php b/src/HTML/Template/HIT.php index de67d2c..6da0b7b 100644 --- a/src/HTML/Template/HIT.php +++ b/src/HTML/Template/HIT.php @@ -45,7 +45,7 @@ class HTML_Template_HIT { * Group of templates to use (a subdirectory in root). * * @var string $group - * @access public + * @access protected */ var $group = ''; @@ -57,6 +57,12 @@ class HTML_Template_HIT { */ var $cache = array(); + /** + * @var array $buffer + * @access protected + */ + var $buffer = array(); + // ~X2C // +X2C Operation 136 @@ -87,27 +93,28 @@ class HTML_Template_HIT { */ function __construct($root = '.', $group = '') // ~X2C { - $this->root = $root; - $this->group = $group; + $this->root = $root; + $this->setGroup($group); } // -X2C // +X2C Operation 138 /** - * Parse a template. + * Parse a template returning the results. If $vars is an array, the {[keys]} are replaced with [values] ($val is ignored). If is a string, {$vars} is replaced with $val. * * @param string $name Name of template to parse. * @param mixed $vars Variables to replace in the template. * @param string $val If $vars is a string, the value to replace for $vars. * - * @return void + * @return string * @access public */ function parse($name, $vars = '', $val = '') // ~X2C { - if ($this->group) { - $file = "{$this->root}/{$this->group}/$name.tpl.html"; + $group = end($this->group); + if ($group) { + $file = "{$this->root}/$group/$name.tpl.html"; } else { $file = "{$this->root}/$name.tpl.html"; } @@ -132,6 +139,89 @@ If $vars is an array, the {[keys]} are replaced with [values] ($val is ignored). } // -X2C + // +X2C Operation 144 + /** + * Parse a template buffering the results. +Parse a template appending the results to an internal buffer. If $vars is an array, the {[keys]} are replaced with [values] ($val is ignored). If is a string, {$vars} is replaced with $val. + * + * @param string $name Name of template to parse. + * @param mixed $vars Variables to replace in the template. + * @param string $val If $vars is a string, the value to replace for $vars. + * + * @return void + * @access public + */ + function parseBuffered($name, $vars = '', $val = '') // ~X2C + { + @$this->buffer["{$this->group}/$name"] .= $this->parse($name, $vars, $val); + } + // -X2C + + // +X2C Operation 145 + /** + * Gets a parsed buffer. + * + * @param string $name Name of the parsed template to get. + * @param bool $flush Flush buffer. + * + * @return string + * @access public + */ + function getBuffer($name, $flush = true) // ~X2C + { + return @$this->buffer["{$this->group}/$name"]; + } + // -X2C + + // +X2C Operation 146 + /** + * Gets a parsed buffer and removes it. + * + * @param int $name Name of the buffer to flush. + * + * @return void + * @access public + */ + function popBuffer($name = '') // ~X2C + { + $return = @$this->buffer["{$this->group}/$name"]; + unset($this->buffer["{$this->group}/$name"]); + return $return; + } + // -X2C + + // +X2C Operation 139 + /** + * Sets the group to use and add it to the groups stack. + * + * @param string $group Group to use. + * + * @return void + * @access public + */ + function setGroup($group = '') // ~X2C + { + if ($group) { + $this->group[] = $group; + } else { + $this->group[] = ''; + } + } + // -X2C + + // +X2C Operation 140 + /** + * Removes the group from the groups stack and returns to the previous used group. + * + * @return void + * @access public + */ + function unsetGroup() // ~X2C + { + array_pop($this->group); + } + // -X2C + } // -X2C Class :HIT -?> +?> \ No newline at end of file