Commit 6506d20d80e122a4ea7d38ca389a6efc171b18b6

Authored by Yarik
1 parent 8b201863

Коммит 25.15.2015 Закончен блог, начато меню админки

backend/views/layouts/header.php
... ... @@ -23,6 +23,19 @@ $username = Yii::$app->user->identity->firstname.' '.Yii::$app->user->identity->
23 23  
24 24 <ul class="nav navbar-nav">
25 25  
  26 + <!-- search form -->
  27 + <li class="header-search">
  28 + <form action="#" method="get" class="sidebar-form">
  29 + <div class="input-group">
  30 + <input type="text" name="q" class="form-control" placeholder="Search..."/>
  31 + <span class="input-group-btn">
  32 + <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
  33 + </button>
  34 + </span>
  35 + </div>
  36 + </form>
  37 + </li>
  38 + <!-- /.search form -->
26 39 <!-- Messages: style can be found in dropdown.less-->
27 40 <li class="dropdown messages-menu">
28 41 <a href="#" class="dropdown-toggle" data-toggle="dropdown">
... ...
backend/views/layouts/left.php
... ... @@ -13,19 +13,40 @@
13 13 <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
14 14 </div>
15 15 </div>
  16 + <?php
  17 + /*
  18 + <ul class="sidebar-menu">
  19 + <?php
  20 + $roots = \backend\models\AdminMenu::find()->where(['parent_id' => NULL])->all();
  21 + foreach($roots as $root) {
  22 + if($root->adminMenus) {
  23 + echo "<li class='header'>{$root->name}</li>";
  24 + echo "<li class='treeview'>";
  25 + foreach($root->adminMenus as $submenu) {
  26 + if($submenu->adminMenus) {
  27 + echo \yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($submenu->name)."</span><i class='fa fa-angle-left pull-right'></i>");
  28 + echo "<ul class='treeview-menu' style='display:none'>";
  29 + foreach($submenu->adminMenus as $item) {
  30 + echo "<li>".\yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($item->name)."</span>", array_merge([$item->path], \common\models\Tools::parseUrlParams($item->params)))."</li>";
  31 + }
  32 + echo "</ul>";
  33 + } else {
  34 + echo \yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($submenu->name)."</span>", array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->params)));
  35 + }
  36 + }
  37 + echo "</li>";
  38 + }
  39 + }
  40 + ?>
  41 + </ul>
  42 + */ ?>
16 43  
17   - <!-- search form -->
18   - <form action="#" method="get" class="sidebar-form">
19   - <div class="input-group">
20   - <input type="text" name="q" class="form-control" placeholder="Search..."/>
21   - <span class="input-group-btn">
22   - <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
23   - </button>
24   - </span>
25   - </div>
26   - </form>
27   - <!-- /.search form -->
28   -
  44 + <?= dmstr\widgets\Menu::widget([
  45 + 'options' => ['class' => 'sidebar-menu'],
  46 + 'items' => \backend\models\AdminMenu::buildMenu(),
  47 + ]) ?>
  48 + <?php
  49 + /*
29 50 <?= dmstr\widgets\Menu::widget(
30 51 [
31 52 'options' => ['class' => 'sidebar-menu'],
... ... @@ -87,6 +108,8 @@
87 108 ],
88 109 ]
89 110 ) ?>
  111 + */
  112 + ?>
90 113  
91 114 </section>
92 115  
... ...
backend/views/site/index.php
... ... @@ -2,6 +2,9 @@
2 2  
3 3 /* @var $this yii\web\View */
4 4  
  5 +use backend\models\AdminMenu;
  6 +use yii\helpers\Url;
  7 +
5 8 $this->title = 'My Yii Application';
6 9 ?>
7 10 <div class="site-index">
... ...
backend/web/css/site.css
... ... @@ -89,3 +89,38 @@ a.desc:after {
89 89 padding: 10px 20px;
90 90 margin: 0 0 15px 0;
91 91 }
  92 +.header-search {
  93 + width: 200px;
  94 +}
  95 +.skin-blue .sidebar-form {
  96 + margin: 5px !important;
  97 +}
  98 +.checkboxer .list-group-item {
  99 + padding: 0;
  100 +}
  101 +.checkboxer .list-group-item:hover {
  102 + background: #ddd;
  103 +}
  104 +.checkboxer .list-group-item.active, .checkboxer .list-group-item.active:hover {
  105 + background: #00a65a;
  106 +}
  107 +.checkboxer .list-group-item.active label, .checkboxer .list-group-item.active:hover label {
  108 + color: white;
  109 +}
  110 +.checkboxer .list-group-item.level0 {
  111 + padding-left: 15px;
  112 +}
  113 +.checkboxer .list-group-item.level1 {
  114 + padding-left: 45px;
  115 +}
  116 +.checkboxer .list-group-item.level2 {
  117 + padding-left: 75px;
  118 +}
  119 +.checkboxer .checkboxer_label {
  120 + padding: 10px 0;
  121 + display: block;
  122 +}
  123 +.checkboxer .checkboxer_label input[type=radio] {
  124 + position: absolute;
  125 + clip: rect(0,0,0,0);
  126 +}
92 127 \ No newline at end of file
... ...
backend/web/js/option.js
... ... @@ -89,4 +89,9 @@ $(function() {
89 89 }
90 90 return false;
91 91 });
  92 + $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() {
  93 + console.log($(this).val());
  94 + $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active');
  95 + $(this).parents('.checkboxer_container').addClass('active');
  96 + });
92 97 });
93 98 \ No newline at end of file
... ...
common/models/Tools.php
... ... @@ -98,4 +98,19 @@ class Tools
98 98  
99 99 return $url;
100 100 }
  101 +
  102 + static function parseUrlParams($params)
  103 + {
  104 + $params = preg_split('/,\s*/', $params, -1, PREG_SPLIT_NO_EMPTY);
  105 + $result = [];
  106 + if($params) {
  107 + foreach($params as $param) {
  108 + $param = preg_split('/\s*=\s*/', $param);
  109 + if(!empty($param[0]) && !empty($param[1])) {
  110 + $result[$param[0]] = $param[1];
  111 + }
  112 + }
  113 + }
  114 + return $result;
  115 + }
101 116 }
102 117 \ No newline at end of file
... ...
common/modules/blog/controllers/AjaxController.php
... ... @@ -7,6 +7,7 @@ use common\modules\blog\models\ArticleCategoryLang;
7 7 use common\modules\blog\models\ArticleCategoryMedia;
8 8 use common\modules\blog\models\ArticleLang;
9 9 use common\modules\blog\models\ArticleMedia;
  10 +use yii\base\InvalidParamException;
10 11 use yii\web\Controller;
11 12 use yii\web\ForbiddenHttpException;
12 13 use yii\web\NotFoundHttpException;
... ... @@ -46,6 +47,32 @@ class AjaxController extends Controller
46 47 return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]);
47 48 }
48 49  
  50 + public function actionArticleMediaForm($lang_id, $widget_id, $type)
  51 + {
  52 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one();
  53 + if(!$model) {
  54 + throw new NotFoundHttpException('Language not found');
  55 + }
  56 + if(!in_array($type, ['full', 'preview'])) {
  57 + throw new InvalidParamException('Type must only be full/preview');
  58 + }
  59 + $article_lang = new ArticleMedia();
  60 + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
  61 + }
  62 +
  63 + public function actionArticleCategoryMediaForm($lang_id, $widget_id, $type)
  64 + {
  65 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one();
  66 + if(!$model) {
  67 + throw new NotFoundHttpException('Language not found');
  68 + }
  69 + if(!in_array($type, ['full', 'preview'])) {
  70 + throw new InvalidParamException('Type must only be full/preview');
  71 + }
  72 + $article_lang = new ArticleCategoryMedia();
  73 + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
  74 + }
  75 +
49 76 public function actionRemoveImage()
50 77 {
51 78 $post = \Yii::$app->request->post();
... ... @@ -63,6 +90,23 @@ class AjaxController extends Controller
63 90 }
64 91 }
65 92  
  93 + public function actionRemoveCategoryImage()
  94 + {
  95 + $post = \Yii::$app->request->post();
  96 + if(!empty($post['category_media_id'])) {
  97 + $category_media = ArticleCategoryMedia::findOne($post['category_media_id']);
  98 + if($post['remove_media']) {
  99 + $media = $category_media->media->delete();
  100 + }
  101 + if(!empty($category_media)) {
  102 + $category_media->delete();
  103 + }
  104 + return true;
  105 + } else {
  106 + return false;
  107 + }
  108 + }
  109 +
66 110 public function actionRemoveImageCategory()
67 111 {
68 112 $post = \Yii::$app->request->post();
... ...
common/modules/blog/controllers/ArticleController.php
... ... @@ -28,28 +28,31 @@ class ArticleController extends Controller
28 28 {
29 29 $article_langs = array();
30 30 $article = new Article();
  31 + $default_lang = Language::getDefaultLang();
31 32 $images = array();
32   - $images['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]);
33   - $images['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]);
34   - $images['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
  33 + $images[$default_lang->language_id]['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]);
  34 + $images[$default_lang->language_id]['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]);
  35 + $images[0]['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
35 36 $article->loadDefaultValues();
36 37 $langs = Language::getActiveLanguages();
37   - $default_lang = Language::getDefaultLang();
38 38 $isValid = false;
39 39 if(!empty(\Yii::$app->request->post())) {
40 40 $isValid = true;
41 41 $article->load(\Yii::$app->request->post());
42 42 $article->author = \Yii::$app->user->getId();
43 43 $isValid = $article->validate();
44   - foreach($images as $index => $value) {
45   - $images[$index]->type = $index;
46   - if($index == 'additional') {
47   - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile");
48   - } else {
49   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
  44 + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
  45 + foreach($value as $type => $fields) {
  46 + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
  47 + $images[$lang][$type]->type = $type;
  48 + $images[$lang][$type]->lang_id = $lang;
  49 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  50 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
50 51 }
51   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
52 52 }
  53 + $images[0]['additional']->lang_id = 0;
  54 + $images[0]['additional']->type = 'additional';
  55 + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
53 56 if(empty(\Yii::$app->request->post()['ArticleLang'])) {
54 57 $article_langs[$default_lang->language_id] = new ArticleLang();
55 58 $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
... ... @@ -74,9 +77,21 @@ class ArticleController extends Controller
74 77 }
75 78 }
76 79 $first = 1;
77   - foreach($images as $index => $image) {
78   - $images[$index]->upload($article->id);
  80 + foreach($images as $lang => $value) {
  81 + foreach($value as $type => $fields) {
  82 + $images[$lang][$type]->upload($article->id);
  83 + if($first && $type != 'additional') {
  84 + $media_clone = clone $images[$lang][$type];
  85 + $media_clone->setIsNewRecord(true);
  86 + unset($media_clone->id);
  87 + $media_clone->lang_id = 0;
  88 + $media_clone->upload($article->id);
  89 + unset($media_clone);
  90 + $first = 0;
  91 + }
  92 + }
79 93 }
  94 + $first = 1;
80 95 foreach($article_langs as $article_lang) {
81 96 if($first) {
82 97 $article_lang_clone = clone $article_lang;
... ... @@ -102,22 +117,22 @@ class ArticleController extends Controller
102 117 public function actionUpdate($id)
103 118 {
104 119 $article = Article::findOne($id);
105   - $images = $article->getArticleMedia()->indexBy('type')->all();
106   - if(!array_key_exists('full', $images)) {
107   - $images['full'] = new ArticleMedia();
108   - }
109   - if(!array_key_exists('preview', $images)) {
110   - $images['preview'] = new ArticleMedia();
111   - }
112   - foreach($images as $index => $image) {
113   - $images[$index]->scenario = $index;
  120 + $imagestack = $article->getArticleMedia()->all();
  121 + $images = [];
  122 + $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
  123 + $images[0]['additional'][0]->type = 'additional';
  124 + $images[0]['additional'][0]->lang_id = 0;
  125 + foreach($imagestack as $image) {
  126 + if(in_array($image->type, ['full', 'preview'])) {
  127 + $images[$image->lang_id][$image->type] = $image;
  128 + $images[$image->lang_id][$image->type]->scenario = $image->type;
  129 + } else {
  130 + $images[$image->lang_id][$image->type][$image->id] = $image;
  131 + $images[$image->lang_id][$image->type][$image->id]->scenario = $image->type;
  132 + }
114 133 }
115   - $images['additional'] = array(
116   - 0 => new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL])
117   - );
118   - $images['additional'] = array_merge($images['additional'], $article->getArticleMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all());
119   - foreach($images['additional'] as $index => $image) {
120   - $images['additional'][$index]->scenario = 'additional';
  134 + foreach($images as $lang => $value) {
  135 + $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
121 136 }
122 137 $article_langs = $article->getArticleLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all();
123 138 $langs = Language::getActiveLanguages();
... ... @@ -136,15 +151,18 @@ class ArticleController extends Controller
136 151 }
137 152 }
138 153 $isValid = $article->validate();
139   - foreach($images as $index => $value) {
140   - if($index == 'additional') {
141   - $images[$index][0]->type = $index;
142   - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile");
143   - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid;
144   - } else {
145   - $images[$index]->type = $index;
146   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
147   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
  154 + $images[0]['additional'][0]->type = 'additional';
  155 + $images[0]['additional'][0]->lang_id = 0;
  156 + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
  157 + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
  158 + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
  159 + foreach($value as $type => $fields) {
  160 + if(!in_array($type, ['full', 'preview'])) continue;
  161 + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
  162 + $images[$lang][$type]->lang_id = $lang;
  163 + $images[$lang][$type]->type = $type;
  164 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  165 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
148 166 }
149 167 }
150 168 if(empty(\Yii::$app->request->post()['ArticleLang'])) {
... ... @@ -162,12 +180,14 @@ class ArticleController extends Controller
162 180 }
163 181 if($isValid) {
164 182 $article->save(false);
165   - foreach($images as $index => $image) {
166   - if($index == 'additional') {
167   - $images[$index][0]->upload($article->id);
168   - } else {
169   - if(!empty($images[$index]->imageFile)) {
170   - $images[$index]->replace($article->id, true);
  183 + foreach($images as $lang => $value) {
  184 + foreach($value as $type => $fields) {
  185 + if($type == 'additional') {
  186 + $images[$lang][$type][0]->upload($article->id);
  187 + } else {
  188 + if(!empty($images[$lang][$type]->imageFile)) {
  189 + $images[$lang][$type]->replace($article->id);
  190 + }
171 191 }
172 192 }
173 193 }
... ...
common/modules/blog/controllers/CategoryController.php
... ... @@ -42,27 +42,30 @@ class CategoryController extends Controller
42 42 {
43 43 $category_langs = array();
44 44 $category = new ArticleCategory();
  45 + $default_lang = Language::getDefaultLang();
45 46 $images = array();
46   - $images['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]);
47   - $images['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]);
48   - $images['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
  47 + $images[$default_lang->language_id]['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]);
  48 + $images[$default_lang->language_id]['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]);
  49 + $images[0]['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
49 50 $category->loadDefaultValues();
50 51 $langs = Language::getActiveLanguages();
51   - $default_lang = Language::getDefaultLang();
52 52 $isValid = false;
53   - foreach($images as $index => $value) {
54   - $images[$index]->type = $index;
55   - if($index == 'additional') {
56   - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile");
57   - } else {
58   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
59   - }
60   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
61   - }
62 53 if(!empty(\Yii::$app->request->post())) {
63 54 $isValid = true;
64 55 $category->load(\Yii::$app->request->post());
65 56 $isValid = $category->validate();
  57 + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
  58 + foreach($value as $type => $fields) {
  59 + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
  60 + $images[$lang][$type]->type = $type;
  61 + $images[$lang][$type]->lang_id = $lang;
  62 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  63 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
  64 + }
  65 + }
  66 + $images[0]['additional']->lang_id = 0;
  67 + $images[0]['additional']->type = 'additional';
  68 + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
66 69 if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
67 70 $category_langs[$default_lang->language_id] = new ArticleCategoryLang();
68 71 $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
... ... @@ -79,9 +82,21 @@ class CategoryController extends Controller
79 82 if($isValid) {
80 83 $category->save(false);
81 84 $first = 1;
82   - foreach($images as $index => $image) {
83   - $images[$index]->upload($category->id);
  85 + foreach($images as $lang => $value) {
  86 + foreach($value as $type => $fields) {
  87 + $images[$lang][$type]->upload($category->id);
  88 + if($first && $type != 'additional') {
  89 + $media_clone = clone $images[$lang][$type];
  90 + $media_clone->setIsNewRecord(true);
  91 + unset($media_clone->id);
  92 + $media_clone->lang_id = 0;
  93 + $media_clone->upload($category->id);
  94 + unset($media_clone);
  95 + $first = 0;
  96 + }
  97 + }
84 98 }
  99 + $first = 1;
85 100 foreach($category_langs as $category_lang) {
86 101 if($first) {
87 102 $category_lang_clone = clone $category_lang;
... ... @@ -107,22 +122,22 @@ class CategoryController extends Controller
107 122 public function actionUpdate($id)
108 123 {
109 124 $category = ArticleCategory::findOne($id);
110   - $images = $category->getArticleCategoryMedia()->indexBy('type')->all();
111   - if(!array_key_exists('full', $images)) {
112   - $images['full'] = new ArticleCategoryMedia();
113   - }
114   - if(!array_key_exists('preview', $images)) {
115   - $images['preview'] = new ArticleCategoryMedia();
116   - }
117   - foreach($images as $index => $image) {
118   - $images[$index]->scenario = $index;
  125 + $imagestack = $category->getArticleCategoryMedia()->all();
  126 + $images = [];
  127 + $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
  128 + $images[0]['additional'][0]->type = 'additional';
  129 + $images[0]['additional'][0]->lang_id = 0;
  130 + foreach($imagestack as $image) {
  131 + if(in_array($image->type, ['full', 'preview'])) {
  132 + $images[$image->lang_id][$image->type] = $image;
  133 + $images[$image->lang_id][$image->type]->scenario = $image->type;
  134 + } else {
  135 + $images[$image->lang_id][$image->type][$image->id] = $image;
  136 + $images[$image->lang_id][$image->type][$image->id]->scenario = $image->type;
  137 + }
119 138 }
120   - $images['additional'] = array(
121   - 0 => new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL])
122   - );
123   - $images['additional'] = array_merge($images['additional'], $category->getArticleCategoryMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all());
124   - foreach($images['additional'] as $index => $image) {
125   - $images['additional'][$index]->scenario = 'additional';
  139 + foreach($images as $lang => $value) {
  140 + $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
126 141 }
127 142 $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all();
128 143 $langs = Language::getActiveLanguages();
... ... @@ -132,15 +147,18 @@ class CategoryController extends Controller
132 147 $isValid = true;
133 148 $category->load(\Yii::$app->request->post());
134 149 $isValid = $category->validate();
135   - foreach($images as $index => $value) {
136   - if($index == 'additional') {
137   - $images[$index][0]->type = $index;
138   - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile");
139   - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid;
140   - } else {
141   - $images[$index]->type = $index;
142   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
143   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
  150 + $images[0]['additional'][0]->type = 'additional';
  151 + $images[0]['additional'][0]->lang_id = 0;
  152 + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
  153 + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
  154 + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
  155 + foreach($value as $type => $fields) {
  156 + if(!in_array($type, ['full', 'preview'])) continue;
  157 + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
  158 + $images[$lang][$type]->lang_id = $lang;
  159 + $images[$lang][$type]->type = $type;
  160 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  161 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
144 162 }
145 163 }
146 164 if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
... ... @@ -158,12 +176,14 @@ class CategoryController extends Controller
158 176 }
159 177 if($isValid) {
160 178 $category->save(false);
161   - foreach($images as $index => $image) {
162   - if($index == 'additional') {
163   - $images[$index][0]->upload($category->id);
164   - } else {
165   - if(!empty($images[$index]->imageFile)) {
166   - $images[$index]->replace($category->id, true);
  179 + foreach($images as $lang => $value) {
  180 + foreach($value as $type => $fields) {
  181 + if($type == 'additional') {
  182 + $images[$lang][$type][0]->upload($category->id);
  183 + } else {
  184 + if(!empty($images[$lang][$type]->imageFile)) {
  185 + $images[$lang][$type]->replace($category->id);
  186 + }
167 187 }
168 188 }
169 189 }
... ...
common/modules/blog/models/ArticleMedia.php
... ... @@ -37,9 +37,9 @@ class ArticleMedia extends \yii\db\ActiveRecord
37 37 public function scenarios()
38 38 {
39 39 $scenarios = parent::scenarios();
40   - $scenarios[self::SCENARIO_FULL] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
41   - $scenarios[self::SCENARIO_PREVIEW] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
42   - $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'article_id', 'media_id', 'type', 'imageFile'];
  40 + $scenarios[self::SCENARIO_FULL] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'lang_id'];
  41 + $scenarios[self::SCENARIO_PREVIEW] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'lang_id'];
  42 + $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'article_id', 'media_id', 'type', 'imageFile', 'lang_id'];
43 43 return $scenarios;
44 44 }
45 45  
... ... @@ -50,7 +50,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
50 50 {
51 51 return [
52 52 [['article_id', 'media_id'], 'required'],
53   - [['article_id', 'media_id'], 'integer'],
  53 + [['article_id', 'media_id', 'lang_id'], 'integer'],
54 54 [['media_alt', 'media_title', 'media_caption'], 'string'],
55 55 [['type'], 'string', 'max' => 10],
56 56 [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL],
... ... @@ -119,8 +119,8 @@ class ArticleMedia extends \yii\db\ActiveRecord
119 119 public function replace($article_id, $removeMedia = false)
120 120 {
121 121 $this->article_id = $article_id;
122   - if($removeMedia) {
123   - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type])->column();
  122 + if($removeMedia && !$this->getIsNewRecord()) {
  123 + $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'lang_id' => $this->lang_id])->column();
124 124 $media = array();
125 125 foreach($article_media as $media_id) {
126 126 $media[] = Media::findOne(['id' => $media_id]);
... ... @@ -147,7 +147,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
147 147 }
148 148 return $ok;
149 149 } elseif(!empty($this->imageFile)) {
150   - ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type]);
  150 + ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type, 'lang_id' => $this->lang_id]);
151 151 $media = new Media();
152 152 $media->imageFile = $this->imageFile;
153 153 $media->upload();
... ...
common/modules/blog/views/ajax/_article_media_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\bootstrap\ActiveField;
  4 +use mihaildev\ckeditor\CKEditor;
  5 +
  6 +$form = \yii\bootstrap\ActiveForm::begin();
  7 +?>
  8 +<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
  9 +
  10 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]lang_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
  11 +
  12 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?>
  13 +
  14 +</div>
  15 +<?php
  16 +$form->end();
  17 +?>
... ...
common/modules/blog/views/article/_form.php
1 1 <?php
2 2 use common\modules\blog\models\ArticleCategory;
  3 +use common\modules\blog\models\ArticleMedia;
3 4 use common\widgets\Multilang;
4 5 use yii\bootstrap\ActiveForm;
5 6 use common\modules\blog\models\Article;
... ... @@ -31,52 +32,84 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
31 32 <?= $form->field($article, 'active')->checkbox() ?>
32 33  
33 34 <ul class="nav nav-tabs" id="image-tabs" role="tablist">
34   - <?php
35   - $first = 1;
36   - foreach($images as $index => $image) {
37   - ?>
38   - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li>
39   - <?php
40   - $first = 0;
41   - }
42   - ?>
  35 + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
  36 + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
  37 + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
43 38 </ul>
44 39 <div class="tab-content image-tab-content">
45   - <?php
46   - $first = 1;
47   - foreach($images as $index => $image) {
  40 + <div role="" class="tab-pane active main-tab" id="image-full">
  41 + <?php
  42 + $imagelang = Multilang::begin([
  43 + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']),
  44 + 'form' => $form,
  45 + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->id, 'type' => 'full'])->indexBy('lang_id')->all()
  46 + ]);
  47 + $first = 1;
  48 + foreach($images as $lang => $value) {
  49 + if(!array_key_exists('full', $value)) continue;
  50 + ?>
  51 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  52 + <?php
  53 + echo $form->field($images[$lang]['full'], "[{$lang}][full]lang_id")->label(false)->hiddenInput(['value' => $lang]);
  54 + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
  55 + if(!empty($images[$lang]['full']->id)) {
  56 + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
  57 + }
  58 + ?>
  59 + </div>
  60 + <?php
  61 + $first = 0;
  62 + }
  63 + $imagelang->end();
48 64 ?>
49   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>">
50   - <?php if($index == 'additional') {
51   - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
52   - if(is_array($image) && count($image) > 1) {
53   - foreach($image as $oneindex => $oneimage) {
54   - if($oneindex) {
55   - ?>
56   - <div class="additional_image_container">
57   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
58   - <a
59   - href="<?= Url::to(['ajax/remove-image']) ?>"
60   - class="remove_image glyphicon glyphicon-remove-circle"
61   - data-params='<?= Json::encode(['article_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
62   - ></a>
63   - </div>
64   - <?php
65   - }
66   - }
  65 + </div>
  66 + <div role="" class="tab-pane" id="image-preview">
  67 + <?php
  68 + $imagelang = Multilang::begin([
  69 + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']),
  70 + 'form' => $form,
  71 + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->id, 'type' => 'preview'])->indexBy('lang_id')->all()
  72 + ]);
  73 + $first = 1;
  74 + foreach($images as $lang => $value) {
  75 + if(!array_key_exists('preview', $value)) continue;
  76 + ?>
  77 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  78 + <?php
  79 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]lang_id")->label(false)->hiddenInput(['value' => $lang]);
  80 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
  81 + if(!empty($images[$lang]['preview']->id)) {
  82 + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
67 83 }
68   - } else {
69   - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']);
70   - if(!empty($image->id)) {
71   - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>";
  84 + ?>
  85 + </div>
  86 + <?php
  87 + $first = 0;
  88 + }
  89 + $imagelang->end();
  90 + ?>
  91 + </div>
  92 + <div role="" class="tab-pane" id="image-additional">
  93 + <?php
  94 + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
  95 + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
  96 + foreach($images[0]['additional'] as $onefield => $oneimage) {
  97 + if($onefield) {
  98 + ?>
  99 + <div class="additional_image_container">
  100 + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
  101 + <a
  102 + href="<?= Url::to(['ajax/remove-image']) ?>"
  103 + class="remove_image glyphicon glyphicon-remove-circle"
  104 + data-params='<?= Json::encode(['article_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
  105 + ></a>
  106 + </div>
  107 + <?php
72 108 }
73 109 }
74   - ?>
75   - </div>
76   - <?php
77   - $first = 0;
78   - }
79   - ?>
  110 + }
  111 + ?>
  112 + </div>
80 113 </div>
81 114  
82 115 <hr>
... ...
common/modules/blog/views/category/_form.php
1 1 <?php
  2 +use common\modules\blog\models\ArticleCategoryMedia;
2 3 use common\widgets\Multilang;
3 4 use yii\bootstrap\ActiveForm;
4 5 use common\modules\blog\models\ArticleCategory;
... ... @@ -26,52 +27,84 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
26 27 <?= $form->field($category, 'active')->checkbox() ?>
27 28  
28 29 <ul class="nav nav-tabs" id="image-tabs" role="tablist">
29   - <?php
30   - $first = 1;
31   - foreach($images as $index => $image) {
32   - ?>
33   - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li>
34   - <?php
35   - $first = 0;
36   - }
37   - ?>
  30 + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
  31 + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
  32 + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
38 33 </ul>
39 34 <div class="tab-content image-tab-content">
40   - <?php
41   - $first = 1;
42   - foreach($images as $index => $image) {
  35 + <div role="" class="tab-pane active main-tab" id="image-full">
  36 + <?php
  37 + $imagelang = Multilang::begin([
  38 + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']),
  39 + 'form' => $form,
  40 + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['category_id' => $category->id, 'type' => 'full'])->indexBy('lang_id')->all()
  41 + ]);
  42 + $first = 1;
  43 + foreach($images as $lang => $value) {
  44 + if(!array_key_exists('full', $value)) continue;
  45 + ?>
  46 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  47 + <?php
  48 + echo $form->field($images[$lang]['full'], "[{$lang}][full]lang_id")->label(false)->hiddenInput(['value' => $lang]);
  49 + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
  50 + if(!empty($images[$lang]['full']->id)) {
  51 + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
  52 + }
  53 + ?>
  54 + </div>
  55 + <?php
  56 + $first = 0;
  57 + }
  58 + $imagelang->end();
43 59 ?>
44   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>">
45   - <?php if($index == 'additional') {
46   - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
47   - if(is_array($image) && count($image) > 1) {
48   - foreach($image as $oneindex => $oneimage) {
49   - if($oneindex) {
50   - ?>
51   - <div class="additional_image_container">
52   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
53   - <a
54   - href="<?= Url::to(['ajax/remove-image-category']) ?>"
55   - class="remove_image glyphicon glyphicon-remove-circle"
56   - data-params='<?= Json::encode(['category_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
57   - ></a>
58   - </div>
59   - <?php
60   - }
61   - }
  60 + </div>
  61 + <div role="" class="tab-pane" id="image-preview">
  62 + <?php
  63 + $imagelang = Multilang::begin([
  64 + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']),
  65 + 'form' => $form,
  66 + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['category_id' => $category->id, 'type' => 'preview'])->indexBy('lang_id')->all()
  67 + ]);
  68 + $first = 1;
  69 + foreach($images as $lang => $value) {
  70 + if(!array_key_exists('preview', $value)) continue;
  71 + ?>
  72 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  73 + <?php
  74 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]lang_id")->label(false)->hiddenInput(['value' => $lang]);
  75 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
  76 + if(!empty($images[$lang]['preview']->id)) {
  77 + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
62 78 }
63   - } else {
64   - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']);
65   - if(!empty($image->id)) {
66   - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>";
  79 + ?>
  80 + </div>
  81 + <?php
  82 + $first = 0;
  83 + }
  84 + $imagelang->end();
  85 + ?>
  86 + </div>
  87 + <div role="" class="tab-pane" id="image-additional">
  88 + <?php
  89 + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
  90 + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
  91 + foreach($images[0]['additional'] as $onefield => $oneimage) {
  92 + if($onefield) {
  93 + ?>
  94 + <div class="additional_image_container">
  95 + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
  96 + <a
  97 + href="<?= Url::to(['ajax/remove-image']) ?>"
  98 + class="remove_image glyphicon glyphicon-remove-circle"
  99 + data-params='<?= Json::encode(['category_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
  100 + ></a>
  101 + </div>
  102 + <?php
67 103 }
68 104 }
69   - ?>
70   - </div>
71   - <?php
72   - $first = 0;
73   - }
74   - ?>
  105 + }
  106 + ?>
  107 + </div>
75 108 </div>
76 109  
77 110 <hr>
... ...
common/modules/blog/views/default/index.php
1 1 <?php
  2 +
  3 +use yii\behaviors\BlameableBehavior;
  4 +use yii\web\Application;
  5 +
  6 +$behavior = new BlameableBehavior();
  7 +var_dump($behavior->value);
2 8 \ No newline at end of file
... ...
common/widgets/views/multilang-begin.php
... ... @@ -18,6 +18,7 @@ use yii\helpers\Url;
18 18 <?php
19 19 $first = 1;
20 20 foreach($data_langs as $index => $data_lang) {
  21 + if(!$index) continue;
21 22 ?>
22 23 <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#<?=$id?>-<?=$index?>" aria-controls="<?=$id?>-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li>
23 24 <?php
... ...
db-migration/artbox_db.backup deleted
No preview for this file type
db-migration/artbox_db3.backup deleted
No preview for this file type
db-migration/article_option_migration.backup deleted
No preview for this file type
db-migration/blog.zip deleted
No preview for this file type
db-migration/catalog.backup deleted
No preview for this file type
db-migration/yarik.sql deleted
1   --- --------------------------------------------------------
2   --- Хост: 127.0.0.1
3   --- Версия сервера: PostgreSQL 9.4.4, compiled by Visual C++ build 1800, 32-bit
4   --- ОС Сервера:
5   --- HeidiSQL Версия: 9.3.0.4984
6   --- --------------------------------------------------------
7   -
8   -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
9   -/*!40101 SET NAMES */;
10   -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
11   -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
12   -
13   --- Дамп структуры для таблица public.article
14   -CREATE TABLE IF NOT EXISTS "article" (
15   - "id" INTEGER NOT NULL DEFAULT nextval('article_id_seq'::regclass) COMMENT E'',
16   - "sort" INTEGER NOT NULL DEFAULT 100 COMMENT E'',
17   - "create_at" TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
18   - "update_at" TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
19   - "code" CHARACTER VARYING NOT NULL COMMENT E'',
20   - "category_id" INTEGER NOT NULL DEFAULT 1 COMMENT E'',
21   - "author" INTEGER NOT NULL COMMENT E'',
22   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
23   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
24   - "active" SMALLINT NOT NULL DEFAULT 0 COMMENT E'',
25   - "comments" SMALLINT NOT NULL DEFAULT 0::smallint COMMENT E'',
26   - "voting" SMALLINT NOT NULL DEFAULT 0::smallint COMMENT E'',
27   - KEY ("author"),
28   - PRIMARY KEY ("id"),
29   - KEY ("parent_id"),
30   - KEY ("category_id"),
31   - KEY ("id")
32   -);
33   -
34   --- Дамп данных таблицы public.article: 3 rows
35   -/*!40000 ALTER TABLE "article" DISABLE KEYS */;
36   -INSERT INTO "article" ("id", "sort", "create_at", "update_at", "code", "category_id", "author", "tags", "parent_id", "active", "comments", "voting") VALUES
37   - (5, 100, E'2015-12-04 14:52:39.54', E'2015-12-04 14:52:39.54', E'test_article', 1, 1, E'test, tag', NULL, 1, 0, 0),
38   - (6, 100, E'2015-12-04 14:52:52.403', E'2015-12-04 14:52:52.403', E'test_article2', 1, 1, E'test, tag', NULL, 1, 0, 0),
39   - (12, 100, E'2015-12-04 14:52:52.403', E'2015-12-04 14:52:52.403', E'test_article3', 1, 1, E'test, tag', 5, 1, 0, 0);
40   -/*!40000 ALTER TABLE "article" ENABLE KEYS */;
41   -
42   -
43   --- Дамп структуры для таблица public.article_category
44   -CREATE TABLE IF NOT EXISTS "article_category" (
45   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_id_seq'::regclass) COMMENT E'',
46   - "sort" INTEGER NOT NULL DEFAULT 100 COMMENT E'',
47   - "code" CHARACTER VARYING NOT NULL COMMENT E'',
48   - "created_at" TIME WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
49   - "updated_at" TIME WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
50   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
51   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
52   - "active" SMALLINT NOT NULL DEFAULT 0 COMMENT E'',
53   - PRIMARY KEY ("id"),
54   - KEY ("parent_id"),
55   - KEY ("id")
56   -);
57   -
58   --- Дамп данных таблицы public.article_category: 2 rows
59   -/*!40000 ALTER TABLE "article_category" DISABLE KEYS */;
60   -INSERT INTO "article_category" ("id", "sort", "code", "created_at", "updated_at", "tags", "parent_id", "active") VALUES
61   - (1, 100, E'static_pages', E'14:08:02.74', E'14:08:02.74', NULL, NULL, 1),
62   - (2, 100, E'qwerty', E'11:00:35.954', E'11:00:35.954', E'qwerty', NULL, 0);
63   -/*!40000 ALTER TABLE "article_category" ENABLE KEYS */;
64   -
65   -
66   --- Дамп структуры для таблица public.article_category_lang
67   -CREATE TABLE IF NOT EXISTS "article_category_lang" (
68   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_lang_id_seq'::regclass) COMMENT E'',
69   - "lang_id" INTEGER NOT NULL DEFAULT 0 COMMENT E'',
70   - "category_id" INTEGER NULL DEFAULT NULL COMMENT E'',
71   - "text" TEXT NOT NULL COMMENT E'',
72   - "preview" TEXT NULL DEFAULT NULL COMMENT E'',
73   - "seo_url" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
74   - "name" CHARACTER VARYING NOT NULL COMMENT E'',
75   - "meta_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
76   - "meta_descr" TEXT NULL DEFAULT NULL COMMENT E'',
77   - "meta_keywords" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
78   - "h1_tag" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
79   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
80   - PRIMARY KEY ("id"),
81   - KEY ("category_id"),
82   - KEY ("lang_id"),
83   - KEY ("id")
84   -);
85   -
86   --- Дамп данных таблицы public.article_category_lang: 3 rows
87   -/*!40000 ALTER TABLE "article_category_lang" DISABLE KEYS */;
88   -INSERT INTO "article_category_lang" ("id", "lang_id", "category_id", "text", "preview", "seo_url", "name", "meta_title", "meta_descr", "meta_keywords", "h1_tag", "tags") VALUES
89   - (1, 0, 1, E'Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem ', E'Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem ', E'lorem', E'Lorem ipsum', E'Lorem title', E'Lorem description', E'lorem, keyword', E'Lorem h1 tag', E'lorem tag'),
90   - (2, 2, 2, E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty'),
91   - (3, 1, 2, E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен');
92   -/*!40000 ALTER TABLE "article_category_lang" ENABLE KEYS */;
93   -
94   -
95   --- Дамп структуры для таблица public.article_category_media
96   -CREATE TABLE IF NOT EXISTS "article_category_media" (
97   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_media_id_seq'::regclass) COMMENT E'',
98   - "category_id" INTEGER NOT NULL COMMENT E'',
99   - "media_id" INTEGER NOT NULL COMMENT E'',
100   - "media_alt" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
101   - "media_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
102   - "media_caption" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
103   - "type" CHARACTER VARYING(10) NOT NULL DEFAULT 'additional'::character varying COMMENT E'',
104   - PRIMARY KEY ("id"),
105   - KEY ("media_id"),
106   - KEY ("category_id"),
107   - KEY ("id")
108   -);
109   -
110   --- Дамп данных таблицы public.article_category_media: 0 rows
111   -/*!40000 ALTER TABLE "article_category_media" DISABLE KEYS */;
112   -/*!40000 ALTER TABLE "article_category_media" ENABLE KEYS */;
113   -
114   -
115   --- Дамп структуры для таблица public.article_lang
116   -CREATE TABLE IF NOT EXISTS "article_lang" (
117   - "id" INTEGER NOT NULL DEFAULT nextval('article_lang_id_seq'::regclass) COMMENT E'',
118   - "lang_id" INTEGER NOT NULL COMMENT E'',
119   - "article_id" INTEGER NOT NULL COMMENT E'',
120   - "text" TEXT NOT NULL COMMENT E'',
121   - "seo_url" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
122   - "name" CHARACTER VARYING NOT NULL COMMENT E'',
123   - "preview" TEXT NULL DEFAULT NULL COMMENT E'',
124   - "meta_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
125   - "meta_descr" TEXT NULL DEFAULT NULL COMMENT E'',
126   - "meta_keywords" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
127   - "h1_tag" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
128   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
129   - PRIMARY KEY ("id"),
130   - KEY ("article_id"),
131   - KEY ("lang_id"),
132   - KEY ("id")
133   -);
134   -
135   --- Дамп данных таблицы public.article_lang: 2 rows
136   -/*!40000 ALTER TABLE "article_lang" DISABLE KEYS */;
137   -INSERT INTO "article_lang" ("id", "lang_id", "article_id", "text", "seo_url", "name", "preview", "meta_title", "meta_descr", "meta_keywords", "h1_tag", "tags") VALUES
138   - (1, 0, 5, E'Lorem Lorem Lorem', E'article1', E'artivle1', E'Lorem preview', E'Lorem title', E'Lorem description', E'lorem, keyword', E'lorem h1 tag', E'tag, lorem'),
139   - (2, 0, 12, E'Lorem Lorem Lorem', E'article3', E'artivle3\r\n', E'Lorem preview', E'Lorem title', E'Lorem description', E'lorem, keyword', E'lorem h1 tag', E'tag, lorem');
140   -/*!40000 ALTER TABLE "article_lang" ENABLE KEYS */;
141   -
142   -
143   --- Дамп структуры для таблица public.article_media
144   -CREATE TABLE IF NOT EXISTS "article_media" (
145   - "id" INTEGER NOT NULL DEFAULT nextval('article_media_id_seq'::regclass) COMMENT E'',
146   - "article_id" INTEGER NOT NULL COMMENT E'',
147   - "media_id" INTEGER NOT NULL COMMENT E'',
148   - "type" CHARACTER VARYING(10) NOT NULL DEFAULT 'additional'::character varying COMMENT E'',
149   - "media_alt" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
150   - "media_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
151   - "media_caption" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
152   - PRIMARY KEY ("id"),
153   - KEY ("media_id"),
154   - KEY ("article_id"),
155   - KEY ("id")
156   -);
157   -
158   --- Дамп данных таблицы public.article_media: 0 rows
159   -/*!40000 ALTER TABLE "article_media" DISABLE KEYS */;
160   -/*!40000 ALTER TABLE "article_media" ENABLE KEYS */;
161   -
162   -
163   --- Дамп структуры для таблица public.media
164   -CREATE TABLE IF NOT EXISTS "media" (
165   - "id" INTEGER NOT NULL DEFAULT nextval('media_id_seq'::regclass) COMMENT E'',
166   - "hash" CHARACTER VARYING NOT NULL COMMENT E'',
167   - PRIMARY KEY ("id"),
168   - KEY ("id")
169   -);
170   -
171   --- Дамп данных таблицы public.media: 0 rows
172   -/*!40000 ALTER TABLE "media" DISABLE KEYS */;
173   -/*!40000 ALTER TABLE "media" ENABLE KEYS */;
174   -
175   -
176   --- Дамп структуры для таблица public.option
177   -CREATE TABLE IF NOT EXISTS "option" (
178   - "model" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
179   - "option_id" INTEGER NOT NULL DEFAULT nextval('option_option_id_seq'::regclass) COMMENT E'',
180   - "model_id" INTEGER NULL DEFAULT NULL COMMENT E'',
181   - "name" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
182   - "template" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
183   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
184   - "translate" BIT(1) NULL DEFAULT NULL COMMENT E'',
185   - "created_at" TIMESTAMP WITHOUT TIME ZONE NULL DEFAULT now() COMMENT E'',
186   - KEY ("option_id"),
187   - KEY ("parent_id"),
188   - PRIMARY KEY ("option_id")
189   -);
190   -
191   --- Дамп данных таблицы public.option: 0 rows
192   -/*!40000 ALTER TABLE "option" DISABLE KEYS */;
193   -/*!40000 ALTER TABLE "option" ENABLE KEYS */;
194   -
195   -
196   --- Дамп структуры для таблица public.option_lang
197   -CREATE TABLE IF NOT EXISTS "option_lang" (
198   - "primary" INTEGER NOT NULL DEFAULT nextval('option_lang_primary_seq'::regclass) COMMENT E'',
199   - "id" INTEGER NULL DEFAULT NULL COMMENT E'',
200   - "lang_id" INTEGER NULL DEFAULT NULL COMMENT E'',
201   - "value" TEXT NULL DEFAULT NULL COMMENT E'',
202   - KEY ("id"),
203   - PRIMARY KEY ("primary")
204   -);
205   -
206   --- Дамп данных таблицы public.option_lang: 0 rows
207   -/*!40000 ALTER TABLE "option_lang" DISABLE KEYS */;
208   -/*!40000 ALTER TABLE "option_lang" ENABLE KEYS */;
209   -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
210   -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
211   -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
db-migration/yarik.zip deleted
No preview for this file type
db-migration/yarik/db.zip deleted
No preview for this file type
frontend/controllers/SiteController.php
... ... @@ -36,7 +36,7 @@ class SiteController extends Controller
36 36 return [
37 37 'access' => [
38 38 'class' => AccessControl::className(),
39   - 'only' => ['logout', 'signup'],
  39 + 'only' => ['logout', 'signup', 'index'],
40 40 'rules' => [
41 41 [
42 42 'actions' => ['signup'],
... ... @@ -48,6 +48,11 @@ class SiteController extends Controller
48 48 'allow' => true,
49 49 'roles' => ['@'],
50 50 ],
  51 + [
  52 + 'actions' => ['index'],
  53 + 'allow' => true,
  54 + 'roles' => ['@'],
  55 + ]
51 56 ],
52 57 ],
53 58 'verbs' => [
... ...