<?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 menuViewItems extends JViewLegacy {
	function display($tmpl=null) {
        $this->menu = 'items';
		$model = $this->getModel();
		$this->app = JFactory::getApplication();
		$this->input = $this->app->input;
		$this->params = JComponentHelper::getParams('com_fwfoodmenu');

		$this->fields = array('limit', 'limitstart', 'search', 'category', 'state');
		foreach ($this->fields as $field) {
			$this->$field = (string)$this->input->getString($field);
		}
		switch ($this->getLayout()) {
			case 'edit' :
			$this->object = $model->loadObject();
			fwFoodMenuHelper::triggerEvent('onLoadMainMenu', array('com_fwfoodmenu', 'item', $this));
			break;
			default :
			$this->extra_link = '';
			$this->list = $model->loadList();
			$this->pagination = $model->getPagination();
			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', 'items', $this));
		}
		parent::display($tmpl);
	}
}
