<?php
/**
 * This file is generated by Sort Filter Unit Class Maker.
 * @version $Id: ModuleListFilterForm.class.php,v 1.1.2.4 2006/03/28 13:29:05 minahito Exp $
 */

if (!defined('XOOPS_ROOT_PATH')) exit();

define("MODULE_SORT_KEY_DEFAULT",     0);
define("MODULE_SORT_KEY_MID",         1);
define("MODULE_SORT_KEY_NAME",        2);
define("MODULE_SORT_KEY_VERSION",     3);
define("MODULE_SORT_KEY_LASTUPDATE",  4);
define("MODULE_SORT_KEY_WEIGHT",      5);
define("MODULE_SORT_KEY_ISACTIVE",    6);
define("MODULE_SORT_KEY_DIRNAME",     7);
define("MODULE_SORT_KEY_HASMAIN",     8);
define("MODULE_SORT_KEY_HASADMIN",    9);
define("MODULE_SORT_KEY_HASSEARCH",  10);
define("MODULE_SORT_KEY_HASCONFIG",  11);
define("MODULE_SORT_KEY_HASCOMMENTS",12);

define("MODULE_SORT_KEY_MAXVALUE",   12);

/**
 *
 */
class ModuleListFilterForm
{
	var $mSpecial=null;

	var $mSortKey=0;

	var $_mSortKeys=array(
		MODULE_SORT_KEY_DEFAULT     => "mid",
		MODULE_SORT_KEY_MID         => "mid",
		MODULE_SORT_KEY_NAME        => "name",
		MODULE_SORT_KEY_VERSION     => "version",
		MODULE_SORT_KEY_LASTUPDATE  => "last_update",
		MODULE_SORT_KEY_WEIGHT      => "weight",
		MODULE_SORT_KEY_ISACTIVE    => "isactive",
		MODULE_SORT_KEY_DIRNAME     => "dirname",
		MODULE_SORT_KEY_HASMAIN     => "hasmain",
		MODULE_SORT_KEY_HASADMIN    => "hasadmin",
		MODULE_SORT_KEY_HASSEARCH   => "hassearch",
		MODULE_SORT_KEY_HASCONFIG   => "hasconfig",
		MODULE_SORT_KEY_HASCOMMENTS => "hascomments"
	);

	function fetch()
	{
		$this->mSpecial=isset($_REQUEST['special']) ? intval($_REQUEST['special']) : null;

		$this->mSortKey=isset($_REQUEST['sort']) ? intval($_REQUEST['sort']) : 0;

		if($this->mSortKey>MODULE_SORT_KEY_MAXVALUE)
			$this->mSortKey=0;
	}

	function getSort()
	{
		$sortkey=abs($this->mSortKey);
		return $this->_mSortKeys[$sortkey];
	}
	
	function getOrder()
	{
		return ($this->mSortKey < 0) ? "DESC" : "ASC";
	}
}

?>