<?php
/**
 * Html controls helper
 * @date 13.07.2006
 * @name Helper
 * @author Margo Poolak <margo 'dot' poolak 'at' mail 'dot' ee>
 * @copyright Copyright &copy;2006 Margo Poolak. All Rights Reserved.
 * @version 2.0
 * @package System.Web.UI.HtmlControls
 * @category 
 * 
 * Generates the html input fields text, password, checkbox, radio etc.
 *
 */
/*
* Icon .png image 
* @parameter string icon name
* @parameter array to set parameter into img
* @returns image
*/
function icon_tag($name,$o=array())
{
	$param = null;
	$icon = ctrl::getApplication()->getRequest()->getBaseUrl().'/images/icons/'.$name.'.png';
	if(file_is_accesible($icon) == false)
	{
		return icon_tag('error',$o);
	}
	foreach($o as $key=>$value)
	{
		$param .= $key.'="'.$value.'"'; 
	}
	return '<img src="'.$icon.'" alt="'.$name.'" title="'.$name.'" '.$param.' />';
}
/*
* Image .gif pictures
* @parameter string image name
* @parameter array to set parameter into image
* @returns image
*/
function image_tag($name,$o=array())
{
	$param = null;
	$image = ctrl::getApplication()->getRequest()->getBaseUrl().'/images/'.$name.'.gif';
	
	foreach($o as $key=>$value)
	{
		$param .= $key.'="'.$value.'"'; 
	}	
	
	return '<img src="'.$image.'" alt="'.$name.'" '.$param.' />';
}
/*
* Displays locked/unlocked icon
* @parameter 0|1 unlocked/locked
* @returns image
*/
function image_lock($status)
{
	if($status == 1)
	{
		$name = 'lock';
	}
	else
	{
		$name = 'lock_open';
	}
	
	return icon_tag($name);
}
/*
* @parameter 0|1 
* @returns image
*/
function toggle_user_status($status = 1, $o = array())
{
	if($status == 0)
	{
		return '<img src="'.ctrl::getApplication()->getRequest()->getBaseUrl().'/images/metacontact_online.png" alt="Online" />';
	}
	else
	{
		return '<img src="'.ctrl::getApplication()->getRequest()->getBaseUrl().'/images/metacontact_offline.png" alt="Offline" />';
	}
}
?>