<?php
/**
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2007 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
class block_pfeat extends tpl_parser {
private static $tagmatch = "#(\{--)(PFEAT)(=)([\w\W]+?)(;)([\w\W]+?)(--})#";
private static $tagfeat = '4';
private static $tagarg = '6';
private $feat;
private $arg;
public function __construct($hdl, $tag, $epos, $depth, $of){
//echo "$depth] New block Tfeat @ ".$tag->start()."<br/>\n";
parent::__construct($hdl, $tag->end(), $epos, $depth, $of);
$this->otag=$tag;
}
public function end(){ return $this->otag->end(); }
public function load_tagargs($tag=NULL){
//echo "$this->depth] Block Lang @ ".$this->otag->start()." : Loading tagargs<br/>\n";
if ( $tag === NULL ){ $tag = $this->otag->read(); }
preg_match(self::$tagmatch, $tag, $result);
if ( FALSE === $result ){
errors::raise('Malformed TFeat tag @ '.$this->otag->start(), CORE_LOG_ERROR, 'TPL');
return FALSE;
}
$this->feat = trim($result[self::$tagfeat]);
$this->arg = trim($result[self::$tagarg]);
return TRUE;
}
public function recurloads(){ return TRUE; }
public function plugparse($l, $g, $return){
//is implented ?
$f = "pfeat_$this->feat::genpart";
if ( $return ){ $r = FALSE; } else { $r = $this->of; }
$o = call_user_func($f, $this->arg, $r);
if ( $return ){ return $o; };
//call_user_func($this->of, $o);
return TRUE;
}
public function plugparse_before($l, $g, $return, $bref){ return $this->plugparse($l, $g, $return); }
}
return 1;