<?php
/**
 * @version		$Id: quanta.php 115 2009-06-17 07:20:36Z eddieajau $
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

jximport('jxtended.database.query');

/**
 * HTML Grid Helper
 *
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class JHtmlQuanta
{
	/**
	 * Returns the options for a state select list.
	 *
	 * @param	string	The selected value for the list.
	 *
	 * @return	string
	 */
	function publishedOptions($selected = null)
	{
		// Published filter
		$options	= array();
		$options[]	= JHtml::_('select.option', '', 'Quanta_Option_Published_Default');
		$options[]	= JHtml::_('select.option', '1', 'Quanta_Option_Published');
		$options[]	= JHtml::_('select.option', '0', 'Quanta_Option_Unpublished');
		$options[]	= JHtml::_('select.option', '-2', 'Quanta_Option_Trash');
		$options[]	= JHtml::_('select.option', '*', 'Quanta_Option_All');

		return JHtml::_('select.options', $options, 'value', 'text', $selected, true);
	}

	/**
	 * Returns the options for a categories select list.
	 *
	 * @param	string	The selected value for the list.
	 *
	 * @return	string
	 */
	function categoryOptions($selected = null)
	{
		$db = &JFactory::getDbo();

		$query = new JxQuery;
		$query->select('id AS value, title AS text');
		$query->from('#__categories');
		$query->where('section = '.$db->quote('com_quanta'));

		$db->setQuery((string) $query);
		$options = $db->loadObjectList();

		//array_unshift($options, JHtml::_('select.option', '', JText::_('Quanta_Option_Category_Filter')));

		return JHtml::_('select.options', $options, 'value', 'text', $selected);
	}

	/**
	 * Returns the options for a records select list.
	 *
	 * @param	string	The selected value for the list.
	 * @param	int		An optional category ID by which to filter the records.
	 *
	 * @return	string
	 */
	function recordOptions($selected = null, $categoryId = null)
	{
		$db = &JFactory::getDbo();

		$query = new JxQuery;
		$query->select('id AS value, title AS text');
		$query->from('#__taoj_quanta_records');
		$query->order('title');

		if ($categoryId) {
			$query->where('category_id = '.(int) $categoryId);
		}

		$db->setQuery((string) $query);
		$options = $db->loadObjectList();

		return JHtml::_('select.options', $options, 'value', 'text', $selected);
	}
}