Browse Source

Theme as settings param

master
Egorka 6 years ago
parent
commit
baecb73486
  1. 4
      common/modules/blog/controllers/PostController.php
  2. 4
      common/modules/pages/controllers/PageController.php
  3. 10
      docs/develope/README.md
  4. 32
      environments/prod/frontend/config/main-local.php
  5. 15
      frontend/bootstrap/SetUp.php
  6. 29
      frontend/components/FrontendController.php
  7. 4
      frontend/controllers/ContactController.php
  8. 4
      frontend/controllers/PostController.php
  9. 4
      frontend/controllers/SiteController.php
  10. 4
      frontend/controllers/auth/AuthController.php
  11. 4
      frontend/controllers/auth/NetworkController.php
  12. 4
      frontend/controllers/auth/ResetController.php
  13. 4
      frontend/controllers/auth/SignupController.php

4
common/modules/blog/controllers/PostController.php

@ -11,16 +11,16 @@ use common\modules\blog\repositories\read\BlogPostReadRepository;
use common\modules\blog\repositories\read\BlogTagReadRepository; use common\modules\blog\repositories\read\BlogTagReadRepository;
use common\modules\blog\services\BlogCommentService; use common\modules\blog\services\BlogCommentService;
use core\entities\Meta; use core\entities\Meta;
use frontend\components\FrontendController;
use Yii; use Yii;
use yii\base\Security; use yii\base\Security;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\helpers\FileHelper; use yii\helpers\FileHelper;
use yii\helpers\Json; use yii\helpers\Json;
use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
class PostController extends FrontendController class PostController extends Controller
{ {
public $layout = 'blog'; public $layout = 'blog';

4
common/modules/pages/controllers/PageController.php

@ -3,12 +3,12 @@
namespace common\modules\pages\controllers; namespace common\modules\pages\controllers;
use common\modules\pages\repositories\read\PageReadRepository; use common\modules\pages\repositories\read\PageReadRepository;
use frontend\components\FrontendController; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
class PageController extends FrontendController class PageController extends Controller
{ {
private $pages; private $pages;

10
docs/develope/README.md

@ -15,4 +15,12 @@ $app->params['search_rules'][] = "SELECT title, content, CONCAT('/blog/manage/po
``` ```
Поиск осуществляется по полям TITLE и CONTENT. В качестве URL указывается ссылка на конкрутную запись. Поиск осуществляется по полям TITLE и CONTENT. В качестве URL указывается ссылка на конкрутную запись.
Если название полей отличаются от TITLE и CONTENT, но, сгласно правилам SQL, указывайте ваше поле, затем `as TITLE` или `as CONTENT` Если название полей отличаются от TITLE и CONTENT, но, сгласно правилам SQL, указывайте ваше поле, затем `as TITLE` или `as CONTENT`
#### Параметры настроек
1. `Yii::$app->params['settings']['site']['short_name']` - Аббревиатура сайта в панели управления
2. `Yii::$app->params['settings']['site']['name']` - Название сайта в панели управления
3. `Yii::$app->params['settings']['design']['theme']` - Тема сайта

32
environments/prod/frontend/config/main-local.php

@ -1,3 +1,33 @@
<?php <?php
return [
$config = [
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'yandex' => [
'class' => 'yii\authclient\clients\Yandex',
'clientId' => '',
'clientSecret' => '',
],
'google' => [
'class' => 'yii\authclient\clients\Google',
'clientId' => '',
'clientSecret' => '',
],
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'clientId' => '',
'clientSecret' => '',
],
'vk' => [
'class' => 'yii\authclient\clients\VKontakte',
'clientId' => '',
'clientSecret' => '',
],
],
]
],
]; ];
return $config;

15
frontend/bootstrap/SetUp.php

@ -3,6 +3,7 @@
namespace frontend\bootstrap; namespace frontend\bootstrap;
use yii\base\BootstrapInterface; use yii\base\BootstrapInterface;
use yii\base\Theme;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
@ -32,5 +33,19 @@ class SetUp implements BootstrapInterface
'<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>', '<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>',
'<_c:[\w\-]+>/<id:\d+>/<_a:[\w\-]+>' => '<_c>/<_a>', '<_c:[\w\-]+>/<id:\d+>/<_a:[\w\-]+>' => '<_c>/<_a>',
]); ]);
// Set site theme
$theme = isset($app->params['settings']['design']['theme']) ? $app->params['settings']['design']['theme'] : 'start';
$app->view->theme = new Theme([
'basePath' => '@webroot/themes/' . $theme,
'baseUrl' => '@web/themes/' . $theme,
'pathMap' => [
'@common/modules' => '@webroot/themes/' . $theme . '/modules',
'@frontend/views' => '@webroot/themes/' . $theme,
'@frontend/widgets' => '@webroot/themes/' . $theme . '/widgets',
],
]);
} }
} }

29
frontend/components/FrontendController.php

@ -1,29 +0,0 @@
<?php
/**
* Created by Error202
* Date: 04.06.2018
*/
namespace frontend\components;
use yii\web\Controller;
use Yii;
class FrontendController extends Controller
{
public function init() {
parent::init();
$theme = 'start'; // sport
Yii::$app->view->theme = new \yii\base\Theme([
'basePath' => '@webroot/themes/' . $theme,
'baseUrl' => '@web/themes/' . $theme,
'pathMap' => [
'@common/modules' => '@webroot/themes/' . $theme . '/modules',
'@frontend/views' => '@webroot/themes/' . $theme,
'@frontend/widgets' => '@webroot/themes/' . $theme . '/widgets',
],
]);
}
}

4
frontend/controllers/ContactController.php

@ -2,11 +2,11 @@
namespace frontend\controllers; namespace frontend\controllers;
use core\services\ContactService; use core\services\ContactService;
use frontend\components\FrontendController;
use Yii; use Yii;
use core\forms\ContactForm; use core\forms\ContactForm;
use yii\web\Controller;
class ContactController extends FrontendController class ContactController extends Controller
{ {
public $layout = 'contacts'; public $layout = 'contacts';

4
frontend/controllers/PostController.php

@ -8,13 +8,13 @@ use core\repositories\post\read\PostCategoryReadRepository;
use core\repositories\post\read\PostReadRepository; use core\repositories\post\read\PostReadRepository;
use core\repositories\post\read\PostTagReadRepository; use core\repositories\post\read\PostTagReadRepository;
use core\services\post\PostCommentService; use core\services\post\PostCommentService;
use frontend\components\FrontendController;
use Yii; use Yii;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
class PostController extends FrontendController class PostController extends Controller
{ {
public $layout = 'post'; public $layout = 'post';

4
frontend/controllers/SiteController.php

@ -3,16 +3,16 @@ namespace frontend\controllers;
use core\forms\SubscribeForm; use core\forms\SubscribeForm;
use core\services\newsletter\Newsletter; use core\services\newsletter\Newsletter;
use frontend\components\FrontendController;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use frontend\components\SiteAccess; use frontend\components\SiteAccess;
use Yii; use Yii;
use yii\web\Controller;
/** /**
* Site controller * Site controller
*/ */
class SiteController extends FrontendController class SiteController extends Controller
{ {
public $newletter; public $newletter;

4
frontend/controllers/auth/AuthController.php

@ -3,12 +3,12 @@ namespace frontend\controllers\auth;
use common\auth\Identity; use common\auth\Identity;
use core\services\auth\AuthService; use core\services\auth\AuthService;
use frontend\components\FrontendController;
use Yii; use Yii;
use core\forms\auth\LoginForm; use core\forms\auth\LoginForm;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Controller;
class AuthController extends FrontendController class AuthController extends Controller
{ {
public $layout = 'auth'; public $layout = 'auth';

4
frontend/controllers/auth/NetworkController.php

@ -4,13 +4,13 @@ namespace frontend\controllers\auth;
use common\auth\Identity; use common\auth\Identity;
use core\services\auth\NetworkService; use core\services\auth\NetworkService;
use frontend\components\FrontendController;
use Yii; use Yii;
use yii\authclient\ClientInterface; use yii\authclient\ClientInterface;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\authclient\AuthAction; use yii\authclient\AuthAction;
use yii\web\Controller;
class NetworkController extends FrontendController class NetworkController extends Controller
{ {
private $service; private $service;

4
frontend/controllers/auth/ResetController.php

@ -2,13 +2,13 @@
namespace frontend\controllers\auth; namespace frontend\controllers\auth;
use core\services\auth\PasswordResetService; use core\services\auth\PasswordResetService;
use frontend\components\FrontendController;
use Yii; use Yii;
use yii\web\BadRequestHttpException; use yii\web\BadRequestHttpException;
use core\forms\auth\PasswordResetRequestForm; use core\forms\auth\PasswordResetRequestForm;
use core\forms\auth\ResetPasswordForm; use core\forms\auth\ResetPasswordForm;
use yii\web\Controller;
class ResetController extends FrontendController class ResetController extends Controller
{ {
public $layout = 'auth'; public $layout = 'auth';

4
frontend/controllers/auth/SignupController.php

@ -2,12 +2,12 @@
namespace frontend\controllers\auth; namespace frontend\controllers\auth;
use core\services\auth\SignupService; use core\services\auth\SignupService;
use frontend\components\FrontendController;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use core\forms\auth\SignupForm; use core\forms\auth\SignupForm;
use yii\web\Controller;
class SignupController extends FrontendController class SignupController extends Controller
{ {
public $layout = 'auth'; public $layout = 'auth';

Loading…
Cancel
Save