Commit 20afc52f2762505edc2310dfcaba004fcc2af924
1 parent
e130021e
+ термины и меню (backup 2)
Showing
27 changed files
with
1488 additions
and
3 deletions
Show diff stats
backend/config/main.php
@@ -16,7 +16,7 @@ return [ | @@ -16,7 +16,7 @@ return [ | ||
16 | 'bootstrap' => ['log'], | 16 | 'bootstrap' => ['log'], |
17 | 'modules' => [ | 17 | 'modules' => [ |
18 | 'permit' => [ | 18 | 'permit' => [ |
19 | - 'class' => 'common\components\developeruz\db_rbac\Yii2DbRbac', | 19 | + 'class' => 'developeruz\db_rbac\Yii2DbRbac', |
20 | 'params' => [ | 20 | 'params' => [ |
21 | 'userClass' => 'common\models\User' | 21 | 'userClass' => 'common\models\User' |
22 | ] | 22 | ] |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\controllers; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use backend\models\MenuLocation; | ||
7 | +use backend\models\MenuSearchLocation; | ||
8 | +use yii\web\Controller; | ||
9 | +use yii\web\NotFoundHttpException; | ||
10 | +use yii\filters\VerbFilter; | ||
11 | + | ||
12 | +/** | ||
13 | + * MenuLocationController implements the CRUD actions for MenuLocation model. | ||
14 | + */ | ||
15 | +class MenuLocationController extends Controller | ||
16 | +{ | ||
17 | + public function behaviors() | ||
18 | + { | ||
19 | + return [ | ||
20 | + 'verbs' => [ | ||
21 | + 'class' => VerbFilter::className(), | ||
22 | + 'actions' => [ | ||
23 | + 'delete' => ['post'], | ||
24 | + ], | ||
25 | + ], | ||
26 | + ]; | ||
27 | + } | ||
28 | + | ||
29 | + /** | ||
30 | + * Lists all MenuLocation models. | ||
31 | + * @return mixed | ||
32 | + */ | ||
33 | + public function actionIndex() | ||
34 | + { | ||
35 | + $searchModel = new MenuSearchLocation(); | ||
36 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
37 | + | ||
38 | + return $this->render('index', [ | ||
39 | + 'searchModel' => $searchModel, | ||
40 | + 'dataProvider' => $dataProvider, | ||
41 | + ]); | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Displays a single MenuLocation model. | ||
46 | + * @param integer $id | ||
47 | + * @return mixed | ||
48 | + */ | ||
49 | + public function actionView($id) | ||
50 | + { | ||
51 | + return $this->render('view', [ | ||
52 | + 'model' => $this->findModel($id), | ||
53 | + ]); | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Creates a new MenuLocation model. | ||
58 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
59 | + * @return mixed | ||
60 | + */ | ||
61 | + public function actionCreate() | ||
62 | + { | ||
63 | + $model = new MenuLocation(); | ||
64 | + | ||
65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
66 | + return $this->redirect(['view', 'id' => $model->menu_location_id]); | ||
67 | + } else { | ||
68 | + return $this->render('create', [ | ||
69 | + 'model' => $model, | ||
70 | + ]); | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Updates an existing MenuLocation model. | ||
76 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
77 | + * @param integer $id | ||
78 | + * @return mixed | ||
79 | + */ | ||
80 | + public function actionUpdate($id) | ||
81 | + { | ||
82 | + $model = $this->findModel($id); | ||
83 | + | ||
84 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
85 | + return $this->redirect(['view', 'id' => $model->menu_location_id]); | ||
86 | + } else { | ||
87 | + return $this->render('update', [ | ||
88 | + 'model' => $model, | ||
89 | + ]); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Deletes an existing MenuLocation model. | ||
95 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
96 | + * @param integer $id | ||
97 | + * @return mixed | ||
98 | + */ | ||
99 | + public function actionDelete($id) | ||
100 | + { | ||
101 | + $this->findModel($id)->delete(); | ||
102 | + | ||
103 | + return $this->redirect(['index']); | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * Finds the MenuLocation model based on its primary key value. | ||
108 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
109 | + * @param integer $id | ||
110 | + * @return MenuLocation the loaded model | ||
111 | + * @throws NotFoundHttpException if the model cannot be found | ||
112 | + */ | ||
113 | + protected function findModel($id) | ||
114 | + { | ||
115 | + if (($model = MenuLocation::findOne($id)) !== null) { | ||
116 | + return $model; | ||
117 | + } else { | ||
118 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
119 | + } | ||
120 | + } | ||
121 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\controllers; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use backend\models\Termin; | ||
7 | +use backend\models\TerminSearch; | ||
8 | +use yii\web\Controller; | ||
9 | +use yii\web\NotFoundHttpException; | ||
10 | +use yii\filters\VerbFilter; | ||
11 | +use backend\models\TerminLang; | ||
12 | +use backend\models\TerminStructure; | ||
13 | + | ||
14 | +/** | ||
15 | + * TerminController implements the CRUD actions for Termin model. | ||
16 | + */ | ||
17 | +class TerminController extends Controller | ||
18 | +{ | ||
19 | + public function behaviors() | ||
20 | + { | ||
21 | + return [ | ||
22 | + 'access' => [ | ||
23 | + 'class' => AccessControl::className(), | ||
24 | + 'except' => ['login', 'error', 'index', 'create', 'update'], | ||
25 | + 'rules' => [ | ||
26 | + [ | ||
27 | + 'allow' => true, | ||
28 | + 'roles' => ['admin'] | ||
29 | + ], | ||
30 | + ], | ||
31 | + ], | ||
32 | + 'verbs' => [ | ||
33 | + 'class' => VerbFilter::className(), | ||
34 | + 'actions' => [ | ||
35 | + 'logout' => ['post'], | ||
36 | + 'delete-req' => ['post'] | ||
37 | + ], | ||
38 | + ], | ||
39 | + ]; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Lists all Termin models. | ||
44 | + * @return mixed | ||
45 | + */ | ||
46 | + public function actionIndex() | ||
47 | + { | ||
48 | + $searchModel = new TerminSearch(); | ||
49 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
50 | + | ||
51 | + return $this->render('index', [ | ||
52 | + 'searchModel' => $searchModel, | ||
53 | + 'dataProvider' => $dataProvider, | ||
54 | + ]); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Displays a single Termin model. | ||
59 | + * @param integer $id | ||
60 | + * @return mixed | ||
61 | + */ | ||
62 | + public function actionView($id) | ||
63 | + { | ||
64 | + return $this->render('view', [ | ||
65 | + 'model' => $this->findModel($id), | ||
66 | + ]); | ||
67 | + } | ||
68 | + | ||
69 | + /** | ||
70 | + * Creates a new Termin model. | ||
71 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
72 | + * @return mixed | ||
73 | + */ | ||
74 | + public function actionCreate() | ||
75 | + { | ||
76 | + $model = new Termin(); | ||
77 | + $model_lang = new TerminLang(); | ||
78 | + | ||
79 | + if ($model->load(Yii::$app->request->post()) | ||
80 | + && $model_lang->load(Yii::$app->request->post())) | ||
81 | + { | ||
82 | + $model->save(); | ||
83 | + $model_lang->termin_id = $model->termin_id; | ||
84 | + $model_lang->save(); | ||
85 | + | ||
86 | + return $this->redirect(['view', 'id' => $model->termin_id]); | ||
87 | + } | ||
88 | + else | ||
89 | + { | ||
90 | + return $this->render('create', [ | ||
91 | + 'model' => $model, | ||
92 | + 'model_lang' => $model_lang, | ||
93 | + ]); | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Updates an existing Termin model. | ||
99 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
100 | + * @param integer $id | ||
101 | + * @return mixed | ||
102 | + */ | ||
103 | + public function actionUpdate($id) | ||
104 | + { | ||
105 | + $model = $this->findModel($id); | ||
106 | + $model_lang = TerminLang::findOne($id); | ||
107 | + $model_pid = TerminStructure::findOne($id)->getRelation('terminPid')->one(); | ||
108 | + | ||
109 | + //var_dump(Yii::$app->request->post()); | ||
110 | + //var_dump($model_pid->termin->termin_id); die; | ||
111 | + | ||
112 | + if ($model->load(Yii::$app->request->post()) | ||
113 | + && $model_lang->load(Yii::$app->request->post()) | ||
114 | + && $model_pid->load(Yii::$app->request->post()) | ||
115 | + ) | ||
116 | + { | ||
117 | + $model->save(); | ||
118 | + $model_lang->save(); | ||
119 | + $model_pid->termin_pid = $model_pid->termin->termin_id; | ||
120 | + | ||
121 | + return $this->redirect(['view', 'id' => $model->termin_id]); | ||
122 | + } | ||
123 | + else | ||
124 | + { | ||
125 | + return $this->render('update', [ | ||
126 | + 'model' => $model, | ||
127 | + 'model_lang' => $model_lang, | ||
128 | + 'model_pid' => $model_pid, | ||
129 | + ]); | ||
130 | + } | ||
131 | + } | ||
132 | + | ||
133 | + /** | ||
134 | + * Deletes an existing Termin model. | ||
135 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
136 | + * @param integer $id | ||
137 | + * @return mixed | ||
138 | + */ | ||
139 | + public function actionDelete($id) | ||
140 | + { | ||
141 | + $this->findModel($id)->delete(); | ||
142 | + | ||
143 | + return $this->redirect(['index']); | ||
144 | + } | ||
145 | + | ||
146 | + /** | ||
147 | + * Finds the Termin model based on its primary key value. | ||
148 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
149 | + * @param integer $id | ||
150 | + * @return Termin the loaded model | ||
151 | + * @throws NotFoundHttpException if the model cannot be found | ||
152 | + */ | ||
153 | + protected function findModel($id) | ||
154 | + { | ||
155 | + if (($model = Termin::findOne($id)) !== null) { | ||
156 | + return $model; | ||
157 | + } else { | ||
158 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
159 | + } | ||
160 | + } | ||
161 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "menu". | ||
9 | + * | ||
10 | + * @property integer $menu_id | ||
11 | + * @property integer $menu_pid | ||
12 | + * @property integer $level | ||
13 | + * @property integer $termin_id | ||
14 | + * @property integer $show | ||
15 | + * @property integer $is_open | ||
16 | + * @property integer $menu_location_id | ||
17 | + * @property integer $sortorder | ||
18 | + * @property string $name | ||
19 | + * @property string $url | ||
20 | + * | ||
21 | + * @property Termin $termin | ||
22 | + */ | ||
23 | +class Menu extends \yii\db\ActiveRecord | ||
24 | +{ | ||
25 | + /** | ||
26 | + * @inheritdoc | ||
27 | + */ | ||
28 | + public static function tableName() | ||
29 | + { | ||
30 | + return 'menu'; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * @inheritdoc | ||
35 | + */ | ||
36 | + public function rules() | ||
37 | + { | ||
38 | + return [ | ||
39 | + [['menu_id', 'menu_pid', 'level', 'termin_id', 'show', 'is_open', 'menu_location_id', 'sortorder'], 'required'], | ||
40 | + [['menu_id', 'menu_pid', 'level', 'termin_id', 'show', 'is_open', 'menu_location_id', 'sortorder'], 'integer'], | ||
41 | + [['name', 'url'], 'string', 'max' => 250] | ||
42 | + ]; | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * @inheritdoc | ||
47 | + */ | ||
48 | + public function attributeLabels() | ||
49 | + { | ||
50 | + return [ | ||
51 | + 'menu_id' => Yii::t('app', 'Menu ID'), | ||
52 | + 'menu_pid' => Yii::t('app', 'Menu Pid'), | ||
53 | + 'level' => Yii::t('app', 'Level'), | ||
54 | + 'termin_id' => Yii::t('app', 'Termin ID'), | ||
55 | + 'show' => Yii::t('app', 'Show'), | ||
56 | + 'is_open' => Yii::t('app', 'Is Open'), | ||
57 | + 'menu_location_id' => Yii::t('app', 'Menu Location ID'), | ||
58 | + 'sortorder' => Yii::t('app', 'Sortorder'), | ||
59 | + 'name' => Yii::t('app', 'Name'), | ||
60 | + 'url' => Yii::t('app', 'Url'), | ||
61 | + ]; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * @return \yii\db\ActiveQuery | ||
66 | + */ | ||
67 | + public function getTermin() | ||
68 | + { | ||
69 | + return $this->hasOne(Termin::className(), ['termin_id' => 'termin_id']); | ||
70 | + } | ||
71 | + | ||
72 | + public function getMenuList ($location_name) | ||
73 | + { | ||
74 | + return yii::$app->db->createCommand(' | ||
75 | + SELECT | ||
76 | + menu.menu_id, menu.menu_pid, menu.level, | ||
77 | + termin_lang.termin_title, termin_lang.termin_alias | ||
78 | + FROM menu | ||
79 | + INNER JOIN menu_location ON menu_location.menu_location_id = menu.menu_location_id | ||
80 | + AND menu_location.menu_location_name = \''.$location_name.'\' | ||
81 | + INNER JOIN termin ON termin.termin_id = menu.termin_id | ||
82 | + INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | ||
83 | + AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' | ||
84 | + ORDER BY menu.level ASC, menu.sortorder ASC | ||
85 | + ')->queryAll(); | ||
86 | +/* | ||
87 | + return $this->find() | ||
88 | + ->selectOption('termin_lang.termin_title') | ||
89 | + ->from('menu') | ||
90 | + ->join( | ||
91 | + 'INNER JOIN', | ||
92 | + 'termin_lang.termin_id = menu.termin_id', | ||
93 | + ['lang_id' => yii::$app->params['lang_id']]) | ||
94 | + ->all(); | ||
95 | + */ | ||
96 | + } | ||
97 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "menu_location". | ||
9 | + * | ||
10 | + * @property integer $menu_location_id | ||
11 | + * @property string $menu_location_name | ||
12 | + * | ||
13 | + * @property MenuLocationLang[] $menuLocationLangs | ||
14 | + * @property Language[] $langs | ||
15 | + */ | ||
16 | +class MenuLocation extends \yii\db\ActiveRecord | ||
17 | +{ | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public static function tableName() | ||
22 | + { | ||
23 | + return 'menu_location'; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function rules() | ||
30 | + { | ||
31 | + return [ | ||
32 | + [['menu_location_id'], 'required'], | ||
33 | + [['menu_location_id'], 'integer'], | ||
34 | + [['menu_location_name'], 'string', 'max' => 250] | ||
35 | + ]; | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * @inheritdoc | ||
40 | + */ | ||
41 | + public function attributeLabels() | ||
42 | + { | ||
43 | + return [ | ||
44 | + 'menu_location_id' => Yii::t('app', 'Menu Location ID'), | ||
45 | + 'menu_location_name' => Yii::t('app', 'Menu Location Name'), | ||
46 | + ]; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * @return \yii\db\ActiveQuery | ||
51 | + */ | ||
52 | + public function getMenuLocationLangs() | ||
53 | + { | ||
54 | + return $this->hasMany(MenuLocationLang::className(), ['menu_location_id' => 'menu_location_id']); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * @return \yii\db\ActiveQuery | ||
59 | + */ | ||
60 | + public function getLangs() | ||
61 | + { | ||
62 | + return $this->hasMany(Language::className(), ['language_id' => 'lang_id'])->viaTable('menu_location_lang', ['menu_location_id' => 'menu_location_id']); | ||
63 | + } | ||
64 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "menu_location_lang". | ||
9 | + * | ||
10 | + * @property integer $menu_location_id | ||
11 | + * @property string $menu_location_title | ||
12 | + * @property integer $lang_id | ||
13 | + * | ||
14 | + * @property Language $lang | ||
15 | + * @property MenuLocation $menuLocation | ||
16 | + */ | ||
17 | +class MenuLocationLang extends \yii\db\ActiveRecord | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public static function tableName() | ||
23 | + { | ||
24 | + return 'menu_location_lang'; | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public function rules() | ||
31 | + { | ||
32 | + return [ | ||
33 | + [['menu_location_id', 'menu_location_title', 'lang_id'], 'required'], | ||
34 | + [['menu_location_id', 'lang_id'], 'integer'], | ||
35 | + [['menu_location_title'], 'string', 'max' => 250] | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'menu_location_id' => Yii::t('app', 'Menu Location ID'), | ||
46 | + 'menu_location_title' => Yii::t('app', 'Menu Location Title'), | ||
47 | + 'lang_id' => Yii::t('app', 'Lang ID'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getLang() | ||
55 | + { | ||
56 | + return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * @return \yii\db\ActiveQuery | ||
61 | + */ | ||
62 | + public function getMenuLocation() | ||
63 | + { | ||
64 | + return $this->hasOne(MenuLocation::className(), ['menu_location_id' => 'menu_location_id']); | ||
65 | + } | ||
66 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use backend\models\MenuLocation; | ||
9 | + | ||
10 | +/** | ||
11 | + * MenuLocationSearch represents the model behind the search form about `backend\models\MenuLocation`. | ||
12 | + */ | ||
13 | +class MenuLocationSearch extends MenuLocation | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['menu_location_id'], 'integer'], | ||
22 | + [['menu_location_name'], '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 = MenuLocation::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 | + 'menu_location_id' => $this->menu_location_id, | ||
60 | + ]); | ||
61 | + | ||
62 | + $query->andFilterWhere(['like', 'menu_location_name', $this->menu_location_name]); | ||
63 | + | ||
64 | + return $dataProvider; | ||
65 | + } | ||
66 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use backend\models\Menu; | ||
9 | + | ||
10 | +/** | ||
11 | + * MenuSearch represents the model behind the search form about `backend\models\Menu`. | ||
12 | + */ | ||
13 | +class MenuSearch extends Menu | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['menu_id', 'menu_pid', 'level', 'termin_id', 'show', 'is_open', 'menu_location_id', 'sortorder'], 'integer'], | ||
22 | + [['name', 'url'], '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 = Menu::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 | + 'menu_id' => $this->menu_id, | ||
60 | + 'menu_pid' => $this->menu_pid, | ||
61 | + 'level' => $this->level, | ||
62 | + 'termin_id' => $this->termin_id, | ||
63 | + 'show' => $this->show, | ||
64 | + 'is_open' => $this->is_open, | ||
65 | + 'menu_location_id' => $this->menu_location_id, | ||
66 | + 'sortorder' => $this->sortorder, | ||
67 | + ]); | ||
68 | + | ||
69 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
70 | + ->andFilterWhere(['like', 'url', $this->url]); | ||
71 | + | ||
72 | + return $dataProvider; | ||
73 | + } | ||
74 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use common\models\Tools; | ||
7 | + | ||
8 | +/** | ||
9 | + * This is the model class for table "termin". | ||
10 | + * | ||
11 | + * @property integer $termin_id | ||
12 | + * @property string $termin_name | ||
13 | + * @property integer $is_book | ||
14 | + * | ||
15 | + * @property Menu[] $menus | ||
16 | + * @property TerminLang[] $terminLangs | ||
17 | + * @property Language[] $langs | ||
18 | + * @property TerminStructure[] $terminStructures | ||
19 | + */ | ||
20 | +class Termin extends \yii\db\ActiveRecord | ||
21 | +{ | ||
22 | + var $termin_title; | ||
23 | + var $termin_pid; | ||
24 | + | ||
25 | + /** | ||
26 | + * @inheritdoc | ||
27 | + */ | ||
28 | + public static function tableName() | ||
29 | + { | ||
30 | + return 'termin'; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * @inheritdoc | ||
35 | + */ | ||
36 | + public function rules() | ||
37 | + { | ||
38 | + return [ | ||
39 | + [['is_book'], 'integer'], | ||
40 | + [['termin_pid'], 'safe'], | ||
41 | + [['termin_title'], 'string', 'max' => 250], | ||
42 | + [['termin_name'], 'string', 'max' => 250] | ||
43 | + ]; | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * @inheritdoc | ||
48 | + */ | ||
49 | + public function attributeLabels() | ||
50 | + { | ||
51 | + return [ | ||
52 | + 'termin_id' => Yii::t('app', 'termin'), | ||
53 | + 'termin_name' => Yii::t('app', 'name').' (SYSTEM NAME)', | ||
54 | + 'is_book' => Yii::t('app', 'book'), | ||
55 | + ]; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Выполняет поиск по параметрам | ||
60 | + * @param array $param принимает [termin_id, lang_id, return_one, return_field, show_all] | ||
61 | + * @return array one | array all | string значение масива | ||
62 | + */ | ||
63 | + public function finInfo (array $params = []) | ||
64 | + { | ||
65 | + Tools::ifNotExist ($params, array ( | ||
66 | + 'termin_id' => false, | ||
67 | + 'termin_pid' => false, | ||
68 | + 'lang_id' => Yii::$app->params['lang_id'], | ||
69 | + 'return_one' => false, | ||
70 | + 'return_field' => false, | ||
71 | + 'show_all' => false, | ||
72 | + 'to_array' => true, | ||
73 | + 'pid_title' => false, | ||
74 | + )); | ||
75 | + | ||
76 | + $WHERE = $SELECT = array (); | ||
77 | + | ||
78 | + $model = new self(); | ||
79 | + | ||
80 | + $SELECT[] = 'termin.*'; | ||
81 | + $query = $model->find(); | ||
82 | + | ||
83 | + if ($params['termin_id']) | ||
84 | + { | ||
85 | + $WHERE['termin.termin_id'] = $params['termin_id']; | ||
86 | + } | ||
87 | + | ||
88 | + // перевод | ||
89 | + $SELECT[] = 'termin_lang.*'; | ||
90 | + $query->join( | ||
91 | + 'INNER JOIN', 'termin_lang', | ||
92 | + 'termin.termin_id = termin_lang.termin_id' | ||
93 | + ); | ||
94 | + | ||
95 | + if ($params['lang_id']) | ||
96 | + { | ||
97 | + $WHERE['termin_lang.lang_id'] = $params['lang_id']; | ||
98 | + } | ||
99 | + | ||
100 | + // структура | ||
101 | + $SELECT[] = 'termin_structure.*'; | ||
102 | + $query->join( | ||
103 | + 'INNER JOIN', 'termin_structure', | ||
104 | + 'termin.termin_id = termin_structure.termin_id' | ||
105 | + ); | ||
106 | + | ||
107 | + if ($params['termin_pid'] !== false) | ||
108 | + { | ||
109 | + $WHERE['termin_structure.termin_pid'] = $params['termin_pid']; | ||
110 | + } | ||
111 | + | ||
112 | + if ($params['pid_title']) | ||
113 | + { | ||
114 | + $SELECT[] = 'termin_pid_lang.termin_title as termin_pid_title'; | ||
115 | + $query->join( | ||
116 | + 'LEFT JOIN', 'termin_lang as termin_pid_lang', | ||
117 | + 'termin_pid_lang.termin_id = termin_structure.termin_pid' | ||
118 | + ); | ||
119 | + } | ||
120 | + | ||
121 | + // SELECT | ||
122 | + if (! empty ($SELECT)) | ||
123 | + { | ||
124 | + $query->select($SELECT); | ||
125 | + } | ||
126 | + | ||
127 | + // WHERE | ||
128 | + if (! empty ($WHERE)) | ||
129 | + { | ||
130 | + $query->where($WHERE); | ||
131 | + } | ||
132 | + | ||
133 | + if ($params['to_array']) | ||
134 | + { | ||
135 | + $query = $query->asArray(); | ||
136 | + } | ||
137 | + | ||
138 | + if ($params['return_one'] || $params['return_field']) | ||
139 | + { | ||
140 | + | ||
141 | + $result = $params['return_field'] ? $query->one($params['return_field']) : $query->one(); | ||
142 | + } | ||
143 | + else | ||
144 | + { | ||
145 | + $result = $query->all(); | ||
146 | + } | ||
147 | + | ||
148 | + return $result; | ||
149 | + } | ||
150 | + | ||
151 | + /** | ||
152 | + * @return \yii\db\ActiveQuery | ||
153 | + */ | ||
154 | + public function getMenus() | ||
155 | + { | ||
156 | + return $this->hasMany(Menu::className(), ['termin_id' => 'termin_id']); | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * @return \yii\db\ActiveQuery | ||
161 | + */ | ||
162 | + public function getTerminLangs() | ||
163 | + { | ||
164 | + return $this->hasMany(TerminLang::className(), ['termin_id' => 'termin_id']); | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * @return \yii\db\ActiveQuery | ||
169 | + */ | ||
170 | + public function getLangs() | ||
171 | + { | ||
172 | + return $this->hasMany(Language::className(), ['language_id' => 'lang_id']) | ||
173 | + ->viaTable('termin_lang', ['termin_id' => 'termin_id']); | ||
174 | + } | ||
175 | + | ||
176 | + /** | ||
177 | + * @return \yii\db\ActiveQuery | ||
178 | + */ | ||
179 | + public function getTerminStructures() | ||
180 | + { | ||
181 | + return $this->hasMany(TerminStructure::className(), ['termin_id' => 'termin_id']); | ||
182 | + } | ||
183 | + | ||
184 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "termin_lang". | ||
9 | + * | ||
10 | + * @property integer $termin_id | ||
11 | + * @property integer $lang_id | ||
12 | + * @property string $termin_title | ||
13 | + * @property string $termin_alias | ||
14 | + * | ||
15 | + * @property Language $lang | ||
16 | + * @property Termin $termin | ||
17 | + */ | ||
18 | +class TerminLang extends \yii\db\ActiveRecord | ||
19 | +{ | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + */ | ||
23 | + public static function tableName() | ||
24 | + { | ||
25 | + return 'termin_lang'; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public function rules() | ||
32 | + { | ||
33 | + return [ | ||
34 | + [['lang_id'], 'required'], | ||
35 | + [['lang_id'], 'integer'], | ||
36 | + [['termin_title', 'termin_alias'], 'string', 'max' => 250] | ||
37 | + ]; | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * @inheritdoc | ||
42 | + */ | ||
43 | + public function attributeLabels() | ||
44 | + { | ||
45 | + return [ | ||
46 | + 'termin_id' => Yii::t('app', 'Termin ID'), | ||
47 | + 'lang_id' => Yii::t('app', 'Lang ID'), | ||
48 | + 'termin_title' => Yii::t('app', 'Termin Title'), | ||
49 | + 'termin_alias' => Yii::t('app', 'Termin Alias'), | ||
50 | + ]; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * @return \yii\db\ActiveQuery | ||
55 | + */ | ||
56 | + public function getLang() | ||
57 | + { | ||
58 | + return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * @return \yii\db\ActiveQuery | ||
63 | + */ | ||
64 | + public function getTermin() | ||
65 | + { | ||
66 | + return $this->hasOne(Termin::className(), ['termin_id' => 'termin_id']); | ||
67 | + } | ||
68 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "termin_relation". | ||
9 | + * | ||
10 | + * @property integer $termin_id | ||
11 | + * @property integer $termin_id_related | ||
12 | + */ | ||
13 | +class TerminRelation extends \yii\db\ActiveRecord | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public static function tableName() | ||
19 | + { | ||
20 | + return 'termin_relation'; | ||
21 | + } | ||
22 | + | ||
23 | + /** | ||
24 | + * @inheritdoc | ||
25 | + */ | ||
26 | + public function rules() | ||
27 | + { | ||
28 | + return [ | ||
29 | + [['termin_id', 'termin_id_related'], 'integer'] | ||
30 | + ]; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * @inheritdoc | ||
35 | + */ | ||
36 | + public function attributeLabels() | ||
37 | + { | ||
38 | + return [ | ||
39 | + 'termin_id' => Yii::t('app', 'Termin ID'), | ||
40 | + 'termin_id_related' => Yii::t('app', 'Termin Id Related'), | ||
41 | + ]; | ||
42 | + } | ||
43 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use backend\models\Termin; | ||
9 | + | ||
10 | +/** | ||
11 | + * TerminSearch represents the model behind the search form about `backend\models\Termin`. | ||
12 | + */ | ||
13 | +class TerminSearch extends Termin | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['termin_id', 'is_book'], 'integer'], | ||
22 | + [['termin_name'], '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 = Termin::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 | + 'is_book' => $this->is_book, | ||
61 | + ]); | ||
62 | + | ||
63 | + $query->andFilterWhere(['like', 'termin_name', $this->termin_name]); | ||
64 | + | ||
65 | + return $dataProvider; | ||
66 | + } | ||
67 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "termin_structure". | ||
9 | + * | ||
10 | + * @property integer $termin_id | ||
11 | + * @property integer $termin_pid | ||
12 | + * | ||
13 | + * @property Termin $termin | ||
14 | + */ | ||
15 | +class TerminStructure extends \yii\db\ActiveRecord | ||
16 | +{ | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public static function tableName() | ||
21 | + { | ||
22 | + return 'termin_structure'; | ||
23 | + } | ||
24 | + | ||
25 | + /** | ||
26 | + * @inheritdoc | ||
27 | + */ | ||
28 | + public function rules() | ||
29 | + { | ||
30 | + return [ | ||
31 | + [['termin_id', 'termin_pid'], 'required'], | ||
32 | + [['termin_id', 'termin_pid'], 'integer'] | ||
33 | + ]; | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * @inheritdoc | ||
38 | + */ | ||
39 | + public function attributeLabels() | ||
40 | + { | ||
41 | + return [ | ||
42 | + 'termin_id' => Yii::t('app', 'Termin ID'), | ||
43 | + 'termin_pid' => Yii::t('app', 'Termin Pid'), | ||
44 | + ]; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * @return \yii\db\ActiveQuery | ||
49 | + */ | ||
50 | + public function getTermin() | ||
51 | + { | ||
52 | + return $this->hasOne(Termin::className(), ['termin_id' => 'termin_id']); | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * @return \yii\db\ActiveQuery | ||
57 | + */ | ||
58 | + public function getTerminPid() | ||
59 | + { | ||
60 | + return $this->hasMany(TerminLang::className(), ['termin_id' => 'termin_pid']); | ||
61 | + } | ||
62 | +} |
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\MenuLocation */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="menu-location-form"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin(); ?> | ||
14 | + | ||
15 | + <?= $form->field($model, 'menu_location_id')->textInput() ?> | ||
16 | + | ||
17 | + <?= $form->field($model, 'menu_location_name')->textInput(['maxlength' => true]) ?> | ||
18 | + | ||
19 | + <?= $form->field($model->menuLocationLangs[0], 'menu_location_title')->textInput() ?> | ||
20 | + | ||
21 | + <div class="form-group"> | ||
22 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
23 | + </div> | ||
24 | + | ||
25 | + <?php ActiveForm::end(); ?> | ||
26 | + | ||
27 | +</div> |
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\MenuSearchLocation */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="menu-location-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'menu_location_id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'menu_location_name') ?> | ||
21 | + | ||
22 | + <div class="form-group"> | ||
23 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
24 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
25 | + </div> | ||
26 | + | ||
27 | + <?php ActiveForm::end(); ?> | ||
28 | + | ||
29 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model backend\models\MenuLocation */ | ||
8 | + | ||
9 | +$this->title = Yii::t('app', 'Create Menu Location'); | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menu Locations'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="menu-location-create"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + ]) ?> | ||
20 | + | ||
21 | +</div> |
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\MenuLocation */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = Yii::t('app', 'Menu Locations'); | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="menu-location-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').' '.Yii::t('app', 'location'), ['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 | + 'menu_location_id', | ||
29 | + 'menu_location_name', | ||
30 | + [ | ||
31 | + 'attribute' => 'menu_location_title', | ||
32 | + 'value' => function ($model) | ||
33 | + { | ||
34 | + | ||
35 | + return $model->menuLocationLangs[0]->menu_location_title; | ||
36 | + }, | ||
37 | + ], | ||
38 | + | ||
39 | + ['class' => 'yii\grid\ActionColumn'], | ||
40 | + ], | ||
41 | + ]); ?> | ||
42 | + | ||
43 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | +/* @var $this yii\web\View */ | ||
6 | +/* @var $model backend\models\MenuLocation */ | ||
7 | + | ||
8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
9 | + 'modelClass' => 'Menu Location', | ||
10 | +]) . ' ' . $model->menu_location_id; | ||
11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menu Locations'), 'url' => ['index']]; | ||
12 | +$this->params['breadcrumbs'][] = ['label' => $model->menu_location_id, 'url' => ['view', 'id' => $model->menu_location_id]]; | ||
13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
14 | +?> | ||
15 | +<div class="menu-location-update"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + | ||
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + ]) ?> | ||
22 | + | ||
23 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\DetailView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model backend\models\MenuLocation */ | ||
8 | + | ||
9 | +$this->title = $model->menu_location_id; | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Menu Locations'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="menu-location-view"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <p> | ||
18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->menu_location_id], ['class' => 'btn btn-primary']) ?> | ||
19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->menu_location_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 | + 'menu_location_id', | ||
32 | + 'menu_location_name', | ||
33 | + ], | ||
34 | + ]) ?> | ||
35 | + | ||
36 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | +use backend\models\Termin; | ||
6 | +use kartik\select2\Select2; | ||
7 | +use yii\helpers\ArrayHelper; | ||
8 | + | ||
9 | +/* @var $this yii\web\View */ | ||
10 | +/* @var $model backend\models\Termin */ | ||
11 | +/* @var $form yii\widgets\ActiveForm */ | ||
12 | + | ||
13 | +?> | ||
14 | + | ||
15 | +<div class="termin-form"> | ||
16 | + | ||
17 | + <?php $form = ActiveForm::begin(); ?> | ||
18 | + | ||
19 | + <?= $form->field($model_pid->termin, 'termin_pid')->widget(Select2::classname(), | ||
20 | + [ | ||
21 | + 'data' => ArrayHelper::map((new Termin)->finInfo([ | ||
22 | + 'show_all' => true, | ||
23 | + ]), | ||
24 | + 'termin_id', | ||
25 | + 'termin_title' | ||
26 | + ), | ||
27 | + 'options' => ['placeholder' => 'Select a state ...'], | ||
28 | + 'pluginOptions' => [ | ||
29 | + 'allowClear' => true | ||
30 | + ], | ||
31 | + ]); | ||
32 | + ?> | ||
33 | + | ||
34 | + <?= $form->field($model, 'termin_name')->textInput(['maxlength' => true]) ?> | ||
35 | + | ||
36 | + <?= $form->field($model_lang, 'termin_title')->textInput() ?> | ||
37 | + | ||
38 | + <?= $form->field($model_lang, 'termin_alias')->textInput() ?> | ||
39 | + | ||
40 | + <?= Html::activeHiddenInput ($model_lang, 'lang_id', [ | ||
41 | + 'value' => ($model_lang->lang_id != 0 ? $model_lang->lang_id : Yii::$app->params['lang_id']), | ||
42 | + ]) ?> | ||
43 | + | ||
44 | + <div class="form-group"> | ||
45 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
46 | + </div> | ||
47 | + | ||
48 | + <?php ActiveForm::end(); ?> | ||
49 | + | ||
50 | +</div> |
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\TerminSearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="termin-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'termin_id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'termin_name') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'is_book') ?> | ||
23 | + | ||
24 | + <div class="form-group"> | ||
25 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
26 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
27 | + </div> | ||
28 | + | ||
29 | + <?php ActiveForm::end(); ?> | ||
30 | + | ||
31 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model backend\models\Termin */ | ||
8 | + | ||
9 | +$this->title = Yii::t('app', 'Create').' '.Yii::t('app', 'termin'); | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Termins'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="termin-create"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + 'model_lang' => $model_lang, | ||
20 | + ]) ?> | ||
21 | + | ||
22 | +</div> |
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\TerminSearch */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = Yii::t('app', 'termin'); | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="termin-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'), ['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 | + 'attribute' => Yii::t('app', 'termin'), | ||
29 | + 'value' => function ($model) { | ||
30 | + return $model->terminLangs[0]->termin_title; | ||
31 | + }, | ||
32 | + ], | ||
33 | + 'termin_name', | ||
34 | + 'is_book', | ||
35 | + | ||
36 | + ['class' => 'yii\grid\ActionColumn'], | ||
37 | + ], | ||
38 | + ]); ?> | ||
39 | + | ||
40 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | +/* @var $this yii\web\View */ | ||
6 | +/* @var $model backend\models\Termin */ | ||
7 | + | ||
8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
9 | + 'modelClass' => 'Termin', | ||
10 | +]) . ' ' . $model->termin_id; | ||
11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Termins'), 'url' => ['index']]; | ||
12 | +$this->params['breadcrumbs'][] = ['label' => $model->termin_id, 'url' => ['view', 'id' => $model->termin_id]]; | ||
13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
14 | +?> | ||
15 | +<div class="termin-update"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + | ||
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + 'model_lang' => $model_lang, | ||
22 | + 'model_pid' => $model_pid, | ||
23 | + ]) ?> | ||
24 | + | ||
25 | + | ||
26 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\DetailView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model backend\models\Termin */ | ||
8 | + | ||
9 | +$this->title = $model->termin_id; | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Termins'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="termin-view"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <p> | ||
18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->termin_id], ['class' => 'btn btn-primary']) ?> | ||
19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->termin_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 | + 'termin_id', | ||
32 | + 'termin_name', | ||
33 | + 'is_book', | ||
34 | + ], | ||
35 | + ]) ?> | ||
36 | + | ||
37 | +</div> |
common/config/main.php
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | return [ | 2 | return [ |
3 | 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', | 3 | 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
4 | 'modules' => [ | 4 | 'modules' => [ |
5 | - 'permit' => [ | ||
6 | - 'class' => 'common\components\developeruz\db_rbac\Yii2DbRbac', | 5 | + 'permit' => [ |
6 | + 'class' => 'developeruz\db_rbac\Yii2DbRbac', | ||
7 | 'params' => [ | 7 | 'params' => [ |
8 | 'userClass' => 'common\models\User' | 8 | 'userClass' => 'common\models\User' |
9 | ] | 9 | ] |
1 | +<?php | ||
2 | + | ||
3 | +return [ | ||
4 | + | ||
5 | + // Ярик | ||
6 | + | ||
7 | + // Вова | ||
8 | + 'page' => 'Сторінка', | ||
9 | + 'date_add' => 'Дата додання', | ||
10 | + 'template' => 'Шаблон', | ||
11 | + 'image' => 'Картинка', | ||
12 | + 'title' => 'Заголовок', | ||
13 | + 'meta_title' => 'Meta Title', | ||
14 | + 'meta_description' => 'Meta Description', | ||
15 | + 'text' => 'Текст', | ||
16 | + 'page_alias' => 'alias', | ||
17 | + 'lang_id' => 'ID мови', | ||
18 | + 'common' => 'Загальне', | ||
19 | + 'lang' => 'Мовні змінні', | ||
20 | + 'termin' => 'Термін', | ||
21 | + 'related' => 'Пов`язані', | ||
22 | + 'menu' => 'Меню', | ||
23 | + 'location' => 'Розташування', | ||
24 | + 'book' => 'Справочник', | ||
25 | + | ||
26 | + // Дима | ||
27 | +]; |