Commit bb7d15c516648e2eff95e5e70bf6a00fea9a6128

Authored by andryeyev
1 parent 19423060

Итерация 3 (Template + Widget + Все категории фильтры)

backend/views/page/_form.php
... ... @@ -14,10 +14,18 @@ use yii\widgets\ActiveForm;
14 14  
15 15 <h2><?= Yii::t('field', 'common'); ?></h2>
16 16  
17   - <?= $form->field($model, 'date_add')->widget(\yii\jui\DatePicker::classname(), [
18   - 'language' => yii::$app->language,
19   - 'dateFormat' => 'yyyy-MM-dd',
20   - ]) ?>
  17 + <?
  18 + // по умолчанию
  19 + if (empty ($model->date_add))
  20 + {
  21 + $model->date_add = date('Y-m-d');
  22 + }
  23 +
  24 + echo $form->field($model, 'date_add')->widget(\yii\jui\DatePicker::classname(), [
  25 + 'language' => yii::$app->language,
  26 + 'dateFormat' => 'yyyy-MM-dd',
  27 + ]);
  28 + ?>
21 29  
22 30 <?= $form->field($model, 'template_id')->textInput() ?>
23 31  
... ...
common/models/Menu.php
... ... @@ -18,14 +18,21 @@ use Yii;
18 18 class Menu extends \yii\db\ActiveRecord
19 19 {
20 20  
21   - public function getMenuList()
22   - {
  21 + public function getMenuList ($location_name)
  22 + {
23 23 return yii::$app->db->createCommand('
24 24 SELECT
25   - `termin_lang`.termin_title, `termin_lang`.termin_id
  25 + `menu`.menu_id, `menu`.menu_pid, `menu`.level,
  26 + `page_lang`.page_title,
  27 + `page_lang`.page_alias
26 28 FROM `menu`
27   - INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id
28   - AND `termin_lang`.lang_id = '.yii::$app->lang_id.'
  29 + INNER JOIN `menu_location` ON `menu_location`.menu_location_id = `menu`.menu_location_id
  30 + AND `menu_location`.menu_location_name = "'.$location_name.'"
  31 + INNER JOIN `page` ON `page`.page_id = `menu`.page_id
  32 + AND `page`.show = 1
  33 + INNER JOIN `page_lang` ON `page_lang`.page_id = `page`.page_id
  34 + AND `page_lang`.lang_id = '.yii::$app->lang_id.'
  35 + WHERE `menu`.show = 1
29 36 ORDER BY `menu`.menu_pid ASC, `menu`.sortorder ASC
30 37 ')->queryAll();
31 38 /*
... ...
common/models/Page.php
... ... @@ -101,6 +101,31 @@ class Page extends \yii\db\ActiveRecord
101 101 return $result;
102 102 }
103 103  
  104 + // ==== FRONT ====
  105 +
  106 + static function getPageByUrl ($url)
  107 + {
  108 + return yii::$app->db->createCommand('
  109 + SELECT
  110 + `page`.show,
  111 + `controller`.controller_name,
  112 + `template`.template_file
  113 + FROM `page`
  114 + INNER JOIN `page_lang` ON `page_lang`.page_id = `page`.page_id
  115 + AND `page_lang`.lang_id = '.yii::$app->lang_id.'
  116 + AND `page_lang`.page_alias = "'.$url.'"
  117 + INNER JOIN `template` ON `template`.template_id = `page`.template_id
  118 + INNER JOIN `controller` ON `controller`.controller_id = `template`.controller_id
  119 + ')->queryOne();
  120 + }
  121 +
  122 + static function isShow ($page)
  123 + {
  124 + return $page['show'] == 1 ? true : false;
  125 + }
  126 +
  127 + // ==== YII ====
  128 +
104 129 /**
105 130 * @inheritdoc
106 131 */
... ...
common/translation/ru/action.php 0 → 100644
  1 +<?php
  2 +
  3 +return [
  4 + 'add' => 'Добавить',
  5 + 'edit' => 'Изменить',
  6 + 'update' => 'Обновить',
  7 + 'del' => 'Удалить',
  8 + 'hide'=> 'Скрыть',
  9 + 'copy' => 'Копировать',
  10 + 'view' => 'Посмотреть',
  11 + 'show' => 'Показать',
  12 +];
0 13 \ No newline at end of file
... ...
common/translation/ru/field.php 0 → 100644
  1 +<?php
  2 +
  3 +return [
  4 + 'page' => 'Страница',
  5 + 'date_add' => 'Дата добавления',
  6 + 'template' => 'Шаблон',
  7 + 'image' => 'Картинка',
  8 + 'title' => 'Заголовок',
  9 + 'meta_title' => 'Meta Title',
  10 + 'meta_description' => 'Meta Description',
  11 + 'text' => 'Текст',
  12 + 'page_alias' => 'alias',
  13 + 'lang_id' => 'ID языка',
  14 + 'common' => 'Общее',
  15 + 'lang' => 'Языковые переменные',
  16 +];
0 17 \ No newline at end of file
... ...
db-migration/artbox_db.sql
... ... @@ -3,7 +3,7 @@
3 3 -- http://www.phpmyadmin.net
4 4 --
5 5 -- Хост: 127.0.0.1:3306
6   --- Час створення: Лис 06 2015 р., 12:08
  6 +-- Час створення: Лис 09 2015 р., 20:55
7 7 -- Версія сервера: 5.5.45
8 8 -- Версія PHP: 5.6.12
9 9  
... ... @@ -23,6 +23,27 @@ SET time_zone = &quot;+00:00&quot;;
23 23 -- --------------------------------------------------------
24 24  
25 25 --
  26 +-- Структура таблиці `controller`
  27 +--
  28 +
  29 +CREATE TABLE IF NOT EXISTS `controller` (
  30 + `controller_id` int(3) NOT NULL AUTO_INCREMENT,
  31 + `controller_name` varchar(50) NOT NULL,
  32 + PRIMARY KEY (`controller_id`)
  33 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
  34 +
  35 +--
  36 +-- Дамп даних таблиці `controller`
  37 +--
  38 +
  39 +INSERT INTO `controller` (`controller_id`, `controller_name`) VALUES
  40 +(1, 'Page'),
  41 +(2, 'Home'),
  42 +(3, 'Catlog');
  43 +
  44 +-- --------------------------------------------------------
  45 +
  46 +--
26 47 -- Структура таблиці `feature`
27 48 --
28 49  
... ... @@ -76,8 +97,8 @@ CREATE TABLE IF NOT EXISTS `language` (
76 97 --
77 98  
78 99 INSERT INTO `language` (`language_id`, `lang_code`, `is_default`) VALUES
79   -(1, 'uk', 1),
80   -(2, 'ru', 0);
  100 +(1, 'uk', 0),
  101 +(2, 'ru', 1);
81 102  
82 103 -- --------------------------------------------------------
83 104  
... ... @@ -111,18 +132,77 @@ CREATE TABLE IF NOT EXISTS `menu` (
111 132 `menu_pid` int(6) NOT NULL,
112 133 `menu_lft` int(6) NOT NULL,
113 134 `menu_rgt` int(6) NOT NULL,
114   - `termin_id` int(6) NOT NULL,
  135 + `level` int(6) NOT NULL,
  136 + `page_id` int(6) NOT NULL,
115 137 `show` tinyint(1) NOT NULL,
  138 + `menu_location_id` int(6) NOT NULL,
116 139 `sortorder` int(6) NOT NULL,
117   - PRIMARY KEY (`menu_id`)
118   -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
  140 + PRIMARY KEY (`menu_id`),
  141 + KEY `show` (`show`),
  142 + KEY `sortorder` (`sortorder`),
  143 + KEY `termin_id` (`page_id`)
  144 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
119 145  
120 146 --
121 147 -- Дамп даних таблиці `menu`
122 148 --
123 149  
124   -INSERT INTO `menu` (`menu_id`, `menu_pid`, `menu_lft`, `menu_rgt`, `termin_id`, `show`, `sortorder`) VALUES
125   -(1, 0, 0, 0, 1, 1, 1);
  150 +INSERT INTO `menu` (`menu_id`, `menu_pid`, `menu_lft`, `menu_rgt`, `level`, `page_id`, `show`, `menu_location_id`, `sortorder`) VALUES
  151 +(1, 0, 0, 0, 0, 2, 1, 1, 1),
  152 +(2, 1, 0, 0, 1, 3, 1, 1, 1),
  153 +(3, 1, 0, 0, 1, 4, 1, 1, 1),
  154 +(4, 0, 0, 0, 0, 5, 1, 1, 1),
  155 +(5, 1, 0, 0, 1, 6, 1, 1, 1),
  156 +(6, 1, 0, 0, 1, 7, 1, 1, 1),
  157 +(7, 0, 0, 0, 0, 8, 1, 1, 1),
  158 +(8, 0, 0, 0, 0, 9, 1, 1, 1),
  159 +(9, 0, 0, 0, 0, 10, 1, 1, 1),
  160 +(10, 0, 0, 0, 0, 11, 1, 1, 1),
  161 +(11, 0, 0, 0, 0, 12, 1, 1, 1),
  162 +(12, 0, 0, 0, 0, 13, 1, 1, 1);
  163 +
  164 +-- --------------------------------------------------------
  165 +
  166 +--
  167 +-- Структура таблиці `menu_location`
  168 +--
  169 +
  170 +CREATE TABLE IF NOT EXISTS `menu_location` (
  171 + `menu_location_id` int(2) NOT NULL AUTO_INCREMENT,
  172 + `menu_location_name` varchar(50) DEFAULT NULL,
  173 + PRIMARY KEY (`menu_location_id`)
  174 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
  175 +
  176 +--
  177 +-- Дамп даних таблиці `menu_location`
  178 +--
  179 +
  180 +INSERT INTO `menu_location` (`menu_location_id`, `menu_location_name`) VALUES
  181 +(1, 'TOP'),
  182 +(2, 'CENTER'),
  183 +(3, 'BOTTOM');
  184 +
  185 +-- --------------------------------------------------------
  186 +
  187 +--
  188 +-- Структура таблиці `menu_location_lang`
  189 +--
  190 +
  191 +CREATE TABLE IF NOT EXISTS `menu_location_lang` (
  192 + `menu_location_id` int(2) NOT NULL,
  193 + `menu_location_title` varchar(50) NOT NULL,
  194 + `lang_id` int(2) NOT NULL,
  195 + PRIMARY KEY (`menu_location_id`,`lang_id`)
  196 +) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  197 +
  198 +--
  199 +-- Дамп даних таблиці `menu_location_lang`
  200 +--
  201 +
  202 +INSERT INTO `menu_location_lang` (`menu_location_id`, `menu_location_title`, `lang_id`) VALUES
  203 +(1, 'Верхнее', 2),
  204 +(2, 'Центр', 2),
  205 +(3, 'Низ', 2);
126 206  
127 207 -- --------------------------------------------------------
128 208  
... ... @@ -154,20 +234,31 @@ INSERT INTO `migration` (`version`, `apply_time`) VALUES
154 234 CREATE TABLE IF NOT EXISTS `page` (
155 235 `page_id` int(6) NOT NULL AUTO_INCREMENT,
156 236 `date_add` datetime NOT NULL,
  237 + `page_type_id` int(2) NOT NULL,
157 238 `template_id` int(6) NOT NULL,
158 239 `image_id` int(6) NOT NULL,
159 240 `show` tinyint(1) NOT NULL,
160 241 PRIMARY KEY (`page_id`)
161   -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
  242 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
162 243  
163 244 --
164 245 -- Дамп даних таблиці `page`
165 246 --
166 247  
167   -INSERT INTO `page` (`page_id`, `date_add`, `template_id`, `image_id`, `show`) VALUES
168   -(1, '2015-11-03 00:00:00', 0, 0, 1),
169   -(2, '2015-11-03 00:00:00', 0, 0, 1),
170   -(3, '2015-11-03 00:00:00', 0, 0, 1);
  248 +INSERT INTO `page` (`page_id`, `date_add`, `page_type_id`, `template_id`, `image_id`, `show`) VALUES
  249 +(1, '2015-11-09 00:00:00', 0, 2, 0, 1),
  250 +(2, '2015-11-09 00:00:00', 0, 1, 0, 1),
  251 +(3, '2015-11-09 00:00:00', 0, 1, 0, 1),
  252 +(4, '2015-11-09 00:00:00', 0, 1, 0, 1),
  253 +(5, '2015-11-09 00:00:00', 0, 1, 0, 1),
  254 +(6, '2015-11-09 00:00:00', 0, 2, 0, 1),
  255 +(7, '2015-11-09 00:00:00', 0, 1, 0, 1),
  256 +(8, '2015-11-09 00:00:00', 0, 3, 0, 1),
  257 +(9, '2015-11-09 00:00:00', 0, 1, 0, 1),
  258 +(10, '2015-11-09 00:00:00', 0, 1, 0, 1),
  259 +(11, '2015-11-09 00:00:00', 0, 1, 0, 1),
  260 +(12, '2015-11-09 00:00:00', 0, 2, 0, 1),
  261 +(13, '2015-11-09 00:00:00', 0, 5, 0, 1);
171 262  
172 263 -- --------------------------------------------------------
173 264  
... ... @@ -177,7 +268,7 @@ INSERT INTO `page` (`page_id`, `date_add`, `template_id`, `image_id`, `show`) VA
177 268  
178 269 CREATE TABLE IF NOT EXISTS `page_lang` (
179 270 `page_id` int(6) NOT NULL,
180   - `title` varchar(256) NOT NULL,
  271 + `page_title` varchar(256) NOT NULL,
181 272 `meta_title` varchar(512) NOT NULL,
182 273 `meta_description` varchar(512) NOT NULL,
183 274 `text` text NOT NULL,
... ... @@ -190,11 +281,72 @@ CREATE TABLE IF NOT EXISTS `page_lang` (
190 281 -- Дамп даних таблиці `page_lang`
191 282 --
192 283  
193   -INSERT INTO `page_lang` (`page_id`, `title`, `meta_title`, `meta_description`, `text`, `page_alias`, `lang_id`) VALUES
194   -(1, 'Головна сторінка', 'Головна сторінка', 'Головна сторінка - Artbox', '', '/', 1),
195   -(1, 'Главная страница', 'Главная страница', 'Главная страница - Artbox', '', '/ru/', 2),
196   -(2, 'Магазин Meta Title', 'Магазин Meta Title', 'Магазин Meta Description', 'Магазин Text', 'shop', 1),
197   -(3, 'Контент', 'Контент', 'Контент', 'Контент', 'content', 1);
  284 +INSERT INTO `page_lang` (`page_id`, `page_title`, `meta_title`, `meta_description`, `text`, `page_alias`, `lang_id`) VALUES
  285 +(1, 'Главная страница', '', '', '', '/', 2),
  286 +(2, 'О компании', '', '', '', 'about', 2),
  287 +(3, 'Условия использования', '', '', '', 'use', 2),
  288 +(4, 'Условия сотрудничества', '', '', '', 'corporation', 2),
  289 +(5, 'Контакты', '', '', '', 'contacts', 2),
  290 +(6, 'Магазины', '', '', '', 'shops', 2),
  291 +(7, 'Поставщики', '', '', '', 'vendors', 2),
  292 +(8, 'Каталог товаров', '', '', '', 'catalog', 2),
  293 +(9, 'Оплата', '', '', '', 'payment', 2),
  294 +(10, 'Доставка', '', '', '', 'delivery', 2),
  295 +(11, 'Гарантия', '', '', '', 'warranty', 2),
  296 +(12, 'Акции', '', '', '', 'promotion', 2),
  297 +(13, 'Новости', '', '', '', 'news', 2);
  298 +
  299 +-- --------------------------------------------------------
  300 +
  301 +--
  302 +-- Структура таблиці `page_type`
  303 +--
  304 +
  305 +CREATE TABLE IF NOT EXISTS `page_type` (
  306 + `page_type_id` int(2) NOT NULL AUTO_INCREMENT,
  307 + `page_type_name` varchar(56) NOT NULL,
  308 + PRIMARY KEY (`page_type_id`)
  309 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
  310 +
  311 +--
  312 +-- Дамп даних таблиці `page_type`
  313 +--
  314 +
  315 +INSERT INTO `page_type` (`page_type_id`, `page_type_name`) VALUES
  316 +(1, 'tag'),
  317 +(2, 'news'),
  318 +(3, 'article'),
  319 +(4, 'category'),
  320 +(5, 'page');
  321 +
  322 +-- --------------------------------------------------------
  323 +
  324 +--
  325 +-- Структура таблиці `page_type_lang`
  326 +--
  327 +
  328 +CREATE TABLE IF NOT EXISTS `page_type_lang` (
  329 + `page_type_id` int(2) NOT NULL,
  330 + `page_type_title` varchar(50) NOT NULL,
  331 + `lang_id` int(2) NOT NULL,
  332 + PRIMARY KEY (`page_type_id`,`lang_id`)
  333 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  334 +
  335 +--
  336 +-- Дамп даних таблиці `page_type_lang`
  337 +--
  338 +
  339 +INSERT INTO `page_type_lang` (`page_type_id`, `page_type_title`, `lang_id`) VALUES
  340 +(1, 'Тег', 1),
  341 +(1, 'Тег', 2),
  342 +(2, 'Новини', 1),
  343 +(2, 'Новости', 2),
  344 +(3, 'Статья', 1),
  345 +(3, 'Статья', 2),
  346 +(4, 'Категорія', 1),
  347 +(4, 'Категория', 2),
  348 +(5, 'Сторінка', 1),
  349 +(5, 'Страница', 2);
198 350  
199 351 -- --------------------------------------------------------
200 352  
... ... @@ -238,34 +390,84 @@ CREATE TABLE IF NOT EXISTS `product_tag` (
238 390 -- --------------------------------------------------------
239 391  
240 392 --
  393 +-- Структура таблиці `template`
  394 +--
  395 +
  396 +CREATE TABLE IF NOT EXISTS `template` (
  397 + `template_id` int(3) NOT NULL AUTO_INCREMENT,
  398 + `controller_id` int(3) NOT NULL,
  399 + `template_name` varchar(50) NOT NULL,
  400 + `template_file` varchar(50) NOT NULL,
  401 + PRIMARY KEY (`template_id`)
  402 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
  403 +
  404 +--
  405 +-- Дамп даних таблиці `template`
  406 +--
  407 +
  408 +INSERT INTO `template` (`template_id`, `controller_id`, `template_name`, `template_file`) VALUES
  409 +(1, 1, 'page', 'page/page'),
  410 +(2, 2, 'home', 'page/home'),
  411 +(3, 3, 'catalog', 'shop/catalog'),
  412 +(4, 0, 'filter', 'shop/filter'),
  413 +(5, 0, 'news', 'news/all');
  414 +
  415 +-- --------------------------------------------------------
  416 +
  417 +--
  418 +-- Структура таблиці `template_lang`
  419 +--
  420 +
  421 +CREATE TABLE IF NOT EXISTS `template_lang` (
  422 + `template_id` int(3) NOT NULL,
  423 + `template_title` varchar(50) NOT NULL,
  424 + `lang_id` int(3) NOT NULL,
  425 + PRIMARY KEY (`template_id`,`lang_id`)
  426 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  427 +
  428 +--
  429 +-- Дамп даних таблиці `template_lang`
  430 +--
  431 +
  432 +INSERT INTO `template_lang` (`template_id`, `template_title`, `lang_id`) VALUES
  433 +(1, 'Страница', 2),
  434 +(2, 'Главная', 2),
  435 +(3, 'Каталог', 2),
  436 +(4, 'Фильтр', 2),
  437 +(5, 'Новости', 2);
  438 +
  439 +-- --------------------------------------------------------
  440 +
  441 +--
241 442 -- Структура таблиці `termin`
242 443 --
243 444  
244 445 CREATE TABLE IF NOT EXISTS `termin` (
245 446 `termin_id` int(6) NOT NULL AUTO_INCREMENT,
246   - `termin_type_id` int(2) NOT NULL,
247   - `page_id` int(6) NOT NULL DEFAULT '0',
248 447 PRIMARY KEY (`termin_id`)
249   -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
  448 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
250 449  
251 450 --
252 451 -- Дамп даних таблиці `termin`
253 452 --
254 453  
255   -INSERT INTO `termin` (`termin_id`, `termin_type_id`, `page_id`) VALUES
256   -(1, 5, 1),
257   -(2, 0, 0),
258   -(3, 0, 0),
259   -(4, 0, 0),
260   -(5, 0, 0),
261   -(6, 0, 0),
262   -(7, 0, 0),
263   -(8, 0, 0),
264   -(9, 0, 0),
265   -(10, 0, 0),
266   -(16, 0, 0),
267   -(17, 0, 0),
268   -(18, 0, 0);
  454 +INSERT INTO `termin` (`termin_id`) VALUES
  455 +(1),
  456 +(2),
  457 +(3),
  458 +(4),
  459 +(5),
  460 +(6),
  461 +(7),
  462 +(8),
  463 +(9),
  464 +(10),
  465 +(11),
  466 +(12),
  467 +(13),
  468 +(14),
  469 +(15),
  470 +(16);
269 471  
270 472 -- --------------------------------------------------------
271 473  
... ... @@ -285,19 +487,22 @@ CREATE TABLE IF NOT EXISTS `termin_lang` (
285 487 --
286 488  
287 489 INSERT INTO `termin_lang` (`termin_id`, `termin_title`, `lang_id`) VALUES
288   -(1, 'Головна', 1),
289   -(2, 'Завод', 1),
290   -(3, 'BMW', 1),
291   -(4, 'Mini', 1),
292   -(5, 'Года (1996-2000)', 1),
293   -(6, 'Кузов', 1),
294   -(7, 'Модель', 1),
295   -(8, 'Серия', 1),
296   -(9, 'Мотор (тип)', 1),
297   -(10, 'Мотор (обьем)', 1),
298   -(16, '1996', 1),
299   -(17, 'X5', 1),
300   -(18, 'Новости', 0);
  490 +(1, 'Главная страница', 2),
  491 +(2, 'О компании', 2),
  492 +(3, 'Условия использования', 2),
  493 +(4, 'Условия сотрудничества', 2),
  494 +(5, 'Контакты', 2),
  495 +(6, 'Магазины', 2),
  496 +(7, 'Поставщики', 2),
  497 +(8, 'Каталог товаров', 2),
  498 +(9, 'Оплата', 2),
  499 +(10, 'Доставка', 2),
  500 +(11, 'Гарантия', 2),
  501 +(12, 'Акции ', 2),
  502 +(13, 'Материалы/блог', 2),
  503 +(14, 'Арбуз', 2),
  504 +(15, 'Артишок', 2),
  505 +(16, 'Баклажан', 2);
301 506  
302 507 -- --------------------------------------------------------
303 508  
... ... @@ -320,25 +525,22 @@ CREATE TABLE IF NOT EXISTS `termin_option` (
320 525 --
321 526  
322 527 INSERT INTO `termin_option` (`termin_id`, `termin_pid`, `level`, `lft`, `rgt`, `sortorder`) VALUES
323   -(1, 0, 0, 1, 2, 1),
324   -(2, 0, 1, 3, 32, 2),
325   -(3, 2, 2, 4, 17, 1),
326   -(4, 2, 2, 18, 31, 2),
327   -(5, 0, 1, 33, 38, 3),
328   -(6, 3, 2, 19, 20, 1),
329   -(6, 4, 2, 19, 20, 1),
330   -(7, 3, 3, 21, 24, 2),
331   -(7, 4, 3, 21, 24, 2),
332   -(8, 3, 2, 25, 26, 3),
333   -(8, 4, 2, 25, 26, 3),
334   -(9, 3, 2, 27, 28, 4),
335   -(9, 4, 2, 27, 28, 4),
336   -(10, 3, 2, 29, 30, 5),
337   -(10, 4, 2, 29, 30, 5),
338   -(16, 5, 2, 34, 37, 4),
339   -(17, 7, 2, 35, 36, 0),
340   -(17, 16, 2, 35, 36, 0),
341   -(18, 1, 0, 0, 0, 0);
  528 +(1, 0, 0, 0, 0, 0),
  529 +(2, 0, 0, 0, 0, 0),
  530 +(3, 0, 0, 0, 0, 0),
  531 +(4, 0, 0, 0, 0, 0),
  532 +(5, 0, 0, 0, 0, 0),
  533 +(6, 0, 0, 0, 0, 0),
  534 +(7, 0, 0, 0, 0, 0),
  535 +(8, 0, 0, 0, 0, 0),
  536 +(9, 0, 0, 0, 0, 0),
  537 +(10, 0, 0, 0, 0, 0),
  538 +(11, 0, 0, 0, 0, 0),
  539 +(12, 0, 0, 0, 0, 0),
  540 +(13, 0, 0, 0, 0, 0),
  541 +(14, 0, 0, 0, 0, 1),
  542 +(15, 0, 0, 0, 0, 1),
  543 +(16, 0, 0, 0, 0, 1);
342 544  
343 545 -- --------------------------------------------------------
344 546  
... ... @@ -354,58 +556,6 @@ CREATE TABLE IF NOT EXISTS `termin_relation` (
354 556 -- --------------------------------------------------------
355 557  
356 558 --
357   --- Структура таблиці `termin_type`
358   ---
359   -
360   -CREATE TABLE IF NOT EXISTS `termin_type` (
361   - `termin_type_id` int(2) NOT NULL AUTO_INCREMENT,
362   - `termin_type_name` varchar(56) NOT NULL,
363   - PRIMARY KEY (`termin_type_id`)
364   -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
365   -
366   ---
367   --- Дамп даних таблиці `termin_type`
368   ---
369   -
370   -INSERT INTO `termin_type` (`termin_type_id`, `termin_type_name`) VALUES
371   -(1, 'tag'),
372   -(2, 'news'),
373   -(3, 'article'),
374   -(4, 'category'),
375   -(5, 'page');
376   -
377   --- --------------------------------------------------------
378   -
379   ---
380   --- Структура таблиці `termin_type_lang`
381   ---
382   -
383   -CREATE TABLE IF NOT EXISTS `termin_type_lang` (
384   - `termin_type_id` int(2) NOT NULL,
385   - `termin_type_title` varchar(56) NOT NULL,
386   - `lang_id` int(2) NOT NULL,
387   - PRIMARY KEY (`termin_type_id`,`lang_id`)
388   -) ENGINE=InnoDB DEFAULT CHARSET=utf8;
389   -
390   ---
391   --- Дамп даних таблиці `termin_type_lang`
392   ---
393   -
394   -INSERT INTO `termin_type_lang` (`termin_type_id`, `termin_type_title`, `lang_id`) VALUES
395   -(1, 'Тег', 1),
396   -(1, 'Тег', 2),
397   -(2, 'Новини', 1),
398   -(2, 'Новости', 2),
399   -(3, 'Статья', 1),
400   -(3, 'Статья', 2),
401   -(4, 'Категорія', 1),
402   -(4, 'Категория', 2),
403   -(5, 'Сторінка', 1),
404   -(5, 'Страница', 2);
405   -
406   --- --------------------------------------------------------
407   -
408   ---
409 559 -- Структура таблиці `user`
410 560 --
411 561  
... ...
frontend/config/main.php
... ... @@ -28,6 +28,13 @@ return [
28 28 'errorHandler' => [
29 29 'errorAction' => 'site/error',
30 30 ],
  31 + 'urlManager' => [
  32 + 'enablePrettyUrl' => true,
  33 + 'showScriptName' => false,
  34 + 'rules' => [
  35 + '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
  36 + ]
  37 + ],
31 38 ],
32 39 'params' => $params,
33 40 ];
... ...
frontend/controllers/PageController.php 0 → 100644
  1 +<?php
  2 +
  3 +//namespace frontend\controllers;
  4 +
  5 +use yii\web\Controller;
  6 +
  7 +/**
  8 + * PageController controller
  9 + */
  10 +class PageController extends Controller
  11 +{
  12 + public function actions()
  13 + {
  14 + die;
  15 + }
  16 +
  17 + public function actionIndex()
  18 + {
  19 + die;
  20 + return $this->render('index');
  21 + }
  22 +}
... ...
frontend/controllers/SiteController.php
... ... @@ -13,6 +13,9 @@ use yii\web\Controller;
13 13 use yii\filters\VerbFilter;
14 14 use yii\filters\AccessControl;
15 15  
  16 +use common\models\Page;
  17 +use frontend\controllers\PageController;
  18 +
16 19 /**
17 20 * Site controller
18 21 */
... ... @@ -53,7 +56,30 @@ class SiteController extends Controller
53 56 * @inheritdoc
54 57 */
55 58 public function actions()
56   - {
  59 + {
  60 + // парсим URL, находим контроллер и подключаем view-файл
  61 +/*
  62 + if ($page = Page::getPageByUrl ('about'))
  63 + {
  64 + if (Page::isShow ($page)
  65 + && $page['template_file'] != NULL
  66 + && is_file (yii::$app->viewPath.'/'.$page['template_file'].'.php'))
  67 + {
  68 + $controller = $page['controller_name'].'Controller';
  69 + require_once __DIR__.'/'.$controller.'.php';
  70 +
  71 + //eval ('use '.$controller.';');
  72 +
  73 + //return new $controller;
  74 +
  75 + return $this->render('/'.$page['template_file']);
  76 + //return yii::$app->runAction($page['template_file']);
  77 + }
  78 + }
  79 +*/
  80 +
  81 +
  82 + // по умолчанию - 404
57 83 return [
58 84 'error' => [
59 85 'class' => 'yii\web\ErrorAction',
... ... @@ -71,7 +97,7 @@ class SiteController extends Controller
71 97 * @return mixed
72 98 */
73 99 public function actionIndex()
74   - {
  100 + {
75 101 return $this->render('index');
76 102 }
77 103  
... ...
frontend/models/Front.php
... ... @@ -11,8 +11,8 @@ use Yii;
11 11 */
12 12 class Front extends Model
13 13 {
14   - public function actionMenu()
  14 + public function actionMenu($location)
15 15 {
16   - return (new Menu)->getMenuList();
17   - }
  16 + return (new Menu)->getMenuList($location);
  17 + }
18 18 }
... ...
frontend/views/layouts/main.php
... ... @@ -45,9 +45,9 @@ AppAsset::register($this);
45 45 // меню с базы
46 46 $menuItems = [];
47 47  
48   - foreach ((new \frontend\models\Front())->actionMenu() as $row)
  48 + foreach ((new \frontend\models\Front())->actionMenu('TOP') as $row)
49 49 {
50   - $menuItems[] = ['label' => $row['termin_title'], 'url' => $row['termin_id']];
  50 + $menuItems[] = ['label' => $row['page_title'], 'url' => $row['page_alias']];
51 51 }
52 52  
53 53 if (Yii::$app->user->isGuest)
... ...
frontend/views/page/home.php 0 → 100644
  1 +Хуй
0 2 \ No newline at end of file
... ...
frontend/views/page/page.php 0 → 100644
  1 +Хуй
0 2 \ No newline at end of file
... ...
frontend/views/site/about.php renamed to frontend/views/site-del/about.php
frontend/views/site/contact.php renamed to frontend/views/site-del/contact.php
frontend/views/site-del/error.php 0 → 100644
  1 +<?php
  2 +
  3 +/* @var $this yii\web\View */
  4 +/* @var $name string */
  5 +/* @var $message string */
  6 +/* @var $exception Exception */
  7 +
  8 +use yii\helpers\Html;
  9 +
  10 +$this->title = $name;
  11 +?>
  12 +<div class="site-error">
  13 +
  14 + <h1><?= Html::encode($this->title) ?></h1>
  15 +
  16 + <div class="alert alert-danger">
  17 + <?= nl2br(Html::encode($message)) ?>
  18 + </div>
  19 +
  20 + <p>
  21 + The above error occurred while the Web server was processing your request.
  22 + </p>
  23 + <p>
  24 + Please contact us if you think this is a server error. Thank you.
  25 + </p>
  26 +
  27 +</div>
... ...
frontend/views/site-del/index.php 0 → 100644
  1 +<?php
  2 +
  3 +/* @var $this yii\web\View */
  4 +
  5 +$this->title = 'My Yii Application';
  6 +?>
  7 +<div class="site-index">
  8 +
  9 + <div class="jumbotron">
  10 + <h1>Congratulations!</h1>
  11 +
  12 + <p class="lead">You have successfully created your Yii-powered application.</p>
  13 +
  14 + <p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
  15 + </div>
  16 +
  17 + <div class="body-content">
  18 +
  19 + <div class="row">
  20 + <div class="col-lg-4">
  21 + <h2>Heading</h2>
  22 +
  23 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  24 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  25 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  26 + fugiat nulla pariatur.</p>
  27 +
  28 + <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
  29 + </div>
  30 + <div class="col-lg-4">
  31 + <h2>Heading</h2>
  32 +
  33 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  34 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  35 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  36 + fugiat nulla pariatur.</p>
  37 +
  38 + <p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
  39 + </div>
  40 + <div class="col-lg-4">
  41 + <h2>Heading</h2>
  42 +
  43 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  44 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  45 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  46 + fugiat nulla pariatur.</p>
  47 +
  48 + <p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
  49 + </div>
  50 + </div>
  51 +
  52 + </div>
  53 +</div>
... ...
frontend/views/site/login.php renamed to frontend/views/site-del/login.php
frontend/views/site/requestPasswordResetToken.php renamed to frontend/views/site-del/requestPasswordResetToken.php
frontend/views/site/resetPassword.php renamed to frontend/views/site-del/resetPassword.php
frontend/views/site/signup.php renamed to frontend/views/site-del/signup.php