diff --git a/backend/controllers/MenuController.php b/backend/controllers/MenuController.php index 6c645b1..9a3abab 100644 --- a/backend/controllers/MenuController.php +++ b/backend/controllers/MenuController.php @@ -66,8 +66,8 @@ class MenuController extends Controller $menu = yii::$app->db->createCommand(' SELECT * - FROM `menu` - LEFT JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id + FROM menu + LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id ')->queryAll(); @@ -105,8 +105,8 @@ class MenuController extends Controller $model = $this->findModel($id); $menu = yii::$app->db->createCommand(' SELECT * - FROM `menu` - LEFT JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id + FROM menu + LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id ')->queryAll() + ['termin_id' => 0, 'termin_title' => 'ROOT']; diff --git a/backend/views/catalog/_form.php b/backend/views/catalog/_form.php index e8b99db..2a6f1c8 100644 --- a/backend/views/catalog/_form.php +++ b/backend/views/catalog/_form.php @@ -30,7 +30,7 @@ use common\models\Catalog; echo '
'; - $array = $model->finInfo([ + $array = $model->findInfo([ 'catalog_id' => 1, 'return_one' => true, 'to_array' => false, diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index e83d434..c6b710e 100644 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -30,9 +30,10 @@ [ 'options' => ['class' => 'sidebar-menu'], 'items' => [ - ['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], - ['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], - ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], + ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']], + //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], + //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], + //['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']], ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], diff --git a/common/models/Catalog.php b/common/models/Catalog.php index 72d4f80..48ee976 100644 --- a/common/models/Catalog.php +++ b/common/models/Catalog.php @@ -51,7 +51,7 @@ class Catalog extends \yii\db\ActiveRecord } /** - * Выполняет поис по параметрам + * Выполняет поиск по параметрам * @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all] * @return array one | array all | string значение масива */ diff --git a/common/models/Menu.php b/common/models/Menu.php index 930e209..cdc0bf1 100644 --- a/common/models/Menu.php +++ b/common/models/Menu.php @@ -22,25 +22,23 @@ class Menu extends \yii\db\ActiveRecord { return yii::$app->db->createCommand(' SELECT - `menu`.menu_id, `menu`.menu_pid, `menu`.level, - `termin_lang`.termin_title, `termin_lang`.termin_alias, - `template`.template_file - FROM `menu` - INNER JOIN `menu_location` ON `menu_location`.menu_location_id = `menu`.menu_location_id - AND `menu_location`.menu_location_name = "'.$location_name.'" - INNER JOIN `termin` ON `termin`.termin_id = `menu`.termin_id - INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id - AND `termin_lang`.lang_id = '.yii::$app->params['lang_id.'].' - INNER JOIN `template` ON `template`.template_id = `termin_lang`.template_id - ORDER BY `menu`.level ASC, `menu`.sortorder ASC + menu.menu_id, menu.menu_pid, menu.level, + termin_lang.termin_title, termin_lang.termin_alias + FROM menu + INNER JOIN menu_location ON menu_location.menu_location_id = menu.menu_location_id + AND menu_location.menu_location_name = \''.$location_name.'\' + INNER JOIN termin ON termin.termin_id = menu.termin_id + INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id + AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' + ORDER BY menu.level ASC, menu.sortorder ASC ')->queryAll(); /* return $this->find() - ->selectOption('`termin_lang`.termin_title') + ->selectOption('termin_lang.termin_title') ->from('menu') ->join( 'INNER JOIN', - '`termin_lang`.termin_id = `menu`.termin_id', + 'termin_lang.termin_id = menu.termin_id', ['lang_id' => yii::$app->params['lang_id']]) ->all(); */ diff --git a/common/models/ShopCategory.php b/common/models/ShopCategory.php new file mode 100644 index 0000000..b299e86 --- /dev/null +++ b/common/models/ShopCategory.php @@ -0,0 +1,85 @@ +db->createCommand(' + SELECT + termin_structure.termin_id, + termin_structure.termin_pid, + termin_lang.termin_title + FROM termin_structure + INNER JOIN termin_lang ON termin_lang.termin_id = termin_structure.termin_id + AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' + ORDER BY termin_structure.termin_id ASC, termin_structure.termin_pid ASC + ')->queryAll(); + } + + // =================== + // ==== STRUCTURE ==== + // =================== + + var $mass = array (); + + public function build () + { + if ($this->mass = self::get ()) + { + return $this->getRecrusive (8); + } + } + + public function findChild ($id) + { + $mass = array (); + + foreach ($this->mass as $row) + { + if ($row['termin_pid'] == $id) + { + $mass[] = $row; + } + } + + return $mass; + } + + public function getRecrusive ($menu_id) + { + $items = $this->findChild($menu_id); + + if (! empty ($items)) + { + echo '