From baecb73486785867b5eb71fd338ada25cfc717a5 Mon Sep 17 00:00:00 2001 From: Egorka Date: Mon, 23 Jul 2018 11:22:31 +0300 Subject: [PATCH] Theme as settings param --- common/modules/blog/controllers/PostController.php | 4 +-- .../modules/pages/controllers/PageController.php | 4 +-- docs/develope/README.md | 10 ++++++- environments/prod/frontend/config/main-local.php | 32 +++++++++++++++++++++- frontend/bootstrap/SetUp.php | 15 ++++++++++ frontend/components/FrontendController.php | 29 -------------------- frontend/controllers/ContactController.php | 4 +-- frontend/controllers/PostController.php | 4 +-- frontend/controllers/SiteController.php | 4 +-- frontend/controllers/auth/AuthController.php | 4 +-- frontend/controllers/auth/NetworkController.php | 4 +-- frontend/controllers/auth/ResetController.php | 4 +-- frontend/controllers/auth/SignupController.php | 4 +-- 13 files changed, 73 insertions(+), 49 deletions(-) delete mode 100644 frontend/components/FrontendController.php diff --git a/common/modules/blog/controllers/PostController.php b/common/modules/blog/controllers/PostController.php index 64bd745..966287d 100644 --- a/common/modules/blog/controllers/PostController.php +++ b/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\services\BlogCommentService; use core\entities\Meta; -use frontend\components\FrontendController; use Yii; use yii\base\Security; use yii\data\ActiveDataProvider; use yii\helpers\FileHelper; use yii\helpers\Json; +use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PostController extends FrontendController +class PostController extends Controller { public $layout = 'blog'; diff --git a/common/modules/pages/controllers/PageController.php b/common/modules/pages/controllers/PageController.php index 94fb026..5608598 100644 --- a/common/modules/pages/controllers/PageController.php +++ b/common/modules/pages/controllers/PageController.php @@ -3,12 +3,12 @@ namespace common\modules\pages\controllers; use common\modules\pages\repositories\read\PageReadRepository; -use frontend\components\FrontendController; +use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PageController extends FrontendController +class PageController extends Controller { private $pages; diff --git a/docs/develope/README.md b/docs/develope/README.md index 5d41cbc..0168818 100644 --- a/docs/develope/README.md +++ b/docs/develope/README.md @@ -15,4 +15,12 @@ $app->params['search_rules'][] = "SELECT title, content, CONCAT('/blog/manage/po ``` Поиск осуществляется по полям TITLE и CONTENT. В качестве URL указывается ссылка на конкрутную запись. -Если название полей отличаются от TITLE и CONTENT, но, сгласно правилам SQL, указывайте ваше поле, затем `as TITLE` или `as CONTENT` \ No newline at end of file +Если название полей отличаются от 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']` - Тема сайта \ No newline at end of file diff --git a/environments/prod/frontend/config/main-local.php b/environments/prod/frontend/config/main-local.php index d0b9c34..fe2e673 100644 --- a/environments/prod/frontend/config/main-local.php +++ b/environments/prod/frontend/config/main-local.php @@ -1,3 +1,33 @@ [ + '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; diff --git a/frontend/bootstrap/SetUp.php b/frontend/bootstrap/SetUp.php index 49ce141..32ab8be 100644 --- a/frontend/bootstrap/SetUp.php +++ b/frontend/bootstrap/SetUp.php @@ -3,6 +3,7 @@ namespace frontend\bootstrap; use yii\base\BootstrapInterface; +use yii\base\Theme; use yii\helpers\ArrayHelper; use yii\widgets\Breadcrumbs; @@ -32,5 +33,19 @@ class SetUp implements BootstrapInterface '<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>', '<_c:[\w\-]+>//<_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', + ], + + ]); } } \ No newline at end of file diff --git a/frontend/components/FrontendController.php b/frontend/components/FrontendController.php deleted file mode 100644 index a365f9f..0000000 --- a/frontend/components/FrontendController.php +++ /dev/null @@ -1,29 +0,0 @@ -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', - ], - ]); - } -} \ No newline at end of file diff --git a/frontend/controllers/ContactController.php b/frontend/controllers/ContactController.php index 9a27b76..30138a8 100644 --- a/frontend/controllers/ContactController.php +++ b/frontend/controllers/ContactController.php @@ -2,11 +2,11 @@ namespace frontend\controllers; use core\services\ContactService; -use frontend\components\FrontendController; use Yii; use core\forms\ContactForm; +use yii\web\Controller; -class ContactController extends FrontendController +class ContactController extends Controller { public $layout = 'contacts'; diff --git a/frontend/controllers/PostController.php b/frontend/controllers/PostController.php index d157834..c103044 100644 --- a/frontend/controllers/PostController.php +++ b/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\PostTagReadRepository; use core\services\post\PostCommentService; -use frontend\components\FrontendController; use Yii; use yii\data\ActiveDataProvider; +use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; -class PostController extends FrontendController +class PostController extends Controller { public $layout = 'post'; diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 50f46b6..249ee93 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -3,16 +3,16 @@ namespace frontend\controllers; use core\forms\SubscribeForm; use core\services\newsletter\Newsletter; -use frontend\components\FrontendController; use yii\filters\VerbFilter; use yii\filters\AccessControl; use frontend\components\SiteAccess; use Yii; +use yii\web\Controller; /** * Site controller */ -class SiteController extends FrontendController +class SiteController extends Controller { public $newletter; diff --git a/frontend/controllers/auth/AuthController.php b/frontend/controllers/auth/AuthController.php index 1d516ca..3e76e83 100644 --- a/frontend/controllers/auth/AuthController.php +++ b/frontend/controllers/auth/AuthController.php @@ -3,12 +3,12 @@ namespace frontend\controllers\auth; use common\auth\Identity; use core\services\auth\AuthService; -use frontend\components\FrontendController; use Yii; use core\forms\auth\LoginForm; use yii\filters\AccessControl; +use yii\web\Controller; -class AuthController extends FrontendController +class AuthController extends Controller { public $layout = 'auth'; diff --git a/frontend/controllers/auth/NetworkController.php b/frontend/controllers/auth/NetworkController.php index 41e95d1..54edaf7 100644 --- a/frontend/controllers/auth/NetworkController.php +++ b/frontend/controllers/auth/NetworkController.php @@ -4,13 +4,13 @@ namespace frontend\controllers\auth; use common\auth\Identity; use core\services\auth\NetworkService; -use frontend\components\FrontendController; use Yii; use yii\authclient\ClientInterface; use yii\helpers\ArrayHelper; use yii\authclient\AuthAction; +use yii\web\Controller; -class NetworkController extends FrontendController +class NetworkController extends Controller { private $service; diff --git a/frontend/controllers/auth/ResetController.php b/frontend/controllers/auth/ResetController.php index 3c54b40..966b4bc 100644 --- a/frontend/controllers/auth/ResetController.php +++ b/frontend/controllers/auth/ResetController.php @@ -2,13 +2,13 @@ namespace frontend\controllers\auth; use core\services\auth\PasswordResetService; -use frontend\components\FrontendController; use Yii; use yii\web\BadRequestHttpException; use core\forms\auth\PasswordResetRequestForm; use core\forms\auth\ResetPasswordForm; +use yii\web\Controller; -class ResetController extends FrontendController +class ResetController extends Controller { public $layout = 'auth'; diff --git a/frontend/controllers/auth/SignupController.php b/frontend/controllers/auth/SignupController.php index 5522374..9fec081 100644 --- a/frontend/controllers/auth/SignupController.php +++ b/frontend/controllers/auth/SignupController.php @@ -2,12 +2,12 @@ namespace frontend\controllers\auth; use core\services\auth\SignupService; -use frontend\components\FrontendController; use Yii; use yii\filters\AccessControl; use core\forms\auth\SignupForm; +use yii\web\Controller; -class SignupController extends FrontendController +class SignupController extends Controller { public $layout = 'auth';