diff --git a/backend/controllers/CatalogController.php b/backend/controllers/CatalogController.php
deleted file mode 100644
index 0471f25..0000000
--- a/backend/controllers/CatalogController.php
+++ /dev/null
@@ -1,139 +0,0 @@
- [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['post'],
- ],
- ],
- ];
- }
-
- /**
- * Lists all Catalog models.
- * @return mixed
- */
- public function actionIndex()
- {
- $searchModel = new SearchCatalog();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- /**
- * Displays a single Catalog model.
- * @param integer $id
- * @return mixed
- */
- public function actionView($id)
- {
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
-
- /**
- * Creates a new Catalog model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return mixed
- */
- public function actionCreate()
- {
- $model = new Catalog();
-
- if ($model->load(Yii::$app->request->post()) && $model->save())
- {
- return $this->redirect(['view', 'id' => $model->id]);
- }
- else
- {
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Updates an existing Catalog model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
- $model_lang = CatalogLang::find()
- ->where(['catalog_id' => $id, 'lang_id' => 1])
- ->one();
-
- if ($model->load(Yii::$app->request->post()))
- {
- $model_lang->title = $model->title;
-
- $model->save();
- $model_lang->save();
-
- return $this->redirect(['view', 'id' => $model->id]);
- }
- else
- {
- return $this->render('update', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Deletes an existing Catalog model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
-
- return $this->redirect(['index']);
- }
-
- /**
- * Finds the Catalog model based on its primary key value.
- * If the model is not found, a 404 HTTP exception will be thrown.
- * @param integer $id
- * @return Catalog the loaded model
- * @throws NotFoundHttpException if the model cannot be found
- */
- protected function findModel($id)
- {
- if (($model = Catalog::findOne($id)) !== null)
- {
- return $model;
- }
- else
- {
- throw new NotFoundHttpException('The requested page does not exist.');
- }
- }
-}
diff --git a/backend/controllers/MenuController.php b/backend/controllers/MenuController.php
index 9a3abab..c060821 100644
--- a/backend/controllers/MenuController.php
+++ b/backend/controllers/MenuController.php
@@ -3,13 +3,11 @@
namespace backend\controllers;
use Yii;
-use common\models\Menu;
+use backend\models\Menu;
use backend\models\MenuSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
-use common\models\TerminLang;
-use backend\models\SearchMenu;
/**
* MenuController implements the CRUD actions for Menu model.
@@ -34,7 +32,7 @@ class MenuController extends Controller
*/
public function actionIndex()
{
- $searchModel = new SearchMenu();
+ $searchModel = new MenuSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
@@ -64,32 +62,11 @@ class MenuController extends Controller
{
$model = new Menu();
- $menu = yii::$app->db->createCommand('
- SELECT *
- FROM menu
- LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id
- ')->queryAll();
-
-
- $termin = TerminLang::find()->all();
-
- if ($model->load(Yii::$app->request->post())) {
-
- if($model->menu_pid == null)
- {
- $model->menu_pid = 0;
- }
-
-
- $model->save();
-
-
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->menu_id]);
} else {
return $this->render('create', [
'model' => $model,
- 'termin' => $termin,
- 'menu' => $menu,
]);
}
}
@@ -103,22 +80,12 @@ class MenuController extends Controller
public function actionUpdate($id)
{
$model = $this->findModel($id);
- $menu = yii::$app->db->createCommand('
- SELECT *
- FROM menu
- LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id
- ')->queryAll() + ['termin_id' => 0, 'termin_title' => 'ROOT'];
-
-
- $termin = TerminLang::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->menu_id]);
} else {
return $this->render('update', [
'model' => $model,
- 'termin' => $termin,
- 'menu' => $menu,
]);
}
}
diff --git a/backend/models/SearchCatalog.php b/backend/models/SearchCatalog.php
deleted file mode 100644
index 6b3f278..0000000
--- a/backend/models/SearchCatalog.php
+++ /dev/null
@@ -1,103 +0,0 @@
- $query,
- ]);
-
- // + поиск по title
- $dataProvider->setSort([
- 'attributes' => [
- 'catalog_id',
- 'title' => [
- 'asc' => ['title' => SORT_ASC],
- 'desc' => ['title' => SORT_DESC],
- 'label' => 'title',
- 'default' => SORT_ASC
- ]
- ]
- ]);
-
- $this->load($params);
-
- // + поиск по title
- $query->joinWith(['relationCatalogLangPlus']);
-
- if (!$this->validate())
- {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
-
- return $dataProvider;
- }
-
- $query->andFilterWhere([
- 'catalog_id' => $this->catalog_id,
- 'parent_id' => $this->parent_id,
- 'status' => $this->status,
- 'sort' => $this->sort,
- ]);
-
- $query->andFilterWhere(['like', 'cover', $this->cover]);
-
- // + поиск по title
- if (! empty ($this->title))
- {
- $query->joinWith(['relationCatalogLangPlus' => function ($q)
- {
- $q->where(['like', 'catalog_i18n.title', $this->title]);
- }]);
- }
-
- return $dataProvider;
- }
-}
diff --git a/backend/models/SearchMenu.php b/backend/models/SearchMenu.php
deleted file mode 100644
index 73581cb..0000000
--- a/backend/models/SearchMenu.php
+++ /dev/null
@@ -1,69 +0,0 @@
- $query,
- ]);
-
- $this->load($params);
-
- if (!$this->validate()) {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
- return $dataProvider;
- }
-
- $query->andFilterWhere([
- 'menu_id' => $this->menu_id,
- 'menu_pid' => $this->menu_pid,
- 'menu_lft' => $this->menu_lft,
- 'menu_rgt' => $this->menu_rgt,
- 'termin_id' => $this->termin_id,
- 'show' => $this->show,
- 'sortorder' => $this->sortorder,
- ]);
-
- return $dataProvider;
- }
-}
diff --git a/backend/models/SearchPage.php b/backend/models/SearchPage.php
deleted file mode 100644
index b977ae9..0000000
--- a/backend/models/SearchPage.php
+++ /dev/null
@@ -1,69 +0,0 @@
- $query,
- ]);
-
- $this->load($params);
-
- if (!$this->validate()) {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
- return $dataProvider;
- }
-
- $query->andFilterWhere([
- 'page_id' => $this->page_id,
- 'date_add' => $this->date_add,
- 'template_id' => $this->template_id,
- 'image_id' => $this->image_id,
- 'show' => $this->show,
- ]);
-
- return $dataProvider;
- }
-}
diff --git a/backend/models/SearchTermin.php b/backend/models/SearchTermin.php
deleted file mode 100644
index 0b5a18e..0000000
--- a/backend/models/SearchTermin.php
+++ /dev/null
@@ -1,68 +0,0 @@
- $query,
- ]);
-
- $this->load($params);
-
- if (!$this->validate()) {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
- return $dataProvider;
- }
-
- $query->andFilterWhere([
- 'termin_id' => $this->termin_id,
- 'termin_pid' => $this->termin_pid,
- 'lfr' => $this->lfr,
- 'rgt' => $this->rgt,
- 'termin_type_id' => $this->termin_type_id,
- 'page_id' => $this->page_id,
- ]);
-
- return $dataProvider;
- }
-}
diff --git a/backend/models/TerminLangSearch.php b/backend/models/TerminLangSearch.php
deleted file mode 100644
index 84d4582..0000000
--- a/backend/models/TerminLangSearch.php
+++ /dev/null
@@ -1,67 +0,0 @@
- $query,
- ]);
-
- $this->load($params);
-
- if (!$this->validate()) {
- // uncomment the following line if you do not want to return any records when validation fails
- // $query->where('0=1');
- return $dataProvider;
- }
-
- $query->andFilterWhere([
- 'termin_id' => $this->termin_id,
- 'lang_id' => $this->lang_id,
- ]);
-
- $query->andFilterWhere(['like', 'termin_title', $this->termin_title]);
-
- return $dataProvider;
- }
-}
diff --git a/backend/views/catalog/_form.php b/backend/views/catalog/_form.php
deleted file mode 100644
index 2a6f1c8..0000000
--- a/backend/views/catalog/_form.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
diff --git a/backend/views/catalog/_search.php b/backend/views/catalog/_search.php
deleted file mode 100644
index 8c1e7c9..0000000
--- a/backend/views/catalog/_search.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- ['index'],
- 'method' => 'get',
- ]); ?>
-
- = $form->field($model, 'catalog_id') ?>
-
- = $form->field($model, 'parent_id') ?>
-
- = $form->field($model, 'cover') ?>
-
- field($model, 'status') ?>
-
- field($model, 'sort') ?>
-
-
- = Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
- = Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
-
-
-
-
-
diff --git a/backend/views/catalog/create.php b/backend/views/catalog/create.php
deleted file mode 100644
index f90279e..0000000
--- a/backend/views/catalog/create.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title = Yii::t('app', 'Create Catalog');
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
diff --git a/backend/views/catalog/index.php b/backend/views/catalog/index.php
deleted file mode 100644
index 29463f3..0000000
--- a/backend/views/catalog/index.php
+++ /dev/null
@@ -1,38 +0,0 @@
-title = Yii::t('app', 'Catalogs');
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
- render('_search', ['model' => $searchModel]); ?>
-
-
- = Html::a(Yii::t('app', 'Create Catalog'), ['create'], ['class' => 'btn btn-success']) ?>
-
-
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
-
- 'catalog_id',
- 'parent_id',
- 'title',
- // 'status',
- // 'sort',
-
- ['class' => 'yii\grid\ActionColumn'],
- ],
- ]); ?>
-
-
diff --git a/backend/views/catalog/update.php b/backend/views/catalog/update.php
deleted file mode 100644
index 1c226d2..0000000
--- a/backend/views/catalog/update.php
+++ /dev/null
@@ -1,23 +0,0 @@
-title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Catalog',
-]) . ' ' . $model->catalog_id;
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->catalog_id, 'url' => ['view', 'id' => $model->catalog_id]];
-$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
diff --git a/backend/views/catalog/view.php b/backend/views/catalog/view.php
deleted file mode 100644
index 207688c..0000000
--- a/backend/views/catalog/view.php
+++ /dev/null
@@ -1,39 +0,0 @@
-title = $model->catalog_id;
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
-
- = Html::a(Yii::t('app', 'Update'), ['update', 'catalog_id' => $model->catalog_id], ['class' => 'btn btn-primary']) ?>
- = Html::a(Yii::t('app', 'Delete'), ['delete', 'catalog_id' => $model->catalog_id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
- ],
- ]) ?>
-
-
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'catalog_id',
- 'parent_id',
- 'cover',
- 'status',
- 'sort',
- ],
- ]) ?>
-
-
diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php
index 9000a6a..35608df 100644
--- a/backend/views/layouts/left.php
+++ b/backend/views/layouts/left.php
@@ -33,7 +33,7 @@
['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' => ['/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/backend/views/menu/_form.php b/backend/views/menu/_form.php
index 1c439c5..a629ae2 100644
--- a/backend/views/menu/_form.php
+++ b/backend/views/menu/_form.php
@@ -2,11 +2,9 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
-use yii\helpers\ArrayHelper;
-use kartik\select2\Select2;
/* @var $this yii\web\View */
-/* @var $model common\models\Menu */
+/* @var $model backend\models\Menu */
/* @var $form yii\widgets\ActiveForm */
?>
@@ -14,33 +12,25 @@ use kartik\select2\Select2;
-
-
- = $form->field($model, 'termin_id')->widget(Select2::classname(), [
- //'data' => $data,
- 'language' => 'ru',
- 'options' => ['placeholder' => 'под меню ...'],
- 'pluginOptions' => [
-
- ],
- 'data' => ArrayHelper::map($termin, 'termin_id', 'termin_title'), // data as array
- ]) ?>
-
- = $form->field($model, 'menu_pid')->widget(Select2::classname(), [
- //'data' => $data,
- 'language' => 'ru',
- 'options' => ['placeholder' => 'Меню родитель ...'],
- 'pluginOptions' => [
-
- ],
- 'data' => ArrayHelper::map($menu, 'termin_id', 'termin_title'), // data as array
- ]) ?>
-
-
-
- = $form->field($model, 'show')->dropDownList(['1' => Yii::t('action', 'show'), '0' => Yii::t('action', 'hide')]) ?>
-
- = $form->field($model, 'sortorder')->dropDownList(['1' => '1', '0' => '2']) ?>
+ = $form->field($model, 'menu_id')->textInput() ?>
+
+ = $form->field($model, 'menu_pid')->textInput() ?>
+
+ = $form->field($model, 'level')->textInput() ?>
+
+ = $form->field($model, 'termin_id')->textInput() ?>
+
+ = $form->field($model, 'show')->textInput() ?>
+
+ = $form->field($model, 'is_open')->textInput() ?>
+
+ = $form->field($model, 'menu_location_id')->textInput() ?>
+
+ = $form->field($model, 'sortorder')->textInput() ?>
+
+ = $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+ = $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/menu/_search.php b/backend/views/menu/_search.php
index ca1ce23..c37685a 100644
--- a/backend/views/menu/_search.php
+++ b/backend/views/menu/_search.php
@@ -19,16 +19,22 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'menu_pid') ?>
- = $form->field($model, 'menu_lft') ?>
-
- = $form->field($model, 'menu_rgt') ?>
+ = $form->field($model, 'level') ?>
= $form->field($model, 'termin_id') ?>
- field($model, 'show') ?>
+ = $form->field($model, 'show') ?>
+
+ field($model, 'is_open') ?>
+
+ field($model, 'menu_location_id') ?>
field($model, 'sortorder') ?>
+ field($model, 'name') ?>
+
+ field($model, 'url') ?>
+
= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
diff --git a/backend/views/menu/create.php b/backend/views/menu/create.php
index 4253a72..1b8eb6e 100644
--- a/backend/views/menu/create.php
+++ b/backend/views/menu/create.php
@@ -4,7 +4,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
-/* @var $model common\models\Menu */
+/* @var $model backend\models\Menu */
$this->title = Yii::t('app', 'Create Menu');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']];
@@ -16,8 +16,6 @@ $this->params['breadcrumbs'][] = $this->title;
= $this->render('_form', [
'model' => $model,
- 'termin' => $termin,
- 'menu' => $menu,
]) ?>
diff --git a/backend/views/menu/index.php b/backend/views/menu/index.php
index 3c55096..11d81c4 100644
--- a/backend/views/menu/index.php
+++ b/backend/views/menu/index.php
@@ -16,7 +16,8 @@ $this->params['breadcrumbs'][] = $this->title;
render('_search', ['model' => $searchModel]); ?>
- = Html::a(Yii::t('app', 'Create Menu'), ['create'], ['class' => 'btn btn-success']) ?>
+ = Html::a(Yii::t('app', 'Create').' '.Yii::t('app', 'menu'), ['create'], ['class' => 'btn btn-success']) ?>
+ = Html::a(Yii::t('app', 'Create').' '.Yii::t('app', 'location'), ['/menu-location/'], ['class' => 'btn btn-primary']) ?>
= GridView::widget([
@@ -25,18 +26,14 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'menu_id',
- 'menu_pid',
[
- 'attribute' => 'menu_pid',
+ 'attribute' => Yii::t('app', 'termin'),
'value' => function ($model) {
return empty($model->termin_id) ? '-' : $model->termin_lang->termin_title;
},
- ],
- // 'menu_lft',
- // 'menu_rgt',
- 'termin_id',
- // 'show',
+ ],
+ 'menu_pid',
+ 'level',
// 'sortorder',
['class' => 'yii\grid\ActionColumn'],
diff --git a/backend/views/menu/update.php b/backend/views/menu/update.php
index 3abfe9e..cb96a01 100644
--- a/backend/views/menu/update.php
+++ b/backend/views/menu/update.php
@@ -3,13 +3,13 @@
use yii\helpers\Html;
/* @var $this yii\web\View */
-/* @var $model common\models\Menu */
+/* @var $model backend\models\Menu */
$this->title = Yii::t('app', 'Update {modelClass}: ', [
'modelClass' => 'Menu',
-]) . ' ' . $model->menu_id;
+]) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->menu_id, 'url' => ['view', 'id' => $model->menu_id]];
+$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->menu_id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
?>
diff --git a/backend/views/menu/view.php b/backend/views/menu/view.php
index d246c04..1cff6d1 100644
--- a/backend/views/menu/view.php
+++ b/backend/views/menu/view.php
@@ -4,9 +4,9 @@ use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
-/* @var $model common\models\Menu */
+/* @var $model backend\models\Menu */
-$this->title = $model->menu_id;
+$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
@@ -30,11 +30,14 @@ $this->params['breadcrumbs'][] = $this->title;
'attributes' => [
'menu_id',
'menu_pid',
- 'menu_lft',
- 'menu_rgt',
+ 'level',
'termin_id',
'show',
+ 'is_open',
+ 'menu_location_id',
'sortorder',
+ 'name',
+ 'url:url',
],
]) ?>
diff --git a/common/models/Catalog.php b/common/models/Catalog.php
index 48ee976..97eca29 100644
--- a/common/models/Catalog.php
+++ b/common/models/Catalog.php
@@ -1,56 +1,34 @@
32],
- ];
+ return yii::$app->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();
}
-
+
/**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'catalog_id' => Yii::t('app', 'ID'),
- 'parent_id' => Yii::t('app', 'Parent ID'),
- 'cover' => Yii::t('app', 'Cover'),
- 'status' => Yii::t('app', 'Status'),
- 'sort' => Yii::t('app', 'Sort'),
- ];
- }
-
- /**
* Выполняет поиск по параметрам
* @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all]
* @return array one | array all | string значение масива
@@ -64,72 +42,117 @@ class Catalog extends \yii\db\ActiveRecord
'return_field' => false,
'show_all' => false,
'to_array' => true,
- ));
-
+ ));
+
$model = new Catalog();
-
- $query = $model->find()->select('*');
-
- $query->joinWith(['relationCatalogLang2']);
-
+
+ $query = $model->find()->select('*');
+
+ $query->joinWith(['relationCatalogLang']);
+
$WHERE = array ();
-
- if ($params['catalog_id'] !== false)
+
+ if ($params['catalog_id'])
{
$WHERE['catalog.catalog_id'] = $params['catalog_id'];
}
-
- if ($params['lang_id'] !== false)
+
+ if ($params['lang_id'])
{
$WHERE['catalog_i18n.lang_id'] = $params['lang_id'];
}
-
+
if (! empty ($WHERE))
- {
+ {
$query->where($WHERE);
}
-
- if ($params['to_array'] !== false)
+
+ if ($params['to_array'])
{
$query = $query->asArray();
}
-
- if ($params['return_one'] !== false || $params['return_field'] !== false)
+
+ if ($params['return_one'] || $params['return_field'])
+ {
+
+ $result = $params['return_field'] ? $query->one($params['return_field']) : $query->one();
+ }
+ else
{
+ $result = $query->all();
+ }
+
+ return $result;
+ }
+
+ // ===================
+ // ==== STRUCTURE ====
+ // ===================
- $result = $params['return_field'] !== false ? $query->one($params['return_field']) : $query->one();
+ var $mass = array ();
+
+ public function build ()
+ {
+ if ($this->mass = self::get ())
+ {
+ return $this->getRecrusive (8);
}
- else
+ }
+
+ public function findChild ($id)
+ {
+ $mass = array ();
+
+ foreach ($this->mass as $row)
{
- $result = $query->all();
+ if ($row['termin_pid'] == $id)
+ {
+ $mass[] = $row;
+ }
}
+
+ return $mass;
+ }
+
+ public function getRecrusive ($menu_id)
+ {
+ $items = $this->findChild($menu_id);
+
+ if (! empty ($items))
+ {
+ echo '
';
+
+ foreach ($items as $row)
+ {
+ echo '- '.$row['termin_title'].'
';
+
+ if ($row['termin_pid'] != 0)
+ {
+ $this->getRecrusive($row['termin_id']);
+ }
+ }
- return $result;
+ echo '
';
+ }
+
}
+
+ // =====
/**
* @return \yii\db\ActiveQuery
*/
public function getRelationCatalogLangPlus()
- {
- return $this->getRelationCatalogLang2()->where(['lang_id' => yii::$app->params['lang_id']]);
+ {
+ return $this->getRelationCatalogLang()->where(['lang_id' => yii::$app->params['lang_id']]);
}
-
+
/**
* @return \yii\db\ActiveQuery
*/
- public function getRelationCatalogLang2()
+ public function getRelationCatalogLang()
{
return $this->hasOne(CatalogLang::className(), ['catalog_id' => 'catalog_id']);
}
- public function getTitle()
- {
- return $this->relationCatalogLangPlus->title;
- }
-
- public function getParentTitle()
- {
- return $this->relationCatalogLangPlus->title;
- }
-}
+}
\ No newline at end of file
diff --git a/common/models/CatalogLang.php b/common/models/CatalogLang.php
deleted file mode 100644
index 66dfc4d..0000000
--- a/common/models/CatalogLang.php
+++ /dev/null
@@ -1,60 +0,0 @@
- 1024],
- [['alias'], 'string', 'max' => 128],
- [['meta_title', 'meta_keywords', 'meta_description', 'full_alias'], 'string', 'max' => 255],
- [['alias', 'lang_id'], 'unique', 'targetAttribute' => ['alias', 'lang_id'], 'message' => 'The combination of Lang ID and Alias has already been taken.']
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'catalog_id' => Yii::t('app', 'catalog_id'),
- 'lang_id' => Yii::t('app', 'Lang ID'),
- 'title' => Yii::t('app', 'Title'),
- 'alias' => Yii::t('app', 'Alias'),
- 'meta_title' => Yii::t('app', 'Meta Title'),
- 'meta_keywords' => Yii::t('app', 'Meta Keywords'),
- 'meta_description' => Yii::t('app', 'Meta Description'),
- 'full_alias' => Yii::t('app', 'Full Alias'),
- ];
- }
-}
diff --git a/common/models/Menu.php b/common/models/Menu.php
deleted file mode 100644
index cdc0bf1..0000000
--- a/common/models/Menu.php
+++ /dev/null
@@ -1,84 +0,0 @@
-db->createCommand('
- SELECT
- 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')
- ->from('menu')
- ->join(
- 'INNER JOIN',
- 'termin_lang.termin_id = menu.termin_id',
- ['lang_id' => yii::$app->params['lang_id']])
- ->all();
-*/
- }
-
- // ==== YII ====
-
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'menu';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'safe'],
- [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'integer']
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'menu_id' => Yii::t('app', 'Menu ID'),
- 'menu_pid' => Yii::t('app', 'Menu Pid'),
- 'menu_lft' => Yii::t('app', 'Menu Lft'),
- 'menu_rgt' => Yii::t('app', 'Menu Rgt'),
- 'termin_id' => Yii::t('app', 'Termin ID'),
- 'show' => Yii::t('app', 'Show'),
- 'sortorder' => Yii::t('app', 'Sortorder'),
- ];
- }
-
-}
diff --git a/common/models/MenuTree.php b/common/models/MenuTree.php
index 4e6ed99..7d2e604 100644
--- a/common/models/MenuTree.php
+++ b/common/models/MenuTree.php
@@ -2,7 +2,7 @@
namespace common\models;
-use common\models\Menu;
+use backend\models\Menu;
use yii\helpers\Url;
class MenuTree extends Menu
diff --git a/common/models/ShopCategory.php b/common/models/ShopCategory.php
deleted file mode 100644
index b299e86..0000000
--- a/common/models/ShopCategory.php
+++ /dev/null
@@ -1,85 +0,0 @@
-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 '
';
-
- foreach ($items as $row)
- {
- echo '- '.$row['termin_title'].'
';
-
- if ($row['termin_pid'] != 0)
- {
- $this->getRecrusive($row['termin_id']);
- }
- }
-
- echo '
';
- }
-
- }
-
- // =====
-
-}
diff --git a/common/models/Termin.php b/common/models/Termin.php
deleted file mode 100644
index fad60cc..0000000
--- a/common/models/Termin.php
+++ /dev/null
@@ -1,225 +0,0 @@
- 'Termin ID',
- 'termin_type_id' => 'Termin Type ID',
- 'page_id' => 'Page ID',
- ];
- }
-
- // ======================
- // ==== MY CASTYL :D ====
- // ======================
-
- // ==== Common ====
-
- /**
- * находит термин и перевод (не учитывает таблицу relation)
- * @param array $array
- * @return array
- */
- static function findTemin (array $array)
- {
- Tools::ifNotExist ($array, [
- 'return_one' => true,
- ]);
-
- $query = new SqlQueryBuilder();
- $query->from('termin_lang');
- $query->innerJoin(
- 'termin', NULL, '
- `termin`.termin_id = `termin_lang`.termin_id
- AND `termin`.type = "'.$array['type'].'"
- ');
-
- if (isset ($array['lang_id']))
- {
- $query->where('`termin_lang`.lang_id = '.(int)$array['lang_id']);
- }
-
- if (isset ($array['termin_title']))
- {
- $query->where('`termin_lang`.termin_title = "'.$array['termin_title'].'"');
- }
-
- // sql
- $result = yii::$app->db->createCommand($query->__toString());
-
- return $array['return_one'] !== false ? $result->queryOne() : $result->queryAll();
- }
-
- /**
- * Создает термин, перевод и связь
- * @param array $array
- * @return int termin_id
- */
- static function add (array $array)
- {
- // термин
- $array['termin_id'] = self::addTermin ($array);
-
- // термин перевод
- self::addTerminLang ($array);
-
- // связи
- self::addTerminRelation ($array);
-
- return $array['termin_id'];
- }
-
- /**
- * Ищет и добавляет того чего нет (термин, перевод, relation)
- * В сновном заточен под импорт
- * @param array $basic
- * @return int termin_id
- */
- static function addIfNotExists (array $basic)
- {
- $termin_id = 0;
-
- // категория
- $termin = Termin::findTemin ($basic);
- if (! empty ($termin))
- {
- // массив связи
- $add = [
- 'termin_id' => $termin['termin_id'],
- 'termin_pid' => $basic['termin_pid'],
- ];
-
- // есть ли связь
- $relation = Termin::findRelation ($add);
- if (empty ($relation))
- {
- // добавляем
- Termin::addTerminRelation ($add);
- }
-
- $termin_id = $termin['termin_id'];
- }
- else
- {
- // добавляем
- $termin_id = Termin::add ($basic);
- }
-
- return $termin_id;
- }
-
- // ==== Termin ===
-
- static function addTermin (array $array)
- {
- Tools::ifNotExist ($array, [
- 'type' => 'H',
- 'page_id' => 0,
- ]);
-
- Yii::$app->db->createCommand()->insert(
- 'termin', [
- 'type' => $array['type'],
- 'page_id' => (int)$array['page_id'],
- ]
- )->execute();
-
- return Yii::$app->db->getLastInsertID();
- }
-
- // ==== Termin Lang ====
-
- static function addTerminLang (array $array)
- {
- Tools::ifNotExist ($array, [
- 'template_id' => 0,
- 'termin_alias' => strtolower (Tools::translit ($array['termin_title'])),
- ]);
-
- Yii::$app->db->createCommand()->insert(
- 'termin_lang', [
- 'termin_id' => $array['termin_id'],
- 'termin_title' => $array['termin_title'],
- 'termin_alias' => $array['termin_alias'],
- 'template_id' => (int)$array['template_id'],
- 'lang_id' => (int)$array['lang_id'],
- ]
- )->execute();
- }
-
- // ==== Termin Relation ====
-
- static function findRelation (array $array)
- {
- $query = new SqlQueryBuilder();
- $query->from('termin_relation');
-
- if (isset ($array['termin_id']))
- {
- $query->where('termin_id = "'.$array['termin_id'].'"');
- }
-
- if (isset ($array['termin_pid']))
- {
- $query->where('termin_pid = "'.$array['termin_pid'].'"');
- }
-
- // sql
- $result = yii::$app->db->createCommand($query->__toString());
-
- return isset ($array['return_one']) ? $result->queryOne() : $result->queryAll();
- }
-
- static function addTerminRelation (array $array)
- {
- Tools::ifNotExist ($array, [
- 'termin_pid' => 0,
- 'is_default' => 1,
- ]);
-
- Yii::$app->db->createCommand()->insert(
- 'termin_relation', [
- 'termin_id' => (int)$array['termin_id'],
- 'termin_pid' => (int)$array['termin_pid'],
- 'is_default' => (int)$array['is_default'],
- ]
- )->execute();
-
- return Yii::$app->db->getLastInsertID();
- }
-}
diff --git a/common/translation/ru/action.php b/common/translation/ru/action.php
deleted file mode 100644
index 6eb8876..0000000
--- a/common/translation/ru/action.php
+++ /dev/null
@@ -1,12 +0,0 @@
- 'Добавить',
- 'edit' => 'Изменить',
- 'update' => 'Обновить',
- 'del' => 'Удалить',
- 'hide'=> 'Скрыть',
- 'copy' => 'Копировать',
- 'view' => 'Посмотреть',
- 'show' => 'Показать',
-];
\ No newline at end of file
diff --git a/common/translation/ru/app.php b/common/translation/ru/app.php
index abb07fb..f15fdf2 100644
--- a/common/translation/ru/app.php
+++ b/common/translation/ru/app.php
@@ -1,5 +1,8 @@
'Добавить',
'Settings' => 'Настройки',
'languages' => 'Языки',
@@ -58,4 +61,26 @@ return [
'Select parent' => 'Выберать родителя',
'Blog' => 'Блог',
'Static pages' => 'Статические страницы',
+
+ // Вова
+ 'page' => 'Страница',
+ 'date_add' => 'Дата добавления',
+ 'template' => 'Шаблон',
+ 'image' => 'Картинка',
+ 'title' => 'Заголовок',
+ 'meta_title' => 'Meta Title',
+ 'meta_description' => 'Meta Description',
+ 'text' => 'Текст',
+ 'page_alias' => 'alias',
+ 'lang_id' => 'ID языка',
+ 'common' => 'Общее',
+ 'lang' => 'Языковые переменные',
+ 'termin' => 'Термин',
+ 'related' => 'Связанные',
+ 'menu' => 'Меню',
+ 'location' => 'Разположение',
+ 'book' => 'Справочник',
+
+ // Дима
+
];
\ No newline at end of file
diff --git a/common/translation/ru/field.php b/common/translation/ru/field.php
deleted file mode 100644
index c1824fe..0000000
--- a/common/translation/ru/field.php
+++ /dev/null
@@ -1,16 +0,0 @@
- 'Страница',
- '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/common/translation/uk/action.php b/common/translation/uk/action.php
deleted file mode 100644
index f852d19..0000000
--- a/common/translation/uk/action.php
+++ /dev/null
@@ -1,12 +0,0 @@
- 'Додати',
- 'edit' => 'Змінити',
- 'update' => 'Оновити',
- 'del' => 'Видалити',
- 'hide' => 'Сховати',
- 'copy' => 'Копіювати',
- 'view' => 'Переглянути',
- 'show' => 'Відображати',
-];
diff --git a/common/translation/uk/field.php b/common/translation/uk/field.php
deleted file mode 100644
index 8a554a3..0000000
--- a/common/translation/uk/field.php
+++ /dev/null
@@ -1,16 +0,0 @@
- 'Сторінка',
- 'date_add' => 'Дата додання',
- 'template' => 'Шаблон',
- 'image' => 'Картинка',
- 'title' => 'Заголовок',
- 'meta_title' => 'Meta Title',
- 'meta_description' => 'Meta Description',
- 'text' => 'Текст',
- 'page_alias' => 'alias',
- 'lang_id' => 'ID мови',
- 'common' => 'Загальне',
- 'lang' => 'Мовні змінні',
-];
diff --git a/frontend/views/catalog/index.php b/frontend/views/catalog/index.php
index 13d25f0..d89d2f1 100644
--- a/frontend/views/catalog/index.php
+++ b/frontend/views/catalog/index.php
@@ -1,6 +1,6 @@
build();
\ No newline at end of file
--
libgit2 0.21.4