/** * Запускает евент на выполнение * Если текущий евент не определен то запускается тот которые определен по умолчанию(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(); }
/** * Запускает евент на выполнение * Если текущий евент не определен то запускается тот которые определен по умолчанию(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']; $this->Hook_Run("action_event_" . strtolower($this->sCurrentAction) . "_before", array('event' => $this->sCurrentEvent, 'params' => $this->GetParams())); $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(); }
$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')); if (preg_match('@^' . $sPreg . '$@iu', $sUrlRequest)) { Router::SetAction(Router::getInstance()->Rewrite('blog')); Router::SetActionEvent('_show_topic_url'); Router::SetParams(array()); /** * Хак - через конфиг передаем нужные параметры в обработчик эвента * Модуль кеша здесь нельзя использовать, т.к. еще не произошло инициализации ядра */ Config::Set('module.topic._router_topic_original_url', $sUrlRequest); } })); /** * Проверяем наличие директории install */ if (is_dir(rtrim(Config::Get('path.application.server'), '/') . '/install') && (!isset($_SERVER['HTTP_APP_ENV']) or $_SERVER['HTTP_APP_ENV'] != 'test')) { $sUrl = rtrim(str_replace('index.php', '', $_SERVER['PHP_SELF']), '/\\') . '/application/install/'; header('Location: ' . $sUrl, true, 302); exit;