<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
jimport('joomla.html.html');
jimport('joomla.html.behavior');
JHTML::_('behavior.modal');
/**
 * MarketplaceViewSuggestedcategory class
 * 
 * @category Component
 * @package  Joomla
 * @author   WebKul software private limited <support@webkul.com>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link     Technical Support:  webkul.uvdesk.com
 */
class MarketplaceViewSuggestedcategory extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    public $seller_info;
    /**
     * Display function
     *
     * @param [type] $tpl var
     * 
     * @return void
     */
    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');
        $this->form=$this->get('form');
        if ($this->getLayout() == 'sendmail_category') {
            $input = JFactory::getApplication()->input;
            $eName = $input->getCmd('e_name');
            $eName = preg_replace('#[^A-Z0-9\-\_\[\]]#i', '', $eName);
            $document = JFactory::getDocument();
            $document->setTitle(JText::_('COM_MARKETPLACE_SENDMAIL_TITLE'));
            $this->eName = &$eName;
            parent::display($tpl);
            return;
        } else {
            if (count($errors = $this->get('Errors'))) {
                JError::raiseError(500, implode('<br />', $errors));
                return false;
            }
            $this->addToolBar();
            $this->sidebar = JHtmlSidebar::render();
            parent::display($tpl);
        }
    }

    /**
     * AddToolBar function
     *
     * @return void
     */
    protected function addToolBar() 
    {
        include_once JPATH_COMPONENT . '/helpers/marketplace.php';
        JToolBarHelper::title(JText::_('SSUGGESTED_CATEGORY'), 'suggested Category');
        JToolbarHelper::publish(
            'suggestedcategory.createCategory', JText::_('PUBLISH_REQUEST'), true
        );
        JToolbarHelper::unpublish(
            'suggestedcategory.deteteCategory', JText::_('UNPUBLISH_REQUEST'), true
        );
        JToolbarHelper::custom(
            'suggestedcategory.mailtoseller', 'mailtoseller',
            '', 'MAIL_TO_SELLER', true
        );
        JToolBarHelper::preferences('com_marketplace');
        JHtmlSidebar::setAction(
            'index.php?option=com_marketplace&view=suggestedcategory'
        );
    }
}
