Commit 3cf50e4cace92f90a4f6b82366df875acbae59e7

Authored by Alexey Boroda
2 parents ff81af45 0d556e29

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	frontend/config/main.php
Showing 47 changed files with 2623 additions and 110 deletions   Show diff stats
backend/controllers/EventController.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 04.04.18
  6 + * Time: 12:19
  7 + */
  8 +
  9 + namespace backend\controllers;
  10 +
  11 + use artbox\core\admin\actions\Create;
  12 + use artbox\core\admin\actions\Delete;
  13 + use artbox\core\admin\actions\Index;
  14 + use artbox\core\admin\actions\Update;
  15 + use artbox\core\admin\actions\View;
  16 + use artbox\core\admin\interfaces\ControllerInterface;
  17 + use artbox\core\admin\widgets\Form;
  18 + use common\models\event\Event;
  19 + use yii\filters\AccessControl;
  20 + use yii\filters\VerbFilter;
  21 + use yii\web\Controller;
  22 + use yii\web\NotFoundHttpException;
  23 +
  24 + class EventController extends Controller implements ControllerInterface
  25 + {
  26 + public function behaviors()
  27 + {
  28 + return [
  29 + 'verbs' => [
  30 + 'class' => VerbFilter::className(),
  31 + 'actions' => [
  32 + 'delete' => [ 'POST' ],
  33 + ],
  34 + ],
  35 + 'access' => [
  36 + 'class' => AccessControl::className(),
  37 + 'rules' => [
  38 + [
  39 + 'allow' => true,
  40 + 'roles' => [ '@' ],
  41 + ],
  42 + ],
  43 + ],
  44 + ];
  45 + }
  46 + public function actions()
  47 + {
  48 + return [
  49 + 'index' => [
  50 + 'class' => Index::className(),
  51 + 'columns' => [
  52 + 'title' => [
  53 + 'type' => Index::ACTION_COL,
  54 + ],
  55 + 'tags' => [
  56 + 'type' => Index::RELATION_COL,
  57 + 'columnConfig' => [
  58 + 'relationField' => 'title',
  59 + ],
  60 + ],
  61 + 'created_at' => [
  62 + 'type' => Index::DATETIME_COL,
  63 + ],
  64 + 'sort' => [
  65 + 'type' => Index::POSITION_COL,
  66 + ],
  67 + 'status' => [
  68 + 'type' => Index::STATUS_COL,
  69 + ],
  70 + ],
  71 + 'model' => Event::className(),
  72 + 'hasLanguage' => true,
  73 + 'enableMassDelete' => true,
  74 + 'modelPrimaryKey' => 'id',
  75 + ],
  76 + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()),
  77 + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()),
  78 + 'view' => [
  79 + 'class' => View::className(),
  80 + 'model' => Event::className(),
  81 + 'hasAlias' => true,
  82 + 'languageFields' => [
  83 + [
  84 + 'name' => 'title',
  85 + 'type' => Form::STRING,
  86 + ],
  87 + [
  88 + 'name' => 'body',
  89 + 'type' => Form::WYSIWYG,
  90 + ],
  91 + [
  92 + 'name' => 'body_preview',
  93 + 'type' => Form::TEXTAREA,
  94 + ],
  95 + ],
  96 + 'fields' => [
  97 + [
  98 + 'name' => 'image_id',
  99 + 'type' => Form::IMAGE,
  100 + ],
  101 + [
  102 + 'name' => 'tagIds',
  103 + 'type' => Form::RELATION,
  104 + 'relationAttribute' => 'label',
  105 + 'relationName' => 'tags',
  106 + 'multiple' => true,
  107 + ],
  108 + ],
  109 + ],
  110 + 'delete' => [
  111 + 'class' => Delete::className(),
  112 + ],
  113 + ];
  114 + }
  115 +
  116 + public function findModel($id)
  117 + {
  118 + $model = Event::find()
  119 + ->with('languages')
  120 + ->where([ 'id' => $id ])
  121 + ->one();
  122 + if ($model !== null) {
  123 + return $model;
  124 + } else {
  125 + throw new NotFoundHttpException('The requested page does not exist.');
  126 + }
  127 + }
  128 +
  129 + public function newModel()
  130 + {
  131 + return new Event();
  132 + }
  133 +
  134 + public function deleteModel($id)
  135 + {
  136 + $page = Event::find()
  137 + ->with('languages.alias')
  138 + ->where(
  139 + [
  140 + 'id' => $id,
  141 + ]
  142 + )
  143 + ->one();
  144 + $langs = call_user_func(
  145 + [
  146 + $page,
  147 + 'getVariationModels',
  148 + ]
  149 + );
  150 + foreach ($langs as $lang) {
  151 + if ($lang->alias !== null) {
  152 + $lang->alias->delete();
  153 + }
  154 + }
  155 +
  156 + return $page->delete();
  157 + }
  158 +
  159 + protected static function fieldsConfig()
  160 + {
  161 + return [
  162 + 'model' => Event::className(),
  163 + 'hasAlias' => true,
  164 + 'languageFields' => [
  165 + [
  166 + 'name' => 'title',
  167 + 'type' => Form::STRING,
  168 + ],
  169 + [
  170 + 'name' => 'body',
  171 + 'type' => Form::WYSIWYG,
  172 + ],
  173 + [
  174 + 'name' => 'body_preview',
  175 + 'type' => Form::TEXTAREA,
  176 + ],
  177 + ],
  178 + 'fields' => [
  179 +
  180 + [
  181 + 'name' => 'image_id',
  182 + 'type' => Form::IMAGE,
  183 + ],
  184 + [
  185 + 'name' => 'tagIds',
  186 + 'type' => Form::RELATION,
  187 + 'relationAttribute' => 'title',
  188 + 'relationName' => 'tags',
  189 + 'multiple' => true,
  190 + ],
  191 + [
  192 + 'name' => 'status',
  193 + 'type' => Form::BOOL,
  194 + ],
  195 + [
  196 + 'name' => 'sort',
  197 + 'type' => Form::NUMBER,
  198 + ],
  199 + ],
  200 + ];
  201 + }
  202 + }
0 \ No newline at end of file 203 \ No newline at end of file
backend/controllers/EventTagController.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 04.04.18
  6 + * Time: 12:42
  7 + */
  8 +
  9 + namespace backend\controllers;
  10 +
  11 + use artbox\core\admin\actions\Create;
  12 + use artbox\core\admin\actions\Delete;
  13 + use artbox\core\admin\actions\Index;
  14 + use artbox\core\admin\actions\Update;
  15 + use artbox\core\admin\actions\View;
  16 + use artbox\core\admin\interfaces\ControllerInterface;
  17 + use artbox\core\admin\widgets\Form;
  18 + use common\models\event\Tag;
  19 + use yii\filters\AccessControl;
  20 + use yii\filters\VerbFilter;
  21 + use yii\web\Controller;
  22 + use yii\web\NotFoundHttpException;
  23 +
  24 + class EventTagController extends Controller implements ControllerInterface
  25 + {
  26 + public function behaviors()
  27 + {
  28 + return [
  29 + 'verbs' => [
  30 + 'class' => VerbFilter::className(),
  31 + 'actions' => [
  32 + 'delete' => [ 'POST' ],
  33 + ],
  34 + ],
  35 + 'access' => [
  36 + 'class' => AccessControl::className(),
  37 + 'rules' => [
  38 + [
  39 + 'allow' => true,
  40 + 'roles' => [ '@' ],
  41 + ],
  42 + ],
  43 + ],
  44 + ];
  45 + }
  46 + public function actions()
  47 + {
  48 + return [
  49 + 'index' => [
  50 + 'class' => Index::className(),
  51 + 'columns' => [
  52 + 'title' => [
  53 + 'type' => Index::ACTION_COL,
  54 + ],
  55 + 'sort' => [
  56 + 'type' => Index::POSITION_COL,
  57 + ],
  58 + ],
  59 + 'model' => Tag::className(),
  60 + 'hasLanguage' => true,
  61 + 'enableMassDelete' => true,
  62 + 'modelPrimaryKey' => 'id',
  63 + ],
  64 + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()),
  65 + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()),
  66 + 'view' => [
  67 + 'class' => View::className(),
  68 + 'model' => Tag::className(),
  69 + 'hasAlias' => true,
  70 + 'hasGallery' => false,
  71 + 'languageFields' => [
  72 + [
  73 + 'name' => 'title',
  74 + 'type' => Form::STRING,
  75 + ]
  76 + ],
  77 + 'fields' => [
  78 + ],
  79 + ],
  80 + 'delete' => [
  81 + 'class' => Delete::className(),
  82 + ],
  83 + ];
  84 + }
  85 +
  86 + public function findModel($id)
  87 + {
  88 + $model = Tag::find()
  89 + ->with('languages')
  90 + ->where([ 'id' => $id ])
  91 + ->one();
  92 + if ($model !== null) {
  93 + return $model;
  94 + } else {
  95 + throw new NotFoundHttpException('The requested page does not exist.');
  96 + }
  97 + }
  98 +
  99 + public function newModel()
  100 + {
  101 + return new Tag();
  102 + }
  103 +
  104 + public function deleteModel($id)
  105 + {
  106 + $category = Tag::find()
  107 + ->with('languages.alias')
  108 + ->where(
  109 + [
  110 + 'id' => $id,
  111 + ]
  112 + )
  113 + ->one();
  114 + $langs = call_user_func(
  115 + [
  116 + $category,
  117 + 'getVariationModels',
  118 + ]
  119 + );
  120 + foreach ($langs as $lang) {
  121 + if ($lang->alias !== null) {
  122 + $lang->alias->delete();
  123 + }
  124 + }
  125 +
  126 + return $category->delete();
  127 + }
  128 +
  129 + protected static function fieldsConfig()
  130 + {
  131 + return [
  132 + 'model' => Tag::className(),
  133 + 'hasAlias' => true,
  134 + 'hasGallery' => false,
  135 + 'languageFields' => [
  136 + [
  137 + 'name' => 'title',
  138 + 'type' => Form::STRING,
  139 + ]
  140 + ],
  141 + 'fields' => [
  142 + [
  143 + 'name' => 'sort',
  144 + 'type' => Form::NUMBER,
  145 + ],
  146 + ],
  147 + ];
  148 + }
  149 + }
0 \ No newline at end of file 150 \ No newline at end of file
backend/controllers/GalleryController.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 07.05.18
  6 + * Time: 15:14
  7 + */
  8 +
  9 + namespace backend\controllers;
  10 +
  11 + use artbox\core\admin\actions\Create;
  12 + use artbox\core\admin\actions\Delete;
  13 + use artbox\core\admin\actions\Index;
  14 + use artbox\core\admin\actions\Update;
  15 + use artbox\core\admin\actions\View;
  16 + use artbox\core\admin\interfaces\ControllerInterface;
  17 + use artbox\core\admin\widgets\Form;
  18 + use common\models\Gallery;
  19 + use yii\filters\AccessControl;
  20 + use yii\filters\VerbFilter;
  21 + use yii\web\Controller;
  22 + use yii\web\NotFoundHttpException;
  23 +
  24 + class GalleryController extends Controller implements ControllerInterface
  25 + {
  26 + public function behaviors()
  27 + {
  28 + return [
  29 + 'verbs' => [
  30 + 'class' => VerbFilter::className(),
  31 + 'actions' => [
  32 + 'delete' => [ 'POST' ],
  33 + ],
  34 + ],
  35 + 'access' => [
  36 + 'class' => AccessControl::className(),
  37 + 'rules' => [
  38 + [
  39 + 'allow' => true,
  40 + 'roles' => [ '@' ],
  41 + ],
  42 + ],
  43 + ],
  44 + ];
  45 + }
  46 + public function actions()
  47 + {
  48 + return [
  49 + 'index' => [
  50 + 'class' => Index::className(),
  51 + 'columns' => [
  52 + 'title' => [
  53 + 'type' => Index::ACTION_COL
  54 + ],
  55 + 'sort' => [
  56 + 'type' => Index::POSITION_COL,
  57 + ],
  58 + 'status' => [
  59 + 'type' => Index::STATUS_COL
  60 + ]
  61 + ],
  62 + 'model' => Gallery::className(),
  63 + 'hasLanguage' => true,
  64 + 'enableMassDelete' => true,
  65 + 'modelPrimaryKey' => 'id',
  66 + ],
  67 + 'create' => array_merge([ 'class' => Create::className() ], self::fieldsConfig()),
  68 + 'update' => array_merge([ 'class' => Update::className() ], self::fieldsConfig()),
  69 + 'view' => [
  70 + 'class' => View::className(),
  71 + 'model' => Gallery::className(),
  72 + 'hasAlias' => false,
  73 + 'hasGallery' => false,
  74 + 'languageFields' => [
  75 + [
  76 + 'name' => 'title',
  77 + 'type' => Form::STRING,
  78 + ]
  79 + ],
  80 + 'fields' => [
  81 + [
  82 + 'name' => 'image_id',
  83 + 'type' => Form::IMAGE,
  84 + ],
  85 + ],
  86 + ],
  87 + 'delete' => [
  88 + 'class' => Delete::className(),
  89 + ],
  90 + ];
  91 + }
  92 +
  93 + public function findModel($id)
  94 + {
  95 + $model = Gallery::find()
  96 + ->with('languages')
  97 + ->where([ 'id' => $id ])
  98 + ->one();
  99 + if ($model !== null) {
  100 + return $model;
  101 + } else {
  102 + throw new NotFoundHttpException('The requested page does not exist.');
  103 + }
  104 + }
  105 +
  106 + public function newModel()
  107 + {
  108 + return new Gallery();
  109 + }
  110 +
  111 + public function deleteModel($id)
  112 + {
  113 + $page = Gallery::find()
  114 + ->with('languages')
  115 + ->where(
  116 + [
  117 + 'id' => $id,
  118 + ]
  119 + )
  120 + ->one();
  121 +
  122 + return $page->delete();
  123 + }
  124 +
  125 + protected static function fieldsConfig()
  126 + {
  127 + return [
  128 + 'model' => Gallery::className(),
  129 + 'hasAlias' => false,
  130 + 'hasGallery' => false,
  131 + 'languageFields' => [
  132 + [
  133 + 'name' => 'title',
  134 + 'type' => Form::STRING,
  135 + ],
  136 + ],
  137 + 'fields' => [
  138 + [
  139 + 'name' => 'image_id',
  140 + 'type' => Form::IMAGE,
  141 + ],
  142 + [
  143 + 'name' => 'status',
  144 + 'type' => Form::BOOL,
  145 + ],
  146 + [
  147 + 'name' => 'sort',
  148 + 'type' => Form::NUMBER,
  149 + ],
  150 + ],
  151 + ];
  152 + }
  153 + }
0 \ No newline at end of file 154 \ No newline at end of file
backend/controllers/SlideController.php
@@ -78,7 +78,12 @@ @@ -78,7 +78,12 @@
78 [ 78 [
79 'name' => 'title', 79 'name' => 'title',
80 'type' => Form::STRING, 80 'type' => Form::STRING,
81 - ],[ 81 + ],
  82 + [
  83 + 'name' => 'description',
  84 + 'type' => Form::TEXTAREA,
  85 + ],
  86 + [
82 'name' => 'link', 87 'name' => 'link',
83 'type' => Form::STRING, 88 'type' => Form::STRING,
84 ], 89 ],
@@ -96,6 +101,10 @@ @@ -96,6 +101,10 @@
96 [ 101 [
97 'name' => 'sort', 102 'name' => 'sort',
98 'type' => Form::NUMBER, 103 'type' => Form::NUMBER,
  104 + ],
  105 + [
  106 + 'name' => 'background_id',
  107 + 'type' => Form::IMAGE,
99 ] 108 ]
100 ], 109 ],
101 ], 110 ],
@@ -163,6 +172,10 @@ @@ -163,6 +172,10 @@
163 'type' => Form::STRING, 172 'type' => Form::STRING,
164 ], 173 ],
165 [ 174 [
  175 + 'name' => 'description',
  176 + 'type' => Form::TEXTAREA,
  177 + ],
  178 + [
166 'name' => 'link', 179 'name' => 'link',
167 'type' => Form::STRING, 180 'type' => Form::STRING,
168 ], 181 ],
@@ -170,6 +183,10 @@ @@ -170,6 +183,10 @@
170 ], 183 ],
171 'fields' => [ 184 'fields' => [
172 [ 185 [
  186 + 'name' => 'background_id',
  187 + 'type' => Form::IMAGE,
  188 + ],
  189 + [
173 'name' => 'status', 190 'name' => 'status',
174 'type' => Form::BOOL, 191 'type' => Form::BOOL,
175 ], 192 ],
backend/views/layouts/menu_items.php
@@ -45,6 +45,11 @@ @@ -45,6 +45,11 @@
45 'url' => [ '/page-category/index' ], 45 'url' => [ '/page-category/index' ],
46 46
47 ], 47 ],
  48 + [
  49 + 'label' => \Yii::t('core', 'Gallery'),
  50 + 'url' => [ '/gallery/index' ],
  51 +
  52 + ],
48 ], 53 ],
49 ], 54 ],
50 55
@@ -95,7 +100,23 @@ @@ -95,7 +100,23 @@
95 ], 100 ],
96 ], 101 ],
97 ], 102 ],
98 - 103 + [
  104 + 'label' => \Yii::t('app', 'Event'),
  105 + 'url' => '#',
  106 + 'template' => '<a href="#"><b class="blog"></b><span>{label}</span>{badge}</a>',
  107 + 'items' => [
  108 + [
  109 + 'label' => \Yii::t('core', 'Articles'),
  110 + 'url' => [ '/event/index' ],
  111 + 'icon' => 'file-text',
  112 + ],
  113 + [
  114 + 'label' => \Yii::t('core', 'Tags'),
  115 + 'url' => [ '/event-tag/index' ],
  116 + 'icon' => 'tag',
  117 + ],
  118 + ],
  119 + ],
99 [ 120 [
100 'label' => \Yii::t('app', 'Настройки'), 121 'label' => \Yii::t('app', 'Настройки'),
101 'url' => [ '/settings' ], 122 'url' => [ '/settings' ],
common/config/main.php
@@ -35,22 +35,10 @@ @@ -35,22 +35,10 @@
35 'class' => 'yii\i18n\PhpMessageSource', 35 'class' => 'yii\i18n\PhpMessageSource',
36 'basePath' => '@artbox/core/messages', 36 'basePath' => '@artbox/core/messages',
37 ], 37 ],
38 - 'catalog' => [  
39 - 'class' => 'yii\i18n\PhpMessageSource',  
40 - 'basePath' => '@artbox/catalog/messages',  
41 - ],  
42 'app' => [ 38 'app' => [
43 'class' => 'yii\i18n\PhpMessageSource', 39 'class' => 'yii\i18n\PhpMessageSource',
44 'basePath' => '@common/messages', 40 'basePath' => '@common/messages',
45 ], 41 ],
46 - 'blog' => [  
47 - 'class' => 'yii\i18n\PhpMessageSource',  
48 - 'basePath' => '@artbox/weblog/messages',  
49 - ],  
50 - 'order' => [  
51 - 'class' => 'yii\i18n\PhpMessageSource',  
52 - 'basePath' => '@artbox/order/messages',  
53 - ],  
54 ], 42 ],
55 ], 43 ],
56 'filedb' => [ 44 'filedb' => [
common/messages/en/app.php 0 → 100644
  1 +<?php
  2 +return [
  3 + 'Читать далее' => 'Read more'
  4 +];
0 \ No newline at end of file 5 \ No newline at end of file
common/messages/ru/app.php 0 → 100644
  1 +<?php
  2 +return [
  3 + 'Home' => 'Главная',
  4 + 'Contacts' => 'Контакты',
  5 + 'About' => 'О нас',
  6 + 'Blog' => 'Блог',
  7 + 'Events' => 'Мероприятия',
  8 + 'Name' => 'Имя',
  9 + 'Phone' => 'Телефон',
  10 + 'Message' => 'Сообщения',
  11 + 'You question' => 'Ваш вопрос',
  12 + 'Send' => 'Отправить',
  13 + 'Contact us!' => 'Свяжитесь с нами',
  14 + 'Go to contact page' => 'Перейти на страницу контактов',
  15 + 'Send message' => 'Отправить сообщение',
  16 + 'Contact form' => "Форма для связи"
  17 +];
0 \ No newline at end of file 18 \ No newline at end of file
common/messages/ua/app.php 0 → 100644
  1 +<?php
  2 +return [
  3 + 'Home' => 'Головна',
  4 + 'Contacts' => 'Контакти',
  5 + 'About' => 'Про нас',
  6 + 'Blog' => 'Блог',
  7 + 'Events' => 'Заходи',
  8 + 'Name' => 'Ім\'я',
  9 + 'Phone' => 'Телефон',
  10 + 'Message' => 'Повідомленя',
  11 + 'You question' => 'Ваше питання',
  12 + 'Send' => 'Відправити',
  13 + 'Contact us!' => 'Зв\'яжіться з нами',
  14 + 'Go to contact page' => 'Перейти до сторінки контактів',
  15 + 'Читать далее' => 'Читати далі',
  16 + "Send message" => 'Надіслати повідомлення',
  17 + "Contact form" => 'Форма для зв\'язку'
  18 +];
0 \ No newline at end of file 19 \ No newline at end of file
common/models/Gallery.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 07.05.18
  6 + * Time: 14:57
  7 + */
  8 +
  9 + namespace common\models;
  10 +
  11 + use artbox\core\models\Image;
  12 + use artbox\core\models\Language;
  13 + use yii\db\ActiveQuery;
  14 + use yii\db\ActiveRecord;
  15 + use yii2tech\ar\position\PositionBehavior;
  16 + use yii2tech\ar\variation\VariationBehavior;
  17 +
  18 + class Gallery extends ActiveRecord
  19 + {
  20 + public function rules()
  21 + {
  22 + return [
  23 + [
  24 + [ 'sort' ],
  25 + 'integer',
  26 + ],
  27 + [
  28 + [ 'status' ],
  29 + 'boolean',
  30 + ],
  31 + [
  32 + [ 'image_id' ],
  33 + 'required'
  34 + ]
  35 + ];
  36 + }
  37 +
  38 + public function behaviors()
  39 + {
  40 + return [
  41 + 'translations' => [
  42 + 'class' => VariationBehavior::className(),
  43 + 'variationsRelation' => 'languages',
  44 + 'defaultVariationRelation' => 'language',
  45 + 'variationOptionReferenceAttribute' => 'language_id',
  46 + 'optionModelClass' => Language::className(),
  47 + 'defaultVariationOptionReference' => function () {
  48 + return Language::getCurrent()->id;
  49 + },
  50 + 'optionQueryFilter' => function (ActiveQuery $query) {
  51 + $query->where(
  52 + [
  53 + 'status' => true,
  54 + ]
  55 + );
  56 + },
  57 + ],
  58 + 'positionBehavior' => [
  59 + 'class' => PositionBehavior::className(),
  60 + 'positionAttribute' => 'sort',
  61 + ],
  62 + ];
  63 + }
  64 +
  65 + public static function tableName()
  66 + {
  67 + return 'gallery';
  68 + }
  69 +
  70 + /**
  71 + * @return \yii\db\ActiveQuery
  72 + */
  73 + public function getLanguages()
  74 + {
  75 + return $this->hasMany(GalleryLang::className(), [ 'gallery_id' => 'id' ]);
  76 + }
  77 +
  78 + /**
  79 + * @return \yii\db\ActiveQuery
  80 + */
  81 + public function getLanguage()
  82 + {
  83 + return $this->hasDefaultVariationRelation();
  84 + }
  85 +
  86 + public function attributeLabels()
  87 + {
  88 + return [
  89 + 'title' => \Yii::t('core', 'Title'),
  90 + 'status' => \Yii::t('core', 'Status'),
  91 + 'sort' => \Yii::t('core', 'Sort'),
  92 + 'image_id' => \Yii::t('core', 'Image'),
  93 + ];
  94 + }
  95 +
  96 + /**
  97 + * @return \yii\db\ActiveQuery
  98 + */
  99 + public function getImage()
  100 + {
  101 + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]);
  102 + }
  103 +
  104 +
  105 + }
0 \ No newline at end of file 106 \ No newline at end of file
common/models/GalleryLang.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 07.05.18
  6 + * Time: 15:09
  7 + */
  8 +
  9 + namespace common\models;
  10 +
  11 + use yii\db\ActiveRecord;
  12 +
  13 + class GalleryLang extends ActiveRecord
  14 + {
  15 + public static function tableName()
  16 + {
  17 + return 'gallery_lang';
  18 + }
  19 +
  20 + public function rules()
  21 + {
  22 + return [
  23 + [
  24 + [
  25 + 'title',
  26 + ],
  27 + 'string',
  28 + ],
  29 + ];
  30 + }
  31 +
  32 + public function attributeLabels()
  33 + {
  34 + return [
  35 + 'title' => \Yii::t('core', 'Title'),
  36 + ];
  37 + }
  38 + }
0 \ No newline at end of file 39 \ No newline at end of file
common/models/blog/Article.php
@@ -18,22 +18,22 @@ @@ -18,22 +18,22 @@
18 /** 18 /**
19 * This is the model class for table "blog_article". 19 * This is the model class for table "blog_article".
20 * 20 *
21 - * @property integer $id  
22 - * @property Image $image  
23 - * @property integer $created_at  
24 - * @property integer $updated_at  
25 - * @property integer $deleted_at  
26 - * @property integer $sort  
27 - * @property boolean $status  
28 - * @property integer $author_id  
29 - * @property integer $image_id 21 + * @property integer $id
  22 + * @property Image $image
  23 + * @property integer $created_at
  24 + * @property integer $updated_at
  25 + * @property integer $deleted_at
  26 + * @property integer $sort
  27 + * @property boolean $status
  28 + * @property integer $author_id
  29 + * @property integer $image_id
30 * @property ArticleLang[] $blogArticleLangs 30 * @property ArticleLang[] $blogArticleLangs
31 - * @property Language[] $languages  
32 - * @property Article[] $relatedBlogArticles  
33 - * @property Article[] $articles  
34 - * @property Category[] $categories  
35 - * @property Category $category  
36 - * @property Tag[] $tags 31 + * @property Language[] $languages
  32 + * @property \common\models\blog\Article[] $relatedBlogArticles
  33 + * @property \common\models\blog\Article[] $articles
  34 + * @property Category[] $categories
  35 + * @property Category $category
  36 + * @property Tag[] $tags
37 * * from VariationBehavior 37 * * from VariationBehavior
38 * @method ActiveQuery hasDefaultVariationRelation(); 38 * @method ActiveQuery hasDefaultVariationRelation();
39 */ 39 */
common/models/blog/ArticleLang.php
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 * @property string $meta_description 19 * @property string $meta_description
20 * @property string $h1 20 * @property string $h1
21 * @property string $seo_text 21 * @property string $seo_text
22 - * @property Article $article 22 + * @property Article $article
23 * @property Language $language 23 * @property Language $language
24 * @property Alias $alias 24 * @property Alias $alias
25 */ 25 */
common/models/blog/Category.php
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * @property integer $sort 18 * @property integer $sort
19 * @property integer $parent_id 19 * @property integer $parent_id
20 * @property boolean $status 20 * @property boolean $status
21 - * @property Article[] $articles 21 + * @property Article[] $articles
22 * @property CategoryLang[] $blogCategoryLangs 22 * @property CategoryLang[] $blogCategoryLangs
23 * @property Language[] $languages 23 * @property Language[] $languages
24 * @property Category $parent 24 * @property Category $parent
common/models/blog/Tag.php
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 * This is the model class for table "blog_tag". 14 * This is the model class for table "blog_tag".
15 * 15 *
16 * @property integer $id 16 * @property integer $id
17 - * @property Article[] $articles 17 + * @property Article[] $articles
18 * @property TagLang[] $blogTagLangs 18 * @property TagLang[] $blogTagLangs
19 * @property Language[] $languages 19 * @property Language[] $languages
20 * * * from VariationBehavior 20 * * * from VariationBehavior
common/models/event/Event.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace common\models\event;
  4 +
  5 + use artbox\core\models\Image;
  6 + use artbox\core\models\traits\AliasableTrait;
  7 + use artbox\webcomment\models\CommentModel;
  8 + use yii\behaviors\TimestampBehavior;
  9 + use yii\db\ActiveRecord;
  10 + use artbox\core\models\Language;
  11 + use yii\db\ActiveQuery;
  12 + use yii\db\Query;
  13 + use yii\helpers\Json;
  14 + use yii2tech\ar\linkmany\LinkManyBehavior;
  15 + use yii2tech\ar\position\PositionBehavior;
  16 + use yii2tech\ar\variation\VariationBehavior;
  17 +
  18 + /**
  19 + * This is the model class for table "blog_article".
  20 + *
  21 + * @property integer $id
  22 + * @property Image $image
  23 + * @property integer $created_at
  24 + * @property integer $updated_at
  25 + * @property integer $deleted_at
  26 + * @property integer $sort
  27 + * @property boolean $status
  28 + * @property integer $author_id
  29 + * @property integer $image_id
  30 + * @property EventLang[] $blogArticleLangs
  31 + * @property Language[] $languages
  32 + * @property Event[] $relatedBlogArticles
  33 + * @property Event[] $articles
  34 + * @property Tag[] $tags
  35 + * * from VariationBehavior
  36 + * @method ActiveQuery hasDefaultVariationRelation();
  37 + */
  38 + class Event extends ActiveRecord
  39 + {
  40 + use AliasableTrait;
  41 +
  42 + /**
  43 + * @inheritdoc
  44 + */
  45 + public static function tableName()
  46 + {
  47 + return 'event';
  48 + }
  49 +
  50 + public function behaviors()
  51 + {
  52 + return [
  53 + 'translations' => [
  54 + 'class' => VariationBehavior::className(),
  55 + 'variationsRelation' => 'languages',
  56 + 'defaultVariationRelation' => 'language',
  57 + 'variationOptionReferenceAttribute' => 'language_id',
  58 + 'optionModelClass' => Language::className(),
  59 + 'defaultVariationOptionReference' => function () {
  60 + return Language::getCurrent()->id;
  61 + },
  62 + 'optionQueryFilter' => function (ActiveQuery $query) {
  63 + $query->where(
  64 + [
  65 + 'status' => true,
  66 + ]
  67 + );
  68 + },
  69 + ],
  70 + 'positionBehavior' => [
  71 + 'class' => PositionBehavior::className(),
  72 + 'positionAttribute' => 'sort',
  73 + ],
  74 + 'linkTagBehavior' => [
  75 + 'class' => LinkManyBehavior::className(),
  76 + 'relation' => 'tags',
  77 + 'relationReferenceAttribute' => 'tagIds',
  78 + ],
  79 + 'timestamp' => [
  80 + 'class' => TimestampBehavior::className(),
  81 + ],
  82 + ];
  83 + }
  84 + /**
  85 + * @inheritdoc
  86 + */
  87 + public function rules()
  88 + {
  89 + return [
  90 + [
  91 + [
  92 + 'created_at',
  93 + 'updated_at',
  94 + 'deleted_at',
  95 + 'sort',
  96 + 'author_id',
  97 + 'image_id',
  98 + ],
  99 + 'integer',
  100 + ],
  101 + [
  102 + [ 'status' ],
  103 + 'boolean',
  104 + ],
  105 +
  106 + [
  107 + [
  108 + 'tagIds',
  109 + ],
  110 + 'safe',
  111 + ],
  112 + ];
  113 + }
  114 +
  115 + /**
  116 + * @inheritdoc
  117 + */
  118 + public function attributeLabels()
  119 + {
  120 + return [
  121 + 'id' => 'ID',
  122 + 'image' => 'Image',
  123 + 'created_at' => 'Created At',
  124 + 'updated_at' => \Yii::t('core', 'Updated At'),
  125 + 'deleted_at' => 'Deleted At',
  126 + 'sort' => \Yii::t('core', 'Sort'),
  127 + 'status' => \Yii::t('core', 'Status'),
  128 + 'author_id' => 'Author ID',
  129 + 'title' => \Yii::t('core', 'Title'),
  130 + 'tags' => \Yii::t('core', 'Tags'),
  131 +
  132 + 'image_id' => \Yii::t('core', 'Image'),
  133 + 'tagIds' => \Yii::t('core', 'Tags'),
  134 + ];
  135 + }
  136 +
  137 + public function getLanguages()
  138 + {
  139 + return $this->hasMany(EventLang::className(), [ 'event_id' => 'id' ]);
  140 + }
  141 +
  142 + /**
  143 + * @return \yii\db\ActiveQuery
  144 + */
  145 + public function getLanguage()
  146 + {
  147 + return $this->hasDefaultVariationRelation();
  148 + }
  149 +
  150 +
  151 + public function getRoute()
  152 + {
  153 + return Json::encode(
  154 + [
  155 + 'event/view',
  156 + 'id' => $this->id,
  157 + ]
  158 + );
  159 + }
  160 +
  161 +
  162 +
  163 +
  164 +
  165 + /**
  166 + * @return \yii\db\ActiveQuery
  167 + */
  168 + public function getImage()
  169 + {
  170 + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]);
  171 + }
  172 +
  173 +
  174 +
  175 +
  176 + /**
  177 + * @return \yii\db\ActiveQuery
  178 + */
  179 + public function getTags()
  180 + {
  181 + return $this->hasMany(Tag::className(), [ 'id' => 'event_tag_id' ])
  182 + ->viaTable('event_to_tag', [ 'event_id' => 'id' ]);
  183 + }
  184 + }
common/models/event/EventLang.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace common\models\event;
  4 +
  5 + use artbox\core\models\Alias;
  6 + use artbox\core\models\Language;
  7 + use yii\db\ActiveRecord;
  8 +
  9 + /**
  10 + * This is the model class for table "blog_article_lang".
  11 + *
  12 + * @property integer $id
  13 + * @property integer $blog_article_id
  14 + * @property integer $language_id
  15 + * @property string $title
  16 + * @property string $body
  17 + * @property string $body_preview
  18 + * @property string $meta_title
  19 + * @property string $meta_description
  20 + * @property string $h1
  21 + * @property string $seo_text
  22 + * @property Event $article
  23 + * @property Language $language
  24 + * @property Alias $alias
  25 + */
  26 + class EventLang extends ActiveRecord
  27 + {
  28 + /**
  29 + * @inheritdoc
  30 + */
  31 + public static function tableName()
  32 + {
  33 + return 'event_lang';
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function rules()
  40 + {
  41 + return [
  42 + [
  43 + [
  44 + 'title',
  45 + ],
  46 + 'required',
  47 + ],
  48 + [
  49 + [
  50 + 'body',
  51 + 'body_preview',
  52 + ],
  53 + 'string',
  54 + ],
  55 + [
  56 + [
  57 + 'title',
  58 + ],
  59 + 'string',
  60 + 'max' => 80,
  61 + ],
  62 +
  63 + ];
  64 + }
  65 +
  66 + public function attributeLabels()
  67 + {
  68 + return [
  69 + 'title' => \Yii::t('core', 'Title'),
  70 + 'body' => \Yii::t('core', 'Body'),
  71 + 'body_preview' => \Yii::t('core', 'Body Preview'),
  72 + ];
  73 + }
  74 +
  75 + /**
  76 + * @return \yii\db\ActiveQuery
  77 + */
  78 + public function getAlias()
  79 + {
  80 + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]);
  81 + }
  82 + }
common/models/event/Tag.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace common\models\event;
  4 +
  5 + use artbox\core\models\traits\AliasableTrait;
  6 + use yii\db\ActiveRecord;
  7 + use artbox\core\models\Language;
  8 + use yii\db\ActiveQuery;
  9 + use yii\helpers\Json;
  10 + use yii2tech\ar\position\PositionBehavior;
  11 + use yii2tech\ar\variation\VariationBehavior;
  12 +
  13 + /**
  14 + * This is the model class for table "blog_tag".
  15 + *
  16 + * @property integer $id
  17 + * @property Event[] $articles
  18 + * @property TagLang[] $blogTagLangs
  19 + * @property Language[] $languages
  20 + * * * from VariationBehavior
  21 + * @method ActiveQuery hasDefaultVariationRelation();
  22 + */
  23 + class Tag extends ActiveRecord
  24 + {
  25 + use AliasableTrait;
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public static function tableName()
  30 + {
  31 + return 'event_tag';
  32 + }
  33 +
  34 + /**
  35 + * @inheritdoc
  36 + */
  37 + public function behaviors()
  38 + {
  39 + return [
  40 + 'translations' => [
  41 + 'class' => VariationBehavior::className(),
  42 + 'variationsRelation' => 'languages',
  43 + 'defaultVariationRelation' => 'language',
  44 + 'variationOptionReferenceAttribute' => 'language_id',
  45 + 'optionModelClass' => Language::className(),
  46 + 'defaultVariationOptionReference' => function () {
  47 + return Language::getCurrent()->id;
  48 + },
  49 + 'optionQueryFilter' => function (ActiveQuery $query) {
  50 + $query->where(
  51 + [
  52 + 'status' => true,
  53 + ]
  54 + );
  55 + },
  56 + ],
  57 + 'positionBehavior' => [
  58 + 'class' => PositionBehavior::className(),
  59 + 'positionAttribute' => 'sort',
  60 + ],
  61 + ];
  62 + }
  63 +
  64 + /**
  65 + * @inheritdoc
  66 + */
  67 + public function rules()
  68 + {
  69 + return [
  70 + [
  71 + [
  72 + 'id',
  73 + 'sort',
  74 + ],
  75 + 'integer',
  76 + ],
  77 + ];
  78 + }
  79 + public function getRoute()
  80 + {
  81 + return Json::encode(
  82 + [
  83 + 'event/tag',
  84 + 'id' => $this->id,
  85 + ]
  86 + );
  87 + }
  88 +
  89 + /**
  90 + * @inheritdoc
  91 + */
  92 + public function attributeLabels()
  93 + {
  94 + return [
  95 + 'id' => 'ID',
  96 + 'label' => \Yii::t('core', 'Label'),
  97 + 'sort' => \Yii::t('core', 'Sort'),
  98 + ];
  99 + }
  100 + /**
  101 + * @return \yii\db\ActiveQuery
  102 + */
  103 + public function getLanguages()
  104 + {
  105 + return $this->hasMany(TagLang::className(), [ 'event_tag_id' => 'id' ]);
  106 + }
  107 +
  108 + /**
  109 + * @return \yii\db\ActiveQuery
  110 + */
  111 + public function getLanguage()
  112 + {
  113 + return $this->hasDefaultVariationRelation();
  114 + }
  115 +
  116 + /**
  117 + * @return \yii\db\ActiveQuery
  118 + */
  119 + public function getArticles()
  120 + {
  121 + return $this->hasMany(Event::className(), [ 'id' => 'event_id' ])
  122 + ->viaTable('event_to_tag', [ 'event_tag_id' => 'id' ]);
  123 + }
  124 + }
common/models/event/TagLang.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace common\models\event;
  4 +
  5 + use artbox\core\models\Alias;
  6 + use artbox\core\models\Language;
  7 + use yii\db\ActiveRecord;
  8 +
  9 + /**
  10 + * This is the model class for table "blog_tag_lang".
  11 + *
  12 + * @property integer $id
  13 + * @property integer $blog_tag_id
  14 + * @property integer $language_id
  15 + * @property string $label
  16 + * @property Tag $blogTag
  17 + * @property Language $language
  18 + */
  19 + class TagLang extends ActiveRecord
  20 + {
  21 +
  22 + /**
  23 + * @inheritdoc
  24 + */
  25 + public static function tableName()
  26 + {
  27 + return 'event_tag_lang';
  28 + }
  29 +
  30 + /**
  31 + * @inheritdoc
  32 + */
  33 + public function rules()
  34 + {
  35 + return [
  36 + [
  37 + [ 'title' ],
  38 + 'string',
  39 + 'max' => 255,
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * @inheritdoc
  46 + */
  47 + public function attributeLabels()
  48 + {
  49 + return [
  50 + 'id' => 'ID',
  51 + 'blog_tag_id' => 'Blog Tag ID',
  52 + 'language_id' => 'Language ID',
  53 + 'title' => \Yii::t('core', 'Title'),
  54 + ];
  55 + }
  56 +
  57 + /**
  58 + * @return \yii\db\ActiveQuery
  59 + */
  60 + public function getTag()
  61 + {
  62 + return $this->hasOne(Tag::className(), [ 'id' => 'event_tag_id' ]);
  63 + }
  64 +
  65 + public function getAlias()
  66 + {
  67 + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]);
  68 + }
  69 +
  70 + /**
  71 + * @return \yii\db\ActiveQuery
  72 + */
  73 + public function getLanguage()
  74 + {
  75 + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
  76 + }
  77 + }
common/models/slider/Slide.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\models\slider; 3 namespace common\models\slider;
4 4
  5 + use artbox\core\models\Image;
5 use artbox\core\models\Language; 6 use artbox\core\models\Language;
6 use yii\db\ActiveQuery; 7 use yii\db\ActiveQuery;
7 use yii\db\ActiveRecord; 8 use yii\db\ActiveRecord;
@@ -72,6 +73,14 @@ @@ -72,6 +73,14 @@
72 [ 'status' ], 73 [ 'status' ],
73 'boolean', 74 'boolean',
74 ], 75 ],
  76 + [
  77 + [ 'background_id' ],
  78 + 'required',
  79 + ],
  80 + [
  81 + [ 'background_id' ],
  82 + 'integer',
  83 + ],
75 ]; 84 ];
76 } 85 }
77 86
@@ -86,6 +95,7 @@ @@ -86,6 +95,7 @@
86 'sort' => \Yii::t('core', 'Sort'), 95 'sort' => \Yii::t('core', 'Sort'),
87 'title' => \Yii::t('core', 'Title'), 96 'title' => \Yii::t('core', 'Title'),
88 'link' => \Yii::t('core', 'Link'), 97 'link' => \Yii::t('core', 'Link'),
  98 + 'background_id' => \Yii::t('core', 'Background'),
89 ]; 99 ];
90 } 100 }
91 101
@@ -110,4 +120,12 @@ @@ -110,4 +120,12 @@
110 return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ]) 120 return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ])
111 ->inverseOf('slide'); 121 ->inverseOf('slide');
112 } 122 }
  123 +
  124 + /**
  125 + * @return \yii\db\ActiveQuery
  126 + */
  127 + public function getBackground()
  128 + {
  129 + return $this->hasOne(Image::className(), [ 'id' => 'background_id' ]);
  130 + }
113 } 131 }
common/models/slider/SlideLang.php
@@ -39,12 +39,6 @@ @@ -39,12 +39,6 @@
39 [ 39 [
40 'image_id', 40 'image_id',
41 ], 41 ],
42 - 'required',  
43 - ],  
44 - [  
45 - [  
46 - 'image_id',  
47 - ],  
48 'integer', 42 'integer',
49 ], 43 ],
50 [ 44 [
@@ -55,6 +49,10 @@ @@ -55,6 +49,10 @@
55 'string', 49 'string',
56 'max' => 255, 50 'max' => 255,
57 ], 51 ],
  52 + [
  53 + [ 'description' ],
  54 + 'string'
  55 + ]
58 ]; 56 ];
59 } 57 }
60 58
@@ -69,6 +67,7 @@ @@ -69,6 +67,7 @@
69 'link' => Yii::t('core', 'Link'), 67 'link' => Yii::t('core', 'Link'),
70 'image_id' => Yii::t('core', 'Image'), 68 'image_id' => Yii::t('core', 'Image'),
71 'title' => Yii::t('core', 'Title'), 69 'title' => Yii::t('core', 'Title'),
  70 + 'description' => Yii::t('core', 'Description'),
72 ]; 71 ];
73 } 72 }
74 73
console/migrations/m180403_141700_add_page_columns.php
@@ -12,8 +12,8 @@ class m180403_141700_add_page_columns extends Migration @@ -12,8 +12,8 @@ class m180403_141700_add_page_columns extends Migration
12 */ 12 */
13 public function safeUp() 13 public function safeUp()
14 { 14 {
15 - $this->addColumn('page','updated_at', $this->timestamp());  
16 - $this->addColumn('page','created_at', $this->timestamp()); 15 + $this->addColumn('page','updated_at', $this->string());
  16 + $this->addColumn('page','created_at', $this->string());
17 } 17 }
18 18
19 /** 19 /**
console/migrations/m180507_115504_create_gallery_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `gallery`.
  7 + */
  8 +class m180507_115504_create_gallery_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('gallery', [
  16 + 'id' => $this->primaryKey(),
  17 + 'image_id' => $this->integer(),
  18 + 'sort' => $this->integer(),
  19 + 'status' => $this->boolean(),
  20 + ]);
  21 + }
  22 +
  23 + /**
  24 + * {@inheritdoc}
  25 + */
  26 + public function safeDown()
  27 + {
  28 + $this->dropTable('gallery');
  29 + }
  30 +}
console/migrations/m180507_120119_create_gallery_lang_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `gallery_lang`.
  7 + */
  8 +class m180507_120119_create_gallery_lang_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('gallery_lang', [
  16 + 'gallery_id' => $this->integer()
  17 + ->notNull(),
  18 + 'language_id' => $this->integer()
  19 + ->notNull(),
  20 + 'title' => $this->string(),
  21 + 'PRIMARY KEY(gallery_id, language_id)',
  22 + ]);
  23 +
  24 +
  25 +
  26 + $this->addForeignKey(
  27 + 'gallery_lang_fk',
  28 + 'gallery_lang',
  29 + 'language_id',
  30 + 'language',
  31 + 'id',
  32 + 'RESTRICT',
  33 + 'CASCADE'
  34 + );
  35 +
  36 + $this->addForeignKey(
  37 + 'gallery_fk',
  38 + 'gallery_lang',
  39 + 'gallery_id',
  40 + 'gallery',
  41 + 'id',
  42 + 'CASCADE',
  43 + 'CASCADE'
  44 + );
  45 + }
  46 +
  47 + /**
  48 + * {@inheritdoc}
  49 + */
  50 + public function safeDown()
  51 + {
  52 + $this->dropForeignKey('gallery_lang_fk', 'gallery_lang');
  53 + $this->dropForeignKey('gallery_fk', 'gallery_lang');
  54 + $this->dropTable('gallery_lang');
  55 + }
  56 +}
console/migrations/m180507_122728_create_event_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `event`.
  7 + */
  8 +class m180507_122728_create_event_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('event', [
  16 + 'id' => $this->primaryKey(),
  17 + 'image_id' => $this->integer(),
  18 + 'created_at' => $this->integer(),
  19 + 'updated_at' => $this->integer(),
  20 + 'deleted_at' => $this->integer(),
  21 + 'sort' => $this->integer(),
  22 + 'status' => $this->boolean(),
  23 + 'author_id' => $this->integer(),
  24 + ]);
  25 + }
  26 +
  27 + /**
  28 + * {@inheritdoc}
  29 + */
  30 + public function safeDown()
  31 + {
  32 + $this->dropTable('event');
  33 + }
  34 +}
console/migrations/m180507_123248_create_event_lang_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `event_lang`.
  7 + */
  8 +class m180507_123248_create_event_lang_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('event_lang', [
  16 + 'id' => $this->primaryKey(),
  17 + 'event_id' => $this->integer()
  18 + ->notNull(),
  19 + 'language_id' => $this->integer()
  20 + ->notNull(),
  21 + 'title' => $this->string(255),
  22 + 'body' => $this->text(),
  23 + 'body_preview' => $this->text(),
  24 + 'alias_id' => $this->integer(),
  25 + ]);
  26 +
  27 + $this->createIndex(
  28 + 'event_lang_uk',
  29 + 'event_lang',
  30 + [
  31 + 'event_id',
  32 + 'language_id',
  33 + ],
  34 + true
  35 + );
  36 +
  37 + $this->createIndex(
  38 + 'event_alias_uk',
  39 + 'event_lang',
  40 + 'alias_id',
  41 + true
  42 + );
  43 +
  44 + /**
  45 + * Add foreign keys in blog_articles and language tables
  46 + */
  47 + $this->addForeignKey(
  48 + 'event_fk',
  49 + 'event_lang',
  50 + 'event_id',
  51 + 'event',
  52 + 'id',
  53 + 'CASCADE',
  54 + 'CASCADE'
  55 + );
  56 +
  57 + $this->addForeignKey(
  58 + 'event_lang_fk',
  59 + 'event_lang',
  60 + 'language_id',
  61 + 'language',
  62 + 'id',
  63 + 'RESTRICT',
  64 + 'CASCADE'
  65 + );
  66 + }
  67 +
  68 + /**
  69 + * {@inheritdoc}
  70 + */
  71 + public function safeDown()
  72 + {
  73 + $this->dropForeignKey('event_lang_fk', 'event_lang');
  74 + $this->dropForeignKey('event_fk', 'event_lang');
  75 + $this->dropIndex('event_alias_uk', 'event_lang');
  76 + $this->dropIndex('event_lang_uk', 'event_lang');
  77 + $this->dropTable('event_lang');
  78 + }
  79 +}
console/migrations/m180507_123642_create_event_tag_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `event_tag`.
  7 + */
  8 +class m180507_123642_create_event_tag_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('event_tag', [
  16 + 'id' => $this->primaryKey(),
  17 + 'sort' => $this->integer()
  18 + ]);
  19 + }
  20 +
  21 + /**
  22 + * {@inheritdoc}
  23 + */
  24 + public function safeDown()
  25 + {
  26 + $this->dropTable('event_tag');
  27 + }
  28 +}
console/migrations/m180507_123737_create_event_tag_lang_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `event_tag_lang`.
  7 + */
  8 +class m180507_123737_create_event_tag_lang_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('event_tag_lang', [
  16 + 'id' => $this->primaryKey(),
  17 + 'event_tag_id' => $this->integer()
  18 + ->notNull(),
  19 + 'language_id' => $this->integer()
  20 + ->notNull(),
  21 + 'alias_id' => $this->integer(),
  22 + 'title' => $this->string(255),
  23 + ]);
  24 +
  25 + $this->createIndex(
  26 + 'event_tag_lang_uk',
  27 + 'event_tag_lang',
  28 + [
  29 + 'event_tag_id',
  30 + 'language_id',
  31 + ],
  32 + true
  33 + );
  34 +
  35 + $this->createIndex('event_tag_lang_auk', 'event_tag_lang', 'alias_id', true);
  36 +
  37 + $this->addForeignKey(
  38 + 'event_tag_lang_fk',
  39 + 'event_tag_lang',
  40 + 'language_id',
  41 + 'language',
  42 + 'id',
  43 + 'RESTRICT',
  44 + 'CASCADE'
  45 + );
  46 +
  47 + $this->addForeignKey(
  48 + 'event_tag_fk',
  49 + 'event_tag_lang',
  50 + 'event_tag_id',
  51 + 'event_tag',
  52 + 'id',
  53 + 'CASCADE',
  54 + 'CASCADE'
  55 + );
  56 + }
  57 +
  58 + /**
  59 + * {@inheritdoc}
  60 + */
  61 + public function safeDown()
  62 + {
  63 + $this->dropForeignKey('event_tag_fk', 'event_tag_lang');
  64 + $this->dropForeignKey('event_tag_lang_fk', 'event_tag_lang');
  65 + $this->dropIndex('event_tag_lang_uk', 'event_tag_lang');
  66 + $this->dropTable('event_tag_lang');
  67 + }
  68 +}
console/migrations/m180507_124405_create_event_to_tag_table.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Handles the creation of table `event_to_tag`.
  7 + */
  8 +class m180507_124405_create_event_to_tag_table extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->createTable('event_to_tag', [
  16 + 'event_id' => $this->integer()
  17 + ->notNull(),
  18 + 'event_tag_id' => $this->integer()
  19 + ->notNull(),
  20 + ]);
  21 +
  22 + /**
  23 + * Create indexes and foreign keys for junction table
  24 + */
  25 + $this->createIndex(
  26 + 'event_to_tag_uk',
  27 + 'event_to_tag',
  28 + [
  29 + 'event_id',
  30 + 'event_tag_id',
  31 + ],
  32 + true
  33 + );
  34 +
  35 + $this->addForeignKey(
  36 + 'event_to_tag_tag_fk',
  37 + 'event_to_tag',
  38 + 'event_tag_id',
  39 + 'event_tag',
  40 + 'id',
  41 + 'CASCADE',
  42 + 'CASCADE'
  43 + );
  44 +
  45 + $this->addForeignKey(
  46 + 'event_to_tag_art_fk',
  47 + 'event_to_tag',
  48 + 'event_id',
  49 + 'event',
  50 + 'id',
  51 + 'CASCADE',
  52 + 'CASCADE'
  53 + );
  54 + }
  55 +
  56 + /**
  57 + * {@inheritdoc}
  58 + */
  59 + public function safeDown()
  60 + {
  61 + $this->dropForeignKey('event_to_tag_art_fk', 'event_to_tag');
  62 + $this->dropForeignKey('event_to_tag_tag_fk', 'event_to_tag');
  63 + $this->dropIndex('event_to_tag_uk', 'event_to_tag');
  64 + $this->dropTable('event_to_tag');
  65 + }
  66 +}
console/migrations/m180507_131039_alter_tables_slide.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +/**
  6 + * Class m180507_131039_alter_tables_slide
  7 + */
  8 +class m180507_131039_alter_tables_slide extends Migration
  9 +{
  10 + /**
  11 + * {@inheritdoc}
  12 + */
  13 + public function safeUp()
  14 + {
  15 + $this->addColumn('slide', 'background_id', $this->integer());
  16 + $this->addColumn('slide_lang', 'description', $this->text());
  17 + }
  18 +
  19 + /**
  20 + * {@inheritdoc}
  21 + */
  22 + public function safeDown()
  23 + {
  24 + $this->dropColumn('slide', 'background_id');
  25 + $this->dropColumn('slide_lang', 'description');
  26 + }
  27 +
  28 + /*
  29 + // Use up()/down() to run migration code without a transaction.
  30 + public function up()
  31 + {
  32 +
  33 + }
  34 +
  35 + public function down()
  36 + {
  37 + echo "m180507_131039_alter_tables_slide cannot be reverted.\n";
  38 +
  39 + return false;
  40 + }
  41 + */
  42 +}
frontend/assets/AppAsset.php
@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
21 '//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800', 21 '//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800',
22 'css/custom.css', 22 'css/custom.css',
23 'css/modal.css', 23 'css/modal.css',
  24 + 'css/style.blue.css',
24 ]; 25 ];
25 public $js = [ 26 public $js = [
26 'js/jquery.cookie.js', 27 'js/jquery.cookie.js',
frontend/assets/GalleryAsset.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 07.05.18
  6 + * Time: 17:29
  7 + */
  8 +
  9 + namespace frontend\assets;
  10 +
  11 + use yii\web\AssetBundle;
  12 +
  13 + class GalleryAsset extends AssetBundle
  14 + {
  15 + public $basePath = '@webroot';
  16 + public $baseUrl = '@web';
  17 + public $css = [
  18 + 'css/photoswipe.css'
  19 + ];
  20 + public $js = [
  21 + 'js/photoswipe.min.js',
  22 + 'js/photoswipe-ui-default.min.js',
  23 + 'js/gallery.js'
  24 + ];
  25 + public $depends = [
  26 + 'frontend\assets\AppAsset',
  27 + ];
  28 + }
0 \ No newline at end of file 29 \ No newline at end of file
frontend/config/main.php
@@ -44,9 +44,9 @@ @@ -44,9 +44,9 @@
44 ], 44 ],
45 ], 45 ],
46 'labels' => [ 46 'labels' => [
47 - 'email' => 'Email',  
48 - 'name' => 'Name',  
49 - 'message' => 'You question', 47 + 'email' => \Yii::t('app','Email'),
  48 + 'name' => \Yii::t('app','Name'),
  49 + 'message' => \Yii::t('app','You question'),
50 ], 50 ],
51 'inputOptions' => [ 51 'inputOptions' => [
52 'message' => [ 52 'message' => [
@@ -54,16 +54,19 @@ @@ -54,16 +54,19 @@
54 'options' => [], 54 'options' => [],
55 ], 55 ],
56 ], 56 ],
  57 + 'buttonContent' => \Yii::t('app','Send'),
57 'scenario' => 'feedback', 58 'scenario' => 'feedback',
58 'sendEmail' => false, 59 'sendEmail' => false,
59 'formId' => 'feedback-form', 60 'formId' => 'feedback-form',
60 'ajax' => true, 61 'ajax' => true,
61 'successCallback' => 'function (data) { 62 'successCallback' => 'function (data) {
  63 + document.getElementById("feedback-form").reset();
62 $(".close").click(); 64 $(".close").click();
63 $(".success_").animate({opacity: 1, top: \'40\'}, 200).addClass("done_"); 65 $(".success_").animate({opacity: 1, top: \'40\'}, 200).addClass("done_");
64 setTimeout(function(){$(".success_").animate({opacity: 0, top: \'0\'}, 200,function(){ 66 setTimeout(function(){$(".success_").animate({opacity: 0, top: \'0\'}, 200,function(){
65 $(this).removeClass("done_"); 67 $(this).removeClass("done_");
66 })}, 4000); 68 })}, 4000);
  69 +
67 }', 70 }',
68 ], 71 ],
69 72
@@ -92,10 +95,10 @@ @@ -92,10 +95,10 @@
92 ] 95 ]
93 ], 96 ],
94 'labels' => [ 97 'labels' => [
95 - 'email' => 'Email',  
96 - 'name' => 'Name',  
97 - 'message' => 'Message',  
98 - 'phone' => 'Phone' 98 + 'email' => \Yii::t('app','Email'),
  99 + 'name' => \Yii::t('app', 'Name'),
  100 + 'message' => \Yii::t('app','Message'),
  101 + 'phone' => \Yii::t('app','Phone')
99 ], 102 ],
100 103
101 'inputOptions' => [ 104 'inputOptions' => [
@@ -118,12 +121,13 @@ @@ -118,12 +121,13 @@
118 'buttonOptions' => [ 121 'buttonOptions' => [
119 'class' => 'btn btn-template-main', 122 'class' => 'btn btn-template-main',
120 ], 123 ],
121 - 'buttonContent' => '<i class="fa fa-envelope-o"></i> Send message', 124 + 'buttonContent' => '<i class="fa fa-envelope-o"></i>' .\Yii::t('app','Send message'),
122 'sendEmail' => false, 125 'sendEmail' => false,
123 'ajax' => true, 126 'ajax' => true,
124 'formId' => 'contact-form', 127 'formId' => 'contact-form',
125 'scenario' => 'default', 128 'scenario' => 'default',
126 'successCallback' => 'function (data) { 129 'successCallback' => 'function (data) {
  130 + document.getElementById("contact-form").reset();
127 $(".close").click(); 131 $(".close").click();
128 $(".success_").animate({opacity: 1, top: \'40\'}, 200).addClass("done_"); 132 $(".success_").animate({opacity: 1, top: \'40\'}, 200).addClass("done_");
129 setTimeout(function(){$(".success_").animate({opacity: 0, top: \'0\'}, 200,function(){ 133 setTimeout(function(){$(".success_").animate({opacity: 0, top: \'0\'}, 200,function(){
frontend/controllers/BlogController.php
@@ -40,12 +40,12 @@ @@ -40,12 +40,12 @@
40 $dataProvider = new ActiveDataProvider( 40 $dataProvider = new ActiveDataProvider(
41 [ 41 [
42 'query' => Article::find() 42 'query' => Article::find()
43 - ->orderBy( 43 + ->orderBy(
44 [ 44 [
45 'created_at' => SORT_DESC, 45 'created_at' => SORT_DESC,
46 ] 46 ]
47 ) 47 )
48 - ->with( 48 + ->with(
49 [ 49 [
50 'categories.language', 50 'categories.language',
51 ] 51 ]
@@ -225,16 +225,16 @@ @@ -225,16 +225,16 @@
225 * @var Article | null $model 225 * @var Article | null $model
226 */ 226 */
227 $model = Article::find() 227 $model = Article::find()
228 - ->where([ 'id' => $id ])  
229 - ->with( 228 + ->where([ 'id' => $id ])
  229 + ->with(
230 [ 230 [
231 'language', 231 'language',
232 'categories.language', 232 'categories.language',
233 'tags.language', 233 'tags.language',
234 ] 234 ]
235 ) 235 )
236 - ->andWhere([ 'status' => true ])  
237 - ->one(); 236 + ->andWhere([ 'status' => true ])
  237 + ->one();
238 238
239 if (empty($model)) { 239 if (empty($model)) {
240 throw new NotFoundHttpException(\Yii::t('app', 'Article not found')); 240 throw new NotFoundHttpException(\Yii::t('app', 'Article not found'));
frontend/controllers/EventController.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace frontend\controllers;
  4 +
  5 + use common\models\event\Event;
  6 + use common\models\event\Tag;
  7 + use yii\data\ActiveDataProvider;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 +
  11 + /**
  12 + * Class BlogController
  13 + *
  14 + * @package frontend\controllers
  15 + */
  16 + class EventController extends Controller
  17 + {
  18 + public function actionIndex($q = '')
  19 + {
  20 + $tags = Tag::find()
  21 + ->with(
  22 + [
  23 + 'language',
  24 + ]
  25 + )
  26 + ->orderBy([ 'sort' => SORT_ASC ])
  27 + ->all();
  28 +
  29 +
  30 + $dataProvider = new ActiveDataProvider(
  31 + [
  32 + 'query' => Event::find()
  33 + ->orderBy(
  34 + [
  35 + 'created_at' => SORT_DESC,
  36 + ]
  37 + )
  38 + ->joinWith('language')
  39 + ->where([ 'event.status' => true ])
  40 + ->andFilterWhere(
  41 + [
  42 + 'ilike',
  43 + 'event_lang.title',
  44 + $q,
  45 + ]
  46 + )
  47 + ->distinct(),
  48 + 'pagination' => [
  49 + 'pageSize' => 3,
  50 + ],
  51 + ]
  52 + );
  53 +
  54 + return $this->render(
  55 + 'index',
  56 + [
  57 + 'tags' => $tags,
  58 + 'dataProvider' => $dataProvider,
  59 + ]
  60 + );
  61 + }
  62 +
  63 + public function actionView($id)
  64 + {
  65 + $model = $this->findModel($id);
  66 +
  67 + $tags = Tag::find()
  68 + ->with([ 'language' ])
  69 + ->orderBy([ 'sort' => SORT_ASC ])
  70 + ->all();
  71 +
  72 + return $this->render(
  73 + 'view',
  74 + [
  75 + 'tags' => $tags,
  76 + 'model' => $model,
  77 + ]
  78 + );
  79 + }
  80 +
  81 +
  82 + public function actionTag($id)
  83 + {
  84 + $tags = Tag::find()
  85 + ->with(
  86 + [
  87 + 'language',
  88 + ]
  89 + )
  90 + ->orderBy([ 'sort' => SORT_ASC ])
  91 + ->all();
  92 +
  93 + $model = Tag::find()
  94 + ->where(
  95 + [
  96 + 'id' => $id,
  97 + ]
  98 + )
  99 + ->with(
  100 + [
  101 + 'articles',
  102 + ]
  103 + )
  104 + ->one();
  105 +
  106 + $dataProvider = new ActiveDataProvider(
  107 + [
  108 + 'query' => $model->getEvents()
  109 + ->with(
  110 + [
  111 + 'language',
  112 + ]
  113 + )
  114 + ->where(['event.status' => true])
  115 + ->orderBy(
  116 + [
  117 + 'created_at' => SORT_DESC,
  118 + ]
  119 + ),
  120 + 'pagination' => [
  121 + 'pageSize' => 3,
  122 + ],
  123 + ]
  124 + );
  125 +
  126 + return $this->render(
  127 + 'tag',
  128 + [
  129 + 'tags' => $tags,
  130 + 'dataProvider' => $dataProvider,
  131 + 'model' => $model,
  132 + ]
  133 + );
  134 + }
  135 +
  136 + /**
  137 + * @param $id
  138 + *
  139 + * @return Event
  140 + * @throws \yii\web\NotFoundHttpException
  141 + */
  142 + protected function findModel($id)
  143 + {
  144 + /**
  145 + * @var Event | null $model
  146 + */
  147 + $model = Event::find()
  148 + ->where([ 'id' => $id ])
  149 + ->with(
  150 + [
  151 + 'language',
  152 + 'tags.language',
  153 + ]
  154 + )
  155 + ->andWhere([ 'status' => true ])
  156 + ->one();
  157 +
  158 + if (empty($model)) {
  159 + throw new NotFoundHttpException(\Yii::t('app', 'Article not found'));
  160 + } else {
  161 + return $model;
  162 + }
  163 + }
  164 + }
0 \ No newline at end of file 165 \ No newline at end of file
frontend/controllers/GalleryController.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: stes
  5 + * Date: 07.05.18
  6 + * Time: 17:08
  7 + */
  8 +
  9 + namespace frontend\controllers;
  10 +
  11 + use common\models\Gallery;
  12 + use yii\web\Controller;
  13 +
  14 + class GalleryController extends Controller
  15 + {
  16 + public function actionIndex(){
  17 + $images = Gallery::find()->with('language')->where(['status' => true])->orderBy('sort')->all();
  18 + return $this->render('index', [
  19 + 'images' => $images
  20 + ]);
  21 + }
  22 + }
0 \ No newline at end of file 23 \ No newline at end of file
frontend/controllers/SiteController.php
@@ -53,11 +53,11 @@ @@ -53,11 +53,11 @@
53 { 53 {
54 $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); 54 $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all();
55 $articles = Article::find() 55 $articles = Article::find()
56 - ->with('language')  
57 - ->where([ 'status' => true ])  
58 - ->orderBy('sort DESC')  
59 - ->limit(4)  
60 - ->all(); 56 + ->with('language')
  57 + ->where([ 'status' => true ])
  58 + ->orderBy('sort DESC')
  59 + ->limit(4)
  60 + ->all();
61 return $this->render('index', [ 61 return $this->render('index', [
62 'slides' => $slides, 62 'slides' => $slides,
63 'articles' => $articles 63 'articles' => $articles
frontend/views/blog/view.php
@@ -7,9 +7,9 @@ @@ -7,9 +7,9 @@
7 use yii\web\View; 7 use yii\web\View;
8 8
9 /** 9 /**
10 - * @var View $this 10 + * @var View $this
11 * @var Article $model 11 * @var Article $model
12 - * @var Tag[] $tags 12 + * @var Tag[] $tags
13 */ 13 */
14 14
15 $this->params[ 'breadcrumbs' ][] = [ 15 $this->params[ 'breadcrumbs' ][] = [
frontend/views/event/_event.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\helpers\ImageHelper;
  4 + use yii\bootstrap\Html;
  5 + use artbox\core\helpers\Url;
  6 +
  7 + /**
  8 + * @var \common\models\blog\Article $model
  9 + */
  10 +
  11 +?>
  12 +
  13 +<section class="post">
  14 + <div class="row">
  15 + <div class="col-xs-4 col-sm-4 col-md-4">
  16 + <div class="image">
  17 + <a href="<?= Url::to(
  18 + [
  19 + 'alias' => $model->alias
  20 + ]
  21 + ) ?>">
  22 + <?= ImageHelper::set($model->image ? $model->image->getPath() : '@frontend/web/img/no-image.png')
  23 + ->cropResize(263, 197)
  24 + ->renderImage(
  25 + [
  26 + 'class' => 'img-responsive',
  27 + 'alt' => $model->title,
  28 + ]
  29 + ) ?>
  30 + </a>
  31 + </div>
  32 + </div>
  33 + <div class="col-xs-8 col-sm-8 col-md-8">
  34 + <h2><a href="<?= Url::to(
  35 + [
  36 + 'alias' => $model->alias
  37 + ]
  38 + ) ?>"><?= $model->title; ?></a></h2>
  39 + <div class="clearfix">
  40 + <?php if (empty($model->categories)) { ?>
  41 + <p class="author-category">Без категории </p>
  42 + <?php } else {
  43 + $i = 0;
  44 + foreach ($model->categories as $category) {
  45 + $i++;
  46 + ?>
  47 + <p class="author-category">
  48 + <a href="<?=Url::to(['alias' => $category->alias])?>"><?=$category->title?></a>
  49 + <?php
  50 +
  51 + if ($i === count($model->categories)) {
  52 + echo '&#160';
  53 + } else {
  54 + echo '&#44&#160';
  55 + }
  56 + ?></p>
  57 + <?php
  58 + }
  59 + } ?>
  60 + <p class="date-comments">
  61 + <i class="fa fa-calendar-o"></i> <?= \Yii::$app->formatter->asDate($model->created_at); ?>
  62 + <!-- <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 комментариев</a>-->
  63 + </p>
  64 + </div>
  65 + <p class="intro"><?= $model->body_preview; ?></p>
  66 + <p class="read-more">
  67 + <?= Html::a(
  68 + 'Продолжить чтение',
  69 + [
  70 + '', 'alias' => $model->alias
  71 + ],
  72 + [
  73 + 'class' => 'btn btn-template-main',
  74 + ]
  75 + ) ?>
  76 + </p>
  77 + </div>
  78 + </div>
  79 +</section>
frontend/views/event/index.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\components\SeoComponent;
  4 + use yii\data\ActiveDataProvider;
  5 + use artbox\core\helpers\Url;
  6 + use yii\web\View;
  7 + use yii\widgets\ListView;
  8 +
  9 + /**
  10 + * @var View $this
  11 + * @var ActiveDataProvider $dataProvider
  12 + * @var SeoComponent $seo
  13 + * @var \common\models\event\Tag[] $tags
  14 + */
  15 + $seo = \Yii::$app->get('seo');
  16 +
  17 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Events');
  18 +
  19 +?>
  20 +
  21 +<div id="content">
  22 + <div class="container">
  23 + <div class="row">
  24 + <!-- *** LEFT COLUMN ***
  25 +_________________________________________________________ -->
  26 +
  27 +
  28 + <?= ListView::widget(
  29 + [
  30 + 'dataProvider' => $dataProvider,
  31 + 'itemView' => '_event',
  32 + 'options' => [
  33 + 'class' => 'col-md-9',
  34 + 'id' => 'blog-listing-medium',
  35 + ],
  36 + 'layout' => '{items}{pager}',
  37 + ]
  38 + ); ?>
  39 +
  40 +
  41 + <!-- *** LEFT COLUMN END *** -->
  42 +
  43 + <!-- *** RIGHT COLUMN ***
  44 +_________________________________________________________ -->
  45 +
  46 + <div class="col-md-3 blog-sidebar">
  47 +
  48 + <!-- *** MENUS AND WIDGETS ***
  49 +_________________________________________________________ -->
  50 +
  51 +<!-- --><?//= BlogSearch::widget(); ?>
  52 + <?php if(!empty($tags)){
  53 + ?>
  54 + <div class="panel sidebar-menu">
  55 + <div class="panel-heading">
  56 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  57 + </div>
  58 +
  59 + <div class="panel-body">
  60 + <ul class="tag-cloud">
  61 + <?php foreach ($tags as $tag) { ?>
  62 + <li><a href="<?= Url::to(
  63 + [
  64 + 'alias' => $tag->alias
  65 + ]
  66 + ) ?>"><i class="fa fa-tag"></i>&#160<?= $tag->title; ?></a>
  67 + </li>
  68 + <?php } ?>
  69 + </ul>
  70 + </div>
  71 + </div>
  72 + <?php
  73 + }
  74 + ?>
  75 +
  76 +
  77 + <!-- *** MENUS AND FILTERS END *** -->
  78 +
  79 + </div>
  80 + <!-- /.col-md-3 -->
  81 +
  82 + <!-- *** RIGHT COLUMN END *** -->
  83 +
  84 + </div>
  85 + <!-- /.row -->
  86 + </div>
  87 + <!-- /.container -->
  88 +</div>
  89 +<!-- /#content -->
0 \ No newline at end of file 90 \ No newline at end of file
frontend/views/event/tag.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\components\SeoComponent;
  4 + use common\models\event\Tag;
  5 + use yii\data\ActiveDataProvider;
  6 + use artbox\core\helpers\Url;
  7 + use yii\web\View;
  8 + use yii\widgets\ListView;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var ActiveDataProvider $dataProvider
  13 + * @var SeoComponent $seo
  14 + * @var Tag[] $tags
  15 + * @var Tag $model
  16 + */
  17 + $seo = \Yii::$app->get('seo');
  18 +
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => \Yii::t('app', 'Events'),
  21 + 'url' => [ 'event/index' ],
  22 + ];
  23 +
  24 + $this->params[ 'breadcrumbs' ][] = $seo->title;
  25 +
  26 +?>
  27 +
  28 +<div id="content">
  29 + <div class="container">
  30 + <div class="row">
  31 + <!-- *** LEFT COLUMN ***
  32 +_________________________________________________________ -->
  33 +
  34 +
  35 + <!-- <ul class="pager">-->
  36 + <!-- <li class="previous"><a href="#">&larr; Назад</a>-->
  37 + <!-- </li>-->
  38 + <!-- <li class="next disabled"><a href="#">Вперед &rarr;</a>-->
  39 + <!-- </li>-->
  40 + <!-- </ul>-->
  41 +
  42 + <!-- /.col-md-9 -->
  43 +
  44 +
  45 + <?= ListView::widget(
  46 + [
  47 + 'dataProvider' => $dataProvider,
  48 + 'itemView' => '_event',
  49 + 'options' => [
  50 + 'class' => 'col-md-9',
  51 + 'id' => 'blog-listing-medium',
  52 + ],
  53 + 'layout' => '{items}{pager}',
  54 + ]
  55 + ); ?>
  56 +
  57 +
  58 + <!-- *** LEFT COLUMN END *** -->
  59 +
  60 + <!-- *** RIGHT COLUMN ***
  61 +_________________________________________________________ -->
  62 +
  63 + <div class="col-md-3">
  64 +
  65 + <!-- *** MENUS AND WIDGETS ***
  66 +_________________________________________________________ -->
  67 +
  68 +
  69 + <div class="panel sidebar-menu">
  70 + <div class="panel-heading">
  71 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  72 + </div>
  73 +
  74 + <div class="panel-body">
  75 + <ul class="tag-cloud">
  76 + <?php foreach ($tags as $tag) { ?>
  77 + <li><a href="<?= Url::to(
  78 + [
  79 + 'alias' => $tag->alias
  80 + ]
  81 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->title; ?></a>
  82 + </li>
  83 + <?php } ?>
  84 + </ul>
  85 + </div>
  86 + </div>
  87 +
  88 + <!-- *** MENUS AND FILTERS END *** -->
  89 +
  90 + </div>
  91 + <!-- /.col-md-3 -->
  92 +
  93 + <!-- *** RIGHT COLUMN END *** -->
  94 +
  95 + </div>
  96 + <!-- /.row -->
  97 + </div>
  98 + <!-- /.container -->
  99 +</div>
  100 +<!-- /#content -->
0 \ No newline at end of file 101 \ No newline at end of file
frontend/views/event/view.php 0 → 100755
  1 +<?php
  2 +
  3 + use common\models\event\Event;
  4 + use common\models\event\Tag;
  5 + use artbox\core\helpers\Url;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Event $model
  11 + * @var Tag[] $tags
  12 + */
  13 +
  14 + $this->params[ 'breadcrumbs' ][] = [
  15 + 'label' => \Yii::t('app', 'Events'),
  16 + 'url' => [ 'event/index' ],
  17 + ];
  18 +
  19 + $this->params[ 'breadcrumbs' ][] = $model->title;
  20 +
  21 +?>
  22 +
  23 +<div id="content">
  24 + <div class="container">
  25 +
  26 + <div class="row">
  27 +
  28 + <!-- *** LEFT COLUMN ***
  29 +_________________________________________________________ -->
  30 +
  31 + <div class="col-md-9" id="blog-post">
  32 +
  33 + <h2><?= $model->title; ?></h2>
  34 +
  35 + <?php if (!empty($model->tags)) { ?>
  36 + <div class="panel sidebar-menu">
  37 + <div class="panel-body">
  38 + <ul class="tag-cloud">
  39 + <?php foreach ($model->tags as $tag) { ?>
  40 + <li><a href="<?= Url::to(
  41 + [
  42 + 'alias' => $tag->alias
  43 + ]
  44 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->title; ?></a>
  45 + </li>
  46 + <?php } ?>
  47 + </ul>
  48 + </div>
  49 + </div>
  50 + <?php } ?>
  51 +
  52 + <p class="text-muted text-uppercase mb-small text-left"><?= \Yii::$app->formatter->asDate(
  53 + $model->created_at
  54 + ); ?></p>
  55 +
  56 + <div id="post-content">
  57 +
  58 + <?= $model->body; ?>
  59 +
  60 + </div>
  61 + <!-- /#post-content -->
  62 +
  63 + <?php
  64 + /*
  65 +
  66 + <div id="comments">
  67 + <h4 class="text-uppercase">2 comments</h4>
  68 +
  69 +
  70 + <div class="row comment">
  71 + <div class="col-sm-3 col-md-2 text-center-xs">
  72 + <p>
  73 + <img src="img/blog-avatar2.jpg" class="img-responsive img-circle" alt="">
  74 + </p>
  75 + </div>
  76 + <div class="col-sm-9 col-md-10">
  77 + <h5 class="text-uppercase">Julie Alma</h5>
  78 + <p class="posted"><i class="fa fa-clock-o"></i> September 23, 2011 в 12:00</p>
  79 + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.
  80 + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  81 + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a>
  82 + </p>
  83 + </div>
  84 + </div>
  85 + <!-- /.comment -->
  86 +
  87 +
  88 + <div class="row comment last">
  89 +
  90 + <div class="col-sm-3 col-md-2 text-center-xs">
  91 + <p>
  92 + <img src="img/blog-avatar.jpg" class="img-responsive img-circle" alt="">
  93 + </p>
  94 + </div>
  95 +
  96 + <div class="col-sm-9 col-md-10">
  97 + <h5 class="text-uppercase">Louise Armero</h5>
  98 + <p class="posted"><i class="fa fa-clock-o"></i> 23 сентября 2012 в 12:00</p>
  99 + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.
  100 + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  101 + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a>
  102 + </p>
  103 + </div>
  104 +
  105 + </div>
  106 + <!-- /.comment -->
  107 + </div>
  108 + <!-- /#comments -->
  109 +
  110 +
  111 + <div id="comment-form">
  112 +
  113 + <h4 class="text-uppercase">Leave comment</h4>
  114 +
  115 + <form>
  116 + <div class="row">
  117 +
  118 + <div class="col-sm-6">
  119 + <div class="form-group">
  120 + <label for="name">Name <span class="required">*</span>
  121 + </label>
  122 + <input type="text" class="form-control" id="name">
  123 + </div>
  124 + </div>
  125 +
  126 + </div>
  127 +
  128 + <div class="row">
  129 + <div class="col-sm-6">
  130 + <div class="form-group">
  131 + <label for="email">Email <span class="required">*</span>
  132 + </label>
  133 + <input type="text" class="form-control" id="email">
  134 + </div>
  135 + </div>
  136 + </div>
  137 +
  138 + <div class="row">
  139 + <div class="col-sm-12">
  140 + <div class="form-group">
  141 + <label for="comment">Comment <span class="required">*</span>
  142 + </label>
  143 + <textarea class="form-control" id="comment" rows="4"></textarea>
  144 + </div>
  145 + </div>
  146 + </div>
  147 +
  148 + <div class="row">
  149 + <div class="col-sm-12 text-right">
  150 + <button class="btn btn-template-main"><i class="fa fa-comment-o"></i> Post comment</button>
  151 + </div>
  152 + </div>
  153 +
  154 +
  155 + </form>
  156 +
  157 + </div>
  158 + <!-- /#comment-form -->
  159 + */
  160 + ?>
  161 + </div>
  162 + <!-- /#blog-post -->
  163 +
  164 + <!-- *** LEFT COLUMN END *** -->
  165 +
  166 + <!-- *** RIGHT COLUMN ***
  167 + _________________________________________________________ -->
  168 +
  169 + <div class="col-md-3">
  170 +
  171 + <!-- *** MENUS AND WIDGETS ***
  172 +_________________________________________________________ -->
  173 +
  174 + <div class="panel sidebar-menu">
  175 + <div class="panel-heading">
  176 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  177 + </div>
  178 +
  179 + <div class="panel-body">
  180 + <ul class="tag-cloud">
  181 + <?php foreach ($tags as $tag) { ?>
  182 + <li><a href="<?= Url::to(
  183 + [
  184 + 'alias' => $tag->alias
  185 + ]
  186 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->title; ?></a>
  187 + </li>
  188 + <?php } ?>
  189 + </ul>
  190 + </div>
  191 + </div>
  192 +
  193 + <!-- *** MENUS AND FILTERS END *** -->
  194 +
  195 + </div>
  196 + <!-- /.col-md-3 -->
  197 + <!-- *** RIGHT COLUMN END *** -->
  198 +
  199 +
  200 + </div>
  201 + <!-- /.row -->
  202 +
  203 + </div>
  204 + <!-- /.container -->
  205 +</div>
  206 +<!-- /#content -->
  207 +
0 \ No newline at end of file 208 \ No newline at end of file
frontend/views/gallery/index.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * @var \common\models\Gallery[] $images;
  4 + */
  5 + use artbox\core\helpers\ImageHelper;
  6 + use frontend\assets\GalleryAsset;
  7 +
  8 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Gallery');
  9 + GalleryAsset::register($this);
  10 + ?>
  11 +
  12 +
  13 +
  14 +
  15 +<div id="content">
  16 + <div class="container">
  17 + <div class="row">
  18 + <div class="col-md-12">
  19 + <div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
  20 + <?php foreach ($images as $gallery){?>
  21 + <figure class="reviews_gallery">
  22 + <a href="<?=$gallery->image->getUrl()?>" itemprop="contentUrl" data-size="<?= getimagesize(
  23 + $gallery->image->getPath()
  24 + )[ 0 ] ?>x<?= getimagesize($gallery->image->getPath()
  25 + )[ 1 ] ?>">
  26 + <img src="<?= ImageHelper::set($gallery->image->getPath())
  27 + ->resize(360, 216)
  28 + ->quality(82)
  29 + ->render(
  30 + ) ?>" itemprop="thumbnail" alt="<?=$gallery->title?>"/>
  31 + </a>
  32 + </figure>
  33 + <?php }?>
  34 + </div>
  35 + </div>
  36 + </div>
  37 + </div>
  38 +</div>
  39 +
  40 +<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
  41 +
  42 + <div class="pswp__bg"></div>
  43 +
  44 + <div class="pswp__scroll-wrap">
  45 +
  46 + <div class="pswp__container">
  47 + <div class="pswp__item"></div>
  48 + <div class="pswp__item"></div>
  49 + <div class="pswp__item"></div>
  50 + </div>
  51 +
  52 + <div class="pswp__ui pswp__ui--hidden">
  53 + <div class="pswp__top-bar">
  54 +
  55 + <div class="pswp__counter"></div>
  56 + <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
  57 + <button class="pswp__button pswp__button--share" title="Share"></button>
  58 + <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
  59 + <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
  60 +
  61 +
  62 + <div class="pswp__preloader">
  63 + <div class="pswp__preloader__icn">
  64 + <div class="pswp__preloader__cut">
  65 + <div class="pswp__preloader__donut"></div>
  66 + </div>
  67 + </div>
  68 + </div>
  69 + </div>
  70 + <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
  71 + <div class="pswp__share-tooltip"></div>
  72 + </div>
  73 + <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
  74 + </button>
  75 + <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
  76 + </button>
  77 + <div class="pswp__caption">
  78 + <div class="pswp__caption__center"></div>
  79 + </div>
  80 + </div>
  81 + </div>
  82 +</div>
  83 +
frontend/views/layouts/main.php
@@ -238,7 +238,8 @@ _________________________________________________________ --&gt; @@ -238,7 +238,8 @@ _________________________________________________________ --&gt;
238 ); 238 );
239 } 239 }
240 ?> 240 ?>
241 - <?php $lang = explode("-", \Yii::$app->language); ?> 241 + <?php $lang = explode("-", \Yii::$app->language);
  242 + ?>
242 <div class="langs"> 243 <div class="langs">
243 <a<?php if ($lang[ '0' ] == 'ru') { 244 <a<?php if ($lang[ '0' ] == 'ru') {
244 echo ' class="active"'; 245 echo ' class="active"';
@@ -250,6 +251,11 @@ _________________________________________________________ --&gt; @@ -250,6 +251,11 @@ _________________________________________________________ --&gt;
250 } else { 251 } else {
251 echo ' href="/en"'; 252 echo ' href="/en"';
252 } ?>>en</a> 253 } ?>>en</a>
  254 + <a<?php if ($lang[ '0' ] == 'ua') {
  255 + echo ' class="active"';
  256 + } else {
  257 + echo ' href="/ua"';
  258 + } ?>>ua</a>
253 </div> 259 </div>
254 </div> 260 </div>
255 </div> 261 </div>
@@ -302,7 +308,6 @@ _________________________________________________________ --&gt; @@ -302,7 +308,6 @@ _________________________________________________________ --&gt;
302 foreach ($category->pages as $page) { 308 foreach ($category->pages as $page) {
303 $pages[] = [ 309 $pages[] = [
304 'label' => $page->title, 310 'label' => $page->title,
305 - // @TODO without index 0 not use createUrl  
306 'url' => Url::to(['alias' => $page->alias]), 311 'url' => Url::to(['alias' => $page->alias]),
307 ]; 312 ];
308 } 313 }
@@ -312,7 +317,7 @@ _________________________________________________________ --&gt; @@ -312,7 +317,7 @@ _________________________________________________________ --&gt;
312 ]; 317 ];
313 } 318 }
314 $items[] = [ 319 $items[] = [
315 - 'label' => \Yii::t('app', 'Contatcs'), 320 + 'label' => \Yii::t('app', 'Contacts'),
316 'url' => [ 'site/contact' ], 321 'url' => [ 'site/contact' ],
317 ]; 322 ];
318 $items[] = [ 323 $items[] = [
@@ -323,6 +328,10 @@ _________________________________________________________ --&gt; @@ -323,6 +328,10 @@ _________________________________________________________ --&gt;
323 'label' => \Yii::t('app', 'Blog'), 328 'label' => \Yii::t('app', 'Blog'),
324 'url' => [ 'blog/index' ], 329 'url' => [ 'blog/index' ],
325 ]; 330 ];
  331 + $items[] = [
  332 + 'label' => \Yii::t('app', 'Events'),
  333 + 'url' => [ 'event/index' ],
  334 + ];
326 echo Nav::widget( 335 echo Nav::widget(
327 [ 336 [
328 'items' => $items, 337 'items' => $items,
@@ -441,43 +450,23 @@ _________________________________________________________ --&gt; @@ -441,43 +450,23 @@ _________________________________________________________ --&gt;
441 <?php 450 <?php
442 } 451 }
443 ?> 452 ?>
444 - <a href="#" class="btn btn-template-transparent-primary modal-link" data-form="feedback-modal" data-toggle="modal">Contact us!</a> 453 + <a href="#" class="btn btn-template-transparent-primary modal-link" data-form="feedback-modal" data-toggle="modal"><?=\Yii::t('app', 'Contact us!')?></a>
445 </div> 454 </div>
446 455
447 <div class="col-md-4 col-sm-12 col-md-offset-2"> 456 <div class="col-md-4 col-sm-12 col-md-offset-2">
448 457
449 - <h4><?php echo \Yii::t('app', 'Contact'); ?></h4> 458 + <h4><?php echo \Yii::t('app', 'Contacts'); ?></h4>
450 459
451 <p> 460 <p>
452 <?php 461 <?php
453 - if (!empty($settings->office)) {  
454 - echo \Yii::t(  
455 - 'app',  
456 - 'Office {office}',  
457 - [  
458 - 'office' => $settings->office,  
459 - ]  
460 - ) . Html::tag('br');  
461 - }  
462 - if (!empty($settings->street)) {  
463 - echo $settings->street;  
464 - if (!empty($settings->house)) {  
465 - echo " " . $settings->house;  
466 - }  
467 - echo Html::tag('br');  
468 - }  
469 - if (!empty($settings->city)) {  
470 - echo $settings->city;  
471 - echo Html::tag('br');  
472 - }  
473 - if (!empty($settings->country)) {  
474 - echo Html::tag('strong', $settings->country); 462 + if (!empty($settings->lang->address)) {
  463 + echo Html::tag('strong', $settings->lang->address);
475 } 464 }
476 ?> 465 ?>
477 </p> 466 </p>
478 467
479 <?= Html::a( 468 <?= Html::a(
480 - 'Go to contact page', 469 + \Yii::t('app', 'Go to contact page'),
481 [ 'site/contact' ], 470 [ 'site/contact' ],
482 [ 471 [
483 'class' => 'btn btn-small btn-template-transparent-primary', 472 'class' => 'btn btn-small btn-template-transparent-primary',
frontend/views/site/contact.php
@@ -10,13 +10,12 @@ @@ -10,13 +10,12 @@
10 use common\models\Settings; 10 use common\models\Settings;
11 use frontend\assets\MapAsset; 11 use frontend\assets\MapAsset;
12 use yii\helpers\Html; 12 use yii\helpers\Html;
13 - use yii\bootstrap\ActiveForm;  
14 use yii\web\View; 13 use yii\web\View;
15 14
16 MapAsset::register($this); 15 MapAsset::register($this);
17 $settings = Settings::getInstance(); 16 $settings = Settings::getInstance();
18 17
19 - $this->title = \Yii::t('app', 'Contact'); 18 + $this->title = \Yii::t('app', 'Contacts');
20 $this->params[ 'breadcrumbs' ][] = $this->title; 19 $this->params[ 'breadcrumbs' ][] = $this->title;
21 20
22 $js = <<< JS 21 $js = <<< JS
@@ -59,18 +58,8 @@ JS; @@ -59,18 +58,8 @@ JS;
59 <h3>Address</h3> 58 <h3>Address</h3>
60 <p> 59 <p>
61 <?php 60 <?php
62 - if (!empty( $settings->street )) {  
63 - echo $settings->street;  
64 - if (!empty( $settings->house )) {  
65 - echo " " . $settings->house;  
66 - }  
67 - echo Html::tag('br');  
68 - }  
69 - if (!empty( $settings->city )) {  
70 - echo $settings->city;  
71 - if (!empty( $settings->country )) {  
72 - echo Html::tag('strong', ", " . $settings->country);  
73 - } 61 + if (!empty( $settings->lang->address )) {
  62 + echo $settings->lang->address;
74 } 63 }
75 ?> 64 ?>
76 </p> 65 </p>
@@ -138,7 +127,7 @@ JS; @@ -138,7 +127,7 @@ JS;
138 127
139 <div class="col-md-12"> 128 <div class="col-md-12">
140 <div class="heading"> 129 <div class="heading">
141 - <h2> Contact form </h2> 130 + <h2> <?=\Yii::t('app', 'Contact form')?> </h2>
142 </div> 131 </div>
143 </div> 132 </div>
144 133
frontend/views/site/index.php
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 /* @var $this yii\web\View 3 /* @var $this yii\web\View
4 * @var \common\models\slider\Slide[] $slides; 4 * @var \common\models\slider\Slide[] $slides;
5 - * @var \common\models\blog\Article[] $articles 5 + * @var \common\models\blog\Article[] $articles
6 */ 6 */
7 7
8 use artbox\core\helpers\ImageHelper; 8 use artbox\core\helpers\ImageHelper;
@@ -21,14 +21,19 @@ _________________________________________________________ --&gt; @@ -21,14 +21,19 @@ _________________________________________________________ --&gt;
21 <div class="dark-mask"></div> 21 <div class="dark-mask"></div>
22 22
23 <div class="container"> 23 <div class="container">
24 - <div class="homepage owl-carousel">  
25 - <?php foreach ($slides as $slide){?> 24 + <div class="homepage owl-carousel" >
  25 +
  26 + <?php foreach ($slides as $key => $slide){?>
  27 +
26 <div class="item"> 28 <div class="item">
27 <div class="row"> 29 <div class="row">
28 - <div class="col-sm-6 right"> 30 + <div class="col-sm-5 <?=($key%2 == 0) ? 'right' : ''?>">
29 <h1><?=$slide->title?></h1> 31 <h1><?=$slide->title?></h1>
  32 + <p><?=$slide->description?></p>
  33 + <p style="margin-top:25px;"> </p>
  34 + <p><a href="<?=$slide->link?>" class="btn btn-template-transparent-primary">Подробнее</a></p>
30 </div> 35 </div>
31 - <div class="col-sm-6"> 36 + <div class="col-sm-7 <?=($key % 2 != 0) ? 'text-center': ''?>">
32 <a href="<?=$slide->link?>"><?=ImageHelper::set($slide->language->image->getPath()) 37 <a href="<?=$slide->link?>"><?=ImageHelper::set($slide->language->image->getPath())
33 ->cropResize(650, 380) 38 ->cropResize(650, 380)
34 ->quality(84) 39 ->quality(84)
@@ -36,8 +41,9 @@ _________________________________________________________ --&gt; @@ -36,8 +41,9 @@ _________________________________________________________ --&gt;
36 </div> 41 </div>
37 </div> 42 </div>
38 </div> 43 </div>
  44 +
39 <?php }?> 45 <?php }?>
40 - </div> 46 + </div>
41 <!-- /.project owl-slider --> 47 <!-- /.project owl-slider -->
42 </div> 48 </div>
43 </div> 49 </div>
frontend/web/js/gallery.js 0 → 100644
  1 +var initPhotoSwipeFromDOM = function(gallerySelector) {
  2 + // parse slide data (url, title, size ...) from DOM elements
  3 + // (children of gallerySelector)
  4 + var parseThumbnailElements = function(el) {
  5 + var thumbElements = el.childNodes, numNodes = thumbElements.length, items = [], figureEl, linkEl, size, item;
  6 + for (var i = 0; i < numNodes; i++) {
  7 + figureEl = thumbElements[ i ]; // <figure> element
  8 + // include only element nodes
  9 + if (figureEl.nodeType !== 1) {
  10 + continue;
  11 + }
  12 + linkEl = figureEl.children[ 0 ]; // <a> element
  13 + size = linkEl.getAttribute('data-size')
  14 + .split('x');
  15 + // create slide object
  16 + item = {
  17 + src: linkEl.getAttribute('href'),
  18 + w: parseInt(size[ 0 ], 10),
  19 + h: parseInt(size[ 1 ], 10)
  20 + };
  21 + if (figureEl.children.length > 1) {
  22 + // <figcaption> content
  23 + item.title = figureEl.children[ 1 ].innerHTML;
  24 + }
  25 + if (linkEl.children.length > 0) {
  26 + // <img> thumbnail element, retrieving thumbnail url
  27 + item.msrc = linkEl.children[ 0 ].getAttribute('src');
  28 + }
  29 + item.el = figureEl; // save link to element for getThumbBoundsFn
  30 + items.push(item);
  31 + }
  32 + return items;
  33 + };
  34 + // find nearest parent element
  35 + var closest = function closest(el, fn) {
  36 + return el && ( fn(el) ? el : closest(el.parentNode, fn) );
  37 + };
  38 + // triggers when user clicks on thumbnail
  39 + var onThumbnailsClick = function(e) {
  40 + e = e || window.event;
  41 + e.preventDefault ? e.preventDefault() : e.returnValue = false;
  42 + var eTarget = e.target || e.srcElement;
  43 + // find root element of slide
  44 + var clickedListItem = closest(
  45 + eTarget, function(el) {
  46 + return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
  47 + }
  48 + );
  49 + if (!clickedListItem) {
  50 + return;
  51 + }
  52 + // find index of clicked item by looping through all child nodes
  53 + // alternatively, you may define index via data- attribute
  54 + var clickedGallery = clickedListItem.parentNode, childNodes = clickedListItem.parentNode.childNodes, numChildNodes = childNodes.length, nodeIndex = 0, index;
  55 + for (var i = 0; i < numChildNodes; i++) {
  56 + if (childNodes[ i ].nodeType !== 1) {
  57 + continue;
  58 + }
  59 + if (childNodes[ i ] === clickedListItem) {
  60 + index = nodeIndex;
  61 + break;
  62 + }
  63 + nodeIndex++;
  64 + }
  65 + if (index >= 0) {
  66 + // open PhotoSwipe if valid index found
  67 + openPhotoSwipe(index, clickedGallery);
  68 + }
  69 + return false;
  70 + };
  71 + // parse picture index and gallery index from URL (#&pid=1&gid=2)
  72 + var photoswipeParseHash = function() {
  73 + var hash = window.location.hash.substring(1), params = {};
  74 + if (hash.length < 5) {
  75 + return params;
  76 + }
  77 + var vars = hash.split('&');
  78 + for (var i = 0; i < vars.length; i++) {
  79 + if (!vars[ i ]) {
  80 + continue;
  81 + }
  82 + var pair = vars[ i ].split('=');
  83 + if (pair.length < 2) {
  84 + continue;
  85 + }
  86 + params[ pair[ 0 ] ] = pair[ 1 ];
  87 + }
  88 + if (params.gid) {
  89 + params.gid = parseInt(params.gid, 10);
  90 + }
  91 + return params;
  92 + };
  93 + var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
  94 + var pswpElement = document.querySelectorAll('.pswp')[ 0 ], gallery, options, items;
  95 + items = parseThumbnailElements(galleryElement);
  96 + // define options (if needed)
  97 + options = {
  98 + // define gallery index (for URL)
  99 + galleryUID: galleryElement.getAttribute('data-pswp-uid'),
  100 + getThumbBoundsFn: function(index) {
  101 + // See Options -> getThumbBoundsFn section of documentation for more info
  102 + var thumbnail = items[ index ].el.getElementsByTagName('img')[ 0 ], // find thumbnail
  103 + pageYScroll = window.pageYOffset || document.documentElement.scrollTop, rect = thumbnail.getBoundingClientRect();
  104 + return {
  105 + x: rect.left,
  106 + y: rect.top + pageYScroll,
  107 + w: rect.width
  108 + };
  109 + }
  110 + };
  111 + // PhotoSwipe opened from URL
  112 + if (fromURL) {
  113 + if (options.galleryPIDs) {
  114 + // parse real index when custom PIDs are used
  115 + // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
  116 + for (var j = 0; j < items.length; j++) {
  117 + if (items[ j ].pid == index) {
  118 + options.index = j;
  119 + break;
  120 + }
  121 + }
  122 + } else {
  123 + // in URL indexes start from 1
  124 + options.index = parseInt(index, 10) - 1;
  125 + }
  126 + } else {
  127 + options.index = parseInt(index, 10);
  128 + }
  129 + // exit if index not found
  130 + if (isNaN(options.index)) {
  131 + return;
  132 + }
  133 + if (disableAnimation) {
  134 + options.showAnimationDuration = 0;
  135 + }
  136 + // Pass data to PhotoSwipe and initialize it
  137 + gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
  138 + gallery.init();
  139 + };
  140 + // loop through all gallery elements and bind events
  141 + var galleryElements = document.querySelectorAll(gallerySelector);
  142 + for (var i = 0, l = galleryElements.length; i < l; i++) {
  143 + galleryElements[ i ].setAttribute('data-pswp-uid', i + 1);
  144 + galleryElements[ i ].onclick = onThumbnailsClick;
  145 + }
  146 + // Parse URL and open gallery if it contains #&pid=3&gid=1
  147 + var hashData = photoswipeParseHash();
  148 + if (hashData.pid && hashData.gid) {
  149 + openPhotoSwipe(hashData.pid, galleryElements[ hashData.gid - 1 ], true, true);
  150 + }
  151 +};
  152 +// execute above function
  153 +initPhotoSwipeFromDOM('.my-gallery');