public function Init() { $this->Viewer_SetResponseAjax(true); $this->sEvent = Router::GetActionEvent(); //$this->SetDefaultEvent($this->sEvent); $this->SetDefaultEvent('file'); }
/** * Запускает евент на выполнение * Если текущий евент не определен то запускается тот которые определен по умолчанию(default event) * * @return unknown */ public function ExecEvent() { $this->sCurrentEvent = Router::GetActionEvent(); if ($this->sCurrentEvent == null) { $this->sCurrentEvent = $this->GetDefaultEvent(); Router::SetActionEvent($this->sCurrentEvent); } foreach ($this->aRegisterEvent as $aEvent) { if (preg_match($aEvent['preg'], $this->sCurrentEvent, $aMatch)) { $this->aParamsEventMatch['event'] = $aMatch; $this->aParamsEventMatch['params'] = array(); foreach ($aEvent['params_preg'] as $iKey => $sParamPreg) { if (preg_match($sParamPreg, $this->GetParam($iKey, ''), $aMatch)) { $this->aParamsEventMatch['params'][$iKey] = $aMatch; } else { continue 2; } } $sCmd = '$result=$this->' . $aEvent['method'] . '();'; $this->Hook_Run("action_event_" . strtolower($this->sCurrentAction) . "_before", array('event' => $this->sCurrentEvent, 'params' => $this->GetParams())); eval($sCmd); $this->Hook_Run("action_event_" . strtolower($this->sCurrentAction) . "_after", array('event' => $this->sCurrentEvent, 'params' => $this->GetParams())); return $result; } } return $this->EventNotFound(); }
public function RegisterHook() { if (ACE::IsMobile()) { return; } if (Config::Get('plugin.' . $this->sPlugin . '.skin')) { $this->sSkinName = Config::Get('plugin.' . $this->sPlugin . '.skin'); } Config::Set('path.admin.skin', '___path.root.web___/plugins/aceadminpanel/templates/skin/admin_' . $this->sSkinName); $sActionEvent = Router::GetActionEvent(); if (Router::GetAction() == 'admin') { if (Config::Get('plugin.aceadminpanel.compatible.default') == 'compatible') { $bCompatible = !in_array($sActionEvent, ACE::Str2Array(Config::Get('plugin.aceadminpanel.autonomous.events'))); } else { $bCompatible = (!$sActionEvent or in_array($sActionEvent, $this->aCompatibleEvents) or in_array($sActionEvent, ACE::Str2Array(Config::Get('plugin.aceadminpanel.compatible.events')))); } if ($bCompatible) { $this->_preInit(); } } $this->_checkSkinDir(); $this->AddHook('engine_init_complete', 'EngineInitComplete', __CLASS__, 1000); $this->AddHook('init_action', 'InitAction', __CLASS__, 1000); $this->AddHook('template_html_head_end', 'HtmlHeadEnd', __CLASS__); $this->AddHook('template_statistics_performance_item', 'TplStatisticsPerformanceItem', __CLASS__); $this->AddHook('template_profile_sidebar_end', 'TplProfileSidebarEnd', __CLASS__); }
protected function _EventPluginsMenu() { $this->PluginDelBlock('right', 'AdminInfo'); $sEvent = Router::GetActionEvent(); if (isset($this->aExternalEvents[$sEvent])) { return $this->EventPluginsExec($this->aExternalEvents[$sEvent]); } }
public function ShutdownAddRating($aParams) { $aBonuses = Config::Get('plugin.ratingbonus.action_bonus'); $oCurrentUser = $this->User_GetUserCurrent(); if (isset($oCurrentUser)) { if (isset($aBonuses[Router::GetActionEvent()]) && isset($aBonuses[Router::GetActionEvent()][Router::GetActionEventName()])) { $sTag = Router::GetActionEvent() . '_' . Router::GetActionEventName(); $oCurrentUser = $this->PluginRatingbonus_Ratingbonus_AddBonus($oCurrentUser, $sTag, $aBonuses[Router::GetActionEvent()][Router::GetActionEventName()]); } $this->User_Update($oCurrentUser); } }
public function WriteActionCounter($aParams) { $sAction = Router::GetAction(); $sEvent = Router::GetActionEvent(); if (!$sEvent) { $sEvent = 'default'; } $oUser = $this->User_GetUserCurrent(); if ($oUser) { $this->PluginBotchecker_Botchecker_writeActionCounter($oUser, $sAction, $sEvent); } }
protected function EventIndex() { $sLanguage = Router::GetActionEvent(); if ($sLanguage) { $this->Session_Set('language', $sLanguage); if (Config::Get('plugin.aceadminpanel.lang_save_period')) { @setcookie('LANG_CURRENT', $sLanguage, time() + 60 * 60 * 24 * intVal(Config::Get('plugin.aceadminpanel.lang_save_period')), Config::Get('sys.cookie.path'), Config::Get('sys.cookie.host')); } if (isset($_SERVER['HTTP_REFERER'])) { func_header_location($_SERVER['HTTP_REFERER']); } } func_header_location(Config::Get('path.root.web')); }
/** * Check user rights * * @return booblean */ protected function CheckUserRights() { $oUser = $this->User_GetUserCurrent(); //Current user // если необходимо - можно будет вынести в конфиг список Events, доступ к которым необходим всем if (Router::GetActionEvent() == 'redirect') { return true; } if (!$oUser || !$oUser->isAdministrator()) { //Test user rigts return false; } return true; }
public function CheckSearch($aVars) { if (!MYSEARCH_HOOK_ENABLE) { return; } if (Router::GetAction() == 'search') { if (getRequest('q') && isset($_SERVER["HTTP_REFERER"]) && preg_match('|/search/(\\w+)/|', $_SERVER["HTTP_REFERER"], $m)) { $sActionEvent = $m[1]; } else { $sActionEvent = Router::GetActionEvent(); } Router::Action('mysearch', $sActionEvent, Router::GetParams()); } }
public function Init() { $this->sCurrentEvent = Router::GetActionEvent(); if ($result = parent::Init()) { return $result; } if ($this->User_IsAuthorization()) { $this->oUserCurrent = $this->PluginAceadminpanel_Admin_GetUserCurrent(); } if (!$this->oUserCurrent or !$this->oUserCurrent->isAdministrator()) { return $this->EventDenied(); } if (!$this->oUserCurrent) { $this->oUserCurrent = $this->User_GetUserCurrent(); } $this->Viewer_Assign('ROUTE_PAGE_ADMIN', ROUTE_PAGE_ADMIN); $this->Viewer_Assign('sModuleVersion', $this->PluginAceadminpanel_Admin_getVersion(true)); $this->_InitParams(); $this->aConfig = array_merge($this->aConfig, HelperPlugin::GetConfig()); if (Config::Get('plugin.avalogs.admin_file') and Config::Get('plugin.avalogs.admin_enable')) { if (!$this->oLogs) { $this->oLogs = $this->Adminlogs_GetLogs(); } $this->oLogs->SetLogOptions('admin', array('file' => Config::Get('plugin.avalogs.admin_file'))); $this->aLogsMsg[] = 'user=>' . $this->oUserCurrent->GetLogin() . ', ip=>' . $_SERVER["REMOTE_ADDR"] . ', action=>' . Router::GetAction() . ', event=>' . Router::GetActionEvent() . ', path=>' . Router::GetPathWebCurrent(); } $this->sPageRef = ACE::Backward('url'); if (ACE::Backward('action') == Router::GetAction()) { $this->sFormAction = $this->sPageRef; } //$this->_PluginSetTemplate(Router::GetActionEvent()); $this->sMenuItemSelect = Router::GetActionEvent(); $this->sMenuSubItemSelect = Router::GetParam(0); $sVerion = HelperPlugin::GetConfig('version'); if (!$sVerion) { $sVerion = ACEADMINPANEL_VERSION . '.' . ACEADMINPANEL_VERSION_BUILD; } if (preg_match('|[a-z\\-]+|i', $sVerion, $m)) { $sVerion = str_replace($m[0], '', $sVerion) . $m[0]; } $this->aPluginInfo = array('version' => $sVerion); $sHtmlTitle = $this->Lang_Get('adm_title') . ' v.' . $this->PluginAceadminpanel_Admin_getVersion(); //$this->Viewer_AddTemplateDir(HelperPlugin::GetTemplatePath(), true); $this->Viewer_AddHtmlTitle($sHtmlTitle); $this->Viewer_Assign('sAdminTitle', 'aceAdminPanel v.' . $this->PluginAceadminpanel_Admin_getVersion()); }
/** * Инициализация * */ public function Init() { /** * Если включены инвайты то перенаправляем на страницу регистрации по инвайтам */ if (!$this->User_IsAuthorization() and Config::Get('general.reg.invite') and in_array(Router::GetActionEvent(), array('register', 'ajax-register')) and !$this->CheckInviteRegister()) { return Router::Action('auth', 'invite'); } /** * Устанавливаем дефолтный евент */ $this->SetDefaultEvent('login'); /** * Отключаем отображение статистики выполнения */ Router::SetIsShowStats(false); }
/** * Инициализация * * @return unknown */ public function Init() { /** * Проверяем аторизован ли юзер */ if ($this->User_IsAuthorization()) { $this->Message_AddErrorSingle($this->Lang_Get('registration_is_authorization'), $this->Lang_Get('attention')); return Router::Action('error'); } /** * Если включены инвайты то перенаправляем на страницу регистрации по инвайтам */ if (!$this->User_IsAuthorization() and Config::Get('general.reg.invite') and !in_array(Router::GetActionEvent(), array('invite', 'activate', 'confirm')) and !$this->CheckInviteRegister()) { return Router::Action('registration', 'invite'); } $this->SetDefaultEvent('index'); $this->Viewer_AddHtmlTitle($this->Lang_Get('registration')); }
public function RegisterHook() { if (Config::Get('plugin.' . $this->sPlugin . '.skin')) { $this->sSkinName = Config::Get('plugin.' . $this->sPlugin . '.skin'); } Config::Set('path.admin.skin', '___path.root.web___/plugins/aceadminpanel/templates/skin/admin_' . $this->sSkinName); $sActionEvent = Router::GetActionEvent(); if (Router::GetAction() == 'admin') { if (Config::Get('plugin.aceadminpanel.compatible.default') == 'compatible') { $bCompatible = !in_array($sActionEvent, ACE::Str2Array(Config::Get('plugin.aceadminpanel.autonomous.events'))); } else { $bCompatible = (!$sActionEvent or in_array($sActionEvent, $this->aCompatibleEvents) or in_array($sActionEvent, ACE::Str2Array(Config::Get('plugin.aceadminpanel.compatible.events')))); } if ($bCompatible) { $this->_preInit(); } } $this->AddHook('engine_init_complete', 'EngineInitComplete', __CLASS__, 1000); $this->AddHook('init_action', 'InitAction', __CLASS__, 1000); $this->AddHook('template_html_head_end', 'HtmlHeadEnd', __CLASS__); $this->AddHook('template_body_end', 'MemoryStats', __CLASS__); }
protected function EventSeopackEdit() { $this->sMainMenuItem = 'content'; $this->_setTitle(E::ModuleLang()->Get('plugin.seopack.seopack_title')); if (F::isPost('submit_seopack_save')) { $this->SubmitSaveSeopack(); } E::ModuleViewer()->Assign('sMode', str_replace('seopack', '', Router::GetActionEvent())); if (Router::GetActionEvent() == 'seopackedit') { if ($oSeopack = E::ModuleSeopack()->GetSeopackBySeopackId($this->GetParam(0))) { if (!F::isPost('submit_seopack_save')) { $_REQUEST['url'] = $oSeopack->getUrl(); $_REQUEST['title'] = $oSeopack->getTitle(); $_REQUEST['description'] = $oSeopack->getDescription(); $_REQUEST['keywords'] = $oSeopack->getKeywords(); $_REQUEST['seopack_id'] = $oSeopack->getSeopackId(); } } else { E::ModuleMessage()->AddError(E::ModuleLang()->Get('plugin.seopack.seopack_edit_notfound'), E::ModuleLang()->Get('error')); $this->SetParam(0, null); } } $this->SetTemplateAction('seopack_edit'); }
/** * Анализируем правила и наборы массивов * получаем окончательные списки блоков */ protected function BuildBlocks() { $sAction = strtolower(Router::GetAction()); $sEvent = strtolower(Router::GetActionEvent()); foreach ($this->aBlockRules as $sName => $aRule) { $bUse = false; /** * Если в правиле не указан список блоков, нам такое не нужно */ if (!array_key_exists('blocks', $aRule)) { continue; } /** * Если не задан action для исполнения и нет ни одного шаблона path, * или текущий не входит в перечисленные в правиле * то выбираем следующее правило */ if (!array_key_exists('action', $aRule) && !array_key_exists('path', $aRule)) { continue; } if (isset($aRule['action'])) { if (in_array($sAction, (array) $aRule['action'])) { $bUse = true; } if (array_key_exists($sAction, (array) $aRule['action'])) { /** * Если задан список event`ов и текущий в него не входит, * переходи к следующему действию. */ foreach ((array) $aRule['action'][$sAction] as $sEventPreg) { if (substr($sEventPreg, 0, 1) != '/') { /** * значит это название event`a */ if ($sEvent == $sEventPreg) { $bUse = true; break; } } else { /** * это регулярное выражение */ if (preg_match($sEventPreg, $sEvent)) { $bUse = true; break; } } } } } /** * Если не найдено совпадение по паре Action/Event, * переходим к поиску по regexp путей. */ if (!$bUse && isset($aRule['path'])) { $sPath = rtrim(Router::GetPathWebCurrent(), "/"); /** * Проверяем последовательно каждый regexp */ foreach ((array) $aRule['path'] as $sRulePath) { $sPattern = "~" . str_replace(array('/', '*'), array('\\/', '[\\w\\-]+'), $sRulePath) . "~"; if (preg_match($sPattern, $sPath)) { $bUse = true; break 1; } } } if ($bUse) { /** * Если задан режим очистки блоков, сначала чистим старые блоки */ if (isset($aRule['clear'])) { switch (true) { /** * Если установлен в true, значит очищаем все */ case $aRule['clear'] === true: $this->ClearBlocksAll(); break; case is_string($aRule['clear']): $this->ClearBlocks($aRule['clear']); break; case is_array($aRule['clear']): foreach ($aRule['clear'] as $sGroup) { $this->ClearBlocks($sGroup); } break; } } /** * Добавляем все блоки, указанные в параметре blocks */ foreach ($aRule['blocks'] as $sGroup => $aBlocks) { foreach ((array) $aBlocks as $sName => $aParams) { /** * Если название блока указывается в параметрах */ if (is_int($sName)) { if (is_array($aParams)) { $sName = $aParams['block']; } } /** * Если $aParams не являются массивом, значит передано только имя блока */ if (!is_array($aParams)) { $this->AddBlock($sGroup, $aParams); } else { $this->AddBlock($sGroup, $sName, isset($aParams['params']) ? $aParams['params'] : array(), isset($aParams['priority']) ? $aParams['priority'] : 5); } } } } } return true; }
public function VarAssign() { $this->_extSortBlocks(); parent::VarAssign(); $aPlugins = $this->Plugin_GetActivePlugins(); $plugins = array(); foreach ($aPlugins as $sPlugin) { $plugins[$sPlugin] = array('skin' => array('name' => HelperPlugin::GetPluginSkin($sPlugin), 'path' => HelperPlugin::GetPluginSkinPath($sPlugin), 'url' => HelperPlugin::GetPluginSkinUrl($sPlugin)), 'config' => Config::Get('plugin.' . $sPlugin)); } $ls = array('site' => array('skin' => array('name' => Config::Get($this->sPlugin . '.saved.view.skin') ? Config::Get($this->sPlugin . '.saved.view.skin') : Config::Get('view.skin'), 'path' => Config::Get($this->sPlugin . '.saved.path.smarty.template') ? Config::Get($this->sPlugin . '.saved.path.smarty.template') : Config::Get('path.smarty.template'), 'url' => Config::Get($this->sPlugin . '.saved.path.static.skin') ? Config::Get($this->sPlugin . '.saved.path.static.skin') : Config::Get('path.static.skin'))), 'js' => array('lib' => Config::Get('js.lib'), 'jquery' => Config::Get('js.jquery'), 'mootools' => Config::Get('js.mootools')), 'router' => array('action' => Router::GetAction(), 'event' => Router::GetActionEvent(), 'param' => Router::GetParams()), 'url' => $this->oSmarty->getTemplateVars('aRouter'), 'plugin' => $plugins); $this->AssignArray('ls', $ls); }
/** * Запускает евент на выполнение * Если текущий евент не определен то запускается тот которые определен по умолчанию(default event) * * @return mixed */ public function ExecEvent() { $this->sCurrentEvent = Router::GetActionEvent(); if ($this->sCurrentEvent == null) { $this->sCurrentEvent = $this->GetDefaultEvent(); Router::SetActionEvent($this->sCurrentEvent); } foreach ($this->aRegisterEvent as $aEvent) { if (preg_match($aEvent['preg'], $this->sCurrentEvent, $aMatch)) { $this->aParamsEventMatch['event'] = $aMatch; $this->aParamsEventMatch['params'] = array(); foreach ($aEvent['params_preg'] as $iKey => $sParamPreg) { if (preg_match($sParamPreg, $this->GetParam($iKey, ''), $aMatch)) { $this->aParamsEventMatch['params'][$iKey] = $aMatch; } else { continue 2; } } $this->sCurrentEventName = $aEvent['name']; if ($aEvent['external']) { if (!isset($this->aRegisterEventExternal[$aEvent['external']])) { throw new Exception("External processing for event not found: " . $aEvent['external']); } } $this->Hook_Run("action_event_" . strtolower($this->sCurrentAction) . "_before", array('event' => $this->sCurrentEvent, 'params' => $this->GetParams())); /** * Проверяем на наличие внешнего обработчика евента */ if ($aEvent['external']) { $sEventClass = $this->Plugin_GetDelegate('event', $this->aRegisterEventExternal[$aEvent['external']]); $oEvent = new $sEventClass(); $oEvent->SetActionObject($this); $oEvent->Init(); if (!$aEvent['method']) { $result = $oEvent->Exec(); } else { $result = call_user_func_array(array($oEvent, $aEvent['method']), array()); } } else { $result = call_user_func_array(array($this, $aEvent['method']), array()); } $this->Hook_Run("action_event_" . strtolower($this->sCurrentAction) . "_after", array('event' => $this->sCurrentEvent, 'params' => $this->GetParams())); return $result; } } return $this->EventNotFound(); }
private function MakePaging($iCount) { $this->iResultCount = $iCount; return $this->Viewer_MakePaging($iCount, $this->iCurrentPage, $this->iPerPage, Config::Get('pagination.pages.count'), Router::GetPath('search') . strtolower(Router::GetActionEvent()), array('q' => $this->OriginalQuerySafe, 'blogid' => $this->iSearchInOneBlogSelected, 'favorite' => (bool) $this->iFavoriteUserId)); }
/** * Подготовка запроса на поиск * * @return array */ protected function PrepareRequest() { $aReq['q'] = F::GetRequestStr('q'); if (!F::CheckVal($aReq['q'], 'text', 2, 255)) { /* * Если запрос слишком короткий перенаправляем на начальную страницу поиска * Хотя тут лучше показывать юзеру в чем он виноват */ Router::Location(Router::GetPath('search')); } $aReq['sType'] = strtolower(Router::GetActionEvent()); // * Определяем текущую страницу вывода результата $aReq['iPage'] = intval(preg_replace('#^page([1-9]\\d{0,5})$#', '\\1', $this->getParam(0))); if (!$aReq['iPage']) { $aReq['iPage'] = 1; } // * Передача данных в шаблонизатор E::ModuleViewer()->Assign('aReq', $aReq); return $aReq; }
protected function EventInfo() { $this->sMenuItemSelect = Router::GetActionEvent(); if ($this->GetParam(0) == 'phpinfo') { $this->EventInfoPhpInfo(1); } elseif ($this->GetParam(0) == 'params') { $this->EventInfoParams(); } else { $this->sMenuSubItemSelect = 'about'; $this->PluginSetTemplate('info_about'); //$this->SetTemplate(HelperPlugin::GetTemplateActionPath('info_about.tpl')); } $aSiteStat = $this->PluginAceAdminPanel_Admin_GetSiteStat(); $this->PluginAddBlock('right', 'admin_info'); $aPlugins = $this->Plugin_GetList(); $this->Viewer_Assign('aSiteStat', $aSiteStat); $this->Viewer_Assign('aPlugins', $aPlugins); }
/** * Загружает виджеты, указанные в правилах * * @return mixed */ protected function _loadWidgetsList() { $aResult = parent::_loadWidgetsList(); // добавляем LS-блоки по старым правилам, если они есть $aBlockRules = Config::Get('block'); if ($aBlockRules) { $sAction = strtolower(Router::GetAction()); $sEvent = strtolower(Router::GetActionEvent()); $sEventName = strtolower(Router::GetActionEventName()); foreach ($aBlockRules as $aRule) { $bUse = false; // * Если в правиле не указан список блоков, нам такое не нужно if (!array_key_exists('blocks', $aRule)) { continue; } /* * Если не задан action для исполнения и нет ни одного шаблона path, * или текущий не входит в перечисленные в правиле * то выбираем следующее правило */ if (!array_key_exists('action', $aRule) && !array_key_exists('path', $aRule)) { continue; } if (isset($aRule['action'])) { if (in_array($sAction, (array) $aRule['action'])) { $bUse = true; } if (array_key_exists($sAction, (array) $aRule['action'])) { /** * Если задан список event`ов и текущий в него не входит, * переходи к следующему действию. */ foreach ((array) $aRule['action'][$sAction] as $sEventPreg) { if (substr($sEventPreg, 0, 1) == '/') { // * Это регулярное выражение if (preg_match($sEventPreg, $sEvent)) { $bUse = true; break; } } elseif (substr($sEventPreg, 0, 1) == '{') { // * Это имя event'a (именованный евент, если его нет, то совпадает с именем метода евента в экшене) if (trim($sEventPreg, '{}') == $sEventName) { $bUse = true; break; } } else { // * Это название event`a if ($sEvent == $sEventPreg) { $bUse = true; break; } } } } } // * Если не найдено совпадение по паре Action/Event, то переходим к поиску по regexp путей. if (!$bUse && isset($aRule['path'])) { $sPath = rtrim(Router::GetPathWebCurrent(), "/"); // * Проверяем последовательно каждый regexp foreach ((array) $aRule['path'] as $sRulePath) { $sPattern = "~" . str_replace(array('/', '*'), array('\\/', '[\\w\\-]+'), $sRulePath) . "~"; if (preg_match($sPattern, $sPath)) { $bUse = true; break 1; } } } if ($bUse) { // * Если задан режим очистки блоков, сначала чистим старые блоки if (isset($aRule['clear'])) { switch (true) { // * Если установлен в true, значит очищаем все case $aRule['clear'] === true: //$this->ClearBlocksAll(); $aResult = array(); break; case is_string($aRule['clear']): //$this->ClearBlocks($aRule['clear']); foreach ($aResult as $sId => $oWidget) { if ($oWidget->GetGroup() == $aRule['clear']) { unset($aResult[$sId]); } } break; case is_array($aRule['clear']): /* foreach ($aRule['clear'] as $sGroup) { $this->ClearBlocks($sGroup); } */ foreach ($aResult as $sId => $oWidget) { if (in_array($oWidget->GetGroup(), $aRule['clear'])) { unset($aResult[$sId]); } } break; } } // * Добавляем все блоки, указанные в параметре blocks foreach ($aRule['blocks'] as $sGroup => $aBlocks) { foreach ((array) $aBlocks as $sName => $aParams) { // * Если название блока указывается в параметрах if (is_int($sName)) { if (is_array($aParams)) { $sName = $aParams['block']; } } // * Если $aParams не являются массивом, значит передано только имя блока if (!is_array($aParams)) { $sName = $aParams; $aParams = array(); $nPriority = isset($aParams['priority']) ? $aParams['priority'] : 5; } else { $nPriority = isset($aParams['priority']) ? $aParams['priority'] : 5; $aParams = isset($aParams['params']) ? $aParams['params'] : array(); } $aWidgetData = array('name' => $sName, 'group' => $sGroup, 'priority' => $nPriority, 'params' => $aParams); $oWidget = $this->MakeWidget($aWidgetData); $aResult[$oWidget->getId()] = $oWidget; } } } } } return $aResult; }
/** * Подготовка запроса на поиск * * @return unknown */ private function PrepareRequest() { $aReq['q'] = getRequest('q'); if (!func_check($aReq['q'], 'text', 2, 255)) { /** * Если запрос слишком короткий перенаправляем на начальную страницу поиска * Хотя тут лучше показывать юзеру в чем он виноват */ Router::Location(Router::GetPath('search')); } $aReq['sType'] = strtolower(Router::GetActionEvent()); /** * Определяем текущую страницу вывода результата */ $aReq['iPage'] = intval(preg_replace('#^page(\\d+)$#', '\\1', $this->getParam(0))); if (!$aReq['iPage']) { $aReq['iPage'] = 1; } /** * Передача данных в шаблонизатор */ $this->Viewer_Assign('aReq', $aReq); return $aReq; }
* Определяем дополнительные параметры роутинга */ $aRouterParams = array('callback_after_parse_url' => array(function () { /** * Логика по ЧПУ топиков * Если URL соответствует шаблону ЧПУ топика, перенаправляем обработку на экшен/евент /blog/_show_topic_url/ * Через свои параметры конфига передаем исходный URL * Суть обработки _show_topic_url в том, чтобы определить ID топика и корректность его URL, если он некорректен, то произвести его корректировку через внешний редирект на правильный URL * Если удалось определить топик и URL корректный, то происходит внутренний редирект на стандартный евент отображения топика по ID (/blog/12345.html) */ $sUrlRequest = ''; if (Router::GetAction()) { $sUrlRequest .= Router::GetAction(); } if (Router::GetActionEvent()) { $sUrlRequest .= '/' . Router::GetActionEvent(); } if (Router::GetParams()) { $sUrlRequest .= '/' . join('/', Router::GetParams()); } /** * Функция для формирования регулярного выражения по маске URL топика * * @param string $sUrl * @return string */ $funcMakePreg = function ($sUrl) { $sUrl = preg_quote(trim($sUrl, '/ ')); return strtr($sUrl, Config::Get('module.topic.url_preg')); }; $sPreg = $funcMakePreg(Config::Get('module.topic.url'));
/** * Восстановление сохраненного скина, чтобы сторонние плагины могли создать свою собственную админику * * @param $aEvents */ static function RestoreAdminSkin($aEvents) { if (Config::Get('saved')) { if ($aEvents and !is_array($aEvents)) { $aEvents = array_map('trim', explode(',', $aEvents)); } else { $aEvents = (array) $aEvents; } if (Router::GetAction() == 'admin' and (!$aEvents or in_array(Router::GetActionEvent(), $aEvents))) { if (Config::Get('saved.view.skin')) { Config::Set('view.skin', Config::Get('saved.view.skin')); } if (Config::Get('saved.path.smarty.template')) { Config::Set('path.smarty.template', Config::Get('saved.path.smarty.template')); } if (Config::Get('saved.path.static.skin')) { Config::Set('path.static.skin', Config::Get('saved.path.static.skin')); } } } }
/** * Обработка основного события */ public function EventIndex() { $sEvent = Router::GetActionEvent(); if ($sEvent == 'comments') { $this->EventComments(); } elseif ($sEvent == 'blogs') { $this->EventBlogs(); } else { $this->EventTopics(); } }
protected function EventPluginsMenu() { $this->PluginSetTemplate('plugins'); $this->PluginDelBlock('right', 'admin_info'); $sEvent = Router::GetActionEvent(); if (isset($this->aExternalEvents[$sEvent])) { return $this->EventPluginsExec($this->aExternalEvents[$sEvent]); } }