<?php
/**
 * FW Food menu 5.1.1
 * @copyright (C) 2020 Fastw3b
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link http://www.fastw3b.net/ Official website
 **/

defined( '_JEXEC' ) or die( 'Restricted access' );

class menuViewCategory extends JViewLegacy {
	function display($tmpl=null) {
		$this->menu = 'category';
		$model = $this->getModel();
		$this->app = JFactory::getApplication();
		$this->input = $this->app->input;
		$this->fields = array('search', 'user', 'state', 'category', 'limit', 'limitstart');
        foreach ($this->fields as $field) {
            $this->$field = (string)$this->app->input->getString($field);
        }
		switch ($this->getLayout()) {
			case 'edit' :
			$this->object = $model->loadObject();
			fwFoodMenuHelper::triggerEvent('onLoadMainMenu', array('com_fwfoodmenu', 'category', $this));
			break;
			default :
			$this->list = $model->loadList();
			$this->pagination = $model->getPagination();
			$this->extra_link = '';
            foreach ($this->fields as $field) {
				if ($this->$field) {
					$this->extra_link .= '&amp;'.$field.'='.urlencode($this->$field);
    				$this->pagination->setAdditionalUrlParam($field, $this->$field);
    			}
            }
			fwFoodMenuHelper::triggerEvent('onLoadMainMenu', array('com_fwfoodmenu', 'categories', $this));
		}
		$this->params = JComponentHelper::getParams('com_fwfoodmenu');
		parent::display($tmpl);
	}
}
