Commit cdb04594bac4f9280d71338ac55825833de19608
1 parent
cd3dad5c
test
Showing
33 changed files
with
81 additions
and
1661 deletions
Show diff stats
common/models/OptionHelper.php
@@ -14,7 +14,7 @@ class OptionHelper extends Model | @@ -14,7 +14,7 @@ class OptionHelper extends Model | ||
14 | const OPTION_VALUE = 3; | 14 | const OPTION_VALUE = 3; |
15 | public function getRule($return = 3) | 15 | public function getRule($return = 3) |
16 | { | 16 | { |
17 | - $result = Options::find()->where(['name' => 'rules'])->with('value'); | 17 | + $result = Option::find()->where(['name' => 'rules'])->with('value'); |
18 | if($return == self::OPTION_OBJECT) { | 18 | if($return == self::OPTION_OBJECT) { |
19 | return $result->one(); | 19 | return $result->one(); |
20 | } elseif($return == self::OPTION_ARRAY) { | 20 | } elseif($return == self::OPTION_ARRAY) { |
console/migrations/m130524_201442_init.php
@@ -16,6 +16,9 @@ class m130524_201442_init extends Migration | @@ -16,6 +16,9 @@ class m130524_201442_init extends Migration | ||
16 | $this->createTable('{{%user}}', [ | 16 | $this->createTable('{{%user}}', [ |
17 | 'id' => $this->primaryKey(), | 17 | 'id' => $this->primaryKey(), |
18 | 'username' => $this->string()->notNull()->unique(), | 18 | 'username' => $this->string()->notNull()->unique(), |
19 | + 'lastname' => $this->string(), | ||
20 | + 'firstname' => $this->string(), | ||
21 | + 'middlename' => $this->string(), | ||
19 | 'auth_key' => $this->string(32)->notNull(), | 22 | 'auth_key' => $this->string(32)->notNull(), |
20 | 'password_hash' => $this->string()->notNull(), | 23 | 'password_hash' => $this->string()->notNull(), |
21 | 'password_reset_token' => $this->string()->unique(), | 24 | 'password_reset_token' => $this->string()->unique(), |
@@ -25,6 +28,19 @@ class m130524_201442_init extends Migration | @@ -25,6 +28,19 @@ class m130524_201442_init extends Migration | ||
25 | 'created_at' => $this->integer()->notNull(), | 28 | 'created_at' => $this->integer()->notNull(), |
26 | 'updated_at' => $this->integer()->notNull(), | 29 | 'updated_at' => $this->integer()->notNull(), |
27 | ], $tableOptions); | 30 | ], $tableOptions); |
31 | + | ||
32 | + $this->insert('{{%user}}', [ | ||
33 | + 'username' => 'admin', | ||
34 | + 'lastname' => 'admin', | ||
35 | + 'firstname' => 'admin', | ||
36 | + 'middlename' => '', | ||
37 | + 'auth_key' => 'SlJ315le5enaDJ4OsdvXX83i_drf-JXl', | ||
38 | + 'password_hash' => '$2y$13$LfYpoaZkKzniNw/7rySAnOVPHy8wKFFznxBVoAWTnbLv/Di0oXqvi', | ||
39 | + 'password_reset_token' => 'NULL', | ||
40 | + 'email' => 'admin@admin.com', | ||
41 | + 'created_at' => '1', | ||
42 | + 'updated_at' => '1', | ||
43 | + ]); | ||
28 | } | 44 | } |
29 | 45 | ||
30 | public function down() | 46 | public function down() |
frontend/assets/AppAsset.php
@@ -26,7 +26,8 @@ class AppAsset extends AssetBundle | @@ -26,7 +26,8 @@ class AppAsset extends AssetBundle | ||
26 | 'js/markerclusterer.js', | 26 | 'js/markerclusterer.js', |
27 | 'js/jquery.scrollbox.min.js', | 27 | 'js/jquery.scrollbox.min.js', |
28 | 'js/slider.js', | 28 | 'js/slider.js', |
29 | - 'js/jquery.rating.js' | 29 | + 'js/jquery.rating.js', |
30 | + '/admin/js/option.js' | ||
30 | ]; | 31 | ]; |
31 | public $depends = [ | 32 | public $depends = [ |
32 | 'yii\web\YiiAsset', | 33 | 'yii\web\YiiAsset', |
frontend/controllers/OptionController.php
@@ -3,12 +3,11 @@ | @@ -3,12 +3,11 @@ | ||
3 | namespace frontend\controllers; | 3 | namespace frontend\controllers; |
4 | 4 | ||
5 | use Yii; | 5 | use Yii; |
6 | -use frontend\models\Option; | ||
7 | -use frontend\models\OptionSearch; | 6 | +use common\models\Option; |
7 | +use common\models\OptionSearch; | ||
8 | use yii\web\Controller; | 8 | use yii\web\Controller; |
9 | use yii\web\NotFoundHttpException; | 9 | use yii\web\NotFoundHttpException; |
10 | use yii\filters\VerbFilter; | 10 | use yii\filters\VerbFilter; |
11 | -use frontend\models\OptionLang; | ||
12 | 11 | ||
13 | /** | 12 | /** |
14 | * OptionController implements the CRUD actions for Option model. | 13 | * OptionController implements the CRUD actions for Option model. |
@@ -61,14 +60,17 @@ class OptionController extends Controller | @@ -61,14 +60,17 @@ class OptionController extends Controller | ||
61 | */ | 60 | */ |
62 | public function actionCreate() | 61 | public function actionCreate() |
63 | { | 62 | { |
64 | - $form[0] = Option::create(\Yii::$app->request->post(), 'User', 10, [['name' => 'phone', 'template' => 'text', 'translate' => true], ['name' => 'adres', 'template' => 'text', 'translate' => false]], true); | ||
65 | - if($form[0]['success'] == false) { | ||
66 | - return $this->render('create', ['forms' => $form]); | 63 | + $model = new Option(); |
64 | + | ||
65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
66 | + return $this->redirect(['view', 'id' => $model->option_id]); | ||
67 | } else { | 67 | } else { |
68 | - return $this->redirect(['index']); | 68 | + return $this->render('create', [ |
69 | + 'model' => $model, | ||
70 | + ]); | ||
69 | } | 71 | } |
70 | } | 72 | } |
71 | - | 73 | + |
72 | /** | 74 | /** |
73 | * Updates an existing Option model. | 75 | * Updates an existing Option model. |
74 | * If update is successful, the browser will be redirected to the 'view' page. | 76 | * If update is successful, the browser will be redirected to the 'view' page. |
@@ -77,11 +79,14 @@ class OptionController extends Controller | @@ -77,11 +79,14 @@ class OptionController extends Controller | ||
77 | */ | 79 | */ |
78 | public function actionUpdate($id) | 80 | public function actionUpdate($id) |
79 | { | 81 | { |
80 | - $form[0] = Option::change($id, \Yii::$app->request->post(), 'User', 10); | ||
81 | - if($form[0]['success'] == false) { | ||
82 | - return $this->render('update', ['forms' => $form]); | 82 | + $model = $this->findModel($id); |
83 | + | ||
84 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
85 | + return $this->redirect(['view', 'id' => $model->option_id]); | ||
83 | } else { | 86 | } else { |
84 | - return $this->redirect(['view', 'id' => $id]); | 87 | + return $this->render('update', [ |
88 | + 'model' => $model, | ||
89 | + ]); | ||
85 | } | 90 | } |
86 | } | 91 | } |
87 | 92 | ||
@@ -93,23 +98,7 @@ class OptionController extends Controller | @@ -93,23 +98,7 @@ class OptionController extends Controller | ||
93 | */ | 98 | */ |
94 | public function actionDelete($id) | 99 | public function actionDelete($id) |
95 | { | 100 | { |
96 | - $model = $this->findModel($id); | ||
97 | - $children = $model->hasMany(Option::className(), ['parent_id' => 'option_id'])->all(); | ||
98 | - $langs = array(); | ||
99 | - if(!empty($children)) { | ||
100 | - foreach($children as $child) { | ||
101 | - $langs = OptionLang::findAll(['id' => $child->option_id]); | ||
102 | - foreach($langs as $lang) { | ||
103 | - $lang->delete(); | ||
104 | - } | ||
105 | - $child->delete(); | ||
106 | - } | ||
107 | - } | ||
108 | - $langs = OptionLang::findAll(['id' => $id]); | ||
109 | - foreach($langs as $lang) { | ||
110 | - $lang->delete(); | ||
111 | - } | ||
112 | - $model->delete(); | 101 | + $this->findModel($id)->delete(); |
113 | 102 | ||
114 | return $this->redirect(['index']); | 103 | return $this->redirect(['index']); |
115 | } | 104 | } |
frontend/controllers/OptionValuesController.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\controllers; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use frontend\models\OptionValues; | ||
7 | -use frontend\models\OptionValuesSearch; | ||
8 | -use yii\web\Controller; | ||
9 | -use yii\web\NotFoundHttpException; | ||
10 | -use yii\filters\VerbFilter; | ||
11 | - | ||
12 | -/** | ||
13 | - * OptionValuesController implements the CRUD actions for OptionValues model. | ||
14 | - */ | ||
15 | -class OptionValuesController 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 OptionValues models. | ||
31 | - * @return mixed | ||
32 | - */ | ||
33 | - public function actionIndex() | ||
34 | - { | ||
35 | - $searchModel = new OptionValuesSearch(); | ||
36 | - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
37 | - return $this->render('index', [ | ||
38 | - 'searchModel' => $searchModel, | ||
39 | - 'dataProvider' => $dataProvider, | ||
40 | - ]); | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * Displays a single OptionValues model. | ||
45 | - * @param integer $id | ||
46 | - * @return mixed | ||
47 | - */ | ||
48 | - public function actionView($id) | ||
49 | - { | ||
50 | - return $this->render('view', [ | ||
51 | - 'model' => $this->findModel($id), | ||
52 | - ]); | ||
53 | - } | ||
54 | - | ||
55 | - /** | ||
56 | - * Creates a new OptionValues model. | ||
57 | - * If creation is successful, the browser will be redirected to the 'view' page. | ||
58 | - * @return mixed | ||
59 | - */ | ||
60 | - public function actionCreate() | ||
61 | - { | ||
62 | - $post = \Yii::$app->request->post(); | ||
63 | - if(is_array($post['OptionValues']['option_value_text'])) { | ||
64 | - $ok = 0; | ||
65 | - $first = 0; | ||
66 | - $id = 0; | ||
67 | - $models = array(); | ||
68 | - foreach($post['OptionValues']['option_value_text'] as $lang => $value) { | ||
69 | - $models[$lang] = new OptionValues(); | ||
70 | - $models[$lang]->load(Yii::$app->request->post()); | ||
71 | - $models[$lang]->option_language_id = $lang; | ||
72 | - $models[$lang]->option_value_text = $value; | ||
73 | - if($first && $id) { | ||
74 | - $models[$lang]->option_value_parent = $id; | ||
75 | - } | ||
76 | - if($models[$lang]->save()) { | ||
77 | - $ok = 1; | ||
78 | - if(!$first) { | ||
79 | - $first = 1; | ||
80 | - $id = $models[$lang]->option_value_id; | ||
81 | - } | ||
82 | - } else { | ||
83 | - unset($models[$lang]); | ||
84 | - } | ||
85 | - } | ||
86 | - if($ok) { | ||
87 | - return $this->redirect(['view', 'id' => $id]); | ||
88 | - } | ||
89 | - } | ||
90 | - $model = new OptionValues(); | ||
91 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
92 | - return $this->redirect(['view', 'id' => $model->option_value_id]); | ||
93 | - } else { | ||
94 | - return $this->render('create', [ | ||
95 | - 'model' => $model, | ||
96 | - ]); | ||
97 | - } | ||
98 | - } | ||
99 | - | ||
100 | - /** | ||
101 | - * Updates an existing OptionValues model. | ||
102 | - * If update is successful, the browser will be redirected to the 'view' page. | ||
103 | - * @param integer $id | ||
104 | - * @return mixed | ||
105 | - */ | ||
106 | - public function actionUpdate($id) | ||
107 | - { | ||
108 | - $model = $this->findModel($id); | ||
109 | - | ||
110 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
111 | - return $this->redirect(['view', 'id' => $model->option_value_id]); | ||
112 | - } else { | ||
113 | - return $this->render('update', [ | ||
114 | - 'model' => $model, | ||
115 | - ]); | ||
116 | - } | ||
117 | - } | ||
118 | - | ||
119 | - /** | ||
120 | - * Deletes an existing OptionValues model. | ||
121 | - * If deletion is successful, the browser will be redirected to the 'index' page. | ||
122 | - * @param integer $id | ||
123 | - * @return mixed | ||
124 | - */ | ||
125 | - public function actionDelete($id) | ||
126 | - { | ||
127 | - $this->findModel($id)->delete(); | ||
128 | - | ||
129 | - return $this->redirect(['index']); | ||
130 | - } | ||
131 | - | ||
132 | - /** | ||
133 | - * Finds the OptionValues model based on its primary key value. | ||
134 | - * If the model is not found, a 404 HTTP exception will be thrown. | ||
135 | - * @param integer $id | ||
136 | - * @return OptionValues the loaded model | ||
137 | - * @throws NotFoundHttpException if the model cannot be found | ||
138 | - */ | ||
139 | - protected function findModel($id) | ||
140 | - { | ||
141 | - if (($model = OptionValues::findOne($id)) !== null) { | ||
142 | - return $model; | ||
143 | - } else { | ||
144 | - throw new NotFoundHttpException('The requested page does not exist.'); | ||
145 | - } | ||
146 | - } | ||
147 | -} |
frontend/controllers/OptionsController.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\controllers; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use frontend\models\Options; | ||
7 | -use frontend\models\OptionsSearch; | ||
8 | -use yii\web\Controller; | ||
9 | -use yii\web\NotFoundHttpException; | ||
10 | -use yii\filters\VerbFilter; | ||
11 | - | ||
12 | -/** | ||
13 | - * OptionsController implements the CRUD actions for Options model. | ||
14 | - */ | ||
15 | -class OptionsController 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 Options models. | ||
31 | - * @return mixed | ||
32 | - */ | ||
33 | - public function actionIndex() | ||
34 | - { | ||
35 | - $searchModel = new OptionsSearch(); | ||
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 Options 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 Options 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 Options(); | ||
64 | - | ||
65 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
66 | - return $this->redirect(['view', 'id' => $model->option_id]); | ||
67 | - } else { | ||
68 | - return $this->render('create', [ | ||
69 | - 'model' => $model, | ||
70 | - ]); | ||
71 | - } | ||
72 | - } | ||
73 | - | ||
74 | - /** | ||
75 | - * Updates an existing Options 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->option_id]); | ||
86 | - } else { | ||
87 | - return $this->render('update', [ | ||
88 | - 'model' => $model, | ||
89 | - ]); | ||
90 | - } | ||
91 | - } | ||
92 | - | ||
93 | - /** | ||
94 | - * Deletes an existing Options 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 Options 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 Options the loaded model | ||
111 | - * @throws NotFoundHttpException if the model cannot be found | ||
112 | - */ | ||
113 | - protected function findModel($id) | ||
114 | - { | ||
115 | - if (($model = Options::findOne($id)) !== null) { | ||
116 | - return $model; | ||
117 | - } else { | ||
118 | - throw new NotFoundHttpException('The requested page does not exist.'); | ||
119 | - } | ||
120 | - } | ||
121 | -} |
frontend/models/Option.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "option". | ||
9 | - * | ||
10 | - * @property integer $option_id | ||
11 | - * @property string $model | ||
12 | - * @property integer $model_id | ||
13 | - * @property string $name | ||
14 | - * @property string $template | ||
15 | - * @property integer $parent_id | ||
16 | - */ | ||
17 | -class Option extends \yii\db\ActiveRecord | ||
18 | -{ | ||
19 | - /** | ||
20 | - * @inheritdoc | ||
21 | - */ | ||
22 | - public static function tableName() | ||
23 | - { | ||
24 | - return 'option'; | ||
25 | - } | ||
26 | - | ||
27 | - /** | ||
28 | - * @inheritdoc | ||
29 | - */ | ||
30 | - public function rules() | ||
31 | - { | ||
32 | - return [ | ||
33 | - [['model', 'model_id', 'name', 'template'], 'required'], | ||
34 | - [['model_id', 'option_pid'], 'integer'], | ||
35 | - [['model', 'name', 'template'], 'string', 'max' => 200] | ||
36 | - ]; | ||
37 | - } | ||
38 | - | ||
39 | - /** | ||
40 | - * @inheritdoc | ||
41 | - */ | ||
42 | - public function attributeLabels() | ||
43 | - { | ||
44 | - return [ | ||
45 | - 'option_id' => Yii::t('app', 'Option ID'), | ||
46 | - 'model' => Yii::t('app', 'Model'), | ||
47 | - 'model_id' => Yii::t('app', 'Model ID'), | ||
48 | - 'name' => Yii::t('app', 'Name'), | ||
49 | - 'template' => Yii::t('app', 'Template'), | ||
50 | - 'option_pid' => Yii::t('app', 'Parent ID'), | ||
51 | - 'date_add' => Yii::t('app', 'Date created'), | ||
52 | - 'translate' => Yii::t('app', 'Translatable'), | ||
53 | - ]; | ||
54 | - } | ||
55 | - | ||
56 | - public function getLangs() { | ||
57 | - return (new Language())->find()->where(['>', 'language_id', 0])->andWhere(['status' => 1])->asArray()->all(); | ||
58 | - } | ||
59 | - | ||
60 | - public static function change($id, $post, $modeldb, $model_id) { | ||
61 | - $models[$id] = Option::findOne($id); | ||
62 | - $modellang[$id] = array(); | ||
63 | - $langs = OptionLang::findAll(['option_language_id' => $id]); | ||
64 | - foreach($langs as $lang) { | ||
65 | - $modellang[$id][$lang->language_id] = $lang; | ||
66 | - } | ||
67 | - $children = (new Option())->find()->where(['option_pid' => $id])->all(); | ||
68 | - foreach($children as $child) { | ||
69 | - $models[$child->option_id] = $child; | ||
70 | - $modellang[$child->option_id] = array(); | ||
71 | - $langs = OptionLang::findAll(['option_id' =>$child->option_id]); | ||
72 | - foreach($langs as $lang) { | ||
73 | - $modellang[$child->option_id][$lang->language_id] = $lang; | ||
74 | - } | ||
75 | - } | ||
76 | - $ok = 1; | ||
77 | - if(!empty($post)) { | ||
78 | - foreach($post['Option'] as $key => $option) { | ||
79 | - if(in_array($key, array('model', 'model_id'))) { continue; } | ||
80 | - if(empty($option['value'][$models[$key]->name]) && !empty($option['lang'])) { | ||
81 | - foreach($option['lang'] as $language_id => $lang) { | ||
82 | - if(!empty($lang)) { | ||
83 | - $option['value'][$models[$key]->name] = $lang; | ||
84 | - break; | ||
85 | - } | ||
86 | - } | ||
87 | - } | ||
88 | - $modellang[$key][0]->value = $option['value'][$models[$key]->name]; | ||
89 | - if(empty($modellang[$key][0]->value) || !$modellang[$key][0]->save()) { | ||
90 | - $ok = 0; | ||
91 | - $models[$key]->addError('value', 'Value must be set'); | ||
92 | - $modellang[$key][0]->addError('value', 'Value must be set'); | ||
93 | - } | ||
94 | - if(!empty($option['lang'])) { | ||
95 | - foreach($option['lang'] as $language_id => $lang) { | ||
96 | - if(empty($modellang[$key][$language_id])) { | ||
97 | - $modellang[$key][$language_id] = new OptionLang(); | ||
98 | - $modellang[$key][$language_id]->option_id = $models[$key]->option_id; | ||
99 | - $modellang[$key][$language_id]->language_id = $language_id; | ||
100 | - $modellang[$key][$language_id]->value = $lang; | ||
101 | - } else { | ||
102 | - $modellang[$key][$language_id]->value = $lang; | ||
103 | - } | ||
104 | - if(!$modellang[$key][$language_id]->save()) { | ||
105 | - $ok = 0; | ||
106 | - } | ||
107 | - } | ||
108 | - } | ||
109 | - } | ||
110 | - if($ok) { | ||
111 | - return array('id' => $id, 'models' => $models, 'modelslang' => $modelslang, 'success' => true); | ||
112 | - } else { | ||
113 | - return array( | ||
114 | - 'models' => $models, | ||
115 | - 'modellang' => $modellang, | ||
116 | - 'modeldb' => $modeldb, | ||
117 | - 'model_id' => $model_id, | ||
118 | - 'success' => false | ||
119 | - ); | ||
120 | - } | ||
121 | - } | ||
122 | - return array( | ||
123 | - 'models' => $models, | ||
124 | - 'modellang' => $modellang, | ||
125 | - 'modeldb' => $modeldb, | ||
126 | - 'model_id' => $model_id, | ||
127 | - 'success' => false | ||
128 | - ); | ||
129 | - } | ||
130 | - | ||
131 | - public static function create($post, $modeldb, $model_id, $fields, $multiple) { | ||
132 | - $multiple = boolval($multiple); | ||
133 | - $model = new Option(); | ||
134 | - $modellang = new OptionLang(); | ||
135 | - if(!empty($post['Option'])) { | ||
136 | - $ok = 1; | ||
137 | - $parentid = null; | ||
138 | - $models = array(); | ||
139 | - foreach($post['Option'] as $index => $option) { | ||
140 | - if(in_array($index, array('model', 'model_id')) && $index !== 0) { continue; } | ||
141 | - $first = 1; | ||
142 | - foreach($option['value'] as $key => $value) { | ||
143 | - $models[$index][$key] = new Option(); | ||
144 | - $models[$index][$key]->model = $post['Option']['model']; | ||
145 | - $models[$index][$key]->model_id = $post['Option']['model_id']; | ||
146 | - $models[$index][$key]->template = $option[$key]['template']; | ||
147 | - $models[$index][$key]->translate = $option[$key]['translate']?1:0; | ||
148 | - $models[$index][$key]->name = $key; | ||
149 | - if(!$first) { | ||
150 | - $models[$index][$key]->option_pid = $parentid; | ||
151 | - } | ||
152 | - $modelslang[$index][$key][0] = new OptionLang(); | ||
153 | - if(!empty($option['lang'][$key])) { | ||
154 | - foreach($option['lang'][$key] as $code => $lang) { | ||
155 | - if(!empty($lang)) { | ||
156 | - $value = $lang; | ||
157 | - break; | ||
158 | - } | ||
159 | - } | ||
160 | - } | ||
161 | - if(!empty($value) && $models[$index][$key]->save()) { | ||
162 | - if($first) { | ||
163 | - $parentid = $models[$index][$key]->option_id; | ||
164 | - } | ||
165 | - $modelslang[$index][$key][0]->option_id = $models[$index][$key]->option_id; | ||
166 | - $modelslang[$index][$key][0]->language_id = 0; | ||
167 | - $modelslang[$index][$key][0]->value = $value; | ||
168 | - if($modelslang[$index][$key][0]->save()) { | ||
169 | - if(!empty($option['lang'][$key])) { | ||
170 | - foreach($option['lang'][$key] as $code => $lang) { | ||
171 | - if(!empty($lang)) { | ||
172 | - $modelslang[$index][$key][$code] = new OptionLang(); | ||
173 | - $modelslang[$index][$key][$code]->option_id = $models[$index][$key]->option_id; | ||
174 | - $modelslang[$index][$key][$code]->language_id = $code; | ||
175 | - $modelslang[$index][$key][$code]->value = $lang; | ||
176 | - if(!$modelslang[$index][$key][$code]->save()) { | ||
177 | - $ok = 0; | ||
178 | - } | ||
179 | - } | ||
180 | - } | ||
181 | - } | ||
182 | - } | ||
183 | - } else { | ||
184 | - $models[$index][$key]->validate(); | ||
185 | - $modelslang[$index][$key][0]->validate(); | ||
186 | - $modelslang[$index][$key][0]->addError('value', 'Value must be set'); | ||
187 | - if(!empty($option['lang'][$key])) { | ||
188 | - foreach($option['lang'][$key] as $code => $lang) { | ||
189 | - if(!empty($lang)) { | ||
190 | - $modelslang[$index][$key][$code] = new OptionLang(); | ||
191 | - $modelslang[$index][$key][$code]->option_id = $models[$index][$key]->option_id; | ||
192 | - $modelslang[$index][$key][$code]->language_id = $code; | ||
193 | - $modelslang[$index][$key][$code]->value = $lang; | ||
194 | - } | ||
195 | - } | ||
196 | - } | ||
197 | - $ok = 0; | ||
198 | - } | ||
199 | - $first = 0; | ||
200 | - } | ||
201 | - } | ||
202 | - if($ok) { | ||
203 | - if($modeldb == 'Feedback') { | ||
204 | - $newflag = new Option(); | ||
205 | - $newflag->model = $modeldb; | ||
206 | - $newflag->model_id = $model_id; | ||
207 | - $newflag->name = 'is_new'; | ||
208 | - $newflag->template = 'checkbox'; | ||
209 | - $newflag->option_pid = $parentid; | ||
210 | - $newflag->translate = 0; | ||
211 | - if($newflag->save()) { | ||
212 | - $newflaglang = new OptionLang(); | ||
213 | - $newflaglang->option_id = $newflag->option_id; | ||
214 | - $newflaglang->language_id = 0; | ||
215 | - $newflaglang->value = '1'; | ||
216 | - if(!$newflaglang->save()) { | ||
217 | - $newflag->delete(); | ||
218 | - } | ||
219 | - } | ||
220 | - } | ||
221 | - return array('models' => $models, 'modelslang' => $modelslang, 'success' => true); | ||
222 | - } else { | ||
223 | - return array( | ||
224 | - 'models' => $models, | ||
225 | - 'modellang' => $modelslang, | ||
226 | - 'modeldb' => $modeldb, | ||
227 | - 'model_id' => $model_id, | ||
228 | - 'fields' => $fields, | ||
229 | - 'success' => false, | ||
230 | - 'multiple' => $multiple | ||
231 | - ); | ||
232 | - } | ||
233 | - } else { | ||
234 | - return array( | ||
235 | - 'model' => $model, | ||
236 | - 'modeldb' => $modeldb, | ||
237 | - 'model_id' => $model_id, | ||
238 | - 'fields' => $fields, | ||
239 | - 'success' => false, | ||
240 | - 'multiple' => $multiple | ||
241 | - ); | ||
242 | - } | ||
243 | - } | ||
244 | - | ||
245 | - public function getOptions() { | ||
246 | - return $this->hasMany(Option::className(), ['option_pid' => 'option_id'])->indexBy('name'); | ||
247 | - } | ||
248 | - | ||
249 | - public function getOption() { | ||
250 | - return $this->hasOne(Option::className(), ['option_id' => 'option_pid']); | ||
251 | - } | ||
252 | - | ||
253 | - public function getOptionLangs() { | ||
254 | - return $this->hasMany(OptionLang::className(), ['option_id' => 'option_id']); | ||
255 | - } | ||
256 | - | ||
257 | - public function getOptionDefaultLang($array = false) { | ||
258 | - $query = $this->getOptionLangs()->where(['language_id' => 0]); | ||
259 | - if($array) { | ||
260 | - $query->asArray(); | ||
261 | - } | ||
262 | - return $query->one(); | ||
263 | - } | ||
264 | - | ||
265 | - public static function markOld($id) { | ||
266 | - $model = Option::findOne($id); | ||
267 | - $is_new = $model->getOptions()->where(['name' => 'is_new'])->one(); | ||
268 | - if(empty($is_new)) return false; | ||
269 | - $is_newlang = $is_new->getOptionDefaultLang(); | ||
270 | - $is_newlang->value = '0'; | ||
271 | - if($is_newlang->save()) { | ||
272 | - return true; | ||
273 | - } else { | ||
274 | - return false; | ||
275 | - } | ||
276 | - } | ||
277 | - | ||
278 | -} |
frontend/models/OptionLang.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "option_lang". | ||
9 | - * | ||
10 | - * @property integer $id | ||
11 | - * @property integer $language_id | ||
12 | - * @property string $value | ||
13 | - */ | ||
14 | -class OptionLang extends \yii\db\ActiveRecord | ||
15 | -{ | ||
16 | - /** | ||
17 | - * @inheritdoc | ||
18 | - */ | ||
19 | - public static function tableName() | ||
20 | - { | ||
21 | - return 'option_lang'; | ||
22 | - } | ||
23 | - | ||
24 | - /** | ||
25 | - * @inheritdoc | ||
26 | - */ | ||
27 | - public function rules() | ||
28 | - { | ||
29 | - return [ | ||
30 | - [['option_id', 'language_id'], 'required'], | ||
31 | - [['option_id', 'language_id'], 'integer'], | ||
32 | - [['value'], 'string'] | ||
33 | - ]; | ||
34 | - } | ||
35 | - | ||
36 | - /** | ||
37 | - * @inheritdoc | ||
38 | - */ | ||
39 | - public function attributeLabels() | ||
40 | - { | ||
41 | - return [ | ||
42 | - 'option_id' => Yii::t('app', 'ID'), | ||
43 | - 'language_id' => Yii::t('app', 'Lang ID'), | ||
44 | - 'value' => Yii::t('app', 'Value'), | ||
45 | - ]; | ||
46 | - } | ||
47 | -} |
frontend/models/OptionLangSearch.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use frontend\models\OptionLang; | ||
9 | - | ||
10 | -/** | ||
11 | - * OptionLangSearch represents the model behind the search form about `frontend\models\OptionLang`. | ||
12 | - */ | ||
13 | -class OptionLangSearch extends OptionLang | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['option_language_id', 'option_id', 'language_id'], 'integer'], | ||
22 | - [['value'], '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 = OptionLang::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 | - 'option_language_id' => $this->option_language_id, | ||
60 | - 'option_id' => $this->option_id, | ||
61 | - 'language_id' => $this->language_id, | ||
62 | - ]); | ||
63 | - | ||
64 | - $query->andFilterWhere(['like', 'value', $this->value]); | ||
65 | - | ||
66 | - return $dataProvider; | ||
67 | - } | ||
68 | -} |
frontend/models/OptionSearch.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use frontend\models\Option; | ||
9 | - | ||
10 | -/** | ||
11 | - * OptionSearch represents the model behind the search form about `frontend\models\Option`. | ||
12 | - */ | ||
13 | -class OptionSearch extends Option | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['option_id', 'model_id', 'option_pid'], 'integer'], | ||
22 | - [['model', 'name', 'template'], '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 = Option::find(); | ||
45 | - | ||
46 | - $dataProvider = new ActiveDataProvider([ | ||
47 | - 'query' => $query, | ||
48 | - ]); | ||
49 | - $data = [ | ||
50 | - 'OptionSearch' => [ | ||
51 | - 'model' => 'Main' | ||
52 | - ] | ||
53 | - ]; | ||
54 | - | ||
55 | - $this->load($params); | ||
56 | - | ||
57 | - if (!$this->validate()) { | ||
58 | - // uncomment the following line if you do not want to return any records when validation fails | ||
59 | - // $query->where('0=1'); | ||
60 | - return $dataProvider; | ||
61 | - } | ||
62 | - | ||
63 | - $query->andWhere(['option_pid' => null]); | ||
64 | - | ||
65 | - $query->andFilterWhere([ | ||
66 | - 'option_id' => $this->option_id, | ||
67 | - 'model_id' => $this->model_id, | ||
68 | - 'option_pid' => $this->option_pid, | ||
69 | - ]); | ||
70 | - | ||
71 | - $query->andFilterWhere(['like', 'model', $this->model]) | ||
72 | - ->andFilterWhere(['like', 'name', $this->name]) | ||
73 | - ->andFilterWhere(['like', 'template', $this->template]); | ||
74 | - | ||
75 | - | ||
76 | - return $dataProvider; | ||
77 | - } | ||
78 | -} |
frontend/models/OptionValues.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "option_values". | ||
9 | - * | ||
10 | - * @property integer $option_value_id | ||
11 | - * @property string $option_key | ||
12 | - * @property string $option_value_text | ||
13 | - * @property integer $option_language_id | ||
14 | - * @property integer $option_value_parent | ||
15 | - * @property integer $option_user | ||
16 | - * | ||
17 | - * @property Language $optionLang | ||
18 | - */ | ||
19 | -class OptionValues extends \yii\db\ActiveRecord | ||
20 | -{ | ||
21 | - /** | ||
22 | - * @inheritdoc | ||
23 | - */ | ||
24 | - public static function tableName() | ||
25 | - { | ||
26 | - return 'option_values'; | ||
27 | - } | ||
28 | - | ||
29 | - /** | ||
30 | - * @inheritdoc | ||
31 | - */ | ||
32 | - public function rules() | ||
33 | - { | ||
34 | - return [ | ||
35 | - [['option_key', 'option_value_text'], 'required'], | ||
36 | - [['option_language_id', 'option_value_parent', 'option_user'], 'integer'], | ||
37 | - [['option_key'], 'string', 'max' => 200] | ||
38 | - ]; | ||
39 | - } | ||
40 | - | ||
41 | - /** | ||
42 | - * @inheritdoc | ||
43 | - */ | ||
44 | - public function attributeLabels() | ||
45 | - { | ||
46 | - return [ | ||
47 | - 'option_value_id' => Yii::t('app', 'Option Value ID'), | ||
48 | - 'option_key' => Yii::t('app', 'Option Key'), | ||
49 | - 'option_value_text' => Yii::t('app', 'Option Value Text'), | ||
50 | - 'option_language_id' => Yii::t('app', 'Option Lang ID'), | ||
51 | - 'option_value_parent' => Yii::t('app', 'Option Value Parent'), | ||
52 | - 'option_user' => Yii::t('app', 'Option User'), | ||
53 | - ]; | ||
54 | - } | ||
55 | - | ||
56 | - /** | ||
57 | - * @return \yii\db\ActiveQuery | ||
58 | - */ | ||
59 | - public function getOptionLang() | ||
60 | - { | ||
61 | - return $this->hasOne(Language::className(), ['language_id' => 'option_language_id']); | ||
62 | - } | ||
63 | - public function getLanguages() { | ||
64 | - return (new LanguageLang())->find()->orderBy('language_id ASC')->asArray()->all(); | ||
65 | - } | ||
66 | - public function getLanguagesCodes() { | ||
67 | - return (new Language())->find()->orderBy('language_id ASC')->asArray()->all(); | ||
68 | - } | ||
69 | - public function getDropDownArray() { | ||
70 | - $langs = array(); | ||
71 | - foreach($this->getLanguages() as $lang) { | ||
72 | - $langs[$lang['language_id']] = $lang['lang_title']; | ||
73 | - } | ||
74 | - return $langs; | ||
75 | - } | ||
76 | - public function beforeSave($insert) { | ||
77 | - if (parent::beforeSave($insert)) { | ||
78 | - $this->option_user = \Yii::$app->user->getId(); | ||
79 | - if($this->option_value_parent == 0) { | ||
80 | - unset($this->option_value_parent); | ||
81 | - } | ||
82 | - return true; | ||
83 | - } else { | ||
84 | - return false; | ||
85 | - } | ||
86 | - } | ||
87 | - public function getUserOptions() { | ||
88 | - return (new OptionValues())->find()->where('option_user=:user')->addParams([':user' => \Yii::$app->user->getID()])->andWhere(['not', ['option_user' => null]])->asArray()->all(); | ||
89 | - } | ||
90 | - public function getUserOptionsArray() { | ||
91 | - $options = array('0' => Yii::t('app', 'Default Parent')); | ||
92 | - foreach($this->getUserOptions() as $option) { | ||
93 | - $options[$option['option_value_id']] = $option['option_key'].' - '.$option['option_value_text']; | ||
94 | - } | ||
95 | - return $options; | ||
96 | - } | ||
97 | -} |
frontend/models/OptionValuesSearch.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use frontend\models\OptionValues; | ||
9 | - | ||
10 | -/** | ||
11 | - * OptionValuesSearch represents the model behind the search form about `frontend\models\OptionValues`. | ||
12 | - */ | ||
13 | -class OptionValuesSearch extends OptionValues | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['option_value_id', 'option_language_id', 'option_value_parent', 'option_user'], 'integer'], | ||
22 | - [['option_key', 'option_value_text'], '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 = OptionValues::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 | - 'option_value_id' => $this->option_value_id, | ||
60 | - 'option_language_id' => $this->option_language_id, | ||
61 | - 'option_value_parent' => $this->option_value_parent, | ||
62 | - 'option_user' => $this->option_user, | ||
63 | - ]); | ||
64 | - | ||
65 | - $query->andFilterWhere(['like', 'option_key', $this->option_key]) | ||
66 | - ->andFilterWhere(['like', 'option_value_text', $this->option_value_text]); | ||
67 | - | ||
68 | - return $dataProvider; | ||
69 | - } | ||
70 | -} |
frontend/models/Options.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | - | ||
7 | -/** | ||
8 | - * This is the model class for table "option". | ||
9 | - * | ||
10 | - * @property integer $option_id | ||
11 | - * @property string $option_key | ||
12 | - * @property integer $option_parent | ||
13 | - * @property integer $option_translatable | ||
14 | - * @property string $option_format | ||
15 | - * | ||
16 | - * @property OptionValues[] $optionValues | ||
17 | - * @property Options $optionParent | ||
18 | - * @property Options[] $options | ||
19 | - */ | ||
20 | -class Options extends \yii\db\ActiveRecord | ||
21 | -{ | ||
22 | - /** | ||
23 | - * @inheritdoc | ||
24 | - */ | ||
25 | - public static function tableName () | ||
26 | - { | ||
27 | - return 'option'; | ||
28 | - } | ||
29 | - | ||
30 | - /** | ||
31 | - * @inheritdoc | ||
32 | - */ | ||
33 | - public function rules () | ||
34 | - { | ||
35 | - return [ | ||
36 | - [['option_key'], 'required'], [['option_parent', 'option_translatable'], 'integer'], [['option_key', 'option_format'], 'string', 'max' => 200] | ||
37 | - ]; | ||
38 | - } | ||
39 | - | ||
40 | - /** | ||
41 | - * @inheritdoc | ||
42 | - */ | ||
43 | - public function attributeLabels () | ||
44 | - { | ||
45 | - return [ | ||
46 | - 'option_id' => Yii::t ('app', 'Option ID'), 'option_key' => Yii::t ('app', 'Option Key'), 'option_parent' => Yii::t ('app', 'Option Parent'), 'option_translatable' => Yii::t ('app', 'Option Translatable'), 'option_format' => Yii::t ('app', 'Option Format'), | ||
47 | - ]; | ||
48 | - } | ||
49 | - | ||
50 | - /** | ||
51 | - * @return \yii\db\ActiveQuery | ||
52 | - */ | ||
53 | - public function getOptionLang () | ||
54 | - { | ||
55 | - return $this->hasMany (OptionLang::className (), ['option_id' => 'option_id']); | ||
56 | - } | ||
57 | - | ||
58 | - public function getValue () | ||
59 | - { | ||
60 | - return $this->hasOne(OptionLang::className(), ['option_id' => 'option_id'])->where(['option_lang.language_id' => '0']); | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * @return \yii\db\ActiveQuery | ||
65 | - */ | ||
66 | - public function getOptionParent() | ||
67 | - { | ||
68 | - return $this->hasOne(Options::className(), ['option_id' => 'option_parent']); | ||
69 | - } | ||
70 | - | ||
71 | - /** | ||
72 | - * @return \yii\db\ActiveQuery | ||
73 | - */ | ||
74 | - public function getOptions() | ||
75 | - { | ||
76 | - return $this->hasMany(Options::className(), ['option_parent' => 'option_id']); | ||
77 | - } | ||
78 | -} |
frontend/models/OptionsSearch.php deleted
1 | -<?php | ||
2 | - | ||
3 | -namespace frontend\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use frontend\models\Options; | ||
9 | - | ||
10 | -/** | ||
11 | - * OptionsSearch represents the model behind the search form about `frontend\models\Options`. | ||
12 | - */ | ||
13 | -class OptionsSearch extends Options | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['option_id', 'option_parent', 'option_translatable'], 'integer'], | ||
22 | - [['option_key', 'option_format'], '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 = Options::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 | - 'option_id' => $this->option_id, | ||
60 | - 'option_parent' => $this->option_parent, | ||
61 | - 'option_translatable' => $this->option_translatable, | ||
62 | - ]); | ||
63 | - | ||
64 | - $query->andFilterWhere(['like', 'option_key', $this->option_key]) | ||
65 | - ->andFilterWhere(['like', 'option_format', $this->option_format]); | ||
66 | - | ||
67 | - return $dataProvider; | ||
68 | - } | ||
69 | -} |
frontend/views/option-values/_form.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 frontend\models\OptionValues */ | ||
8 | -/* @var $form yii\widgets\ActiveForm */ | ||
9 | -?> | ||
10 | - | ||
11 | -<div class="option-values-form"> | ||
12 | - | ||
13 | - <?php $form = ActiveForm::begin(); ?> | ||
14 | - | ||
15 | - <?= $form->field($model, 'option_key')->textInput(['maxlength' => true]) ?> | ||
16 | - | ||
17 | - <div class="optionvalues-option_value_text-active"> | ||
18 | - <?= $form->field($model, 'option_value_text', ['enableClientValidation' => false])->label($model->getAttributeLabel('option_key').' | <span class="glyphicon glyphicon-globe add-langs"></span>')->textInput() ?> | ||
19 | - | ||
20 | - <?= $form->field($model, 'option_language_id')->dropDownList($model->getDropDownArray()) ?> | ||
21 | - </div> | ||
22 | - | ||
23 | - <?= $form->field($model, 'option_value_parent')->dropDownList($model->getUserOptionsArray()) ?> | ||
24 | - | ||
25 | - <div class="form-group"> | ||
26 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
27 | - </div> | ||
28 | - | ||
29 | - <?php ActiveForm::end(); ?> | ||
30 | - | ||
31 | -</div> | ||
32 | -<div class="reserved_inputs"> | ||
33 | - <div class="lang-inputs form-group optionvalues-option_value_text-lang"> | ||
34 | - <label for="OptionValues[option_value_text][0]" class="col-xs-12 optionvalues-option_value_text" data-group="optionvalues-option_value_text"><?php echo $model->getAttributeLabel('option_key'); ?> | <span class="glyphicon glyphicon-globe remove-langs"></span></label> | ||
35 | - <?php foreach($model->getLanguagesCodes() as $lang) { | ||
36 | - ?> | ||
37 | - <div class="col-xs-1 text-right"><span><?=$lang['lang_code']?></span></div> | ||
38 | - <div class="col-xs-11"><input type="text" id="optionvalues-<?=$lang['lang_code']?>-option_value_text" class="form-control" name="OptionValues[option_value_text][<?=$lang['language_id']?>]" /></div> | ||
39 | - <?php | ||
40 | - }?> | ||
41 | - <div class="clearfix"></div> | ||
42 | - </div> | ||
43 | -</div> | ||
44 | -<script> | ||
45 | - $(function() { | ||
46 | - $(document).on('click', '.add-langs', function() { | ||
47 | - var group = $(this).parent().attr('for'); | ||
48 | - $(this).parent().parent().appendTo('.reserved_inputs'); | ||
49 | - $('.field-optionvalues-option_language_id').appendTo('.reserved_inputs'); | ||
50 | - $('.'+group+'-lang').appendTo('.'+group+'-active'); | ||
51 | - }); | ||
52 | - $(document).on('click', '.remove-langs', function() { | ||
53 | - var group = $(this).parent().data('group'); | ||
54 | - $(this).parent().parent().appendTo('.reserved_inputs'); | ||
55 | - console.log('field-'+group); | ||
56 | - $('.reserved_inputs .field-'+group).appendTo('.'+group+'-active'); | ||
57 | - $('.field-optionvalues-option_language_id').appendTo('.'+group+'-active'); | ||
58 | - }); | ||
59 | - }); | ||
60 | -</script> | ||
61 | \ No newline at end of file | 0 | \ No newline at end of file |
frontend/views/option-values/_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 frontend\models\OptionValuesSearch */ | ||
8 | -/* @var $form yii\widgets\ActiveForm */ | ||
9 | -?> | ||
10 | - | ||
11 | -<div class="option-values-search"> | ||
12 | - | ||
13 | - <?php $form = ActiveForm::begin([ | ||
14 | - 'action' => ['index'], | ||
15 | - 'method' => 'get', | ||
16 | - ]); ?> | ||
17 | - | ||
18 | - <?= $form->field($model, 'option_value_id') ?> | ||
19 | - | ||
20 | - <?= $form->field($model, 'option_key') ?> | ||
21 | - | ||
22 | - <?= $form->field($model, 'option_value_text') ?> | ||
23 | - | ||
24 | - <?= $form->field($model, 'option_language_id') ?> | ||
25 | - | ||
26 | - <?= $form->field($model, 'option_value_parent') ?> | ||
27 | - | ||
28 | - <?php // echo $form->field($model, 'option_user') ?> | ||
29 | - | ||
30 | - <div class="form-group"> | ||
31 | - <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
32 | - <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
33 | - </div> | ||
34 | - | ||
35 | - <?php ActiveForm::end(); ?> | ||
36 | - | ||
37 | -</div> |
frontend/views/option-values/create.php deleted
1 | -<?php | ||
2 | - | ||
3 | -use yii\helpers\Html; | ||
4 | - | ||
5 | - | ||
6 | -/* @var $this yii\web\View */ | ||
7 | -/* @var $model frontend\models\OptionValues */ | ||
8 | - | ||
9 | -$this->title = Yii::t('app', 'Create Option Values'); | ||
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="option-values-create"> | ||
14 | - | ||
15 | - <h1><?= Html::encode($this->title) ?></h1> | ||
16 | - | ||
17 | - <?= $this->render('_form', [ | ||
18 | - 'model' => $model, | ||
19 | - ]) ?> | ||
20 | - | ||
21 | -</div> |
frontend/views/option-values/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 frontend\models\OptionValuesSearch */ | ||
8 | -/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | - | ||
10 | -$this->title = Yii::t('app', 'Option Values'); | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="option-values-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 Option Values'), ['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 | - 'option_value_id', | ||
29 | - 'option_key', | ||
30 | - 'option_value_text:ntext', | ||
31 | - 'option_language_id', | ||
32 | - 'option_value_parent', | ||
33 | - // 'option_user', | ||
34 | - | ||
35 | - ['class' => 'yii\grid\ActionColumn'], | ||
36 | - ], | ||
37 | - ]); ?> | ||
38 | - | ||
39 | -</div> |
frontend/views/option-values/update.php deleted
1 | -<?php | ||
2 | - | ||
3 | -use yii\helpers\Html; | ||
4 | - | ||
5 | -/* @var $this yii\web\View */ | ||
6 | -/* @var $model frontend\models\OptionValues */ | ||
7 | - | ||
8 | -$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
9 | - 'modelClass' => 'Option Values', | ||
10 | -]) . ' ' . $model->option_value_id; | ||
11 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
12 | -$this->params['breadcrumbs'][] = ['label' => $model->option_value_id, 'url' => ['view', 'id' => $model->option_value_id]]; | ||
13 | -$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
14 | -?> | ||
15 | -<div class="option-values-update"> | ||
16 | - | ||
17 | - <h1><?= Html::encode($this->title) ?></h1> | ||
18 | - | ||
19 | - <?= $this->render('_form', [ | ||
20 | - 'model' => $model, | ||
21 | - ]) ?> | ||
22 | - | ||
23 | -</div> |
frontend/views/option-values/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 frontend\models\OptionValues */ | ||
8 | - | ||
9 | -$this->title = $model->option_value_id; | ||
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="option-values-view"> | ||
14 | - | ||
15 | - <h1><?= Html::encode($this->title) ?></h1> | ||
16 | - | ||
17 | - <p> | ||
18 | - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->option_value_id], ['class' => 'btn btn-primary']) ?> | ||
19 | - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->option_value_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 | - 'option_value_id', | ||
32 | - 'option_key', | ||
33 | - 'option_value_text:ntext', | ||
34 | - 'option_language_id', | ||
35 | - 'option_value_parent', | ||
36 | - 'option_user', | ||
37 | - ], | ||
38 | - ]) ?> | ||
39 | - | ||
40 | -</div> |
frontend/views/option/_form.php
@@ -4,125 +4,30 @@ use yii\helpers\Html; | @@ -4,125 +4,30 @@ use yii\helpers\Html; | ||
4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
5 | 5 | ||
6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model frontend\models\Option */ | 7 | +/* @var $model common\models\Option */ |
8 | /* @var $form yii\widgets\ActiveForm */ | 8 | /* @var $form yii\widgets\ActiveForm */ |
9 | ?> | 9 | ?> |
10 | 10 | ||
11 | <div class="option-form"> | 11 | <div class="option-form"> |
12 | + | ||
12 | <?php $form = ActiveForm::begin(); ?> | 13 | <?php $form = ActiveForm::begin(); ?> |
13 | - <input type="hidden" name="Option[model]" value="<?=$modeldb?>"/> | ||
14 | - <input type="hidden" name="Option[model_id]" value="<?=$model_id?>"/> | ||
15 | - <?php if($multiple) { ?><p class="text-right"><span class="glyphicon glyphicon-plus add_row"></span></p><?php }?> | ||
16 | - <?php if(empty($models)) { | ||
17 | - ?> | ||
18 | - <div class="form-group" id="main_row"> | ||
19 | - <?php foreach($fields as $index => $field) { | ||
20 | - ?> | ||
21 | - <div class="fields_block"> | ||
22 | - <label for="Option[0][<?=$field['name']?>]"><?php echo Yii::t('app', $field['name']); ?></label> | ||
23 | - <?php | ||
24 | - if($field['translate']) { ?><p class="text-right"><span class="glyphicon glyphicon-globe add_lang"></span></p><?php } | ||
25 | - ?> | ||
26 | - <input type="hidden" name="Option[0][<?=$field['name']?>][template]" value="<?=$field['template']?>"/> | ||
27 | - <input type="hidden" name="Option[0][<?=$field['name']?>][translate]" value="<?=$field['translate']?>"/> | ||
28 | - <input type="<?=$field['template']?>" name="Option[0][value][<?=$field['name']?>]" class="form-control required main_input" required/> | ||
29 | - <?php | ||
30 | - if($field['translate']) { | ||
31 | - ?> | ||
32 | - <div class="lang_inputs" style="display: none"> | ||
33 | - <?php | ||
34 | - foreach($model->getLangs() as $lang) { | ||
35 | - ?> | ||
36 | - <div class="form-group"> | ||
37 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
38 | - <div class="col-xs-11"><input type="<?=$field['template']?>" name="Option[0][lang][<?=$field['name']?>][<?=$lang['language_id']?>]" class="form-control" /></div> | ||
39 | - <div class="clearfix"></div> | ||
40 | - </div> | ||
41 | - <?php | ||
42 | - } | ||
43 | - ?> | ||
44 | - </div> | ||
45 | - <?php | ||
46 | - } | ||
47 | - ?> | ||
48 | - </div> | ||
49 | - <?php | ||
50 | - }?> | ||
51 | - </div> | ||
52 | - <?php | ||
53 | - } else { | ||
54 | - $first = 1; | ||
55 | - foreach($models as $index => $row) { | ||
56 | - foreach($row as $key => $value) { | ||
57 | - if(!$modellang[$index][$key][0]->hasErrors('value')) { | ||
58 | - continue; | ||
59 | - } | ||
60 | - if($first) { | ||
61 | - ?> | ||
62 | - <div class="form-group" id="main_row"> | ||
63 | - <?php | ||
64 | - } | ||
65 | - ?> | ||
66 | - <div class="fields_block"> | ||
67 | - <label for="Option[0][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> | ||
68 | - <input type="hidden" name="Option[0][template]" value="<?=$value->template?>"/> | ||
69 | - <input type="<?=$value->template?>" name="Option[0][value][<?=$key?>]" class="form-control required main_input" required value="<?=$modellang[$index][$key][0]->value?>"/> | ||
70 | - <div class="help-block"><?=$modellang[$index][$key][0]->getFirstError('value')?></div> | ||
71 | - <?php | ||
72 | - if($field['translate']) { | ||
73 | - ?> | ||
74 | - <div class="lang_inputs"> | ||
75 | - <?php | ||
76 | - foreach($value->getLangs() as $lang) { | ||
77 | - ?> | ||
78 | - <div class="form-group"> | ||
79 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
80 | - <div class="col-xs-11"><input type="<?=$value->template?>" name="Option[0][lang][<?=$key?>][<?=$lang['language_id']?>]" class="form-control" value="<?=$modellang[$index][$key][$lang['language_id']]->value?>"/></div> | ||
81 | - </div> | ||
82 | - <?php | ||
83 | - } | ||
84 | - ?> | ||
85 | - </div> | ||
86 | - <?php | ||
87 | - } ?> | ||
88 | - </div> | ||
89 | - <?php | ||
90 | - if($first) { | ||
91 | - ?> | ||
92 | - </div> | ||
93 | - <?php | ||
94 | - $first = 0; | ||
95 | - } | ||
96 | - } | ||
97 | - } | ||
98 | - }?> | ||
99 | - | 14 | + |
15 | + <?= $form->field($model, 'model')->textInput(['maxlength' => true]) ?> | ||
16 | + | ||
17 | + <?= $form->field($model, 'model_id')->textInput() ?> | ||
18 | + | ||
19 | + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | ||
20 | + | ||
21 | + <?= $form->field($model, 'template')->textInput(['maxlength' => true]) ?> | ||
22 | + | ||
23 | + <?= $form->field($model, 'option_pid')->textInput() ?> | ||
24 | + | ||
25 | + <?= $form->field($model, 'date_add')->textInput() ?> | ||
26 | + | ||
100 | <div class="form-group"> | 27 | <div class="form-group"> |
101 | <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 28 | <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
102 | </div> | 29 | </div> |
103 | 30 | ||
104 | <?php ActiveForm::end(); ?> | 31 | <?php ActiveForm::end(); ?> |
105 | - <script> | ||
106 | - $(function() { | ||
107 | - var counter = 0; | ||
108 | - $(document).on('click', '.add_row', function() { | ||
109 | - counter++; | ||
110 | - var clone = $('#main_row').clone().html().replace(new RegExp("Option\\[0\\]", 'g'), "Option["+counter+"]"); | ||
111 | - $(clone).appendTo('#<?=$form->getId()?>'); | ||
112 | - $('#<?=$form->getId()?> button[type=submit]').parent().appendTo('#<?=$form->getId()?>'); | ||
113 | - }); | ||
114 | - $(document).on('click', '.add_lang', function() { | ||
115 | - var field_block = $(this).parent().parent(); | ||
116 | - if($(this).hasClass('active')) { | ||
117 | - $(field_block).find('.main_input').attr('required', '').show(); | ||
118 | - $(field_block).find('.lang_inputs').hide(); | ||
119 | - $(this).removeClass('active'); | ||
120 | - } else { | ||
121 | - $(field_block).find('.main_input').removeAttr('required').hide(); | ||
122 | - $(field_block).find('.lang_inputs').show(); | ||
123 | - $(this).addClass('active'); | ||
124 | - } | ||
125 | - }); | ||
126 | - }); | ||
127 | - </script> | 32 | + |
128 | </div> | 33 | </div> |
frontend/views/option/_form_edit.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 frontend\models\Option */ | ||
8 | -/* @var $form yii\widgets\ActiveForm */ | ||
9 | -?> | ||
10 | - | ||
11 | -<div class="option-form"> | ||
12 | - <?php $form = ActiveForm::begin(); ?> | ||
13 | - <input type="hidden" name="Option[model]" value="<?=$modeldb?>"/> | ||
14 | - <input type="hidden" name="Option[model_id]" value="<?=$model_id?>"/> | ||
15 | - <?php foreach($models as $id => $row) { | ||
16 | - ?> | ||
17 | - <label for="Option[<?=$id?>][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> | ||
18 | - <input type="hidden" name="Option[<?=$id?>][id]" value="<?=$id?>" /> | ||
19 | - <input type="hidden" name="Option[<?=$id?>][template]" value="<?=$row->template?>"/> | ||
20 | - <input type="<?=$row->template?>" name="Option[<?=$id?>][value][<?=$row->name?>]" class="form-control required" required value="<?=$modellang[$id][0]->value?>"/> | ||
21 | - <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?> | ||
22 | - <?php | ||
23 | - if($row->translate) { | ||
24 | - foreach($row->getLangs() as $language_id => $lang) { | ||
25 | - ?> | ||
26 | - <div class="form-group"> | ||
27 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
28 | - <div class="col-xs-11"><input type="<?=$row->template?>" name="Option[<?=$id?>][lang][<?=$lang['language_id']?>]" class="form-control" value="<?=$modellang[$id][$lang['language_id']]->value?>"/></div> | ||
29 | - </div> | ||
30 | - <?php | ||
31 | - } | ||
32 | - } | ||
33 | - | ||
34 | - }?> | ||
35 | - | ||
36 | - <div class="form-group"> | ||
37 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
38 | - </div> | ||
39 | - | ||
40 | - <?php ActiveForm::end(); ?> | ||
41 | -</div> |
frontend/views/option/_search.php
@@ -4,7 +4,7 @@ use yii\helpers\Html; | @@ -4,7 +4,7 @@ use yii\helpers\Html; | ||
4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
5 | 5 | ||
6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model frontend\models\OptionSearch */ | 7 | +/* @var $model common\models\OptionSearch */ |
8 | /* @var $form yii\widgets\ActiveForm */ | 8 | /* @var $form yii\widgets\ActiveForm */ |
9 | ?> | 9 | ?> |
10 | 10 | ||
@@ -15,17 +15,19 @@ use yii\widgets\ActiveForm; | @@ -15,17 +15,19 @@ use yii\widgets\ActiveForm; | ||
15 | 'method' => 'get', | 15 | 'method' => 'get', |
16 | ]); ?> | 16 | ]); ?> |
17 | 17 | ||
18 | - <?= $form->field($model, 'option_id') ?> | ||
19 | - | ||
20 | <?= $form->field($model, 'model') ?> | 18 | <?= $form->field($model, 'model') ?> |
21 | 19 | ||
20 | + <?= $form->field($model, 'option_id') ?> | ||
21 | + | ||
22 | <?= $form->field($model, 'model_id') ?> | 22 | <?= $form->field($model, 'model_id') ?> |
23 | 23 | ||
24 | <?= $form->field($model, 'name') ?> | 24 | <?= $form->field($model, 'name') ?> |
25 | 25 | ||
26 | <?= $form->field($model, 'template') ?> | 26 | <?= $form->field($model, 'template') ?> |
27 | 27 | ||
28 | - <?php // echo $form->field($model, 'parent_id') ?> | 28 | + <?php // echo $form->field($model, 'option_pid') ?> |
29 | + | ||
30 | + <?php // echo $form->field($model, 'date_add') ?> | ||
29 | 31 | ||
30 | <div class="form-group"> | 32 | <div class="form-group"> |
31 | <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | 33 | <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> |
frontend/views/option/create.php
@@ -4,16 +4,18 @@ use yii\helpers\Html; | @@ -4,16 +4,18 @@ use yii\helpers\Html; | ||
4 | 4 | ||
5 | 5 | ||
6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model frontend\models\Option */ | 7 | +/* @var $model common\models\Option */ |
8 | 8 | ||
9 | $this->title = Yii::t('app', 'Create Option'); | 9 | $this->title = Yii::t('app', 'Create Option'); |
10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | 10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; |
11 | $this->params['breadcrumbs'][] = $this->title; | 11 | $this->params['breadcrumbs'][] = $this->title; |
12 | ?> | 12 | ?> |
13 | <div class="option-create"> | 13 | <div class="option-create"> |
14 | + | ||
14 | <h1><?= Html::encode($this->title) ?></h1> | 15 | <h1><?= Html::encode($this->title) ?></h1> |
15 | - <?php foreach($forms as $oneform) { | ||
16 | - echo $this->render('_form', $oneform); | ||
17 | - }?> | 16 | + |
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + ]) ?> | ||
18 | 20 | ||
19 | </div> | 21 | </div> |
frontend/views/option/index.php
@@ -4,7 +4,7 @@ use yii\helpers\Html; | @@ -4,7 +4,7 @@ use yii\helpers\Html; | ||
4 | use yii\grid\GridView; | 4 | use yii\grid\GridView; |
5 | 5 | ||
6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $searchModel frontend\models\OptionSearch */ | 7 | +/* @var $searchModel common\models\OptionSearch */ |
8 | /* @var $dataProvider yii\data\ActiveDataProvider */ | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
9 | 9 | ||
10 | $this->title = Yii::t('app', 'Options'); | 10 | $this->title = Yii::t('app', 'Options'); |
@@ -25,12 +25,13 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,12 +25,13 @@ $this->params['breadcrumbs'][] = $this->title; | ||
25 | 'columns' => [ | 25 | 'columns' => [ |
26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
27 | 27 | ||
28 | - 'option_id', | ||
29 | 'model', | 28 | 'model', |
29 | + 'option_id', | ||
30 | 'model_id', | 30 | 'model_id', |
31 | 'name', | 31 | 'name', |
32 | 'template', | 32 | 'template', |
33 | - // 'parent_id', | 33 | + // 'option_pid', |
34 | + // 'date_add', | ||
34 | 35 | ||
35 | ['class' => 'yii\grid\ActionColumn'], | 36 | ['class' => 'yii\grid\ActionColumn'], |
36 | ], | 37 | ], |
frontend/views/option/update.php
@@ -3,19 +3,21 @@ | @@ -3,19 +3,21 @@ | ||
3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
4 | 4 | ||
5 | /* @var $this yii\web\View */ | 5 | /* @var $this yii\web\View */ |
6 | -/* @var $model frontend\models\Option */ | 6 | +/* @var $model common\models\Option */ |
7 | 7 | ||
8 | $this->title = Yii::t('app', 'Update {modelClass}: ', [ | 8 | $this->title = Yii::t('app', 'Update {modelClass}: ', [ |
9 | 'modelClass' => 'Option', | 9 | 'modelClass' => 'Option', |
10 | -]) . ' ' . $forms[0]['models'][\Yii::$app->request->get('id')]->name; | 10 | +]) . ' ' . $model->name; |
11 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | 11 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; |
12 | -$this->params['breadcrumbs'][] = ['label' => $forms[0]['models'][\Yii::$app->request->get('id')]->name, 'url' => ['view', 'id' => $forms[0]['models'][\Yii::$app->request->get('id')]->option_id]]; | 12 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->option_id]]; |
13 | $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | 13 | $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); |
14 | ?> | 14 | ?> |
15 | <div class="option-update"> | 15 | <div class="option-update"> |
16 | + | ||
16 | <h1><?= Html::encode($this->title) ?></h1> | 17 | <h1><?= Html::encode($this->title) ?></h1> |
17 | - <?php foreach($forms as $oneform) { | ||
18 | - echo $this->render('_form_edit', $oneform); | ||
19 | - }?> | 18 | + |
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + ]) ?> | ||
20 | 22 | ||
21 | </div> | 23 | </div> |
frontend/views/option/view.php
@@ -4,7 +4,7 @@ use yii\helpers\Html; | @@ -4,7 +4,7 @@ use yii\helpers\Html; | ||
4 | use yii\widgets\DetailView; | 4 | use yii\widgets\DetailView; |
5 | 5 | ||
6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
7 | -/* @var $model frontend\models\Option */ | 7 | +/* @var $model common\models\Option */ |
8 | 8 | ||
9 | $this->title = $model->name; | 9 | $this->title = $model->name; |
10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | 10 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; |
@@ -28,12 +28,13 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -28,12 +28,13 @@ $this->params['breadcrumbs'][] = $this->title; | ||
28 | <?= DetailView::widget([ | 28 | <?= DetailView::widget([ |
29 | 'model' => $model, | 29 | 'model' => $model, |
30 | 'attributes' => [ | 30 | 'attributes' => [ |
31 | - 'option_id', | ||
32 | 'model', | 31 | 'model', |
32 | + 'option_id', | ||
33 | 'model_id', | 33 | 'model_id', |
34 | 'name', | 34 | 'name', |
35 | 'template', | 35 | 'template', |
36 | - 'parent_id', | 36 | + 'option_pid', |
37 | + 'date_add', | ||
37 | ], | 38 | ], |
38 | ]) ?> | 39 | ]) ?> |
39 | 40 |
frontend/views/options/_form.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 frontend\models\Options */ | ||
8 | -/* @var $form yii\widgets\ActiveForm */ | ||
9 | -?> | ||
10 | - | ||
11 | -<div class="options-form"> | ||
12 | - | ||
13 | - <?php $form = ActiveForm::begin(); ?> | ||
14 | - | ||
15 | - <?= $form->field($model, 'option_key')->textInput(['maxlength' => true]) ?> | ||
16 | - | ||
17 | - <?= $form->field($model, 'option_parent')->textInput() ?> | ||
18 | - | ||
19 | - <?= $form->field($model, 'option_translatable')->textInput() ?> | ||
20 | - | ||
21 | - <?= $form->field($model, 'option_format')->textInput(['maxlength' => true]) ?> | ||
22 | - | ||
23 | - <div class="form-group"> | ||
24 | - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
25 | - </div> | ||
26 | - | ||
27 | - <?php ActiveForm::end(); ?> | ||
28 | - | ||
29 | -</div> |
frontend/views/options/_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 frontend\models\OptionsSearch */ | ||
8 | -/* @var $form yii\widgets\ActiveForm */ | ||
9 | -?> | ||
10 | - | ||
11 | -<div class="options-search"> | ||
12 | - | ||
13 | - <?php $form = ActiveForm::begin([ | ||
14 | - 'action' => ['index'], | ||
15 | - 'method' => 'get', | ||
16 | - ]); ?> | ||
17 | - | ||
18 | - <?= $form->field($model, 'option_id') ?> | ||
19 | - | ||
20 | - <?= $form->field($model, 'option_key') ?> | ||
21 | - | ||
22 | - <?= $form->field($model, 'option_parent') ?> | ||
23 | - | ||
24 | - <?= $form->field($model, 'option_translatable') ?> | ||
25 | - | ||
26 | - <?= $form->field($model, 'option_format') ?> | ||
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> |
frontend/views/options/create.php deleted
1 | -<?php | ||
2 | - | ||
3 | -use yii\helpers\Html; | ||
4 | - | ||
5 | - | ||
6 | -/* @var $this yii\web\View */ | ||
7 | -/* @var $model frontend\models\Options */ | ||
8 | - | ||
9 | -$this->title = Yii::t('app', 'Create Options'); | ||
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="options-create"> | ||
14 | - | ||
15 | - <h1><?= Html::encode($this->title) ?></h1> | ||
16 | - | ||
17 | - <?= $this->render('_form', [ | ||
18 | - 'model' => $model, | ||
19 | - ]) ?> | ||
20 | - | ||
21 | -</div> |
frontend/views/options/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 frontend\models\OptionsSearch */ | ||
8 | -/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | - | ||
10 | -$this->title = Yii::t('app', 'Options'); | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="options-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 Options'), ['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 | - 'option_id', | ||
29 | - 'option_key', | ||
30 | - 'option_parent', | ||
31 | - 'option_translatable', | ||
32 | - 'option_format', | ||
33 | - | ||
34 | - ['class' => 'yii\grid\ActionColumn'], | ||
35 | - ], | ||
36 | - ]); ?> | ||
37 | - | ||
38 | -</div> |
frontend/views/options/update.php deleted
1 | -<?php | ||
2 | - | ||
3 | -use yii\helpers\Html; | ||
4 | - | ||
5 | -/* @var $this yii\web\View */ | ||
6 | -/* @var $model frontend\models\Options */ | ||
7 | - | ||
8 | -$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
9 | - 'modelClass' => 'Options', | ||
10 | -]) . ' ' . $model->option_id; | ||
11 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
12 | -$this->params['breadcrumbs'][] = ['label' => $model->option_id, 'url' => ['view', 'id' => $model->option_id]]; | ||
13 | -$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
14 | -?> | ||
15 | -<div class="options-update"> | ||
16 | - | ||
17 | - <h1><?= Html::encode($this->title) ?></h1> | ||
18 | - | ||
19 | - <?= $this->render('_form', [ | ||
20 | - 'model' => $model, | ||
21 | - ]) ?> | ||
22 | - | ||
23 | -</div> |
frontend/views/options/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 frontend\models\Options */ | ||
8 | - | ||
9 | -$this->title = $model->option_id; | ||
10 | -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | ||
12 | -?> | ||
13 | -<div class="options-view"> | ||
14 | - | ||
15 | - <h1><?= Html::encode($this->title) ?></h1> | ||
16 | - | ||
17 | - <p> | ||
18 | - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->option_id], ['class' => 'btn btn-primary']) ?> | ||
19 | - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->option_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 | - 'option_id', | ||
32 | - 'option_key', | ||
33 | - 'option_parent', | ||
34 | - 'option_translatable', | ||
35 | - 'option_format', | ||
36 | - ], | ||
37 | - ]) ?> | ||
38 | - | ||
39 | -</div> |