<?php
defined('VSIGN') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");

class HelpManager
{
	private $db;
	private $user;
	
	/**
	 * Constructs the Module Manager.
	 * @return 
	 * @param $db Object
	 * @param $user Object
	 */
	public function __construct(database $db, User $user)
	{
            $this->db       =& $db;
            $this->user 	=& $user;
	}
	
	/**
	 * Help Button
	 * @return 
	 * @param $location Object
	 * @param $return Object[optional]
	 */
	public function HelpButton($location, $return = false) 
	{
		$db 		=& $this->db;
		
		$location	= explode('/', $location);
		$topic		= ucfirst($location[0]);
		$category	= ucfirst($location[1]);
		
		$msgHelp	= __('Help');
		
		$button = '<input type="button" class="VsignHelpButton" href="' . 'index.php?p=help&q=Display&Topic=' . $topic . '&Category=' . $category . '" value="'. $msgHelp .'" />';
	
		if ($return)
		{
			return $button;
		}
		else
		{
			echo $button;
			return true;
		}
	}
	
	/**
	 * Help Icon
	 * @return 
	 * @param $title Object
	 * @param $return Object[optional]
	 * @param $image Object[optional]
	 * @param $alt Object[optional]
	 */
	public function HelpIcon($title, $return = false, $image = "img/forms/info_icon.gif", $alt = "Hover for more info")
	{
		$button = <<<END
		<img src="$image" alt="$alt" title="$title">
END;
		
		if ($return)
		{
			return $button;
		}
		else
		{
			echo $button;
			return true;
		}
	}
	
	/**
	 * Outputs a help link
	 * @return 
	 * @param $topic Object[optional]
	 * @param $category Object[optional]
	 */
	public static function Link($topic = "", $category = "General")
	{
		// if topic is empty use the page name
		$topic	= ($topic == '') ? Kit::GetParam('p', _REQUEST, _WORD) : $topic;
		$topic	= ucfirst($topic);
		
		$link	= 'index.php?p=help&q=Display&Topic=' . $topic . '&Category=' . $category . '';
		
		return $link;		
	}
}
?>
