Commit e130021e5c81a41d21319b72fdc7786aa4de6362
1 parent
89744ceb
+ термины и меню (backup)
Showing
32 changed files
with
178 additions
and
1406 deletions
Show diff stats
backend/controllers/CatalogController.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\controllers; | |
4 | - | |
5 | -use Yii; | |
6 | -use common\models\Catalog; | |
7 | -use backend\models\SearchCatalog; | |
8 | -use yii\web\Controller; | |
9 | -use yii\web\NotFoundHttpException; | |
10 | -use yii\filters\VerbFilter; | |
11 | -use common\models\CatalogLang; | |
12 | - | |
13 | -/** | |
14 | - * CatalogController implements the CRUD actions for Catalog model. | |
15 | - */ | |
16 | -class CatalogController extends Controller | |
17 | -{ | |
18 | - public function behaviors() | |
19 | - { | |
20 | - return [ | |
21 | - 'verbs' => [ | |
22 | - 'class' => VerbFilter::className(), | |
23 | - 'actions' => [ | |
24 | - 'delete' => ['post'], | |
25 | - ], | |
26 | - ], | |
27 | - ]; | |
28 | - } | |
29 | - | |
30 | - /** | |
31 | - * Lists all Catalog models. | |
32 | - * @return mixed | |
33 | - */ | |
34 | - public function actionIndex() | |
35 | - { | |
36 | - $searchModel = new SearchCatalog(); | |
37 | - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
38 | - | |
39 | - return $this->render('index', [ | |
40 | - 'searchModel' => $searchModel, | |
41 | - 'dataProvider' => $dataProvider, | |
42 | - ]); | |
43 | - } | |
44 | - | |
45 | - /** | |
46 | - * Displays a single Catalog model. | |
47 | - * @param integer $id | |
48 | - * @return mixed | |
49 | - */ | |
50 | - public function actionView($id) | |
51 | - { | |
52 | - return $this->render('view', [ | |
53 | - 'model' => $this->findModel($id), | |
54 | - ]); | |
55 | - } | |
56 | - | |
57 | - /** | |
58 | - * Creates a new Catalog model. | |
59 | - * If creation is successful, the browser will be redirected to the 'view' page. | |
60 | - * @return mixed | |
61 | - */ | |
62 | - public function actionCreate() | |
63 | - { | |
64 | - $model = new Catalog(); | |
65 | - | |
66 | - if ($model->load(Yii::$app->request->post()) && $model->save()) | |
67 | - { | |
68 | - return $this->redirect(['view', 'id' => $model->id]); | |
69 | - } | |
70 | - else | |
71 | - { | |
72 | - return $this->render('create', [ | |
73 | - 'model' => $model, | |
74 | - ]); | |
75 | - } | |
76 | - } | |
77 | - | |
78 | - /** | |
79 | - * Updates an existing Catalog model. | |
80 | - * If update is successful, the browser will be redirected to the 'view' page. | |
81 | - * @param integer $id | |
82 | - * @return mixed | |
83 | - */ | |
84 | - public function actionUpdate($id) | |
85 | - { | |
86 | - $model = $this->findModel($id); | |
87 | - $model_lang = CatalogLang::find() | |
88 | - ->where(['catalog_id' => $id, 'lang_id' => 1]) | |
89 | - ->one(); | |
90 | - | |
91 | - if ($model->load(Yii::$app->request->post())) | |
92 | - { | |
93 | - $model_lang->title = $model->title; | |
94 | - | |
95 | - $model->save(); | |
96 | - $model_lang->save(); | |
97 | - | |
98 | - return $this->redirect(['view', 'id' => $model->id]); | |
99 | - } | |
100 | - else | |
101 | - { | |
102 | - return $this->render('update', [ | |
103 | - 'model' => $model, | |
104 | - ]); | |
105 | - } | |
106 | - } | |
107 | - | |
108 | - /** | |
109 | - * Deletes an existing Catalog model. | |
110 | - * If deletion is successful, the browser will be redirected to the 'index' page. | |
111 | - * @param integer $id | |
112 | - * @return mixed | |
113 | - */ | |
114 | - public function actionDelete($id) | |
115 | - { | |
116 | - $this->findModel($id)->delete(); | |
117 | - | |
118 | - return $this->redirect(['index']); | |
119 | - } | |
120 | - | |
121 | - /** | |
122 | - * Finds the Catalog model based on its primary key value. | |
123 | - * If the model is not found, a 404 HTTP exception will be thrown. | |
124 | - * @param integer $id | |
125 | - * @return Catalog the loaded model | |
126 | - * @throws NotFoundHttpException if the model cannot be found | |
127 | - */ | |
128 | - protected function findModel($id) | |
129 | - { | |
130 | - if (($model = Catalog::findOne($id)) !== null) | |
131 | - { | |
132 | - return $model; | |
133 | - } | |
134 | - else | |
135 | - { | |
136 | - throw new NotFoundHttpException('The requested page does not exist.'); | |
137 | - } | |
138 | - } | |
139 | -} |
backend/controllers/MenuController.php
... | ... | @@ -3,13 +3,11 @@ |
3 | 3 | namespace backend\controllers; |
4 | 4 | |
5 | 5 | use Yii; |
6 | -use common\models\Menu; | |
6 | +use backend\models\Menu; | |
7 | 7 | use backend\models\MenuSearch; |
8 | 8 | use yii\web\Controller; |
9 | 9 | use yii\web\NotFoundHttpException; |
10 | 10 | use yii\filters\VerbFilter; |
11 | -use common\models\TerminLang; | |
12 | -use backend\models\SearchMenu; | |
13 | 11 | |
14 | 12 | /** |
15 | 13 | * MenuController implements the CRUD actions for Menu model. |
... | ... | @@ -34,7 +32,7 @@ class MenuController extends Controller |
34 | 32 | */ |
35 | 33 | public function actionIndex() |
36 | 34 | { |
37 | - $searchModel = new SearchMenu(); | |
35 | + $searchModel = new MenuSearch(); | |
38 | 36 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
39 | 37 | |
40 | 38 | return $this->render('index', [ |
... | ... | @@ -64,32 +62,11 @@ class MenuController extends Controller |
64 | 62 | { |
65 | 63 | $model = new Menu(); |
66 | 64 | |
67 | - $menu = yii::$app->db->createCommand(' | |
68 | - SELECT * | |
69 | - FROM menu | |
70 | - LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | |
71 | - ')->queryAll(); | |
72 | - | |
73 | - | |
74 | - $termin = TerminLang::find()->all(); | |
75 | - | |
76 | - if ($model->load(Yii::$app->request->post())) { | |
77 | - | |
78 | - if($model->menu_pid == null) | |
79 | - { | |
80 | - $model->menu_pid = 0; | |
81 | - } | |
82 | - | |
83 | - | |
84 | - $model->save(); | |
85 | - | |
86 | - | |
65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
87 | 66 | return $this->redirect(['view', 'id' => $model->menu_id]); |
88 | 67 | } else { |
89 | 68 | return $this->render('create', [ |
90 | 69 | 'model' => $model, |
91 | - 'termin' => $termin, | |
92 | - 'menu' => $menu, | |
93 | 70 | ]); |
94 | 71 | } |
95 | 72 | } |
... | ... | @@ -103,22 +80,12 @@ class MenuController extends Controller |
103 | 80 | public function actionUpdate($id) |
104 | 81 | { |
105 | 82 | $model = $this->findModel($id); |
106 | - $menu = yii::$app->db->createCommand(' | |
107 | - SELECT * | |
108 | - FROM menu | |
109 | - LEFT JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | |
110 | - ')->queryAll() + ['termin_id' => 0, 'termin_title' => 'ROOT']; | |
111 | - | |
112 | - | |
113 | - $termin = TerminLang::find()->all(); | |
114 | 83 | |
115 | 84 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
116 | 85 | return $this->redirect(['view', 'id' => $model->menu_id]); |
117 | 86 | } else { |
118 | 87 | return $this->render('update', [ |
119 | 88 | 'model' => $model, |
120 | - 'termin' => $termin, | |
121 | - 'menu' => $menu, | |
122 | 89 | ]); |
123 | 90 | } |
124 | 91 | } | ... | ... |
backend/models/SearchCatalog.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use yii\base\Model; | |
7 | -use yii\data\ActiveDataProvider; | |
8 | -use common\models\Catalog; | |
9 | - | |
10 | -/** | |
11 | - * SearchCatalog represents the model behind the search form about `common\models\Catalog`. | |
12 | - */ | |
13 | -class SearchCatalog extends Catalog | |
14 | -{ | |
15 | - /** | |
16 | - * для поиска | |
17 | - * @var $title | |
18 | - */ | |
19 | - var $title; | |
20 | - | |
21 | - /** | |
22 | - * @inheritdoc | |
23 | - */ | |
24 | - public function rules() | |
25 | - { | |
26 | - return [ | |
27 | - [['catalog_id', 'parent_id', 'status', 'sort'], 'integer'], | |
28 | - // + поиск по title | |
29 | - [['title'], 'safe'] | |
30 | - ]; | |
31 | - } | |
32 | - | |
33 | - /** | |
34 | - * @inheritdoc | |
35 | - */ | |
36 | - public function scenarios() | |
37 | - { | |
38 | - // bypass scenarios() implementation in the parent class | |
39 | - return Model::scenarios(); | |
40 | - } | |
41 | - | |
42 | - /** | |
43 | - * Creates data provider instance with search query applied | |
44 | - * | |
45 | - * @param array $params | |
46 | - * | |
47 | - * @return ActiveDataProvider | |
48 | - */ | |
49 | - public function search($params) | |
50 | - { | |
51 | - $query = Catalog::find(); | |
52 | - | |
53 | - $dataProvider = new ActiveDataProvider([ | |
54 | - 'query' => $query, | |
55 | - ]); | |
56 | - | |
57 | - // + поиск по title | |
58 | - $dataProvider->setSort([ | |
59 | - 'attributes' => [ | |
60 | - 'catalog_id', | |
61 | - 'title' => [ | |
62 | - 'asc' => ['title' => SORT_ASC], | |
63 | - 'desc' => ['title' => SORT_DESC], | |
64 | - 'label' => 'title', | |
65 | - 'default' => SORT_ASC | |
66 | - ] | |
67 | - ] | |
68 | - ]); | |
69 | - | |
70 | - $this->load($params); | |
71 | - | |
72 | - // + поиск по title | |
73 | - $query->joinWith(['relationCatalogLangPlus']); | |
74 | - | |
75 | - if (!$this->validate()) | |
76 | - { | |
77 | - // uncomment the following line if you do not want to return any records when validation fails | |
78 | - // $query->where('0=1'); | |
79 | - | |
80 | - return $dataProvider; | |
81 | - } | |
82 | - | |
83 | - $query->andFilterWhere([ | |
84 | - 'catalog_id' => $this->catalog_id, | |
85 | - 'parent_id' => $this->parent_id, | |
86 | - 'status' => $this->status, | |
87 | - 'sort' => $this->sort, | |
88 | - ]); | |
89 | - | |
90 | - $query->andFilterWhere(['like', 'cover', $this->cover]); | |
91 | - | |
92 | - // + поиск по title | |
93 | - if (! empty ($this->title)) | |
94 | - { | |
95 | - $query->joinWith(['relationCatalogLangPlus' => function ($q) | |
96 | - { | |
97 | - $q->where(['like', 'catalog_i18n.title', $this->title]); | |
98 | - }]); | |
99 | - } | |
100 | - | |
101 | - return $dataProvider; | |
102 | - } | |
103 | -} |
backend/models/SearchMenu.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use yii\base\Model; | |
7 | -use yii\data\ActiveDataProvider; | |
8 | -use common\models\Menu; | |
9 | - | |
10 | -/** | |
11 | - * SearchMenu represents the model behind the search form about `common\models\Menu`. | |
12 | - */ | |
13 | -class SearchMenu extends Menu | |
14 | -{ | |
15 | - /** | |
16 | - * @inheritdoc | |
17 | - */ | |
18 | - public function rules() | |
19 | - { | |
20 | - return [ | |
21 | - [['menu_id', 'menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'integer'], | |
22 | - ]; | |
23 | - } | |
24 | - | |
25 | - /** | |
26 | - * @inheritdoc | |
27 | - */ | |
28 | - public function scenarios() | |
29 | - { | |
30 | - // bypass scenarios() implementation in the parent class | |
31 | - return Model::scenarios(); | |
32 | - } | |
33 | - | |
34 | - /** | |
35 | - * Creates data provider instance with search query applied | |
36 | - * | |
37 | - * @param array $params | |
38 | - * | |
39 | - * @return ActiveDataProvider | |
40 | - */ | |
41 | - public function search($params) | |
42 | - { | |
43 | - $query = Menu::find(); | |
44 | - | |
45 | - $dataProvider = new ActiveDataProvider([ | |
46 | - 'query' => $query, | |
47 | - ]); | |
48 | - | |
49 | - $this->load($params); | |
50 | - | |
51 | - if (!$this->validate()) { | |
52 | - // uncomment the following line if you do not want to return any records when validation fails | |
53 | - // $query->where('0=1'); | |
54 | - return $dataProvider; | |
55 | - } | |
56 | - | |
57 | - $query->andFilterWhere([ | |
58 | - 'menu_id' => $this->menu_id, | |
59 | - 'menu_pid' => $this->menu_pid, | |
60 | - 'menu_lft' => $this->menu_lft, | |
61 | - 'menu_rgt' => $this->menu_rgt, | |
62 | - 'termin_id' => $this->termin_id, | |
63 | - 'show' => $this->show, | |
64 | - 'sortorder' => $this->sortorder, | |
65 | - ]); | |
66 | - | |
67 | - return $dataProvider; | |
68 | - } | |
69 | -} |
backend/models/SearchPage.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\models; | |
4 | - | |
5 | -use yii\base\Model; | |
6 | -use yii\data\ActiveDataProvider; | |
7 | -use common\models\Page; | |
8 | - | |
9 | - | |
10 | -/** | |
11 | - * SearchPage represents the model behind the search form about `common\models\Page`. | |
12 | - */ | |
13 | -class SearchPage extends Page | |
14 | -{ | |
15 | - /** | |
16 | - * @inheritdoc | |
17 | - */ | |
18 | - public function rules() | |
19 | - { | |
20 | - return [ | |
21 | - [['page_id', 'template_id', 'image_id', 'show'], 'integer'], | |
22 | - [['date_add'], 'safe'], | |
23 | - ]; | |
24 | - } | |
25 | - | |
26 | - /** | |
27 | - * @inheritdoc | |
28 | - */ | |
29 | - public function scenarios() | |
30 | - { | |
31 | - // bypass scenarios() implementation in the parent class | |
32 | - return Model::scenarios(); | |
33 | - } | |
34 | - | |
35 | - | |
36 | - /** | |
37 | - * Creates data provider instance with search query applied | |
38 | - * | |
39 | - * @param array $params | |
40 | - * | |
41 | - * @return ActiveDataProvider | |
42 | - */ | |
43 | - public function search($params) | |
44 | - { | |
45 | - $query = Page::find(); | |
46 | - | |
47 | - $dataProvider = new ActiveDataProvider([ | |
48 | - 'query' => $query, | |
49 | - ]); | |
50 | - | |
51 | - $this->load($params); | |
52 | - | |
53 | - if (!$this->validate()) { | |
54 | - // uncomment the following line if you do not want to return any records when validation fails | |
55 | - // $query->where('0=1'); | |
56 | - return $dataProvider; | |
57 | - } | |
58 | - | |
59 | - $query->andFilterWhere([ | |
60 | - 'page_id' => $this->page_id, | |
61 | - 'date_add' => $this->date_add, | |
62 | - 'template_id' => $this->template_id, | |
63 | - 'image_id' => $this->image_id, | |
64 | - 'show' => $this->show, | |
65 | - ]); | |
66 | - | |
67 | - return $dataProvider; | |
68 | - } | |
69 | -} |
backend/models/SearchTermin.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use yii\base\Model; | |
7 | -use yii\data\ActiveDataProvider; | |
8 | -use common\models\Termin; | |
9 | - | |
10 | -/** | |
11 | - * SearchTermin represents the model behind the search form about `common\models\Termin`. | |
12 | - */ | |
13 | -class SearchTermin extends Termin | |
14 | -{ | |
15 | - /** | |
16 | - * @inheritdoc | |
17 | - */ | |
18 | - public function rules() | |
19 | - { | |
20 | - return [ | |
21 | - [['termin_id', 'termin_pid', 'lfr', 'rgt', 'termin_type_id', 'page_id'], 'integer'], | |
22 | - ]; | |
23 | - } | |
24 | - | |
25 | - /** | |
26 | - * @inheritdoc | |
27 | - */ | |
28 | - public function scenarios() | |
29 | - { | |
30 | - // bypass scenarios() implementation in the parent class | |
31 | - return Model::scenarios(); | |
32 | - } | |
33 | - | |
34 | - /** | |
35 | - * Creates data provider instance with search query applied | |
36 | - * | |
37 | - * @param array $params | |
38 | - * | |
39 | - * @return ActiveDataProvider | |
40 | - */ | |
41 | - public function search($params) | |
42 | - { | |
43 | - $query = Termin::find(); | |
44 | - | |
45 | - $dataProvider = new ActiveDataProvider([ | |
46 | - 'query' => $query, | |
47 | - ]); | |
48 | - | |
49 | - $this->load($params); | |
50 | - | |
51 | - if (!$this->validate()) { | |
52 | - // uncomment the following line if you do not want to return any records when validation fails | |
53 | - // $query->where('0=1'); | |
54 | - return $dataProvider; | |
55 | - } | |
56 | - | |
57 | - $query->andFilterWhere([ | |
58 | - 'termin_id' => $this->termin_id, | |
59 | - 'termin_pid' => $this->termin_pid, | |
60 | - 'lfr' => $this->lfr, | |
61 | - 'rgt' => $this->rgt, | |
62 | - 'termin_type_id' => $this->termin_type_id, | |
63 | - 'page_id' => $this->page_id, | |
64 | - ]); | |
65 | - | |
66 | - return $dataProvider; | |
67 | - } | |
68 | -} |
backend/models/TerminLangSearch.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace backend\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use yii\base\Model; | |
7 | -use yii\data\ActiveDataProvider; | |
8 | -use common\models\TerminLang; | |
9 | - | |
10 | -/** | |
11 | - * TerminLangSearch represents the model behind the search form about `common\models\TerminLang`. | |
12 | - */ | |
13 | -class TerminLangSearch extends TerminLang | |
14 | -{ | |
15 | - /** | |
16 | - * @inheritdoc | |
17 | - */ | |
18 | - public function rules() | |
19 | - { | |
20 | - return [ | |
21 | - [['termin_id', 'lang_id'], 'integer'], | |
22 | - [['termin_title'], 'safe'], | |
23 | - ]; | |
24 | - } | |
25 | - | |
26 | - /** | |
27 | - * @inheritdoc | |
28 | - */ | |
29 | - public function scenarios() | |
30 | - { | |
31 | - // bypass scenarios() implementation in the parent class | |
32 | - return Model::scenarios(); | |
33 | - } | |
34 | - | |
35 | - /** | |
36 | - * Creates data provider instance with search query applied | |
37 | - * | |
38 | - * @param array $params | |
39 | - * | |
40 | - * @return ActiveDataProvider | |
41 | - */ | |
42 | - public function search($params) | |
43 | - { | |
44 | - $query = TerminLang::find(); | |
45 | - | |
46 | - $dataProvider = new ActiveDataProvider([ | |
47 | - 'query' => $query, | |
48 | - ]); | |
49 | - | |
50 | - $this->load($params); | |
51 | - | |
52 | - if (!$this->validate()) { | |
53 | - // uncomment the following line if you do not want to return any records when validation fails | |
54 | - // $query->where('0=1'); | |
55 | - return $dataProvider; | |
56 | - } | |
57 | - | |
58 | - $query->andFilterWhere([ | |
59 | - 'termin_id' => $this->termin_id, | |
60 | - 'lang_id' => $this->lang_id, | |
61 | - ]); | |
62 | - | |
63 | - $query->andFilterWhere(['like', 'termin_title', $this->termin_title]); | |
64 | - | |
65 | - return $dataProvider; | |
66 | - } | |
67 | -} |
backend/views/catalog/_form.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\ActiveForm; | |
5 | -use yii\helpers\ArrayHelper; | |
6 | -use common\models\Catalog; | |
7 | - | |
8 | -/* @var $this yii\web\View */ | |
9 | -/* @var $model common\models\Catalog */ | |
10 | -/* @var $form yii\widgets\ActiveForm */ | |
11 | -?> | |
12 | - | |
13 | -<div class="catalog-form"> | |
14 | - | |
15 | - <?php $form = ActiveForm::begin(); ?> | |
16 | - | |
17 | - <?= $form->field($model, 'title')->textInput() ?> | |
18 | - | |
19 | - <?= $form->field($model, 'parent_id')->dropDownList( | |
20 | - ArrayHelper::map($model->find()->all(), 'parent_id', 'title') | |
21 | - ) | |
22 | - ?> | |
23 | - | |
24 | - <?= $form->field($model, 'cover')->textInput(['maxlength' => true]) ?> | |
25 | - | |
26 | - <?= $form->field($model, 'status')->dropDownList([ | |
27 | - '1' => Yii::t('action', 'show'), | |
28 | - '0' => Yii::t('action', 'hide'), | |
29 | - ]); | |
30 | - | |
31 | - echo '<pre>'; | |
32 | - | |
33 | - $array = $model->findInfo([ | |
34 | - 'catalog_id' => 1, | |
35 | - 'return_one' => true, | |
36 | - 'to_array' => false, | |
37 | - ]); | |
38 | - | |
39 | - var_dump($array->relationCatalogLang2->title); | |
40 | - //var_dump($array->relationCatalogLang2->title); | |
41 | - | |
42 | - echo '</pre>'; | |
43 | - | |
44 | - ?> | |
45 | - | |
46 | - <?= $form->field($model, 'sort')->textInput() ?> | |
47 | - | |
48 | - <div class="form-group"> | |
49 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('action', 'add') : Yii::t('action', 'update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
50 | - </div> | |
51 | - | |
52 | - <?php ActiveForm::end(); ?> | |
53 | - | |
54 | -</div> |
backend/views/catalog/_search.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\ActiveForm; | |
5 | - | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model backend\models\SearchCatalog */ | |
8 | -/* @var $form yii\widgets\ActiveForm */ | |
9 | -?> | |
10 | - | |
11 | -<div class="catalog-search"> | |
12 | - | |
13 | - <?php $form = ActiveForm::begin([ | |
14 | - 'action' => ['index'], | |
15 | - 'method' => 'get', | |
16 | - ]); ?> | |
17 | - | |
18 | - <?= $form->field($model, 'catalog_id') ?> | |
19 | - | |
20 | - <?= $form->field($model, 'parent_id') ?> | |
21 | - | |
22 | - <?= $form->field($model, 'cover') ?> | |
23 | - | |
24 | - <?php // echo $form->field($model, 'status') ?> | |
25 | - | |
26 | - <?php // echo $form->field($model, 'sort') ?> | |
27 | - | |
28 | - <div class="form-group"> | |
29 | - <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | |
30 | - <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | |
31 | - </div> | |
32 | - | |
33 | - <?php ActiveForm::end(); ?> | |
34 | - | |
35 | -</div> |
backend/views/catalog/create.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | - | |
5 | - | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model common\models\Catalog */ | |
8 | - | |
9 | -$this->title = Yii::t('app', 'Create Catalog'); | |
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']]; | |
11 | -$this->params['breadcrumbs'][] = $this->title; | |
12 | -?> | |
13 | -<div class="catalog-create"> | |
14 | - | |
15 | - <h1><?= Html::encode($this->title) ?></h1> | |
16 | - | |
17 | - <?= $this->render('_form', [ | |
18 | - 'model' => $model, | |
19 | - ]) ?> | |
20 | - | |
21 | -</div> |
backend/views/catalog/index.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\grid\GridView; | |
5 | - | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $searchModel backend\models\SearchCatalog */ | |
8 | -/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | - | |
10 | -$this->title = Yii::t('app', 'Catalogs'); | |
11 | -$this->params['breadcrumbs'][] = $this->title; | |
12 | -?> | |
13 | -<div class="catalog-index"> | |
14 | - | |
15 | - <h1><?= Html::encode($this->title) ?></h1> | |
16 | - <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
17 | - | |
18 | - <p> | |
19 | - <?= Html::a(Yii::t('app', 'Create Catalog'), ['create'], ['class' => 'btn btn-success']) ?> | |
20 | - </p> | |
21 | - | |
22 | - <?= GridView::widget([ | |
23 | - 'dataProvider' => $dataProvider, | |
24 | - 'filterModel' => $searchModel, | |
25 | - 'columns' => [ | |
26 | - ['class' => 'yii\grid\SerialColumn'], | |
27 | - | |
28 | - 'catalog_id', | |
29 | - 'parent_id', | |
30 | - 'title', | |
31 | - // 'status', | |
32 | - // 'sort', | |
33 | - | |
34 | - ['class' => 'yii\grid\ActionColumn'], | |
35 | - ], | |
36 | - ]); ?> | |
37 | - | |
38 | -</div> |
backend/views/catalog/update.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | - | |
5 | -/* @var $this yii\web\View */ | |
6 | -/* @var $model common\models\Catalog */ | |
7 | - | |
8 | -$this->title = Yii::t('app', 'Update {modelClass}: ', [ | |
9 | - 'modelClass' => 'Catalog', | |
10 | -]) . ' ' . $model->catalog_id; | |
11 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']]; | |
12 | -$this->params['breadcrumbs'][] = ['label' => $model->catalog_id, 'url' => ['view', 'id' => $model->catalog_id]]; | |
13 | -$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | |
14 | -?> | |
15 | -<div class="catalog-update"> | |
16 | - | |
17 | - <h1><?= Html::encode($this->title) ?></h1> | |
18 | - | |
19 | - <?= $this->render('_form', [ | |
20 | - 'model' => $model, | |
21 | - ]) ?> | |
22 | - | |
23 | -</div> |
backend/views/catalog/view.php deleted
1 | -<?php | |
2 | - | |
3 | -use yii\helpers\Html; | |
4 | -use yii\widgets\DetailView; | |
5 | - | |
6 | -/* @var $this yii\web\View */ | |
7 | -/* @var $model common\models\Catalog */ | |
8 | - | |
9 | -$this->title = $model->catalog_id; | |
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Catalogs'), 'url' => ['index']]; | |
11 | -$this->params['breadcrumbs'][] = $this->title; | |
12 | -?> | |
13 | -<div class="catalog-view"> | |
14 | - | |
15 | - <h1><?= Html::encode($this->title) ?></h1> | |
16 | - | |
17 | - <p> | |
18 | - <?= Html::a(Yii::t('app', 'Update'), ['update', 'catalog_id' => $model->catalog_id], ['class' => 'btn btn-primary']) ?> | |
19 | - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'catalog_id' => $model->catalog_id], [ | |
20 | - 'class' => 'btn btn-danger', | |
21 | - 'data' => [ | |
22 | - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
23 | - 'method' => 'post', | |
24 | - ], | |
25 | - ]) ?> | |
26 | - </p> | |
27 | - | |
28 | - <?= DetailView::widget([ | |
29 | - 'model' => $model, | |
30 | - 'attributes' => [ | |
31 | - 'catalog_id', | |
32 | - 'parent_id', | |
33 | - 'cover', | |
34 | - 'status', | |
35 | - 'sort', | |
36 | - ], | |
37 | - ]) ?> | |
38 | - | |
39 | -</div> |
backend/views/layouts/left.php
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']], |
34 | 34 | //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], |
35 | 35 | //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], |
36 | - //['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], | |
36 | + ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], | |
37 | 37 | ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']], |
38 | 38 | ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], |
39 | 39 | ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], | ... | ... |
backend/views/menu/_form.php
... | ... | @@ -2,11 +2,9 @@ |
2 | 2 | |
3 | 3 | use yii\helpers\Html; |
4 | 4 | use yii\widgets\ActiveForm; |
5 | -use yii\helpers\ArrayHelper; | |
6 | -use kartik\select2\Select2; | |
7 | 5 | |
8 | 6 | /* @var $this yii\web\View */ |
9 | -/* @var $model common\models\Menu */ | |
7 | +/* @var $model backend\models\Menu */ | |
10 | 8 | /* @var $form yii\widgets\ActiveForm */ |
11 | 9 | ?> |
12 | 10 | |
... | ... | @@ -14,33 +12,25 @@ use kartik\select2\Select2; |
14 | 12 | |
15 | 13 | <?php $form = ActiveForm::begin(); ?> |
16 | 14 | |
17 | - | |
18 | - | |
19 | - <?= $form->field($model, 'termin_id')->widget(Select2::classname(), [ | |
20 | - //'data' => $data, | |
21 | - 'language' => 'ru', | |
22 | - 'options' => ['placeholder' => 'под меню ...'], | |
23 | - 'pluginOptions' => [ | |
24 | - | |
25 | - ], | |
26 | - 'data' => ArrayHelper::map($termin, 'termin_id', 'termin_title'), // data as array | |
27 | - ]) ?> | |
28 | - | |
29 | - <?= $form->field($model, 'menu_pid')->widget(Select2::classname(), [ | |
30 | - //'data' => $data, | |
31 | - 'language' => 'ru', | |
32 | - 'options' => ['placeholder' => 'Меню родитель ...'], | |
33 | - 'pluginOptions' => [ | |
34 | - | |
35 | - ], | |
36 | - 'data' => ArrayHelper::map($menu, 'termin_id', 'termin_title'), // data as array | |
37 | - ]) ?> | |
38 | - | |
39 | - | |
40 | - | |
41 | - <?= $form->field($model, 'show')->dropDownList(['1' => Yii::t('action', 'show'), '0' => Yii::t('action', 'hide')]) ?> | |
42 | - | |
43 | - <?= $form->field($model, 'sortorder')->dropDownList(['1' => '1', '0' => '2']) ?> | |
15 | + <?= $form->field($model, 'menu_id')->textInput() ?> | |
16 | + | |
17 | + <?= $form->field($model, 'menu_pid')->textInput() ?> | |
18 | + | |
19 | + <?= $form->field($model, 'level')->textInput() ?> | |
20 | + | |
21 | + <?= $form->field($model, 'termin_id')->textInput() ?> | |
22 | + | |
23 | + <?= $form->field($model, 'show')->textInput() ?> | |
24 | + | |
25 | + <?= $form->field($model, 'is_open')->textInput() ?> | |
26 | + | |
27 | + <?= $form->field($model, 'menu_location_id')->textInput() ?> | |
28 | + | |
29 | + <?= $form->field($model, 'sortorder')->textInput() ?> | |
30 | + | |
31 | + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | |
32 | + | |
33 | + <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?> | |
44 | 34 | |
45 | 35 | <div class="form-group"> |
46 | 36 | <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ... | ... |
backend/views/menu/_search.php
... | ... | @@ -19,16 +19,22 @@ use yii\widgets\ActiveForm; |
19 | 19 | |
20 | 20 | <?= $form->field($model, 'menu_pid') ?> |
21 | 21 | |
22 | - <?= $form->field($model, 'menu_lft') ?> | |
23 | - | |
24 | - <?= $form->field($model, 'menu_rgt') ?> | |
22 | + <?= $form->field($model, 'level') ?> | |
25 | 23 | |
26 | 24 | <?= $form->field($model, 'termin_id') ?> |
27 | 25 | |
28 | - <?php // echo $form->field($model, 'show') ?> | |
26 | + <?= $form->field($model, 'show') ?> | |
27 | + | |
28 | + <?php // echo $form->field($model, 'is_open') ?> | |
29 | + | |
30 | + <?php // echo $form->field($model, 'menu_location_id') ?> | |
29 | 31 | |
30 | 32 | <?php // echo $form->field($model, 'sortorder') ?> |
31 | 33 | |
34 | + <?php // echo $form->field($model, 'name') ?> | |
35 | + | |
36 | + <?php // echo $form->field($model, 'url') ?> | |
37 | + | |
32 | 38 | <div class="form-group"> |
33 | 39 | <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> |
34 | 40 | <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ... | ... |
backend/views/menu/create.php
... | ... | @@ -4,7 +4,7 @@ use yii\helpers\Html; |
4 | 4 | |
5 | 5 | |
6 | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model common\models\Menu */ | |
7 | +/* @var $model backend\models\Menu */ | |
8 | 8 | |
9 | 9 | $this->title = Yii::t('app', 'Create Menu'); |
10 | 10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']]; |
... | ... | @@ -16,8 +16,6 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | |
17 | 17 | <?= $this->render('_form', [ |
18 | 18 | 'model' => $model, |
19 | - 'termin' => $termin, | |
20 | - 'menu' => $menu, | |
21 | 19 | ]) ?> |
22 | 20 | |
23 | 21 | </div> | ... | ... |
backend/views/menu/index.php
... | ... | @@ -16,7 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; |
16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
17 | 17 | |
18 | 18 | <p> |
19 | - <?= Html::a(Yii::t('app', 'Create Menu'), ['create'], ['class' => 'btn btn-success']) ?> | |
19 | + <?= Html::a(Yii::t('app', 'Create').' '.Yii::t('app', 'menu'), ['create'], ['class' => 'btn btn-success']) ?> | |
20 | + <?= Html::a(Yii::t('app', 'Create').' '.Yii::t('app', 'location'), ['/menu-location/'], ['class' => 'btn btn-primary']) ?> | |
20 | 21 | </p> |
21 | 22 | |
22 | 23 | <?= GridView::widget([ |
... | ... | @@ -25,18 +26,14 @@ $this->params['breadcrumbs'][] = $this->title; |
25 | 26 | 'columns' => [ |
26 | 27 | ['class' => 'yii\grid\SerialColumn'], |
27 | 28 | |
28 | - 'menu_id', | |
29 | - 'menu_pid', | |
30 | 29 | [ |
31 | - 'attribute' => 'menu_pid', | |
30 | + 'attribute' => Yii::t('app', 'termin'), | |
32 | 31 | 'value' => function ($model) { |
33 | 32 | return empty($model->termin_id) ? '-' : $model->termin_lang->termin_title; |
34 | 33 | }, |
35 | - ], | |
36 | - // 'menu_lft', | |
37 | - // 'menu_rgt', | |
38 | - 'termin_id', | |
39 | - // 'show', | |
34 | + ], | |
35 | + 'menu_pid', | |
36 | + 'level', | |
40 | 37 | // 'sortorder', |
41 | 38 | |
42 | 39 | ['class' => 'yii\grid\ActionColumn'], | ... | ... |
backend/views/menu/update.php
... | ... | @@ -3,13 +3,13 @@ |
3 | 3 | use yii\helpers\Html; |
4 | 4 | |
5 | 5 | /* @var $this yii\web\View */ |
6 | -/* @var $model common\models\Menu */ | |
6 | +/* @var $model backend\models\Menu */ | |
7 | 7 | |
8 | 8 | $this->title = Yii::t('app', 'Update {modelClass}: ', [ |
9 | 9 | 'modelClass' => 'Menu', |
10 | -]) . ' ' . $model->menu_id; | |
10 | +]) . ' ' . $model->name; | |
11 | 11 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']]; |
12 | -$this->params['breadcrumbs'][] = ['label' => $model->menu_id, 'url' => ['view', 'id' => $model->menu_id]]; | |
12 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->menu_id]]; | |
13 | 13 | $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); |
14 | 14 | ?> |
15 | 15 | <div class="menu-update"> |
... | ... | @@ -18,8 +18,6 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); |
18 | 18 | |
19 | 19 | <?= $this->render('_form', [ |
20 | 20 | 'model' => $model, |
21 | - 'termin' => $termin, | |
22 | - 'menu' => $menu, | |
23 | 21 | ]) ?> |
24 | 22 | |
25 | 23 | </div> | ... | ... |
backend/views/menu/view.php
... | ... | @@ -4,9 +4,9 @@ use yii\helpers\Html; |
4 | 4 | use yii\widgets\DetailView; |
5 | 5 | |
6 | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model common\models\Menu */ | |
7 | +/* @var $model backend\models\Menu */ | |
8 | 8 | |
9 | -$this->title = $model->menu_id; | |
9 | +$this->title = $model->name; | |
10 | 10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menus'), 'url' => ['index']]; |
11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | 12 | ?> |
... | ... | @@ -30,11 +30,14 @@ $this->params['breadcrumbs'][] = $this->title; |
30 | 30 | 'attributes' => [ |
31 | 31 | 'menu_id', |
32 | 32 | 'menu_pid', |
33 | - 'menu_lft', | |
34 | - 'menu_rgt', | |
33 | + 'level', | |
35 | 34 | 'termin_id', |
36 | 35 | 'show', |
36 | + 'is_open', | |
37 | + 'menu_location_id', | |
37 | 38 | 'sortorder', |
39 | + 'name', | |
40 | + 'url:url', | |
38 | 41 | ], |
39 | 42 | ]) ?> |
40 | 43 | ... | ... |
common/models/Catalog.php
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace common\models; |
4 | - | |
4 | + | |
5 | 5 | use Yii; |
6 | -use yii\data\ActiveDataProvider; | |
6 | +use yii\base\Model; | |
7 | +use yii\db\Query; | |
7 | 8 | |
8 | 9 | /** |
9 | - * This is the model class for table "catalog". | |
10 | - * | |
11 | - * @property integer $id | |
12 | - * @property integer $parent_id | |
13 | - * @property string $cover | |
14 | - * @property string $options | |
15 | - * @property integer $status | |
16 | - * @property integer $sort | |
10 | + * Signup form | |
17 | 11 | */ |
18 | -class Catalog extends \yii\db\ActiveRecord | |
19 | -{ | |
20 | - /** | |
21 | - * @inheritdoc | |
22 | - */ | |
23 | - public static function tableName() | |
24 | - { | |
25 | - return 'catalog'; | |
26 | - } | |
27 | - | |
12 | +class Catalog extends Model | |
13 | +{ | |
28 | 14 | /** |
29 | - * @inheritdoc | |
15 | + * весь список терминов | |
30 | 16 | */ |
31 | - public function rules() | |
17 | + static function get () | |
32 | 18 | { |
33 | - return [ | |
34 | - [['parent_id', 'status', 'sort'], 'integer'], | |
35 | - [['cover'], 'string', 'max' => 32], | |
36 | - ]; | |
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(); | |
37 | 29 | } |
38 | - | |
30 | + | |
39 | 31 | /** |
40 | - * @inheritdoc | |
41 | - */ | |
42 | - public function attributeLabels() | |
43 | - { | |
44 | - return [ | |
45 | - 'catalog_id' => Yii::t('app', 'ID'), | |
46 | - 'parent_id' => Yii::t('app', 'Parent ID'), | |
47 | - 'cover' => Yii::t('app', 'Cover'), | |
48 | - 'status' => Yii::t('app', 'Status'), | |
49 | - 'sort' => Yii::t('app', 'Sort'), | |
50 | - ]; | |
51 | - } | |
52 | - | |
53 | - /** | |
54 | 32 | * Выполняет поиск по параметрам |
55 | 33 | * @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all] |
56 | 34 | * @return array one | array all | string значение масива |
... | ... | @@ -64,72 +42,117 @@ class Catalog extends \yii\db\ActiveRecord |
64 | 42 | 'return_field' => false, |
65 | 43 | 'show_all' => false, |
66 | 44 | 'to_array' => true, |
67 | - )); | |
68 | - | |
45 | + )); | |
46 | + | |
69 | 47 | $model = new Catalog(); |
70 | - | |
71 | - $query = $model->find()->select('*'); | |
72 | - | |
73 | - $query->joinWith(['relationCatalogLang2']); | |
74 | - | |
48 | + | |
49 | + $query = $model->find()->select('*'); | |
50 | + | |
51 | + $query->joinWith(['relationCatalogLang']); | |
52 | + | |
75 | 53 | $WHERE = array (); |
76 | - | |
77 | - if ($params['catalog_id'] !== false) | |
54 | + | |
55 | + if ($params['catalog_id']) | |
78 | 56 | { |
79 | 57 | $WHERE['catalog.catalog_id'] = $params['catalog_id']; |
80 | 58 | } |
81 | - | |
82 | - if ($params['lang_id'] !== false) | |
59 | + | |
60 | + if ($params['lang_id']) | |
83 | 61 | { |
84 | 62 | $WHERE['catalog_i18n.lang_id'] = $params['lang_id']; |
85 | 63 | } |
86 | - | |
64 | + | |
87 | 65 | if (! empty ($WHERE)) |
88 | - { | |
66 | + { | |
89 | 67 | $query->where($WHERE); |
90 | 68 | } |
91 | - | |
92 | - if ($params['to_array'] !== false) | |
69 | + | |
70 | + if ($params['to_array']) | |
93 | 71 | { |
94 | 72 | $query = $query->asArray(); |
95 | 73 | } |
96 | - | |
97 | - if ($params['return_one'] !== false || $params['return_field'] !== false) | |
74 | + | |
75 | + if ($params['return_one'] || $params['return_field']) | |
76 | + { | |
77 | + | |
78 | + $result = $params['return_field'] ? $query->one($params['return_field']) : $query->one(); | |
79 | + } | |
80 | + else | |
98 | 81 | { |
82 | + $result = $query->all(); | |
83 | + } | |
84 | + | |
85 | + return $result; | |
86 | + } | |
87 | + | |
88 | + // =================== | |
89 | + // ==== STRUCTURE ==== | |
90 | + // =================== | |
99 | 91 | |
100 | - $result = $params['return_field'] !== false ? $query->one($params['return_field']) : $query->one(); | |
92 | + var $mass = array (); | |
93 | + | |
94 | + public function build () | |
95 | + { | |
96 | + if ($this->mass = self::get ()) | |
97 | + { | |
98 | + return $this->getRecrusive (8); | |
101 | 99 | } |
102 | - else | |
100 | + } | |
101 | + | |
102 | + public function findChild ($id) | |
103 | + { | |
104 | + $mass = array (); | |
105 | + | |
106 | + foreach ($this->mass as $row) | |
103 | 107 | { |
104 | - $result = $query->all(); | |
108 | + if ($row['termin_pid'] == $id) | |
109 | + { | |
110 | + $mass[] = $row; | |
111 | + } | |
105 | 112 | } |
113 | + | |
114 | + return $mass; | |
115 | + } | |
116 | + | |
117 | + public function getRecrusive ($menu_id) | |
118 | + { | |
119 | + $items = $this->findChild($menu_id); | |
120 | + | |
121 | + if (! empty ($items)) | |
122 | + { | |
123 | + echo '<ul>'; | |
124 | + | |
125 | + foreach ($items as $row) | |
126 | + { | |
127 | + echo '<li>'.$row['termin_title'].'</li>'; | |
128 | + | |
129 | + if ($row['termin_pid'] != 0) | |
130 | + { | |
131 | + $this->getRecrusive($row['termin_id']); | |
132 | + } | |
133 | + } | |
106 | 134 | |
107 | - return $result; | |
135 | + echo '</ul>'; | |
136 | + } | |
137 | + | |
108 | 138 | } |
139 | + | |
140 | + // ===== | |
109 | 141 | |
110 | 142 | /** |
111 | 143 | * @return \yii\db\ActiveQuery |
112 | 144 | */ |
113 | 145 | public function getRelationCatalogLangPlus() |
114 | - { | |
115 | - return $this->getRelationCatalogLang2()->where(['lang_id' => yii::$app->params['lang_id']]); | |
146 | + { | |
147 | + return $this->getRelationCatalogLang()->where(['lang_id' => yii::$app->params['lang_id']]); | |
116 | 148 | } |
117 | - | |
149 | + | |
118 | 150 | /** |
119 | 151 | * @return \yii\db\ActiveQuery |
120 | 152 | */ |
121 | - public function getRelationCatalogLang2() | |
153 | + public function getRelationCatalogLang() | |
122 | 154 | { |
123 | 155 | return $this->hasOne(CatalogLang::className(), ['catalog_id' => 'catalog_id']); |
124 | 156 | } |
125 | 157 | |
126 | - public function getTitle() | |
127 | - { | |
128 | - return $this->relationCatalogLangPlus->title; | |
129 | - } | |
130 | - | |
131 | - public function getParentTitle() | |
132 | - { | |
133 | - return $this->relationCatalogLangPlus->title; | |
134 | - } | |
135 | -} | |
158 | +} | |
136 | 159 | \ No newline at end of file | ... | ... |
common/models/CatalogLang.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace common\models; | |
4 | - | |
5 | -use Yii; | |
6 | - | |
7 | -/** | |
8 | - * This is the model class for table "catalog_i18n". | |
9 | - * | |
10 | - * @property integer $catalog_id | |
11 | - * @property integer $lang_id | |
12 | - * @property string $title | |
13 | - * @property string $alias | |
14 | - * @property string $meta_title | |
15 | - * @property string $meta_keywords | |
16 | - * @property string $meta_description | |
17 | - * @property string $full_alias | |
18 | - */ | |
19 | -class CatalogLang extends \yii\db\ActiveRecord | |
20 | -{ | |
21 | - /** | |
22 | - * @inheritdoc | |
23 | - */ | |
24 | - public static function tableName() | |
25 | - { | |
26 | - return 'catalog_i18n'; | |
27 | - } | |
28 | - | |
29 | - /** | |
30 | - * @inheritdoc | |
31 | - */ | |
32 | - public function rules() | |
33 | - { | |
34 | - return [ | |
35 | - [['catalog_id', 'lang_id', 'title', 'alias'], 'required'], | |
36 | - [['catalog_id', 'lang_id'], 'integer'], | |
37 | - [['title'], 'string', 'max' => 1024], | |
38 | - [['alias'], 'string', 'max' => 128], | |
39 | - [['meta_title', 'meta_keywords', 'meta_description', 'full_alias'], 'string', 'max' => 255], | |
40 | - [['alias', 'lang_id'], 'unique', 'targetAttribute' => ['alias', 'lang_id'], 'message' => 'The combination of Lang ID and Alias has already been taken.'] | |
41 | - ]; | |
42 | - } | |
43 | - | |
44 | - /** | |
45 | - * @inheritdoc | |
46 | - */ | |
47 | - public function attributeLabels() | |
48 | - { | |
49 | - return [ | |
50 | - 'catalog_id' => Yii::t('app', 'catalog_id'), | |
51 | - 'lang_id' => Yii::t('app', 'Lang ID'), | |
52 | - 'title' => Yii::t('app', 'Title'), | |
53 | - 'alias' => Yii::t('app', 'Alias'), | |
54 | - 'meta_title' => Yii::t('app', 'Meta Title'), | |
55 | - 'meta_keywords' => Yii::t('app', 'Meta Keywords'), | |
56 | - 'meta_description' => Yii::t('app', 'Meta Description'), | |
57 | - 'full_alias' => Yii::t('app', 'Full Alias'), | |
58 | - ]; | |
59 | - } | |
60 | -} |
common/models/Menu.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace common\models; | |
4 | - | |
5 | -use Yii; | |
6 | - | |
7 | - | |
8 | -/** | |
9 | - * This is the model class for table "menu". | |
10 | - * | |
11 | - * @property integer $menu_id | |
12 | - * @property integer $menu_pid | |
13 | - * @property integer $menu_lft | |
14 | - * @property integer $menu_rgt | |
15 | - * @property integer $termin_id | |
16 | - * @property integer $show | |
17 | - * @property integer $sortorder | |
18 | - */ | |
19 | -class Menu extends \yii\db\ActiveRecord | |
20 | -{ | |
21 | - public function getMenuList ($location_name) | |
22 | - { | |
23 | - return yii::$app->db->createCommand(' | |
24 | - SELECT | |
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 | |
34 | - ')->queryAll(); | |
35 | -/* | |
36 | - return $this->find() | |
37 | - ->selectOption('termin_lang.termin_title') | |
38 | - ->from('menu') | |
39 | - ->join( | |
40 | - 'INNER JOIN', | |
41 | - 'termin_lang.termin_id = menu.termin_id', | |
42 | - ['lang_id' => yii::$app->params['lang_id']]) | |
43 | - ->all(); | |
44 | -*/ | |
45 | - } | |
46 | - | |
47 | - // ==== YII ==== | |
48 | - | |
49 | - /** | |
50 | - * @inheritdoc | |
51 | - */ | |
52 | - public static function tableName() | |
53 | - { | |
54 | - return 'menu'; | |
55 | - } | |
56 | - | |
57 | - /** | |
58 | - * @inheritdoc | |
59 | - */ | |
60 | - public function rules() | |
61 | - { | |
62 | - return [ | |
63 | - [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'safe'], | |
64 | - [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'integer'] | |
65 | - ]; | |
66 | - } | |
67 | - | |
68 | - /** | |
69 | - * @inheritdoc | |
70 | - */ | |
71 | - public function attributeLabels() | |
72 | - { | |
73 | - return [ | |
74 | - 'menu_id' => Yii::t('app', 'Menu ID'), | |
75 | - 'menu_pid' => Yii::t('app', 'Menu Pid'), | |
76 | - 'menu_lft' => Yii::t('app', 'Menu Lft'), | |
77 | - 'menu_rgt' => Yii::t('app', 'Menu Rgt'), | |
78 | - 'termin_id' => Yii::t('app', 'Termin ID'), | |
79 | - 'show' => Yii::t('app', 'Show'), | |
80 | - 'sortorder' => Yii::t('app', 'Sortorder'), | |
81 | - ]; | |
82 | - } | |
83 | - | |
84 | -} |
common/models/MenuTree.php
common/models/ShopCategory.php deleted
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 | -} |
common/models/Termin.php deleted
1 | -<?php | |
2 | - | |
3 | -namespace common\models; | |
4 | - | |
5 | -use Yii; | |
6 | -use common\models\SqlQueryBuilder; | |
7 | - | |
8 | -/** | |
9 | - * This is the model class for table "termin". | |
10 | - * | |
11 | - * @property integer $termin_id | |
12 | - * @property integer $termin_type_id | |
13 | - * @property integer $page_id | |
14 | - */ | |
15 | -class Termin extends \yii\db\ActiveRecord | |
16 | -{ | |
17 | - /** | |
18 | - * @inheritdoc | |
19 | - */ | |
20 | - public static function tableName() | |
21 | - { | |
22 | - return 'termin'; | |
23 | - } | |
24 | - | |
25 | - /** | |
26 | - * @inheritdoc | |
27 | - */ | |
28 | - public function rules() | |
29 | - { | |
30 | - return [ | |
31 | - [['termin_type_id', 'page_id'], 'integer'] | |
32 | - ]; | |
33 | - } | |
34 | - | |
35 | - /** | |
36 | - * @inheritdoc | |
37 | - */ | |
38 | - public function attributeLabels() | |
39 | - { | |
40 | - return [ | |
41 | - 'termin_id' => 'Termin ID', | |
42 | - 'termin_type_id' => 'Termin Type ID', | |
43 | - 'page_id' => 'Page ID', | |
44 | - ]; | |
45 | - } | |
46 | - | |
47 | - // ====================== | |
48 | - // ==== MY CASTYL :D ==== | |
49 | - // ====================== | |
50 | - | |
51 | - // ==== Common ==== | |
52 | - | |
53 | - /** | |
54 | - * находит термин и перевод (не учитывает таблицу relation) | |
55 | - * @param array $array | |
56 | - * @return array | |
57 | - */ | |
58 | - static function findTemin (array $array) | |
59 | - { | |
60 | - Tools::ifNotExist ($array, [ | |
61 | - 'return_one' => true, | |
62 | - ]); | |
63 | - | |
64 | - $query = new SqlQueryBuilder(); | |
65 | - $query->from('termin_lang'); | |
66 | - $query->innerJoin( | |
67 | - 'termin', NULL, ' | |
68 | - `termin`.termin_id = `termin_lang`.termin_id | |
69 | - AND `termin`.type = "'.$array['type'].'" | |
70 | - '); | |
71 | - | |
72 | - if (isset ($array['lang_id'])) | |
73 | - { | |
74 | - $query->where('`termin_lang`.lang_id = '.(int)$array['lang_id']); | |
75 | - } | |
76 | - | |
77 | - if (isset ($array['termin_title'])) | |
78 | - { | |
79 | - $query->where('`termin_lang`.termin_title = "'.$array['termin_title'].'"'); | |
80 | - } | |
81 | - | |
82 | - // sql | |
83 | - $result = yii::$app->db->createCommand($query->__toString()); | |
84 | - | |
85 | - return $array['return_one'] !== false ? $result->queryOne() : $result->queryAll(); | |
86 | - } | |
87 | - | |
88 | - /** | |
89 | - * Создает термин, перевод и связь | |
90 | - * @param array $array | |
91 | - * @return int termin_id | |
92 | - */ | |
93 | - static function add (array $array) | |
94 | - { | |
95 | - // термин | |
96 | - $array['termin_id'] = self::addTermin ($array); | |
97 | - | |
98 | - // термин перевод | |
99 | - self::addTerminLang ($array); | |
100 | - | |
101 | - // связи | |
102 | - self::addTerminRelation ($array); | |
103 | - | |
104 | - return $array['termin_id']; | |
105 | - } | |
106 | - | |
107 | - /** | |
108 | - * Ищет и добавляет того чего нет (термин, перевод, relation) <br/> | |
109 | - * В сновном заточен под импорт | |
110 | - * @param array $basic | |
111 | - * @return int termin_id | |
112 | - */ | |
113 | - static function addIfNotExists (array $basic) | |
114 | - { | |
115 | - $termin_id = 0; | |
116 | - | |
117 | - // категория | |
118 | - $termin = Termin::findTemin ($basic); | |
119 | - if (! empty ($termin)) | |
120 | - { | |
121 | - // массив связи | |
122 | - $add = [ | |
123 | - 'termin_id' => $termin['termin_id'], | |
124 | - 'termin_pid' => $basic['termin_pid'], | |
125 | - ]; | |
126 | - | |
127 | - // есть ли связь | |
128 | - $relation = Termin::findRelation ($add); | |
129 | - if (empty ($relation)) | |
130 | - { | |
131 | - // добавляем | |
132 | - Termin::addTerminRelation ($add); | |
133 | - } | |
134 | - | |
135 | - $termin_id = $termin['termin_id']; | |
136 | - } | |
137 | - else | |
138 | - { | |
139 | - // добавляем | |
140 | - $termin_id = Termin::add ($basic); | |
141 | - } | |
142 | - | |
143 | - return $termin_id; | |
144 | - } | |
145 | - | |
146 | - // ==== Termin === | |
147 | - | |
148 | - static function addTermin (array $array) | |
149 | - { | |
150 | - Tools::ifNotExist ($array, [ | |
151 | - 'type' => 'H', | |
152 | - 'page_id' => 0, | |
153 | - ]); | |
154 | - | |
155 | - Yii::$app->db->createCommand()->insert( | |
156 | - 'termin', [ | |
157 | - 'type' => $array['type'], | |
158 | - 'page_id' => (int)$array['page_id'], | |
159 | - ] | |
160 | - )->execute(); | |
161 | - | |
162 | - return Yii::$app->db->getLastInsertID(); | |
163 | - } | |
164 | - | |
165 | - // ==== Termin Lang ==== | |
166 | - | |
167 | - static function addTerminLang (array $array) | |
168 | - { | |
169 | - Tools::ifNotExist ($array, [ | |
170 | - 'template_id' => 0, | |
171 | - 'termin_alias' => strtolower (Tools::translit ($array['termin_title'])), | |
172 | - ]); | |
173 | - | |
174 | - Yii::$app->db->createCommand()->insert( | |
175 | - 'termin_lang', [ | |
176 | - 'termin_id' => $array['termin_id'], | |
177 | - 'termin_title' => $array['termin_title'], | |
178 | - 'termin_alias' => $array['termin_alias'], | |
179 | - 'template_id' => (int)$array['template_id'], | |
180 | - 'lang_id' => (int)$array['lang_id'], | |
181 | - ] | |
182 | - )->execute(); | |
183 | - } | |
184 | - | |
185 | - // ==== Termin Relation ==== | |
186 | - | |
187 | - static function findRelation (array $array) | |
188 | - { | |
189 | - $query = new SqlQueryBuilder(); | |
190 | - $query->from('termin_relation'); | |
191 | - | |
192 | - if (isset ($array['termin_id'])) | |
193 | - { | |
194 | - $query->where('termin_id = "'.$array['termin_id'].'"'); | |
195 | - } | |
196 | - | |
197 | - if (isset ($array['termin_pid'])) | |
198 | - { | |
199 | - $query->where('termin_pid = "'.$array['termin_pid'].'"'); | |
200 | - } | |
201 | - | |
202 | - // sql | |
203 | - $result = yii::$app->db->createCommand($query->__toString()); | |
204 | - | |
205 | - return isset ($array['return_one']) ? $result->queryOne() : $result->queryAll(); | |
206 | - } | |
207 | - | |
208 | - static function addTerminRelation (array $array) | |
209 | - { | |
210 | - Tools::ifNotExist ($array, [ | |
211 | - 'termin_pid' => 0, | |
212 | - 'is_default' => 1, | |
213 | - ]); | |
214 | - | |
215 | - Yii::$app->db->createCommand()->insert( | |
216 | - 'termin_relation', [ | |
217 | - 'termin_id' => (int)$array['termin_id'], | |
218 | - 'termin_pid' => (int)$array['termin_pid'], | |
219 | - 'is_default' => (int)$array['is_default'], | |
220 | - ] | |
221 | - )->execute(); | |
222 | - | |
223 | - return Yii::$app->db->getLastInsertID(); | |
224 | - } | |
225 | -} |
common/translation/ru/action.php deleted
common/translation/ru/app.php
1 | 1 | <?php |
2 | + | |
2 | 3 | return [ |
4 | + | |
5 | + // Ярик | |
3 | 6 | 'Create' => 'Добавить', |
4 | 7 | 'Settings' => 'Настройки', |
5 | 8 | 'languages' => 'Языки', |
... | ... | @@ -58,4 +61,26 @@ return [ |
58 | 61 | 'Select parent' => 'Выберать родителя', |
59 | 62 | 'Blog' => 'Блог', |
60 | 63 | 'Static pages' => 'Статические страницы', |
64 | + | |
65 | + // Вова | |
66 | + 'page' => 'Страница', | |
67 | + 'date_add' => 'Дата добавления', | |
68 | + 'template' => 'Шаблон', | |
69 | + 'image' => 'Картинка', | |
70 | + 'title' => 'Заголовок', | |
71 | + 'meta_title' => 'Meta Title', | |
72 | + 'meta_description' => 'Meta Description', | |
73 | + 'text' => 'Текст', | |
74 | + 'page_alias' => 'alias', | |
75 | + 'lang_id' => 'ID языка', | |
76 | + 'common' => 'Общее', | |
77 | + 'lang' => 'Языковые переменные', | |
78 | + 'termin' => 'Термин', | |
79 | + 'related' => 'Связанные', | |
80 | + 'menu' => 'Меню', | |
81 | + 'location' => 'Разположение', | |
82 | + 'book' => 'Справочник', | |
83 | + | |
84 | + // Дима | |
85 | + | |
61 | 86 | ]; |
62 | 87 | \ No newline at end of file | ... | ... |
common/translation/ru/field.php deleted
1 | -<?php | |
2 | - | |
3 | -return [ | |
4 | - 'page' => 'Страница', | |
5 | - 'date_add' => 'Дата добавления', | |
6 | - 'template' => 'Шаблон', | |
7 | - 'image' => 'Картинка', | |
8 | - 'title' => 'Заголовок', | |
9 | - 'meta_title' => 'Meta Title', | |
10 | - 'meta_description' => 'Meta Description', | |
11 | - 'text' => 'Текст', | |
12 | - 'page_alias' => 'alias', | |
13 | - 'lang_id' => 'ID языка', | |
14 | - 'common' => 'Общее', | |
15 | - 'lang' => 'Языковые переменные', | |
16 | -]; | |
17 | 0 | \ No newline at end of file |
common/translation/uk/action.php deleted
common/translation/uk/field.php deleted
1 | -<?php | |
2 | - | |
3 | -return [ | |
4 | - 'page' => 'Сторінка', | |
5 | - 'date_add' => 'Дата додання', | |
6 | - 'template' => 'Шаблон', | |
7 | - 'image' => 'Картинка', | |
8 | - 'title' => 'Заголовок', | |
9 | - 'meta_title' => 'Meta Title', | |
10 | - 'meta_description' => 'Meta Description', | |
11 | - 'text' => 'Текст', | |
12 | - 'page_alias' => 'alias', | |
13 | - 'lang_id' => 'ID мови', | |
14 | - 'common' => 'Загальне', | |
15 | - 'lang' => 'Мовні змінні', | |
16 | -]; |