Location: PHPKode > projects > Simple Way to Usenet > libs/core/parser/tpl_block.class.php
<?php
/**
 *  
 * @author  Benjamin Gillissen <hide@address.com>
 * 
 *	**************************************************************

	Copyright (C) 2009  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 tpl_block {
	
	private static $knowplug=Array('logic', 'logic_else', 'array', 'array_else', 'lang', 'inc', 'define', 'tfeat', 'pfeat', 'href');		//block_*.class.php found in libs
	
	private $otag;		//open tag object
	private $BLK;		//the block plugin object
	
	public function __construct($tag){
		$this->otag = $tag;
		//is valid tag object ?
		if ( !isset(self::$knowblocks) ){
			//searchdeps(PATH_LIBS, '', 'block_', 'class', 'php');
		}
		
	}
	
	public function plugin(){
		if ( isset($this->otag) ){ $o = $this->otag->plugin(); }
		if ( isset($this->BLK) ){ $o = $this->BLK->plugin(); }
		if ( !isset($o) ){ return FALSE; }
		if ( FALSE !== array_search($o, self::$knowplug) ){ return $o; }
		return FALSE; 
	}
	public function ref(){
		if ( !isset($this->BLK) ){ return FALSE; }
		if ( !method_exists($this->BLK, 'ref' ) ){ return FALSE; }
		return $this->BLK->ref();
	}
	
	public function load_plugin($hdl, $epos, $depth, $of){
		if ( FALSE === $this->otag->detect() ){ return FALSE; }
		$plug = $this->plugin();
		if ( $plug == FALSE ){
			errors::raise("Invalid block plugin used in tag @ ".$this->otag->start()." depth:$depth", CORE_LOG_ERROR, 'TPL'); 
			return FALSE; 
		}
		$plug = 'block_'.$plug;
		unset($ar);
		$this->BLK = new $plug($hdl, $this->otag, $epos, $depth, $of);
		unset($this->otag);
		return $this->BLK->load_tagargs();
	}
	
	public function detect_recur(){ return $this->BLK->recurloads(); }
	public function start(){return $this->BLK->start(); }
	public function end(){ 	return $this->BLK->end(); }
	
	public function parse($l, $g, $return){							return $this->BLK->plugparse($l, $g, $return); }
	public function parse_before($l, $g, $return, $bref){			return $this->BLK->plugparse_before($l, $g, $return, $bref); }
	public function parse_once($l, $g, $return, $bref, $data, $key){return $this->BLK->plugparse_once($l, $g, $return, $bref, $data, $key); }
	public function parse_after($l, $g, $return, $bref){			return $this->BLK->plugparse_after($l, $g, $return, $bref); }
	public function parse_between($l, $g, $return, $sbref, $ebref){	return $this->BLK->plugparse_between($l, $g, $return, $sbref, $ebref); }

}
return 1;
Return current item: Simple Way to Usenet