Skip to content

Commit

Permalink
Возможность указывать дефолтные event, params и request при запросе к…
Browse files Browse the repository at this point in the history
… главной странице
  • Loading branch information
mzhelskiy committed Apr 17, 2014
1 parent 3285bf8 commit 2dfbfc1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions classes/engine/Router.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,20 @@ protected function DefineActionClass() {
if (isset($this->aConfigRoute['page'][self::$sAction])) {

} elseif (self::$sAction===null) {
self::$sAction=$this->aConfigRoute['config']['action_default'];
self::$sAction=$this->aConfigRoute['config']['default']['action'];
if (!is_null($sEvent=$this->aConfigRoute['config']['default']['event'])) {
self::$sActionEvent=$sEvent;
}
if (is_array($aParams=$this->aConfigRoute['config']['default']['params'])) {
self::$aParams=$aParams;
}
if (is_array($aRequest=$this->aConfigRoute['config']['default']['request'])) {
foreach($aRequest as $k=>$v) {
if (!array_key_exists($k,$_REQUEST)) {
$_REQUEST[$k]=$v;
}
}
}
} else {
//Если не находим нужного класса то отправляем на страницу ошибки
self::$sAction=$this->aConfigRoute['config']['action_not_found'];
Expand Down Expand Up @@ -491,7 +504,7 @@ static public function GetPath($sAction) {
}
// Если пользователь запросил action по умолчанию
$sPage = ($sAction == 'default')
? self::getInstance()->aConfigRoute['config']['action_default']
? self::getInstance()->aConfigRoute['config']['default']['action']
: $sAction;
$aUrl=explode('/',$sPage);
$sPage=array_shift($aUrl);
Expand Down
5 changes: 4 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@
$config['router']['page']['error'] = 'ActionError';
$config['router']['page']['index'] = 'ActionIndex';
// Глобальные настройки роутинга
$config['router']['config']['action_default'] = 'index';
$config['router']['config']['default']['action'] = 'index';
$config['router']['config']['default']['event'] = null;
$config['router']['config']['default']['params'] = null;
$config['router']['config']['default']['request'] = null;
$config['router']['config']['action_not_found'] = 'error';

$config['head']['default']['js'] = array(
Expand Down

0 comments on commit 2dfbfc1

Please sign in to comment.