<?php
/**
 * @version $Id: CategoryListAction.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/AbstractListAction.class.php';

class Myuploader_Admin_CategoryListAction extends Myuploader_AbstractListAction
{
	/**
	 * @protected
	 */
	function &_getHandler()
	{
		$handler =& $this->mAsset->getObject('handler', 'category');
		return $handler;
	}

	/**
	 * @protected
	 */
	function &_getFilterForm()
	{
		// $filter = new Myuploader_Admin_CategoryFilterForm();
        // TODO
        $mytrustdirname = $this->mAsset->mTrustDirname;
		$filter =& $this->mAsset->getObject('filter', 'category', true);
		$filter->prepare($this->_getPageNavi(), $this->_getHandler());
		return $filter;
	}

	/**
	 * @protected
	 */
	function _getBaseUrl()
	{
		return "./index.php?op=CategoryList";
	}

	/**
	 * @public
	 */
	function executeViewIndex(&$render)
	{
		$render->setTemplateName('category_list.html');
		#cubson::lazy_load_array('category', $this->mObjects);
        $cat_handler =& $this->_getHandler();
        $categoryTree = $cat_handler->getChildTreeArray();
        foreach($this->mObjects as $obj) {
        	$obj->set('cat_name', $categoryTree[$obj->get('category_id')]);
        }
        $render->setAttribute('objects', $this->mObjects);
		$render->setAttribute('pageNavi', $this->mFilter->mNavi);
        $render->setAttribute('module', $this->mModuleGlobal->mXoopsModule);
	}
}

?>