From 3fe153437050c711aa92ae0f1a255e8a4423711f Mon Sep 17 00:00:00 2001 From: andryeyev Date: Tue, 8 Dec 2015 17:35:12 +0200 Subject: [PATCH] + новая версия (drupal + термины) --- backend/controllers/MenuController.php | 8 ++++---- backend/views/catalog/_form.php | 2 +- backend/views/layouts/left.php | 7 ++++--- common/models/Catalog.php | 2 +- common/models/Menu.php | 24 +++++++++++------------- common/models/ShopCategory.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ db-migration/artbox_db.backup | Bin 5564980 -> 0 bytes frontend/controllers/CatalogController.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/catalog/index.php | 6 ++++++ frontend/views/layouts/main.php | 2 +- 10 files changed, 185 insertions(+), 23 deletions(-) create mode 100644 common/models/ShopCategory.php create mode 100644 frontend/controllers/CatalogController.php create mode 100644 frontend/views/catalog/index.php 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 '';
+        }
+
+    }
+    
+    // =====
+    
+}
diff --git a/db-migration/artbox_db.backup b/db-migration/artbox_db.backup
index 7a51361..fa970ab 100644
Binary files a/db-migration/artbox_db.backup and b/db-migration/artbox_db.backup differ
diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php
new file mode 100644
index 0000000..e8d60d6
--- /dev/null
+++ b/frontend/controllers/CatalogController.php
@@ -0,0 +1,72 @@
+ [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function actions()
+    {
+        return [
+            'error' => [
+                'class' => 'yii\web\ErrorAction',
+            ],
+            'captcha' => [
+                'class' => 'yii\captcha\CaptchaAction',
+                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
+            ],
+        ];
+    }
+
+    /**
+     * Displays homepage.
+     *
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        return $this->render('index'); 
+    }
+ 
+}
diff --git a/frontend/views/catalog/index.php b/frontend/views/catalog/index.php
new file mode 100644
index 0000000..13d25f0
--- /dev/null
+++ b/frontend/views/catalog/index.php
@@ -0,0 +1,6 @@
+build();
\ No newline at end of file
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index 103ebc0..8f8b8d5 100644
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -35,11 +35,11 @@ AppAsset::register($this);
         ]
     ]);
  
-/*
     echo Nav::widget([
         'options' => ['class' => 'navbar-nav navbar-right'],
         'items' => (new MenuTree())->build('TOP')
     ]);
+/*
 
     $menuItems = [
         ['label' => 'Home', 'url' => ['/site/index']],
--
libgit2 0.21.4