Commit 3fe153437050c711aa92ae0f1a255e8a4423711f
1 parent
c4f409df
+ новая версия (drupal + термины)
Showing
10 changed files
with
185 additions
and
23 deletions
Show diff stats
backend/controllers/MenuController.php
| ... | ... | @@ -66,8 +66,8 @@ class MenuController extends Controller |
| 66 | 66 | |
| 67 | 67 | $menu = yii::$app->db->createCommand(' |
| 68 | 68 | SELECT * |
| 69 | - FROM `menu` | |
| 70 | - LEFT JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id | |
| 69 | + FROM menu | |
| 70 | + LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | |
| 71 | 71 | ')->queryAll(); |
| 72 | 72 | |
| 73 | 73 | |
| ... | ... | @@ -105,8 +105,8 @@ class MenuController extends Controller |
| 105 | 105 | $model = $this->findModel($id); |
| 106 | 106 | $menu = yii::$app->db->createCommand(' |
| 107 | 107 | SELECT * |
| 108 | - FROM `menu` | |
| 109 | - LEFT JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id | |
| 108 | + FROM menu | |
| 109 | + LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | |
| 110 | 110 | ')->queryAll() + ['termin_id' => 0, 'termin_title' => 'ROOT']; |
| 111 | 111 | |
| 112 | 112 | ... | ... |
backend/views/catalog/_form.php
backend/views/layouts/left.php
| ... | ... | @@ -30,9 +30,10 @@ |
| 30 | 30 | [ |
| 31 | 31 | 'options' => ['class' => 'sidebar-menu'], |
| 32 | 32 | 'items' => [ |
| 33 | - ['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], | |
| 34 | - ['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], | |
| 35 | - ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], | |
| 33 | + ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']], | |
| 34 | + //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], | |
| 35 | + //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], | |
| 36 | + //['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], | |
| 36 | 37 | ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']], |
| 37 | 38 | ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], |
| 38 | 39 | ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], | ... | ... |
common/models/Catalog.php
| ... | ... | @@ -51,7 +51,7 @@ class Catalog extends \yii\db\ActiveRecord |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * Выполняет поис по параметрам | |
| 54 | + * Выполняет поиск по параметрам | |
| 55 | 55 | * @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all] |
| 56 | 56 | * @return array one | array all | string значение масива |
| 57 | 57 | */ | ... | ... |
common/models/Menu.php
| ... | ... | @@ -22,25 +22,23 @@ class Menu extends \yii\db\ActiveRecord |
| 22 | 22 | { |
| 23 | 23 | return yii::$app->db->createCommand(' |
| 24 | 24 | SELECT |
| 25 | - `menu`.menu_id, `menu`.menu_pid, `menu`.level, | |
| 26 | - `termin_lang`.termin_title, `termin_lang`.termin_alias, | |
| 27 | - `template`.template_file | |
| 28 | - FROM `menu` | |
| 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 `termin` ON `termin`.termin_id = `menu`.termin_id | |
| 32 | - INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id | |
| 33 | - AND `termin_lang`.lang_id = '.yii::$app->params['lang_id.'].' | |
| 34 | - INNER JOIN `template` ON `template`.template_id = `termin_lang`.template_id | |
| 35 | - ORDER BY `menu`.level ASC, `menu`.sortorder ASC | |
| 25 | + menu.menu_id, menu.menu_pid, menu.level, | |
| 26 | + termin_lang.termin_title, termin_lang.termin_alias | |
| 27 | + FROM menu | |
| 28 | + INNER JOIN menu_location ON menu_location.menu_location_id = menu.menu_location_id | |
| 29 | + AND menu_location.menu_location_name = \''.$location_name.'\' | |
| 30 | + INNER JOIN termin ON termin.termin_id = menu.termin_id | |
| 31 | + INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | |
| 32 | + AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' | |
| 33 | + ORDER BY menu.level ASC, menu.sortorder ASC | |
| 36 | 34 | ')->queryAll(); |
| 37 | 35 | /* |
| 38 | 36 | return $this->find() |
| 39 | - ->selectOption('`termin_lang`.termin_title') | |
| 37 | + ->selectOption('termin_lang.termin_title') | |
| 40 | 38 | ->from('menu') |
| 41 | 39 | ->join( |
| 42 | 40 | 'INNER JOIN', |
| 43 | - '`termin_lang`.termin_id = `menu`.termin_id', | |
| 41 | + 'termin_lang.termin_id = menu.termin_id', | |
| 44 | 42 | ['lang_id' => yii::$app->params['lang_id']]) |
| 45 | 43 | ->all(); |
| 46 | 44 | */ | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace common\models; | |
| 4 | + | |
| 5 | +use Yii; | |
| 6 | +use yii\base\Model; | |
| 7 | +use yii\db\Query; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Signup form | |
| 11 | + */ | |
| 12 | +class ShopCategory extends Model | |
| 13 | +{ | |
| 14 | + /** | |
| 15 | + * весь список терминов | |
| 16 | + */ | |
| 17 | + static function get () | |
| 18 | + { | |
| 19 | + return yii::$app->db->createCommand(' | |
| 20 | + SELECT | |
| 21 | + termin_structure.termin_id, | |
| 22 | + termin_structure.termin_pid, | |
| 23 | + termin_lang.termin_title | |
| 24 | + FROM termin_structure | |
| 25 | + INNER JOIN termin_lang ON termin_lang.termin_id = termin_structure.termin_id | |
| 26 | + AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' | |
| 27 | + ORDER BY termin_structure.termin_id ASC, termin_structure.termin_pid ASC | |
| 28 | + ')->queryAll(); | |
| 29 | + } | |
| 30 | + | |
| 31 | + // =================== | |
| 32 | + // ==== STRUCTURE ==== | |
| 33 | + // =================== | |
| 34 | + | |
| 35 | + var $mass = array (); | |
| 36 | + | |
| 37 | + public function build () | |
| 38 | + { | |
| 39 | + if ($this->mass = self::get ()) | |
| 40 | + { | |
| 41 | + return $this->getRecrusive (8); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + public function findChild ($id) | |
| 46 | + { | |
| 47 | + $mass = array (); | |
| 48 | + | |
| 49 | + foreach ($this->mass as $row) | |
| 50 | + { | |
| 51 | + if ($row['termin_pid'] == $id) | |
| 52 | + { | |
| 53 | + $mass[] = $row; | |
| 54 | + } | |
| 55 | + } | |
| 56 | + | |
| 57 | + return $mass; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public function getRecrusive ($menu_id) | |
| 61 | + { | |
| 62 | + $items = $this->findChild($menu_id); | |
| 63 | + | |
| 64 | + if (! empty ($items)) | |
| 65 | + { | |
| 66 | + echo '<ul>'; | |
| 67 | + | |
| 68 | + foreach ($items as $row) | |
| 69 | + { | |
| 70 | + echo '<li>'.$row['termin_title'].'</li>'; | |
| 71 | + | |
| 72 | + if ($row['termin_pid'] != 0) | |
| 73 | + { | |
| 74 | + $this->getRecrusive($row['termin_id']); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + echo '</ul>'; | |
| 79 | + } | |
| 80 | + | |
| 81 | + } | |
| 82 | + | |
| 83 | + // ===== | |
| 84 | + | |
| 85 | +} | ... | ... |
db-migration/artbox_db.backup
No preview for this file type
| 1 | +<?php | |
| 2 | +namespace frontend\controllers; | |
| 3 | + | |
| 4 | +use Yii; | |
| 5 | +use common\models\LoginForm; | |
| 6 | +use frontend\models\PasswordResetRequestForm; | |
| 7 | +use frontend\models\ResetPasswordForm; | |
| 8 | +use frontend\models\SignupForm; | |
| 9 | +use frontend\models\ContactForm; | |
| 10 | +use frontend\models\Options; | |
| 11 | +use frontend\models\OptionValues; | |
| 12 | +use yii\base\InvalidParamException; | |
| 13 | +use yii\web\BadRequestHttpException; | |
| 14 | +use yii\web\Controller; | |
| 15 | +use yii\filters\VerbFilter; | |
| 16 | +use yii\filters\AccessControl; | |
| 17 | +use frontend\models\OptionsToValues; | |
| 18 | +use yii\validators\EmailValidator; | |
| 19 | +use common\models\User; | |
| 20 | +use yii\helpers\VarDumper; | |
| 21 | +use common\models\Page; | |
| 22 | +use frontend\models\Option; | |
| 23 | +use common\models\Social; | |
| 24 | + | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * Site controller | |
| 28 | + */ | |
| 29 | +class CatalogController extends Controller | |
| 30 | +{ | |
| 31 | + /** | |
| 32 | + * @inheritdoc | |
| 33 | + */ | |
| 34 | + public function behaviors() | |
| 35 | + { | |
| 36 | + return [ | |
| 37 | + 'verbs' => [ | |
| 38 | + 'class' => VerbFilter::className(), | |
| 39 | + 'actions' => [ | |
| 40 | + 'delete' => ['post'], | |
| 41 | + ], | |
| 42 | + ], | |
| 43 | + ]; | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * @inheritdoc | |
| 48 | + */ | |
| 49 | + public function actions() | |
| 50 | + { | |
| 51 | + return [ | |
| 52 | + 'error' => [ | |
| 53 | + 'class' => 'yii\web\ErrorAction', | |
| 54 | + ], | |
| 55 | + 'captcha' => [ | |
| 56 | + 'class' => 'yii\captcha\CaptchaAction', | |
| 57 | + 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | |
| 58 | + ], | |
| 59 | + ]; | |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Displays homepage. | |
| 64 | + * | |
| 65 | + * @return mixed | |
| 66 | + */ | |
| 67 | + public function actionIndex() | |
| 68 | + { | |
| 69 | + return $this->render('index'); | |
| 70 | + } | |
| 71 | + | |
| 72 | +} | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -35,11 +35,11 @@ AppAsset::register($this); |
| 35 | 35 | ] |
| 36 | 36 | ]); |
| 37 | 37 | |
| 38 | -/* | |
| 39 | 38 | echo Nav::widget([ |
| 40 | 39 | 'options' => ['class' => 'navbar-nav navbar-right'], |
| 41 | 40 | 'items' => (new MenuTree())->build('TOP') |
| 42 | 41 | ]); |
| 42 | +/* | |
| 43 | 43 | |
| 44 | 44 | $menuItems = [ |
| 45 | 45 | ['label' => 'Home', 'url' => ['/site/index']], | ... | ... |