<?php
/*
 *
 * @package		ARI Smart Content
 * @author		ARI Soft
 * @copyright	Copyright (c) 2011 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 * 
 */

defined('_JEXEC') or die;

class JToolbarButtonArismartcontenthelp extends JButton
{
	var $_name = 'Arismartcontenthelp';

	function fetchButton($type = 'Arismartcontenthelp', $url = '', $internal = true)
	{
		$text	= JText::_('Help');
		$doTask = $this->_getCommand($this->_buildLink($url, $internal));

		$html = "<button href=\"#\" onclick=\"$doTask\" rel=\"help\" class=\"btn btn-small\">\n";
		$html .= "<i class=\"icon-question-sign\">\n";
		$html .= "</i>\n";
		$html .= "$text\n";
		$html .= "</button>\n"; 

		return $html;
	}

	function fetchId($name)
	{
		return uniqid('aqh-', false) . "arismartcontenthelp";
	}

	function _buildLink($url, $internal)
	{
		if (!$internal)
			return $url;

		$config = AriSmartContentHelper::getConfig();
		$helpPath = $config->get('HelpPath');
		
		return $helpPath . $url;
	}

	function _getCommand($url)
	{
		$url = htmlspecialchars($url, ENT_QUOTES);
		$cmd = "Joomla.popupWindow('$url', '" . JText::_('JHELP', true) . "', 800, 700, 1)";

		return $cmd;
	}
}