<?php
namespace Joomla\Component\Panggilan\Administrator\View\Items;

use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;

defined('_JEXEC') or die;

class HtmlView extends BaseHtmlView
{
    protected $items;
    protected $pagination;
    protected $state;
    public $filterForm;
    public $activeFilters;

    public function display($tpl = null)
    {
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');
        $this->filterForm = $this->get('FilterForm');
        $this->activeFilters = $this->get('ActiveFilters');

        $errors = $this->get('Errors');
        if (is_array($errors) && count($errors)) {
            throw new \Exception(implode("\n", $errors), 500);
        }

        $this->addToolbar();
        parent::display($tpl);
    }

    protected function addToolbar()
    {
        ToolbarHelper::title('Panggilan Sidang', 'file-alt');
        ToolbarHelper::addNew('item.add');
        ToolbarHelper::editList('item.edit');
        ToolbarHelper::publish('items.publish', 'JTOOLBAR_PUBLISH', true);
        ToolbarHelper::unpublish('items.unpublish', 'JTOOLBAR_UNPUBLISH', true);
        ToolbarHelper::deleteList('', 'items.delete');
        ToolbarHelper::preferences('com_panggilan');
    }
}
