<?php
class BS_FFECS_XenForo_ControllerPublic_Forum extends XFCP_BS_FFECS_XenForo_ControllerPublic_Forum
{
use BS_Init_Main;
public function actionForum()
{
$forumId = $this->filter('node_id', 'uint');
$forumName = $this->filter('node_name', 'string');
$ftpHelper = $this->getHelper('ForumThreadPost');
$forum = $this->getHelper('ForumThreadPost')->assertForumValidAndViewable(
$forumId ? $forumId : $forumName,
$this->_getForumFetchOptions()
);
if ($forum['estcs_type'] === 1)
{
$userId = $this->visitorId();
$GLOBALS['ffecs_type'] = XenForo_Helper_Cookie::getCookie('ffecs_type') && $userId ?
XenForo_Helper_Cookie::getCookie('ffecs_type') : 'all';
$GLOBALS['ffecs_type_state'] = XenForo_Helper_Cookie::getCookie('ffecs_type_state') && $userId ?
XenForo_Helper_Cookie::getCookie('ffecs_type_state') : 'all';
if ($ffecs = $this->filter('ffecs', 'string'))
{
$GLOBALS['ffecs'] = $ffecs;
}
$ffecsPhrases = $this->_getFfecsPhrases();
$ffecsTypePhrases = $this->_getFfecsTypePhrases();
$parent = parent::actionForum();
if ($parent instanceof XenForo_ControllerResponse_View)
{
$params = &$parent->params;
$params['ffecsFilter'] = isset($ffecsPhrases[$ffecs]) ?
$this->phrase($ffecsPhrases[$ffecs]) :
$this->phrase($ffecsPhrases['default']);
$params['ffecsType'] = isset($ffecsTypePhrases[$GLOBALS['ffecs_type']]) ?
$this->phrase($ffecsTypePhrases[$GLOBALS['ffecs_type']]) :
$this->phrase($ffecsTypePhrases['all']);
$params['ffecsTypeState'] = ($GLOBALS['ffecs_type_state'] === 'all') ?
$this->phrase('all') :
$this->phrase('ffecs_filter_type_state_' . $GLOBALS['ffecs_type_state']);
$params['ffescTypeStateEnable'] = ($GLOBALS['ffecs_type'] === 'visitor');
if (!empty($ffecs))
{
$params['pageNavParams'] += ['ffecs' => $ffecs];
}
}
return $parent;
}
return parent::actionForum();
}
protected function _getFfecsPhrases()
{
return [
'default' => 'ffecs_filter_stage',
'open' => 'estcs_shopping_stage_open',
'active' => 'estcs_notice_type_active',
'finished' => 'estcs_shopping_stage_finished',
'closed' => 'ffecs_stage_closed'
];
}
protected function _getFfecsTypePhrases()
{
return [
'all' => 'ffecs_filter_all_cs',
'visitor' => 'ffecs_filter_type_visitor'
];
}
}