Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/html/tag/object.php
<?php

class AnUikitHtmlTagObject extends KObject
{	
	private $options	 = array();
	private $tagName 	 = null;
	private $content	 = null;
	
	public function __construct($tagName,$content,$options=array())
	{	
		$this->tagName  = $tagName;
		$this->content  = $content;
		$this->options  = $options;
	}
	
	public function setContent($content)
	{
		$this->content = $content;
		return $this;
	}
	
	public function parseTagOptions($options)
	{	
		return $options;
	}
	
	
	
	public function __toString()
	{		
		$attr = array();
		$tag  = '<'.$this->tagName;
		$options = $this->parseTagOptions($this->options);
		foreach($options as $key=>$value)
			$attr[] = $key.'='.'"'.$value.'"';

		$attr = implode(' ',$attr);
		$tag .= ' '.$attr;
		if ( isset($this->content) && !is_null($this->content) )
			$tag .= '>'.$this->content.'</'.$this->tagName.'>';
		else
			$tag .= ' />';
		
		return $tag;		
	}
	
	
	
	public function __call($method,$args)
	{
		if ( strpos($method,'set') === false )
			throw new Exception(sprintf('Call to undefined method %s::%s',__CLASS__,$method));

		$attr   = KInflector::underscore(substr($method,3, strlen($method)));

		foreach($args as &$arg) 
			if ( is_array($arg) ) {
				$arg =& str_replace('"','\'', json_encode($arg));
			}
		$value 	= implode(' ',$args);
		return $this->set($attr,$value);
	}
	
	
		
	public function toString()
	{
		return $this->__toString();		
	}
	
	
	
	public function set()
	{
		$args  = func_get_args();
		
		if ( count($args) == 2 )			
			$this->options[$args[0]] = $args[1];
		else if ( count($args) == 1 && is_array($args[0]) ) {
			$this->options = ( array_merge($this->options,$args[0]) );
		}
		
		return $this;
	}	
}
Return current item: Anahita Social Engine