Source for file go_template_parser.class.inc.php
Documentation is available at go_template_parser.class.inc.php
* This file is part of Group-Office. You should have received a copy of the
* Group-Office license along with Group-Office. See the file /LICENSE.TXT
* If you have questions write an e-mail to info@intermesh.nl
* @copyright Copyright Intermesh
* @version $Id: go_template_parser.class.inc.php 1229 2008-10-25 13:13:38Z mschering $
* @author Merijn Schering <mschering@intermesh.nl>
* @author Merijn Schering <mschering@intermesh.nl>
* @version $Id: go_template_parser.class.inc.php 1229 2008-10-25 13:13:38Z mschering $
* @copyright Copyright Intermesh
* @license AGPL Affero General Public License
* @since Group-Office 3.0
var $tags = array('gotpl');
private function get_tag($tag, $content) {
if ($start_pos !== false) {
$end_pos = $this->get_end_pos($tag, $content, $start_pos);
if($sub_start_pos!== false)
//echo $sub_start_pos.' < '.$sub_end_pos."\n---\n";
while($sub_start_pos< $sub_end_pos)
$sub_end_pos = $this->get_end_pos($tag, $content, $sub_end_pos);
$tag_length = $end_pos- $start_pos;
return substr($content, $start_pos, $tag_length);
private function get_end_pos($tag, $content, $offset= 0)
private function get_attributes($tag) {
for ($i = 0; $i < $length; $i ++ ) {
$attributes[trim($name)] = trim($value);
private function replace_template(&$content)
foreach($this->fields as $field)
$value = isset ($this->values[$field]) ? $this->values[$field] : '';
$content = str_replace('{'. $field. '}', $value, $content);
public function parse(&$content)
$this->parse_tags($content);
$this->replace_template($content);
private function parse_tags(&$content)
foreach($this->values as $varname=> $value)
foreach($this->tags as $tagname)
while ($tag = $this->get_tag($tagname, $content)) {
$attributes = $this->get_attributes($tag);
//echo '$print = '.$attributes['if'].';'."\n\n";
//eval('$print = '.html_entity_decode($attributes['if']).';');
$print = !empty($ $attributes['if']);
$this->parse_tags($tagcontent, $conditions);
//echo "\n\n########\n\n";
|