Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/html/tag.php
<?php
/**
 * @version		1.0.0
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.anahitapolis.com
 */

class AnUikitHtmlTag extends KObject
{	

	static public function tag($tagName,$content,$options=array())
	{
/*
		$class = 'AnHtmlTag'.ucfirst($tagName);
		if ( !class_exists($class,false) )
			$class = 'AnHtmlTag';*/
			
		return new AnUikitHtmlTagObject($tagName,$content,$options);
	}
		
	static public function selectOptions($container,$selected = null) 
	{
		$container   = (array) $container;
		$selected    = (array) $selected;
		$options     = array();
//		$associative = AnHelperArray::isAssociative($container);
				
		foreach($container as $value=>$content) 
		{		
				if ( is_array($content) && count($content) == 2 ) {
					$value   = $content[0];
					$content = $content[1];
				} 
				
				if ( in_array($value, $selected) )
					$tag = '<option selected value='.$value.'>'.$content.'</option>';
				else
					$tag = '<option value='.$value.'>'.$content.'</option>';
					
//				$tag = self::tag('option',$content)->setValue($value);
				$options[] = $tag;
		}		
		return implode("\n",$options);
	}	
	
	static public function select($name, $selectedOption = null, $options=array())
	{
		return self::tag('select', $selectedOption, $options)->setName($name);
	}	
	
	static public function textarea($name, $value, $options=array())
	{
		return self::tag('textarea',$value)
					->set(array('name'=>$name,'id'=>$name))
					->set($options);
	}	
	
	static public function inputFieldTag($type,$name,$value,$options=array())
	{
		return self::tag('input',null)
					->set(array('type'=>$type,'value'=>$value,'name'=>$name,'id'=>$name))
					->set($options);		
	}	
	
	static public function textfield( $name, $value, $options=array())
	{
		return self::inputFieldTag('text',$name,$value,$options);
	}
	
	static public function hiddenfield( $name, $value, $options=array())
	{
		return self::inputFieldTag('hidden',$name,$value,$options);
	}		
	
	static public function passwordfield( $name,$value, $options=array())
	{
		return self::inputFieldTag('password',$name,$value,$options);
	}	
	
	static public function submit($value='submit',$name='commit',$options=array())
	{			
		return self::inputFieldTag('submit',$name,$value,$options);
	}	
	
	static public function button($name, $value=null, $options=array())
	{
		return self::tag('button',$value)
					->set(array('id'=>$name,'name'=>$name))
					->set($options);
	}		
	
	static 	public function link($content,$url='',$options=array())
	{
		$options['href'] = $url;
		return self::tag('a', $content, $options);
	}
	
	static	public function radioButton( $name, $value, $checked = false, $options=array())
	{
		if ($checked) 
			$options['checked'] = 'checked' ;
		else	
			unset($options['checked']);
			
		return self::inputFieldTag('radio', $name, $value, $options);
	}
	
	static public function checkbox( $name, $value, $checked = false, $options=array())
	{		
		if ($checked) 
			$options['checked'] = 'checked' ;
		else	
			unset($options['checked']);
			
		return self::inputFieldTag('checkbox', $name, $value, $options);
	}	
	
	static public function image($src,$options=array())
	{		
		return self::tag('img',null,$options)->set('src',$src);
	}	
		
}
Return current item: Anahita Social Engine