<?php
/**
 * @version $Id: CategoryFilterForm.class.php 679 2012-08-20 12:41:35Z hodaka $
 * @package myuploader
 */

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

require_once dirname(dirname(dirname(__FILE__))) . "/class/AbstractFilterForm.class.php";

define('MYUPLOADER_CATEGORY_SORT_KEY_CATEGORY_ID', 1);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_NAME', 2);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_DESCRIPTION', 3);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_MAXSIZE', 4);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_MAXLENGTH', 5);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_RESIZELENGTH', 6);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_THUMBLENGTH', 7);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_ACTIVE', 8);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_WEIGHT', 9);
define('MYUPLOADER_CATEGORY_SORT_KEY_CAT_PID', 10);
define('MYUPLOADER_CATEGORY_SORT_KEY_DEFAULT', MYUPLOADER_CATEGORY_SORT_KEY_CAT_WEIGHT);

class Myuploader_Admin_CategoryFilterForm extends Myuploader_AbstractFilterForm
{
	var $mSortKeys = array(
		MYUPLOADER_CATEGORY_SORT_KEY_CATEGORY_ID => 'category_id',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_NAME => 'cat_name',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_DESCRIPTION => 'cat_description',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_MAXSIZE => 'cat_maxsize',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_MAXLENGTH => 'cat_maxlength',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_RESIZELENGTH => 'cat_resizelength',
        MYUPLOADER_CATEGORY_SORT_KEY_CAT_THUMBLENGTH => 'cat_thumblength',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_ACTIVE => 'cat_active',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_WEIGHT => 'cat_weight',
		MYUPLOADER_CATEGORY_SORT_KEY_CAT_PID => 'cat_pid'
	);

	/**
	 * @public
	 */
	function getDefaultSortKey()
	{
		return MYUPLOADER_CATEGORY_SORT_KEY_DEFAULT;
	}

	/**
	 * @public
	 */
	function fetch()
	{
		parent::fetch();
	
		$root = XCube_Root::getSingleton();
	
		if (($value = $root->mContext->mRequest->getRequest('category_id')) !== null) {
			$this->mNavi->addExtra('category_id', $value);
			$this->_mCriteria->add(new Criteria('category_id', $value));
		}
	
		if (($value = $root->mContext->mRequest->getRequest('cat_name')) !== null) {
			$this->mNavi->addExtra('cat_name', $value);
			$this->_mCriteria->add(new Criteria('cat_name', $value));
		}
        
        if (($value = $root->mContext->mRequest->getRequest('cat_description')) !== null) {
            $this->mNavi->addExtra('cat_description', $value);
            $this->_mCriteria->add(new Criteria('cat_description', $value));
        }
        
		if (($value = $root->mContext->mRequest->getRequest('cat_maxsize')) !== null) {
			$this->mNavi->addExtra('cat_maxsize', $value);
			$this->_mCriteria->add(new Criteria('cat_maxsize', $value));
		}
	
		if (($value = $root->mContext->mRequest->getRequest('cat_maxlength')) !== null) {
			$this->mNavi->addExtra('cat_maxlength', $value);
			$this->_mCriteria->add(new Criteria('cat_maxlength', $value));
		}
	
		if (($value = $root->mContext->mRequest->getRequest('cat_resizelength')) !== null) {
			$this->mNavi->addExtra('cat_resizelength', $value);
			$this->_mCriteria->add(new Criteria('cat_resizelength', $value));
		}
    
        if (($value = $root->mContext->mRequest->getRequest('cat_thumblength')) !== null) {
            $this->mNavi->addExtra('cat_thumblength', $value);
            $this->_mCriteria->add(new Criteria('cat_thumblength', $value));
        }
	
		if (($value = $root->mContext->mRequest->getRequest('cat_active')) !== null) {
			$this->mNavi->addExtra('cat_active', $value);
			$this->_mCriteria->add(new Criteria('cat_active', $value));
		}
	
		if (($value = $root->mContext->mRequest->getRequest('cat_weight')) !== null) {
			$this->mNavi->addExtra('cat_weight', $value);
			$this->_mCriteria->add(new Criteria('cat_weight', $value));
		}
	
		if (($value = $root->mContext->mRequest->getRequest('cat_pid')) !== null) {
			$this->mNavi->addExtra('cat_pid', $value);
			$this->_mCriteria->add(new Criteria('cat_pid', $value));
		}
	
		$this->_mCriteria->addSort($this->getSort(), $this->getOrder());
	}
}

?>