Location: PHPKode > scripts > UI Template > ui-template/frea/Template/Dom/Namespace/Definecomponent.php
<?php
/**
 * @package frea-framework
 * @subpackage Template
 * 
 * @copyright 2009 frea-framework
 * @author Dawid Kraczkowski hide@address.com
 * @license  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
 */
class Template_Dom_Namespace_Definecomponent extends Template_Dom_Namespace
{	
	public function init()
	{
		
		$this->node->disable();
		
	}
	public function insertBefore()
	{
		
	}
	public function insertAfter()
	{
		
	}
	public function preprocessor()
	{
		
		preg_match_all("#\\<\\?php(.*?)\\?\\>#is",$this->node->parsedContents,$m);
		//echo $this->node->parsedContents;
		$replacements = array();
		foreach($m[0] as $phpsnip)
		{
			$replacements[$phpsnip] = preg_replace("#\\\${([a-z][a-z0-9_]*?)}#is","\\\\\$this->values['$1']",$phpsnip);
		}
		//print_r($replacements);
		$p = str_replace(array_keys($replacements),array_values($replacements),$this->node->parsedContents);
		
		$p = preg_replace("#\\\${([a-z][a-z0-9_]*?)}#is","<?=\\\\\$this->values['$1'];?>",$p);
		$cmp = <<<CMP
	\$cmp = new Template_Component();
	\$cnts = <<<CNTS
	{$p}
CNTS;
	\$cmp->defineContents(\$cnts);
	
CMP;
		$params = $this->node->getElementsByTagname('param');
		foreach((array)$params as $param)
		{
			$cmp.= "\$cmp->addParam('".str_replace("-","_",$param->getAttribute("name"))."');";
		}
		$cmp .= "\n\tTemplate_ComponentManager::registerComponent(\"{$this->node->getAttribute("name")}\",\$cmp);";
		return $cmp;
	}
}
Return current item: UI Template