All pastes #468399 Raw Edit

k4st

public php v1 · immutable
·published 2007-05-03 02:29 UTC
rendered paste body
<?phpclass TemplateScope{	protected $tpl_vars;		public function __construct()	{			}		// handle scope for template variables...	// or is it fake scope? loool.	public function setVar($name, $val)	{		$this->pushVar($name, $val);	}	public function pushVar($name = '', $val)	{		$this->tpl_vars[$name] = $val;	}	public function pullVar($name = '', $parent = FALSE)	{		$ret = NULL;		$parts = array();				if(strpos($name, '.') !== FALSE)		{			$parts = explode('.', $name);						$name = array_shift($parts);		}				$parent = $parent !== FALSE ? $parent : $this->tpl_vars;				if(isset($parent[$name]))		{			if(is_array($parent))				$ret = $parent[$name];			else if(is_object($parent))				$ret = $parent->$name;			else			{				$ret = NULL;				$parts = array();			}					if(count($parts) > 0)				foreach($parts as $part)					$ret = $this->pullVar($part, $ret);		}				return $ret;	}	public function popVar($name)	{		unset($this->tpl_vars[$name]);	}}?>