From bb7d15c516648e2eff95e5e70bf6a00fea9a6128 Mon Sep 17 00:00:00 2001 From: andryeyev Date: Mon, 9 Nov 2015 20:01:52 +0200 Subject: [PATCH] Итерация 3 (Template + Widget + Все категории фильтры) --- backend/views/page/_form.php | 16 ++++++++++++---- common/models/Menu.php | 17 ++++++++++++----- common/models/Page.php | 25 +++++++++++++++++++++++++ common/translation/ru/action.php | 12 ++++++++++++ common/translation/ru/field.php | 16 ++++++++++++++++ db-migration/artbox_db.sql | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------ frontend/config/main.php | 7 +++++++ frontend/controllers/PageController.php | 22 ++++++++++++++++++++++ frontend/controllers/SiteController.php | 30 ++++++++++++++++++++++++++++-- frontend/models/Front.php | 6 +++--- frontend/views/layouts/main.php | 4 ++-- frontend/views/page/home.php | 1 + frontend/views/page/page.php | 1 + frontend/views/site-del/about.php | 16 ++++++++++++++++ frontend/views/site-del/contact.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ frontend/views/site-del/error.php | 27 +++++++++++++++++++++++++++ frontend/views/site-del/index.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/site-del/login.php | 39 +++++++++++++++++++++++++++++++++++++++ frontend/views/site-del/requestPasswordResetToken.php | 31 +++++++++++++++++++++++++++++++ frontend/views/site-del/resetPassword.php | 31 +++++++++++++++++++++++++++++++ frontend/views/site-del/signup.php | 35 +++++++++++++++++++++++++++++++++++ frontend/views/site/about.php | 16 ---------------- frontend/views/site/contact.php | 45 --------------------------------------------- frontend/views/site/login.php | 39 --------------------------------------- frontend/views/site/requestPasswordResetToken.php | 31 ------------------------------- frontend/views/site/resetPassword.php | 31 ------------------------------- frontend/views/site/signup.php | 35 ----------------------------------- 27 files changed, 688 insertions(+), 333 deletions(-) create mode 100644 common/translation/ru/action.php create mode 100644 common/translation/ru/field.php create mode 100644 frontend/controllers/PageController.php create mode 100644 frontend/views/page/home.php create mode 100644 frontend/views/page/page.php create mode 100644 frontend/views/site-del/about.php create mode 100644 frontend/views/site-del/contact.php create mode 100644 frontend/views/site-del/error.php create mode 100644 frontend/views/site-del/index.php create mode 100644 frontend/views/site-del/login.php create mode 100644 frontend/views/site-del/requestPasswordResetToken.php create mode 100644 frontend/views/site-del/resetPassword.php create mode 100644 frontend/views/site-del/signup.php delete mode 100644 frontend/views/site/about.php delete mode 100644 frontend/views/site/contact.php delete mode 100644 frontend/views/site/login.php delete mode 100644 frontend/views/site/requestPasswordResetToken.php delete mode 100644 frontend/views/site/resetPassword.php delete mode 100644 frontend/views/site/signup.php diff --git a/backend/views/page/_form.php b/backend/views/page/_form.php index cd846f7..c85b816 100644 --- a/backend/views/page/_form.php +++ b/backend/views/page/_form.php @@ -14,10 +14,18 @@ use yii\widgets\ActiveForm;

- field($model, 'date_add')->widget(\yii\jui\DatePicker::classname(), [ - 'language' => yii::$app->language, - 'dateFormat' => 'yyyy-MM-dd', - ]) ?> + date_add)) + { + $model->date_add = date('Y-m-d'); + } + + echo $form->field($model, 'date_add')->widget(\yii\jui\DatePicker::classname(), [ + 'language' => yii::$app->language, + 'dateFormat' => 'yyyy-MM-dd', + ]); + ?> field($model, 'template_id')->textInput() ?> diff --git a/common/models/Menu.php b/common/models/Menu.php index 3f49759..bce2131 100644 --- a/common/models/Menu.php +++ b/common/models/Menu.php @@ -18,14 +18,21 @@ use Yii; class Menu extends \yii\db\ActiveRecord { - public function getMenuList() - { + public function getMenuList ($location_name) + { return yii::$app->db->createCommand(' SELECT - `termin_lang`.termin_title, `termin_lang`.termin_id + `menu`.menu_id, `menu`.menu_pid, `menu`.level, + `page_lang`.page_title, + `page_lang`.page_alias FROM `menu` - INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id - AND `termin_lang`.lang_id = '.yii::$app->lang_id.' + INNER JOIN `menu_location` ON `menu_location`.menu_location_id = `menu`.menu_location_id + AND `menu_location`.menu_location_name = "'.$location_name.'" + INNER JOIN `page` ON `page`.page_id = `menu`.page_id + AND `page`.show = 1 + INNER JOIN `page_lang` ON `page_lang`.page_id = `page`.page_id + AND `page_lang`.lang_id = '.yii::$app->lang_id.' + WHERE `menu`.show = 1 ORDER BY `menu`.menu_pid ASC, `menu`.sortorder ASC ')->queryAll(); /* diff --git a/common/models/Page.php b/common/models/Page.php index ca0a1d2..a5b2b17 100644 --- a/common/models/Page.php +++ b/common/models/Page.php @@ -101,6 +101,31 @@ class Page extends \yii\db\ActiveRecord return $result; } + // ==== FRONT ==== + + static function getPageByUrl ($url) + { + return yii::$app->db->createCommand(' + SELECT + `page`.show, + `controller`.controller_name, + `template`.template_file + FROM `page` + INNER JOIN `page_lang` ON `page_lang`.page_id = `page`.page_id + AND `page_lang`.lang_id = '.yii::$app->lang_id.' + AND `page_lang`.page_alias = "'.$url.'" + INNER JOIN `template` ON `template`.template_id = `page`.template_id + INNER JOIN `controller` ON `controller`.controller_id = `template`.controller_id + ')->queryOne(); + } + + static function isShow ($page) + { + return $page['show'] == 1 ? true : false; + } + + // ==== YII ==== + /** * @inheritdoc */ diff --git a/common/translation/ru/action.php b/common/translation/ru/action.php new file mode 100644 index 0000000..4420200 --- /dev/null +++ b/common/translation/ru/action.php @@ -0,0 +1,12 @@ + 'Добавить', + 'edit' => 'Изменить', + 'update' => 'Обновить', + 'del' => 'Удалить', + 'hide'=> 'Скрыть', + 'copy' => 'Копировать', + 'view' => 'Посмотреть', + 'show' => 'Показать', +]; \ No newline at end of file diff --git a/common/translation/ru/field.php b/common/translation/ru/field.php new file mode 100644 index 0000000..c1824fe --- /dev/null +++ b/common/translation/ru/field.php @@ -0,0 +1,16 @@ + 'Страница', + 'date_add' => 'Дата добавления', + 'template' => 'Шаблон', + 'image' => 'Картинка', + 'title' => 'Заголовок', + 'meta_title' => 'Meta Title', + 'meta_description' => 'Meta Description', + 'text' => 'Текст', + 'page_alias' => 'alias', + 'lang_id' => 'ID языка', + 'common' => 'Общее', + 'lang' => 'Языковые переменные', +]; \ No newline at end of file diff --git a/db-migration/artbox_db.sql b/db-migration/artbox_db.sql index 9999d73..a82dc19 100644 --- a/db-migration/artbox_db.sql +++ b/db-migration/artbox_db.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Хост: 127.0.0.1:3306 --- Час створення: Лис 06 2015 р., 12:08 +-- Час створення: Лис 09 2015 р., 20:55 -- Версія сервера: 5.5.45 -- Версія PHP: 5.6.12 @@ -23,6 +23,27 @@ SET time_zone = "+00:00"; -- -------------------------------------------------------- -- +-- Структура таблиці `controller` +-- + +CREATE TABLE IF NOT EXISTS `controller` ( + `controller_id` int(3) NOT NULL AUTO_INCREMENT, + `controller_name` varchar(50) NOT NULL, + PRIMARY KEY (`controller_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; + +-- +-- Дамп даних таблиці `controller` +-- + +INSERT INTO `controller` (`controller_id`, `controller_name`) VALUES +(1, 'Page'), +(2, 'Home'), +(3, 'Catlog'); + +-- -------------------------------------------------------- + +-- -- Структура таблиці `feature` -- @@ -76,8 +97,8 @@ CREATE TABLE IF NOT EXISTS `language` ( -- INSERT INTO `language` (`language_id`, `lang_code`, `is_default`) VALUES -(1, 'uk', 1), -(2, 'ru', 0); +(1, 'uk', 0), +(2, 'ru', 1); -- -------------------------------------------------------- @@ -111,18 +132,77 @@ CREATE TABLE IF NOT EXISTS `menu` ( `menu_pid` int(6) NOT NULL, `menu_lft` int(6) NOT NULL, `menu_rgt` int(6) NOT NULL, - `termin_id` int(6) NOT NULL, + `level` int(6) NOT NULL, + `page_id` int(6) NOT NULL, `show` tinyint(1) NOT NULL, + `menu_location_id` int(6) NOT NULL, `sortorder` int(6) NOT NULL, - PRIMARY KEY (`menu_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + PRIMARY KEY (`menu_id`), + KEY `show` (`show`), + KEY `sortorder` (`sortorder`), + KEY `termin_id` (`page_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ; -- -- Дамп даних таблиці `menu` -- -INSERT INTO `menu` (`menu_id`, `menu_pid`, `menu_lft`, `menu_rgt`, `termin_id`, `show`, `sortorder`) VALUES -(1, 0, 0, 0, 1, 1, 1); +INSERT INTO `menu` (`menu_id`, `menu_pid`, `menu_lft`, `menu_rgt`, `level`, `page_id`, `show`, `menu_location_id`, `sortorder`) VALUES +(1, 0, 0, 0, 0, 2, 1, 1, 1), +(2, 1, 0, 0, 1, 3, 1, 1, 1), +(3, 1, 0, 0, 1, 4, 1, 1, 1), +(4, 0, 0, 0, 0, 5, 1, 1, 1), +(5, 1, 0, 0, 1, 6, 1, 1, 1), +(6, 1, 0, 0, 1, 7, 1, 1, 1), +(7, 0, 0, 0, 0, 8, 1, 1, 1), +(8, 0, 0, 0, 0, 9, 1, 1, 1), +(9, 0, 0, 0, 0, 10, 1, 1, 1), +(10, 0, 0, 0, 0, 11, 1, 1, 1), +(11, 0, 0, 0, 0, 12, 1, 1, 1), +(12, 0, 0, 0, 0, 13, 1, 1, 1); + +-- -------------------------------------------------------- + +-- +-- Структура таблиці `menu_location` +-- + +CREATE TABLE IF NOT EXISTS `menu_location` ( + `menu_location_id` int(2) NOT NULL AUTO_INCREMENT, + `menu_location_name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`menu_location_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; + +-- +-- Дамп даних таблиці `menu_location` +-- + +INSERT INTO `menu_location` (`menu_location_id`, `menu_location_name`) VALUES +(1, 'TOP'), +(2, 'CENTER'), +(3, 'BOTTOM'); + +-- -------------------------------------------------------- + +-- +-- Структура таблиці `menu_location_lang` +-- + +CREATE TABLE IF NOT EXISTS `menu_location_lang` ( + `menu_location_id` int(2) NOT NULL, + `menu_location_title` varchar(50) NOT NULL, + `lang_id` int(2) NOT NULL, + PRIMARY KEY (`menu_location_id`,`lang_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Дамп даних таблиці `menu_location_lang` +-- + +INSERT INTO `menu_location_lang` (`menu_location_id`, `menu_location_title`, `lang_id`) VALUES +(1, 'Верхнее', 2), +(2, 'Центр', 2), +(3, 'Низ', 2); -- -------------------------------------------------------- @@ -154,20 +234,31 @@ INSERT INTO `migration` (`version`, `apply_time`) VALUES CREATE TABLE IF NOT EXISTS `page` ( `page_id` int(6) NOT NULL AUTO_INCREMENT, `date_add` datetime NOT NULL, + `page_type_id` int(2) NOT NULL, `template_id` int(6) NOT NULL, `image_id` int(6) NOT NULL, `show` tinyint(1) NOT NULL, PRIMARY KEY (`page_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ; -- -- Дамп даних таблиці `page` -- -INSERT INTO `page` (`page_id`, `date_add`, `template_id`, `image_id`, `show`) VALUES -(1, '2015-11-03 00:00:00', 0, 0, 1), -(2, '2015-11-03 00:00:00', 0, 0, 1), -(3, '2015-11-03 00:00:00', 0, 0, 1); +INSERT INTO `page` (`page_id`, `date_add`, `page_type_id`, `template_id`, `image_id`, `show`) VALUES +(1, '2015-11-09 00:00:00', 0, 2, 0, 1), +(2, '2015-11-09 00:00:00', 0, 1, 0, 1), +(3, '2015-11-09 00:00:00', 0, 1, 0, 1), +(4, '2015-11-09 00:00:00', 0, 1, 0, 1), +(5, '2015-11-09 00:00:00', 0, 1, 0, 1), +(6, '2015-11-09 00:00:00', 0, 2, 0, 1), +(7, '2015-11-09 00:00:00', 0, 1, 0, 1), +(8, '2015-11-09 00:00:00', 0, 3, 0, 1), +(9, '2015-11-09 00:00:00', 0, 1, 0, 1), +(10, '2015-11-09 00:00:00', 0, 1, 0, 1), +(11, '2015-11-09 00:00:00', 0, 1, 0, 1), +(12, '2015-11-09 00:00:00', 0, 2, 0, 1), +(13, '2015-11-09 00:00:00', 0, 5, 0, 1); -- -------------------------------------------------------- @@ -177,7 +268,7 @@ INSERT INTO `page` (`page_id`, `date_add`, `template_id`, `image_id`, `show`) VA CREATE TABLE IF NOT EXISTS `page_lang` ( `page_id` int(6) NOT NULL, - `title` varchar(256) NOT NULL, + `page_title` varchar(256) NOT NULL, `meta_title` varchar(512) NOT NULL, `meta_description` varchar(512) NOT NULL, `text` text NOT NULL, @@ -190,11 +281,72 @@ CREATE TABLE IF NOT EXISTS `page_lang` ( -- Дамп даних таблиці `page_lang` -- -INSERT INTO `page_lang` (`page_id`, `title`, `meta_title`, `meta_description`, `text`, `page_alias`, `lang_id`) VALUES -(1, 'Головна сторінка', 'Головна сторінка', 'Головна сторінка - Artbox', '', '/', 1), -(1, 'Главная страница', 'Главная страница', 'Главная страница - Artbox', '', '/ru/', 2), -(2, 'Магазин Meta Title', 'Магазин Meta Title', 'Магазин Meta Description', 'Магазин Text', 'shop', 1), -(3, 'Контент', 'Контент', 'Контент', 'Контент', 'content', 1); +INSERT INTO `page_lang` (`page_id`, `page_title`, `meta_title`, `meta_description`, `text`, `page_alias`, `lang_id`) VALUES +(1, 'Главная страница', '', '', '', '/', 2), +(2, 'О компании', '', '', '', 'about', 2), +(3, 'Условия использования', '', '', '', 'use', 2), +(4, 'Условия сотрудничества', '', '', '', 'corporation', 2), +(5, 'Контакты', '', '', '', 'contacts', 2), +(6, 'Магазины', '', '', '', 'shops', 2), +(7, 'Поставщики', '', '', '', 'vendors', 2), +(8, 'Каталог товаров', '', '', '', 'catalog', 2), +(9, 'Оплата', '', '', '', 'payment', 2), +(10, 'Доставка', '', '', '', 'delivery', 2), +(11, 'Гарантия', '', '', '', 'warranty', 2), +(12, 'Акции', '', '', '', 'promotion', 2), +(13, 'Новости', '', '', '', 'news', 2); + +-- -------------------------------------------------------- + +-- +-- Структура таблиці `page_type` +-- + +CREATE TABLE IF NOT EXISTS `page_type` ( + `page_type_id` int(2) NOT NULL AUTO_INCREMENT, + `page_type_name` varchar(56) NOT NULL, + PRIMARY KEY (`page_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; + +-- +-- Дамп даних таблиці `page_type` +-- + +INSERT INTO `page_type` (`page_type_id`, `page_type_name`) VALUES +(1, 'tag'), +(2, 'news'), +(3, 'article'), +(4, 'category'), +(5, 'page'); + +-- -------------------------------------------------------- + +-- +-- Структура таблиці `page_type_lang` +-- + +CREATE TABLE IF NOT EXISTS `page_type_lang` ( + `page_type_id` int(2) NOT NULL, + `page_type_title` varchar(50) NOT NULL, + `lang_id` int(2) NOT NULL, + PRIMARY KEY (`page_type_id`,`lang_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп даних таблиці `page_type_lang` +-- + +INSERT INTO `page_type_lang` (`page_type_id`, `page_type_title`, `lang_id`) VALUES +(1, 'Тег', 1), +(1, 'Тег', 2), +(2, 'Новини', 1), +(2, 'Новости', 2), +(3, 'Статья', 1), +(3, 'Статья', 2), +(4, 'Категорія', 1), +(4, 'Категория', 2), +(5, 'Сторінка', 1), +(5, 'Страница', 2); -- -------------------------------------------------------- @@ -238,34 +390,84 @@ CREATE TABLE IF NOT EXISTS `product_tag` ( -- -------------------------------------------------------- -- +-- Структура таблиці `template` +-- + +CREATE TABLE IF NOT EXISTS `template` ( + `template_id` int(3) NOT NULL AUTO_INCREMENT, + `controller_id` int(3) NOT NULL, + `template_name` varchar(50) NOT NULL, + `template_file` varchar(50) NOT NULL, + PRIMARY KEY (`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; + +-- +-- Дамп даних таблиці `template` +-- + +INSERT INTO `template` (`template_id`, `controller_id`, `template_name`, `template_file`) VALUES +(1, 1, 'page', 'page/page'), +(2, 2, 'home', 'page/home'), +(3, 3, 'catalog', 'shop/catalog'), +(4, 0, 'filter', 'shop/filter'), +(5, 0, 'news', 'news/all'); + +-- -------------------------------------------------------- + +-- +-- Структура таблиці `template_lang` +-- + +CREATE TABLE IF NOT EXISTS `template_lang` ( + `template_id` int(3) NOT NULL, + `template_title` varchar(50) NOT NULL, + `lang_id` int(3) NOT NULL, + PRIMARY KEY (`template_id`,`lang_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Дамп даних таблиці `template_lang` +-- + +INSERT INTO `template_lang` (`template_id`, `template_title`, `lang_id`) VALUES +(1, 'Страница', 2), +(2, 'Главная', 2), +(3, 'Каталог', 2), +(4, 'Фильтр', 2), +(5, 'Новости', 2); + +-- -------------------------------------------------------- + +-- -- Структура таблиці `termin` -- CREATE TABLE IF NOT EXISTS `termin` ( `termin_id` int(6) NOT NULL AUTO_INCREMENT, - `termin_type_id` int(2) NOT NULL, - `page_id` int(6) NOT NULL DEFAULT '0', PRIMARY KEY (`termin_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ; -- -- Дамп даних таблиці `termin` -- -INSERT INTO `termin` (`termin_id`, `termin_type_id`, `page_id`) VALUES -(1, 5, 1), -(2, 0, 0), -(3, 0, 0), -(4, 0, 0), -(5, 0, 0), -(6, 0, 0), -(7, 0, 0), -(8, 0, 0), -(9, 0, 0), -(10, 0, 0), -(16, 0, 0), -(17, 0, 0), -(18, 0, 0); +INSERT INTO `termin` (`termin_id`) VALUES +(1), +(2), +(3), +(4), +(5), +(6), +(7), +(8), +(9), +(10), +(11), +(12), +(13), +(14), +(15), +(16); -- -------------------------------------------------------- @@ -285,19 +487,22 @@ CREATE TABLE IF NOT EXISTS `termin_lang` ( -- INSERT INTO `termin_lang` (`termin_id`, `termin_title`, `lang_id`) VALUES -(1, 'Головна', 1), -(2, 'Завод', 1), -(3, 'BMW', 1), -(4, 'Mini', 1), -(5, 'Года (1996-2000)', 1), -(6, 'Кузов', 1), -(7, 'Модель', 1), -(8, 'Серия', 1), -(9, 'Мотор (тип)', 1), -(10, 'Мотор (обьем)', 1), -(16, '1996', 1), -(17, 'X5', 1), -(18, 'Новости', 0); +(1, 'Главная страница', 2), +(2, 'О компании', 2), +(3, 'Условия использования', 2), +(4, 'Условия сотрудничества', 2), +(5, 'Контакты', 2), +(6, 'Магазины', 2), +(7, 'Поставщики', 2), +(8, 'Каталог товаров', 2), +(9, 'Оплата', 2), +(10, 'Доставка', 2), +(11, 'Гарантия', 2), +(12, 'Акции ', 2), +(13, 'Материалы/блог', 2), +(14, 'Арбуз', 2), +(15, 'Артишок', 2), +(16, 'Баклажан', 2); -- -------------------------------------------------------- @@ -320,25 +525,22 @@ CREATE TABLE IF NOT EXISTS `termin_option` ( -- INSERT INTO `termin_option` (`termin_id`, `termin_pid`, `level`, `lft`, `rgt`, `sortorder`) VALUES -(1, 0, 0, 1, 2, 1), -(2, 0, 1, 3, 32, 2), -(3, 2, 2, 4, 17, 1), -(4, 2, 2, 18, 31, 2), -(5, 0, 1, 33, 38, 3), -(6, 3, 2, 19, 20, 1), -(6, 4, 2, 19, 20, 1), -(7, 3, 3, 21, 24, 2), -(7, 4, 3, 21, 24, 2), -(8, 3, 2, 25, 26, 3), -(8, 4, 2, 25, 26, 3), -(9, 3, 2, 27, 28, 4), -(9, 4, 2, 27, 28, 4), -(10, 3, 2, 29, 30, 5), -(10, 4, 2, 29, 30, 5), -(16, 5, 2, 34, 37, 4), -(17, 7, 2, 35, 36, 0), -(17, 16, 2, 35, 36, 0), -(18, 1, 0, 0, 0, 0); +(1, 0, 0, 0, 0, 0), +(2, 0, 0, 0, 0, 0), +(3, 0, 0, 0, 0, 0), +(4, 0, 0, 0, 0, 0), +(5, 0, 0, 0, 0, 0), +(6, 0, 0, 0, 0, 0), +(7, 0, 0, 0, 0, 0), +(8, 0, 0, 0, 0, 0), +(9, 0, 0, 0, 0, 0), +(10, 0, 0, 0, 0, 0), +(11, 0, 0, 0, 0, 0), +(12, 0, 0, 0, 0, 0), +(13, 0, 0, 0, 0, 0), +(14, 0, 0, 0, 0, 1), +(15, 0, 0, 0, 0, 1), +(16, 0, 0, 0, 0, 1); -- -------------------------------------------------------- @@ -354,58 +556,6 @@ CREATE TABLE IF NOT EXISTS `termin_relation` ( -- -------------------------------------------------------- -- --- Структура таблиці `termin_type` --- - -CREATE TABLE IF NOT EXISTS `termin_type` ( - `termin_type_id` int(2) NOT NULL AUTO_INCREMENT, - `termin_type_name` varchar(56) NOT NULL, - PRIMARY KEY (`termin_type_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; - --- --- Дамп даних таблиці `termin_type` --- - -INSERT INTO `termin_type` (`termin_type_id`, `termin_type_name`) VALUES -(1, 'tag'), -(2, 'news'), -(3, 'article'), -(4, 'category'), -(5, 'page'); - --- -------------------------------------------------------- - --- --- Структура таблиці `termin_type_lang` --- - -CREATE TABLE IF NOT EXISTS `termin_type_lang` ( - `termin_type_id` int(2) NOT NULL, - `termin_type_title` varchar(56) NOT NULL, - `lang_id` int(2) NOT NULL, - PRIMARY KEY (`termin_type_id`,`lang_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Дамп даних таблиці `termin_type_lang` --- - -INSERT INTO `termin_type_lang` (`termin_type_id`, `termin_type_title`, `lang_id`) VALUES -(1, 'Тег', 1), -(1, 'Тег', 2), -(2, 'Новини', 1), -(2, 'Новости', 2), -(3, 'Статья', 1), -(3, 'Статья', 2), -(4, 'Категорія', 1), -(4, 'Категория', 2), -(5, 'Сторінка', 1), -(5, 'Страница', 2); - --- -------------------------------------------------------- - --- -- Структура таблиці `user` -- diff --git a/frontend/config/main.php b/frontend/config/main.php index 1ed8305..99d7bc5 100644 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -28,6 +28,13 @@ return [ 'errorHandler' => [ 'errorAction' => 'site/error', ], + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'rules' => [ + '//' => '/', + ] + ], ], 'params' => $params, ]; diff --git a/frontend/controllers/PageController.php b/frontend/controllers/PageController.php new file mode 100644 index 0000000..b65f57d --- /dev/null +++ b/frontend/controllers/PageController.php @@ -0,0 +1,22 @@ +render('index'); + } +} diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index cf691ae..f633201 100644 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -13,6 +13,9 @@ use yii\web\Controller; use yii\filters\VerbFilter; use yii\filters\AccessControl; +use common\models\Page; +use frontend\controllers\PageController; + /** * Site controller */ @@ -53,7 +56,30 @@ class SiteController extends Controller * @inheritdoc */ public function actions() - { + { + // парсим URL, находим контроллер и подключаем view-файл +/* + if ($page = Page::getPageByUrl ('about')) + { + if (Page::isShow ($page) + && $page['template_file'] != NULL + && is_file (yii::$app->viewPath.'/'.$page['template_file'].'.php')) + { + $controller = $page['controller_name'].'Controller'; + require_once __DIR__.'/'.$controller.'.php'; + + //eval ('use '.$controller.';'); + + //return new $controller; + + return $this->render('/'.$page['template_file']); + //return yii::$app->runAction($page['template_file']); + } + } +*/ + + + // по умолчанию - 404 return [ 'error' => [ 'class' => 'yii\web\ErrorAction', @@ -71,7 +97,7 @@ class SiteController extends Controller * @return mixed */ public function actionIndex() - { + { return $this->render('index'); } diff --git a/frontend/models/Front.php b/frontend/models/Front.php index a962928..c533a2c 100644 --- a/frontend/models/Front.php +++ b/frontend/models/Front.php @@ -11,8 +11,8 @@ use Yii; */ class Front extends Model { - public function actionMenu() + public function actionMenu($location) { - return (new Menu)->getMenuList(); - } + return (new Menu)->getMenuList($location); + } } diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index ab4bcd5..6b5faa4 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -45,9 +45,9 @@ AppAsset::register($this); // меню с базы $menuItems = []; - foreach ((new \frontend\models\Front())->actionMenu() as $row) + foreach ((new \frontend\models\Front())->actionMenu('TOP') as $row) { - $menuItems[] = ['label' => $row['termin_title'], 'url' => $row['termin_id']]; + $menuItems[] = ['label' => $row['page_title'], 'url' => $row['page_alias']]; } if (Yii::$app->user->isGuest) diff --git a/frontend/views/page/home.php b/frontend/views/page/home.php new file mode 100644 index 0000000..8fab606 --- /dev/null +++ b/frontend/views/page/home.php @@ -0,0 +1 @@ +Хуй \ No newline at end of file diff --git a/frontend/views/page/page.php b/frontend/views/page/page.php new file mode 100644 index 0000000..8fab606 --- /dev/null +++ b/frontend/views/page/page.php @@ -0,0 +1 @@ +Хуй \ No newline at end of file diff --git a/frontend/views/site-del/about.php b/frontend/views/site-del/about.php new file mode 100644 index 0000000..8eb0764 --- /dev/null +++ b/frontend/views/site-del/about.php @@ -0,0 +1,16 @@ +title = 'About'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ +

This is the About page. You may modify the following file to customize its content:

+ + +
diff --git a/frontend/views/site-del/contact.php b/frontend/views/site-del/contact.php new file mode 100644 index 0000000..16ebdb2 --- /dev/null +++ b/frontend/views/site-del/contact.php @@ -0,0 +1,45 @@ +title = 'Contact'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ +

+ If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. +

+ +
+
+ 'contact-form']); ?> + + field($model, 'name') ?> + + field($model, 'email') ?> + + field($model, 'subject') ?> + + field($model, 'body')->textArea(['rows' => 6]) ?> + + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'template' => '
{image}
{input}
', + ]) ?> + +
+ 'btn btn-primary', 'name' => 'contact-button']) ?> +
+ + +
+
+ +
diff --git a/frontend/views/site-del/error.php b/frontend/views/site-del/error.php new file mode 100644 index 0000000..0ba2574 --- /dev/null +++ b/frontend/views/site-del/error.php @@ -0,0 +1,27 @@ +title = $name; +?> +
+ +

title) ?>

+ +
+ +
+ +

+ The above error occurred while the Web server was processing your request. +

+

+ Please contact us if you think this is a server error. Thank you. +

+ +
diff --git a/frontend/views/site-del/index.php b/frontend/views/site-del/index.php new file mode 100644 index 0000000..f780610 --- /dev/null +++ b/frontend/views/site-del/index.php @@ -0,0 +1,53 @@ +title = 'My Yii Application'; +?> +
+ +
+

Congratulations!

+ +

You have successfully created your Yii-powered application.

+ +

Get started with Yii

+
+ +
+ +
+
+

Heading

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

+ +

Yii Documentation »

+
+
+

Heading

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

+ +

Yii Forum »

+
+
+

Heading

+ +

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

+ +

Yii Extensions »

+
+
+ +
+
diff --git a/frontend/views/site-del/login.php b/frontend/views/site-del/login.php new file mode 100644 index 0000000..fe67ee0 --- /dev/null +++ b/frontend/views/site-del/login.php @@ -0,0 +1,39 @@ +title = 'Login'; +$this->params['breadcrumbs'][] = $this->title; +?> + diff --git a/frontend/views/site-del/requestPasswordResetToken.php b/frontend/views/site-del/requestPasswordResetToken.php new file mode 100644 index 0000000..494ddb3 --- /dev/null +++ b/frontend/views/site-del/requestPasswordResetToken.php @@ -0,0 +1,31 @@ +title = 'Request password reset'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ +

Please fill out your email. A link to reset password will be sent there.

+ +
+
+ 'request-password-reset-form']); ?> + + field($model, 'email') ?> + +
+ 'btn btn-primary']) ?> +
+ + +
+
+
diff --git a/frontend/views/site-del/resetPassword.php b/frontend/views/site-del/resetPassword.php new file mode 100644 index 0000000..8e6d93f --- /dev/null +++ b/frontend/views/site-del/resetPassword.php @@ -0,0 +1,31 @@ +title = 'Reset password'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ +

Please choose your new password:

+ +
+
+ 'reset-password-form']); ?> + + field($model, 'password')->passwordInput() ?> + +
+ 'btn btn-primary']) ?> +
+ + +
+
+
diff --git a/frontend/views/site-del/signup.php b/frontend/views/site-del/signup.php new file mode 100644 index 0000000..58ccd8e --- /dev/null +++ b/frontend/views/site-del/signup.php @@ -0,0 +1,35 @@ +title = 'Signup'; +$this->params['breadcrumbs'][] = $this->title; +?> + diff --git a/frontend/views/site/about.php b/frontend/views/site/about.php deleted file mode 100644 index 8eb0764..0000000 --- a/frontend/views/site/about.php +++ /dev/null @@ -1,16 +0,0 @@ -title = 'About'; -$this->params['breadcrumbs'][] = $this->title; -?> -
-

title) ?>

- -

This is the About page. You may modify the following file to customize its content:

- - -
diff --git a/frontend/views/site/contact.php b/frontend/views/site/contact.php deleted file mode 100644 index 16ebdb2..0000000 --- a/frontend/views/site/contact.php +++ /dev/null @@ -1,45 +0,0 @@ -title = 'Contact'; -$this->params['breadcrumbs'][] = $this->title; -?> -
-

title) ?>

- -

- If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. -

- -
-
- 'contact-form']); ?> - - field($model, 'name') ?> - - field($model, 'email') ?> - - field($model, 'subject') ?> - - field($model, 'body')->textArea(['rows' => 6]) ?> - - field($model, 'verifyCode')->widget(Captcha::className(), [ - 'template' => '
{image}
{input}
', - ]) ?> - -
- 'btn btn-primary', 'name' => 'contact-button']) ?> -
- - -
-
- -
diff --git a/frontend/views/site/login.php b/frontend/views/site/login.php deleted file mode 100644 index fe67ee0..0000000 --- a/frontend/views/site/login.php +++ /dev/null @@ -1,39 +0,0 @@ -title = 'Login'; -$this->params['breadcrumbs'][] = $this->title; -?> - diff --git a/frontend/views/site/requestPasswordResetToken.php b/frontend/views/site/requestPasswordResetToken.php deleted file mode 100644 index 494ddb3..0000000 --- a/frontend/views/site/requestPasswordResetToken.php +++ /dev/null @@ -1,31 +0,0 @@ -title = 'Request password reset'; -$this->params['breadcrumbs'][] = $this->title; -?> -
-

title) ?>

- -

Please fill out your email. A link to reset password will be sent there.

- -
-
- 'request-password-reset-form']); ?> - - field($model, 'email') ?> - -
- 'btn btn-primary']) ?> -
- - -
-
-
diff --git a/frontend/views/site/resetPassword.php b/frontend/views/site/resetPassword.php deleted file mode 100644 index 8e6d93f..0000000 --- a/frontend/views/site/resetPassword.php +++ /dev/null @@ -1,31 +0,0 @@ -title = 'Reset password'; -$this->params['breadcrumbs'][] = $this->title; -?> -
-

title) ?>

- -

Please choose your new password:

- -
-
- 'reset-password-form']); ?> - - field($model, 'password')->passwordInput() ?> - -
- 'btn btn-primary']) ?> -
- - -
-
-
diff --git a/frontend/views/site/signup.php b/frontend/views/site/signup.php deleted file mode 100644 index 58ccd8e..0000000 --- a/frontend/views/site/signup.php +++ /dev/null @@ -1,35 +0,0 @@ -title = 'Signup'; -$this->params['breadcrumbs'][] = $this->title; -?> - -- libgit2 0.21.4