diff --git a/frontend/components/UrlManager.php b/frontend/components/UrlManager.php index 6c70334..3c5da8a 100644 --- a/frontend/components/UrlManager.php +++ b/frontend/components/UrlManager.php @@ -48,7 +48,7 @@ parent::__construct($config); } - + /** * @param \yii\web\Request $request * @@ -58,7 +58,7 @@ */ public function parseRequest($request) { - $this->checkRedirect($request->url); + // $this->checkRedirect($request->url); $request = $this->parseLanguage($request); /** @@ -77,7 +77,7 @@ ) ->one(); - if ($alias !== NULL) { + if ($alias !== null) { $params = Json::decode($alias->route); $route = array_shift($params); @@ -105,27 +105,29 @@ */ public function createUrl($params) { + if ($this->hideDefaultLanguagePrefix && ( $this->languages->getCurrent( + )->url == $this->languages->getDefault()->url )) { + $prefix = ''; + } else { + $prefix = '/' . $this->languages->getCurrent()->url; + } + if (isset($params[ 'alias' ])) { if ($params[ 'alias' ] instanceof Alias) { - return '/' . $this->languages->getCurrent()->url . '/' . $params[ 'alias' ]->value; + return $prefix . '/' . $params[ 'alias' ]->value; } elseif (is_array($params[ 'alias' ])) { - return '/' . $this->languages->getCurrent()->url . '/' . $params[ 'alias' ][ 'value' ]; + return $prefix . '/' . $params[ 'alias' ][ 'value' ]; } } - if ($this->hideDefaultLanguagePrefix && ( $this->languages->getCurrent( - )->url == $this->languages->getDefault()->url )) { - return parent::createUrl($params); - } else { - return '/' . $this->languages->getCurrent()->url . parent::createUrl($params); - - } + return $prefix . parent::createUrl($params); } /** - * @param Request $request + * @param $request * - * @return Request + * @return mixed + * @throws \yii\base\ExitException * @throws \yii\base\InvalidConfigException */ protected function parseLanguage($request) @@ -137,6 +139,7 @@ \Yii::$app->response->redirect('/' . implode('/', $split), 301) ->send(); + \Yii::$app->end(); } else { $this->languages->setCurrent($split[ 0 ]); @@ -153,6 +156,7 @@ 301 ) ->send(); + \Yii::$app->end(); } } diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 797f37d..f91e998 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -1,12 +1,12 @@ user->identity; $seo = Yii::$app->get('seo'); @@ -36,19 +36,19 @@ $default_controller = Yii::$app->defaultRoute; $isHome = ( ( $controller->id === $default_controller ) && ( $controller->action->id === $controller->defaultAction ) ) ? true : false; $pageCategories = Category::find() - ->with( - [ - 'language', - 'pages' => function (ActiveQuery $query) { - $query->with('language.alias') - ->where(['in_menu' => true]) - ->orderBy([ 'sort' => SORT_ASC ]); - }, - ] - ) - ->where([ 'status' => true ]) - ->orderBy([ 'sort' => SORT_ASC ]) - ->all(); + ->with( + [ + 'language', + 'pages' => function (ActiveQuery $query) { + $query->with('language.alias') + ->where([ 'in_menu' => true ]) + ->orderBy([ 'sort' => SORT_ASC ]); + }, + ] + ) + ->where([ 'status' => true ]) + ->orderBy([ 'sort' => SORT_ASC ]) + ->all(); $logo = null; if ($settings->logo) { $logo_img = ImageManager::findOne($settings->logo); @@ -79,24 +79,24 @@
beginBody() ?> - ga_code)) { ?> - - + ga('create', '=$settings->ga_code?>', 'auto'); + ga('send', 'pageview'); + + + @@ -300,35 +284,35 @@ _________________________________________________________ --> 'url' => [ 'site/index' ], ]; foreach ($pageCategories as $category) { - + if (empty($category->pages)) { - continue; + continue; } $pages = []; foreach ($category->pages as $page) { - $pages[] = [ - 'label' => $page->title, - 'url' => Url::to(['alias' => $page->alias]), - ]; + $pages[] = [ + 'label' => $page->title, + 'url' => Url::to([ 'alias' => $page->alias ]), + ]; } $items[] = [ - 'label' => $category->title, - 'items' => $pages, + 'label' => $category->title, + 'items' => $pages, ]; } $items[] = [ 'label' => \Yii::t('app', 'Contacts'), 'url' => [ 'site/contact' ], ]; - $items[] = [ + $items[] = [ 'label' => \Yii::t('app', 'About'), 'url' => [ 'site/about' ], ]; - $items[] = [ + $items[] = [ 'label' => \Yii::t('app', 'Blog'), 'url' => [ 'blog/index' ], ]; - $items[] = [ + $items[] = [ 'label' => \Yii::t('app', 'Events'), 'url' => [ 'event/index' ], ]; @@ -374,36 +358,38 @@ _________________________________________________________ --> - [ - 'id' => 'feedback-modal' - ] - ]); - - $module->renderForm($this); - - ArtboxModalWidget::end(); - ?> + [ + 'id' => 'feedback-modal', + ], + ] + ); + + $module->renderForm($this); + + ArtboxModalWidget::end(); + ?>