Commit 69bd5fc6b421e994ffbcc9de27ea89689699248b
1 parent
46bf80cf
Добавлены языки по новой технологии и опции
Showing
27 changed files
with
1189 additions
and
40 deletions
Show diff stats
backend/config/bootstrap.php
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use backend\models\Language; | ||
| 7 | +use backend\models\LanguageSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * LanguageController implements the CRUD actions for Language model. | ||
| 14 | + */ | ||
| 15 | +class LanguageController extends Controller | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | + public function behaviors() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + 'verbs' => [ | ||
| 22 | + 'class' => VerbFilter::className(), | ||
| 23 | + 'actions' => [ | ||
| 24 | + 'delete' => ['post'], | ||
| 25 | + ], | ||
| 26 | + ], | ||
| 27 | + ]; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Lists all Language models. | ||
| 32 | + * @return mixed | ||
| 33 | + */ | ||
| 34 | + public function actionIndex() | ||
| 35 | + { | ||
| 36 | + $searchModel = new LanguageSearch(); | ||
| 37 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 38 | + | ||
| 39 | + return $this->render('index', [ | ||
| 40 | + 'searchModel' => $searchModel, | ||
| 41 | + 'dataProvider' => $dataProvider, | ||
| 42 | + ]); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Creates a new Language model. | ||
| 47 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 48 | + * @return mixed | ||
| 49 | + */ | ||
| 50 | + public function actionCreate() | ||
| 51 | + { | ||
| 52 | + if(!empty(Yii::$app->request->get('id'))) { | ||
| 53 | + $model = $this->findModel(Yii::$app->request->get('id')); | ||
| 54 | + $model->active = 1; | ||
| 55 | + $model->save(); | ||
| 56 | + return $this->redirect(['index']); | ||
| 57 | + } else { | ||
| 58 | + $searchModel = new LanguageSearch(); | ||
| 59 | + $dataProvider = $searchModel->searchNew(Yii::$app->request->queryParams); | ||
| 60 | + | ||
| 61 | + return $this->render('create', [ | ||
| 62 | + 'searchModel' => $searchModel, | ||
| 63 | + 'dataProvider' => $dataProvider, | ||
| 64 | + ]); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * Deletes an existing Language model. | ||
| 70 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 71 | + * @param integer $id | ||
| 72 | + * @return mixed | ||
| 73 | + */ | ||
| 74 | + public function actionDelete($id) | ||
| 75 | + { | ||
| 76 | + $model = $this->findModel($id); | ||
| 77 | + $model->active = 0; | ||
| 78 | + $model->save(); | ||
| 79 | + | ||
| 80 | + return $this->redirect(['index']); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public function actionDefault($id) | ||
| 84 | + { | ||
| 85 | + $model = $this->findModel($id); | ||
| 86 | + $models = Language::find()->where(['is_default' => 1])->all(); | ||
| 87 | + foreach($models as $onemodel) { | ||
| 88 | + $onemodel->is_default = 0; | ||
| 89 | + $onemodel->save(); | ||
| 90 | + } | ||
| 91 | + $model->is_default = 1; | ||
| 92 | + $model->save(); | ||
| 93 | + return $this->redirect(['index']); | ||
| 94 | + } | ||
| 95 | + /** | ||
| 96 | + * Finds the Language model based on its primary key value. | ||
| 97 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 98 | + * @param integer $id | ||
| 99 | + * @return Language the loaded model | ||
| 100 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 101 | + */ | ||
| 102 | + protected function findModel($id) | ||
| 103 | + { | ||
| 104 | + if (($model = Language::findOne($id)) !== null) { | ||
| 105 | + return $model; | ||
| 106 | + } else { | ||
| 107 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use frontend\models\Option; | ||
| 7 | +use frontend\models\OptionSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | +use frontend\models\OptionLang; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * OptionController implements the CRUD actions for Option model. | ||
| 15 | + */ | ||
| 16 | +class OptionController extends Controller | ||
| 17 | +{ | ||
| 18 | + public function behaviors() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + 'verbs' => [ | ||
| 22 | + 'class' => VerbFilter::className(), | ||
| 23 | + 'actions' => [ | ||
| 24 | + 'delete' => ['post'], | ||
| 25 | + ], | ||
| 26 | + ], | ||
| 27 | + ]; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Lists all Option models. | ||
| 32 | + * @return mixed | ||
| 33 | + */ | ||
| 34 | + public function actionIndex() | ||
| 35 | + { | ||
| 36 | + $searchModel = new OptionSearch(); | ||
| 37 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 38 | + | ||
| 39 | + return $this->render('index', [ | ||
| 40 | + 'searchModel' => $searchModel, | ||
| 41 | + 'dataProvider' => $dataProvider, | ||
| 42 | + ]); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Displays a single Option model. | ||
| 47 | + * @param integer $id | ||
| 48 | + * @return mixed | ||
| 49 | + */ | ||
| 50 | + public function actionView($id) | ||
| 51 | + { | ||
| 52 | + return $this->render('view', [ | ||
| 53 | + 'model' => $this->findModel($id), | ||
| 54 | + ]); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * Creates a new Option model. | ||
| 59 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 60 | + * @return mixed | ||
| 61 | + */ | ||
| 62 | + public function actionCreate() | ||
| 63 | + { | ||
| 64 | + $form[0] = Option::create(\Yii::$app->request->post(), 'User', 10, [['name' => 'phone', 'template' => 'text', 'translate' => true], ['name' => 'adres', 'template' => 'text', 'translate' => false]]); | ||
| 65 | + if($form[0]['success'] == false) { | ||
| 66 | + return $this->render('create', ['forms' => $form]); | ||
| 67 | + } else { | ||
| 68 | + return $this->redirect(['index']); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * Updates an existing Option model. | ||
| 74 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 75 | + * @param integer $id | ||
| 76 | + * @return mixed | ||
| 77 | + */ | ||
| 78 | + public function actionUpdate($id) | ||
| 79 | + { | ||
| 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]); | ||
| 83 | + } else { | ||
| 84 | + return $this->redirect(['view', 'id' => $id]); | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * Deletes an existing Option model. | ||
| 90 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 91 | + * @param integer $id | ||
| 92 | + * @return mixed | ||
| 93 | + */ | ||
| 94 | + public function actionDelete($id) | ||
| 95 | + { | ||
| 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(); | ||
| 113 | + | ||
| 114 | + return $this->redirect(['index']); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * Finds the Option model based on its primary key value. | ||
| 119 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 120 | + * @param integer $id | ||
| 121 | + * @return Option the loaded model | ||
| 122 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 123 | + */ | ||
| 124 | + protected function findModel($id) | ||
| 125 | + { | ||
| 126 | + if (($model = Option::findOne($id)) !== null) { | ||
| 127 | + return $model; | ||
| 128 | + } else { | ||
| 129 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "language". | ||
| 9 | + * | ||
| 10 | + * @property integer $language_id | ||
| 11 | + * @property string $lang_code | ||
| 12 | + * @property boolean $is_default | ||
| 13 | + * @property string $language_name | ||
| 14 | + * @property boolean $active | ||
| 15 | + */ | ||
| 16 | +class Language extends \yii\db\ActiveRecord | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @inheritdoc | ||
| 20 | + */ | ||
| 21 | + public static function tableName() | ||
| 22 | + { | ||
| 23 | + return 'language'; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function rules() | ||
| 30 | + { | ||
| 31 | + return [ | ||
| 32 | + [['lang_code', 'language_name'], 'required'], | ||
| 33 | + [['is_default', 'active'], 'boolean'], | ||
| 34 | + [['lang_code'], 'string', 'max' => 4], | ||
| 35 | + [['language_name'], 'string', 'max' => 255] | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public function attributeLabels() | ||
| 43 | + { | ||
| 44 | + return [ | ||
| 45 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
| 46 | + 'lang_code' => Yii::t('app', 'Lang Code'), | ||
| 47 | + 'is_default' => Yii::t('app', 'Is Default'), | ||
| 48 | + 'language_name' => Yii::t('app', 'Language Name'), | ||
| 49 | + 'active' => Yii::t('app', 'Active'), | ||
| 50 | + ]; | ||
| 51 | + } | ||
| 52 | +} |
| 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\Language; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * LanguageSearch represents the model behind the search form about `backend\models\Language`. | ||
| 12 | + */ | ||
| 13 | +class LanguageSearch extends Language | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['language_id'], 'integer'], | ||
| 22 | + [['lang_code', 'language_name'], 'safe'], | ||
| 23 | + [['is_default', 'active'], 'boolean'], | ||
| 24 | + ]; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @inheritdoc | ||
| 29 | + */ | ||
| 30 | + public function scenarios() | ||
| 31 | + { | ||
| 32 | + // bypass scenarios() implementation in the parent class | ||
| 33 | + return Model::scenarios(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Creates data provider instance with search query applied | ||
| 38 | + * | ||
| 39 | + * @param array $params | ||
| 40 | + * | ||
| 41 | + * @return ActiveDataProvider | ||
| 42 | + */ | ||
| 43 | + public function search($params) | ||
| 44 | + { | ||
| 45 | + $query = Language::find(); | ||
| 46 | + | ||
| 47 | + $dataProvider = new ActiveDataProvider([ | ||
| 48 | + 'query' => $query, | ||
| 49 | + ]); | ||
| 50 | + | ||
| 51 | + $this->load($params); | ||
| 52 | + | ||
| 53 | + if (!$this->validate()) { | ||
| 54 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 55 | + // $query->where('0=1'); | ||
| 56 | + return $dataProvider; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + $query->andFilterWhere([ | ||
| 60 | + 'language_id' => $this->language_id, | ||
| 61 | + 'is_default' => $this->is_default, | ||
| 62 | + 'active' => $this->active, | ||
| 63 | + ]); | ||
| 64 | + | ||
| 65 | + $query->andFilterWhere(['like', 'lang_code', $this->lang_code]) | ||
| 66 | + ->andFilterWhere(['like', 'language_name', $this->language_name]) | ||
| 67 | + ->andWhere(['active' => '1']); | ||
| 68 | + | ||
| 69 | + return $dataProvider; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public function searchNew($params) | ||
| 73 | + { | ||
| 74 | + $query = Language::find(); | ||
| 75 | + | ||
| 76 | + $dataProvider = new ActiveDataProvider([ | ||
| 77 | + 'query' => $query, | ||
| 78 | + ]); | ||
| 79 | + | ||
| 80 | + $this->load($params); | ||
| 81 | + | ||
| 82 | + if (!$this->validate()) { | ||
| 83 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 84 | + // $query->where('0=1'); | ||
| 85 | + return $dataProvider; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + $query->andFilterWhere([ | ||
| 89 | + 'language_id' => $this->language_id, | ||
| 90 | + 'is_default' => $this->is_default, | ||
| 91 | + 'active' => $this->active, | ||
| 92 | + ]); | ||
| 93 | + | ||
| 94 | + $query->andFilterWhere(['like', 'lang_code', $this->lang_code]) | ||
| 95 | + ->andFilterWhere(['like', 'language_name', $this->language_name]) | ||
| 96 | + ->andWhere(['active' => '0']); | ||
| 97 | + | ||
| 98 | + return $dataProvider; | ||
| 99 | + } | ||
| 100 | +} |
| 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\LanguageSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="language-search"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin([ | ||
| 14 | + 'action' => ['index'], | ||
| 15 | + 'method' => 'get', | ||
| 16 | + ]); ?> | ||
| 17 | + | ||
| 18 | + <?= $form->field($model, 'language_id') ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'lang_code') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'is_default')->checkbox() ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'language_name') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'active')->checkbox() ?> | ||
| 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> |
| 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\LanguageSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Languages'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +echo $this->render('layout'); | ||
| 13 | +?> | ||
| 14 | +<div class="lang-column-2"> | ||
| 15 | + | ||
| 16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 17 | + | ||
| 18 | + <?= GridView::widget([ | ||
| 19 | + 'dataProvider' => $dataProvider, | ||
| 20 | + 'filterModel' => $searchModel, | ||
| 21 | + 'layout' => "{items}", | ||
| 22 | + 'columns' => [ | ||
| 23 | + 'language_name', | ||
| 24 | + 'lang_code', | ||
| 25 | + [ | ||
| 26 | + 'class' => 'yii\grid\ActionColumn', | ||
| 27 | + 'template' => '{create}', | ||
| 28 | + 'buttons' => [ | ||
| 29 | + 'create' => function ($url, $model, $key) { | ||
| 30 | + return Html::a('', $url, ['class' => 'glyphicon glyphicon-plus', 'title' => Yii::t('app', 'Create Language')]); | ||
| 31 | + }, | ||
| 32 | + ], | ||
| 33 | + ] | ||
| 34 | + ] | ||
| 35 | + ]); ?> | ||
| 36 | + | ||
| 37 | + <p class="text-right"> | ||
| 38 | + <?= Html::a(Yii::t('app', 'Cancel'), ['index'], ['class' => 'btn btn-success']) ?> | ||
| 39 | + </p> | ||
| 40 | + | ||
| 41 | +</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\LanguageSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Languages'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +echo $this->render('layout'); | ||
| 13 | +?> | ||
| 14 | +<div class="lang-column-2"> | ||
| 15 | + | ||
| 16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 17 | + | ||
| 18 | + <?= GridView::widget([ | ||
| 19 | + 'dataProvider' => $dataProvider, | ||
| 20 | + 'filterModel' => $searchModel, | ||
| 21 | + 'layout' => "{items}", | ||
| 22 | + 'columns' => [ | ||
| 23 | + 'language_name', | ||
| 24 | + 'lang_code', | ||
| 25 | + 'is_default:boolean', | ||
| 26 | + [ | ||
| 27 | + 'class' => 'yii\grid\ActionColumn', | ||
| 28 | + 'template' => '{default} {delete}', | ||
| 29 | + 'buttons' => [ | ||
| 30 | + 'default' => function ($url, $model, $key) { | ||
| 31 | + return Html::a('', $model->is_default?'#':$url, ['class' => $model->is_default?'glyphicon glyphicon-star':'glyphicon glyphicon-star-empty', 'title' => Yii::t('app', 'Make default')]); | ||
| 32 | + }, | ||
| 33 | + ], | ||
| 34 | + ] | ||
| 35 | + ] | ||
| 36 | + ]); ?> | ||
| 37 | + | ||
| 38 | + <p class="text-right"> | ||
| 39 | + <?= Html::a(Yii::t('app', 'Create Language'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 40 | + </p> | ||
| 41 | + | ||
| 42 | +</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\LanguageSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | +$this->registerCssFile('/backend/web/css/language.css'); | ||
| 10 | +$this->registerJsFile('/backend/web/js/language.js', ['depends' => ['yii\web\JqueryAsset'], 'position' => $this::POS_END]); | ||
| 11 | +$this->title = Yii::t('app', 'Settings'); | ||
| 12 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 13 | +?> | ||
| 14 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 15 | + <div class="lang-column-1"> | ||
| 16 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 17 | + <ul class="settings_menu sidebar-menu"> | ||
| 18 | + <li> | ||
| 19 | + <a href="#collapseLanguages" data-toggle="collapse" aria-expanded="false" aria-controls="collapseLanguages"><?php echo \Yii::t('app', 'languages');?></a> | ||
| 20 | + <ul class="collapse settings_menu_inner" id="collapseLanguages"> | ||
| 21 | + <li> | ||
| 22 | + <?= Html::a(Yii::t('app', 'Language list'), ['index']) ?> | ||
| 23 | + </li> | ||
| 24 | + <li> | ||
| 25 | + <a href="#collapseLanguagesStaticFront" data-toggle="collapse" aria-expanded="false" aria-controls="collapseLanguagesStaticFront"><?php echo \Yii::t('app', 'languages_static_front');?></a> | ||
| 26 | + </li> | ||
| 27 | + <li> | ||
| 28 | + <a href="#collapseLanguagesStaticAdmin" data-toggle="collapse" aria-expanded="false" aria-controls="collapseLanguagesStaticAdmin"><?php echo \Yii::t('app', 'languages_static_admin');?></a> | ||
| 29 | + </li> | ||
| 30 | + </ul> | ||
| 31 | + </li> | ||
| 32 | + <li> | ||
| 33 | + <a href="#collapseRoles" data-toggle="collapse" aria-expanded="false" aria-controls="collapseRoles"><?php echo \Yii::t('app', 'roles');?></a> | ||
| 34 | + <ul class="collapse settings_menu_inner" id="collapseRoles"> | ||
| 35 | + <li>Ipsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum Ipsum</li> | ||
| 36 | + <li>Ipsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum IpsumIpsum Ipsum</li> | ||
| 37 | + </ul> | ||
| 38 | + </li> | ||
| 39 | + </ul> | ||
| 40 | + </div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model backend\models\Language */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
| 9 | + 'modelClass' => 'Language', | ||
| 10 | +]) . ' ' . $model->language_id; | ||
| 11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Languages'), 'url' => ['index']]; | ||
| 12 | +$this->params['breadcrumbs'][] = ['label' => $model->language_id, 'url' => ['view', 'id' => $model->language_id]]; | ||
| 13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 14 | +?> | ||
| 15 | +<div class="language-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\Language */ | ||
| 8 | + | ||
| 9 | +$this->title = $model->language_id; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Languages'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="language-view"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <p> | ||
| 18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->language_id], ['class' => 'btn btn-primary']) ?> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->language_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 | + 'language_id', | ||
| 32 | + 'lang_code', | ||
| 33 | + 'is_default:boolean', | ||
| 34 | + 'language_name', | ||
| 35 | + 'active:boolean', | ||
| 36 | + ], | ||
| 37 | + ]) ?> | ||
| 38 | + | ||
| 39 | +</div> |
| 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 | + <p class="text-right"><span class="glyphicon glyphicon-plus add_row"></span></p> | ||
| 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 | + | ||
| 100 | + <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']) ?> | ||
| 102 | + </div> | ||
| 103 | + | ||
| 104 | + <?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> | ||
| 128 | +</div> |
| 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 $lang_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> |
| 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\OptionSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-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, 'model') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'model_id') ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'name') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'template') ?> | ||
| 27 | + | ||
| 28 | + <?php // echo $form->field($model, 'parent_id') ?> | ||
| 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> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Option */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Create Option'); | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-create"> | ||
| 14 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 15 | + <?php foreach($forms as $oneform) { | ||
| 16 | + echo $this->render('_form', $oneform); | ||
| 17 | + }?> | ||
| 18 | + | ||
| 19 | +</div> |
| 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\OptionSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Options'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="col-xs-6"> | ||
| 14 | + <div class="option-index"> | ||
| 15 | + | ||
| 16 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 17 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 18 | + | ||
| 19 | + <p> | ||
| 20 | + <?= Html::a(Yii::t('app', 'Create Option'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 21 | + </p> | ||
| 22 | + | ||
| 23 | + <?= GridView::widget([ | ||
| 24 | + 'dataProvider' => $dataProvider, | ||
| 25 | + 'filterModel' => $searchModel, | ||
| 26 | + 'columns' => [ | ||
| 27 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 28 | + | ||
| 29 | + 'option_id', | ||
| 30 | + 'model', | ||
| 31 | + 'model_id', | ||
| 32 | + 'name', | ||
| 33 | + 'template', | ||
| 34 | + // 'parent_id', | ||
| 35 | + | ||
| 36 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 37 | + ], | ||
| 38 | + ]); ?> | ||
| 39 | + | ||
| 40 | + </div> | ||
| 41 | +</div> | ||
| 42 | +<div class="col-xs-6"> | ||
| 43 | + <div class="option-index"> | ||
| 44 | + | ||
| 45 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 46 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 47 | + | ||
| 48 | + <p> | ||
| 49 | + <?= Html::a(Yii::t('app', 'Create Option'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 50 | + </p> | ||
| 51 | + | ||
| 52 | + <?= GridView::widget([ | ||
| 53 | + 'dataProvider' => $dataProvider, | ||
| 54 | + 'filterModel' => $searchModel, | ||
| 55 | + 'columns' => [ | ||
| 56 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 57 | + | ||
| 58 | + 'option_id', | ||
| 59 | + 'model', | ||
| 60 | + 'model_id', | ||
| 61 | + 'name', | ||
| 62 | + 'template', | ||
| 63 | + // 'parent_id', | ||
| 64 | + | ||
| 65 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 66 | + ], | ||
| 67 | + ]); ?> | ||
| 68 | + | ||
| 69 | + </div> | ||
| 70 | +</div> | ||
| 71 | +<div class="clearfix"></div> | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model frontend\models\Option */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
| 9 | + 'modelClass' => 'Option', | ||
| 10 | +]) . ' ' . $forms[0]['models'][\Yii::$app->request->get('id')]->name; | ||
| 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]]; | ||
| 13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 14 | +?> | ||
| 15 | +<div class="option-update"> | ||
| 16 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 17 | + <?php foreach($forms as $oneform) { | ||
| 18 | + echo $this->render('_form_edit', $oneform); | ||
| 19 | + }?> | ||
| 20 | + | ||
| 21 | +</div> |
| 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\Option */ | ||
| 8 | + | ||
| 9 | +$this->title = $model->name; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-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 | + 'model', | ||
| 33 | + 'model_id', | ||
| 34 | + 'name', | ||
| 35 | + 'template', | ||
| 36 | + 'parent_id', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + | ||
| 40 | +</div> |
| 1 | +section.content-header { | ||
| 2 | + display: none; | ||
| 3 | +} | ||
| 4 | +section.content { | ||
| 5 | + height: 100%; | ||
| 6 | + padding: 0; | ||
| 7 | +} | ||
| 8 | +.content-wrapper { | ||
| 9 | + background: #444444 !important; | ||
| 10 | + position: absolute; | ||
| 11 | + top: 50px; | ||
| 12 | + height: calc(100% - 50px); | ||
| 13 | + left:0; | ||
| 14 | + width: calc(100% - 230px); | ||
| 15 | +} | ||
| 16 | +footer.main-footer { | ||
| 17 | + position: absolute; | ||
| 18 | + width: 100%; | ||
| 19 | + bottom: 0; | ||
| 20 | + left: 0; | ||
| 21 | +} | ||
| 22 | +footer.main-footer div.pull-right.hidden-xs { | ||
| 23 | + margin-right: 230px; | ||
| 24 | +} | ||
| 25 | +.lang-column-1 { | ||
| 26 | + float: left; | ||
| 27 | + width: 50%; | ||
| 28 | + height: 100%; | ||
| 29 | + overflow: auto; | ||
| 30 | +} | ||
| 31 | +.lang-column-1 h1 { | ||
| 32 | + text-align: center; | ||
| 33 | + color: #ecf0f5; | ||
| 34 | +} | ||
| 35 | +.lang-column-2 { | ||
| 36 | + background: #ecf0f5; | ||
| 37 | + padding: 50px 10px 0 10px; | ||
| 38 | + width: 50%; | ||
| 39 | + height: 100%; | ||
| 40 | + display:inline-block; | ||
| 41 | +} | ||
| 42 | +.settings_menu { | ||
| 43 | + color: #ecf0f5; | ||
| 44 | + white-space: normal !important; | ||
| 45 | +} | ||
| 46 | +.settings_menu a { | ||
| 47 | + color: #ecf0f5; | ||
| 48 | +} | ||
| 49 | +.settings_menu a:focus { | ||
| 50 | + color: #ecf0f5; | ||
| 51 | +} | ||
| 52 | +.settings_menu_inner { | ||
| 53 | + list-style: none; | ||
| 54 | + padding-left: 20px; | ||
| 55 | + background: #2c3b41; | ||
| 56 | +} | ||
| 57 | +.settings_menu_inner li { | ||
| 58 | + color: #8aa4af; | ||
| 59 | + padding: 5px 0; | ||
| 60 | +} | ||
| 61 | +.settings_menu_inner li .grid-view { | ||
| 62 | + background: #ecf0f5; | ||
| 63 | + margin-right: 10px; | ||
| 64 | + padding: 5px; | ||
| 65 | + color: #8aa4af !important; | ||
| 66 | +} | ||
| 67 | +.settings_menu_inner li .grid-view a:hover, .settings_menu_inner li .grid-view a:focus { | ||
| 68 | + color: #3C8DBC; | ||
| 69 | +} | ||
| 70 | +.settings_menu_inner li:hover { | ||
| 71 | + color: #ecf0f5; | ||
| 72 | + padding: 5px 0; | ||
| 73 | +} | ||
| 74 | +.settings_menu_inner li:focus { | ||
| 75 | + color: #ecf0f5; | ||
| 76 | + padding: 5px 0; | ||
| 77 | +} | ||
| 78 | +.settings_menu_inner li a { | ||
| 79 | + color: #8aa4af; | ||
| 80 | +} | ||
| 81 | +.settings_menu_inner li a:hover { | ||
| 82 | + color: #ecf0f5; | ||
| 83 | +} | ||
| 84 | +.settings_menu_inner li a:focus { | ||
| 85 | + color: #ecf0f5; | ||
| 86 | +} | ||
| 87 | +.settings_menu_inner li a.glyphicon { | ||
| 88 | + padding-left: 15px; | ||
| 89 | +} | ||
| 0 | \ No newline at end of file | 90 | \ No newline at end of file |
common/config/main.php
| @@ -27,9 +27,9 @@ return [ | @@ -27,9 +27,9 @@ return [ | ||
| 27 | ], | 27 | ], |
| 28 | 'i18n' => [ | 28 | 'i18n' => [ |
| 29 | 'translations' => [ | 29 | 'translations' => [ |
| 30 | - '*' => [ | 30 | + 'app*' => [ |
| 31 | 'class' => 'yii\i18n\PhpMessageSource', | 31 | 'class' => 'yii\i18n\PhpMessageSource', |
| 32 | - 'basePath' => $_SERVER['DOCUMENT_ROOT'].'/common/translation', | 32 | + 'basePath' => '@common/translation', |
| 33 | 'fileMap' => [ | 33 | 'fileMap' => [ |
| 34 | 'app' => 'app.php', | 34 | 'app' => 'app.php', |
| 35 | 'app/error' => 'error.php', | 35 | 'app/error' => 'error.php', |
| @@ -41,4 +41,5 @@ return [ | @@ -41,4 +41,5 @@ return [ | ||
| 41 | 'class' => 'yii\rbac\DbManager', | 41 | 'class' => 'yii\rbac\DbManager', |
| 42 | ], | 42 | ], |
| 43 | ], | 43 | ], |
| 44 | + 'language' => 'ru-RU' | ||
| 44 | ]; | 45 | ]; |
| 1 | +<?php | ||
| 2 | +return [ | ||
| 3 | + 'Create' => 'Добавить', | ||
| 4 | + 'Settings' => 'Настройки', | ||
| 5 | + 'languages' => 'Языки', | ||
| 6 | + 'Languages' => 'Языки', | ||
| 7 | + 'Language list' => 'Список языков', | ||
| 8 | + 'roles' => 'Роли', | ||
| 9 | + 'Create Language' => 'Добавить язык', | ||
| 10 | + 'Cancel' => 'Отмена' | ||
| 11 | +]; | ||
| 0 | \ No newline at end of file | 12 | \ No newline at end of file |
frontend/controllers/OptionController.php
| @@ -61,7 +61,7 @@ class OptionController extends Controller | @@ -61,7 +61,7 @@ class OptionController extends Controller | ||
| 61 | */ | 61 | */ |
| 62 | public function actionCreate() | 62 | public function actionCreate() |
| 63 | { | 63 | { |
| 64 | - $form[0] = Option::create(\Yii::$app->request->post(), 'User', 10, [['name' => 'phone', 'template' => 'text'], ['name' => 'adres', 'template' => 'text']]); | 64 | + $form[0] = Option::create(\Yii::$app->request->post(), 'User', 10, [['name' => 'phone', 'template' => 'text', 'translate' => true], ['name' => 'adres', 'template' => 'text', 'translate' => false]]); |
| 65 | if($form[0]['success'] == false) { | 65 | if($form[0]['success'] == false) { |
| 66 | return $this->render('create', ['forms' => $form]); | 66 | return $this->render('create', ['forms' => $form]); |
| 67 | } else { | 67 | } else { |
frontend/models/Option.php
| @@ -73,21 +73,33 @@ class Option extends \yii\db\ActiveRecord | @@ -73,21 +73,33 @@ class Option extends \yii\db\ActiveRecord | ||
| 73 | if(!empty($post)) { | 73 | if(!empty($post)) { |
| 74 | foreach($post['Option'] as $key => $option) { | 74 | foreach($post['Option'] as $key => $option) { |
| 75 | if(in_array($key, array('model', 'model_id'))) { continue; } | 75 | if(in_array($key, array('model', 'model_id'))) { continue; } |
| 76 | + if(empty($option['value'][$models[$key]->name]) && !empty($option['lang'])) { | ||
| 77 | + foreach($option['lang'] as $lang_id => $lang) { | ||
| 78 | + if(!empty($lang)) { | ||
| 79 | + $option['value'][$models[$key]->name] = $lang; | ||
| 80 | + break; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 76 | $modellang[$key][0]->value = $option['value'][$models[$key]->name]; | 84 | $modellang[$key][0]->value = $option['value'][$models[$key]->name]; |
| 77 | - if(!$modellang[$key][0]->save()) { | 85 | + if(empty($modellang[$key][0]->value) || !$modellang[$key][0]->save()) { |
| 78 | $ok = 0; | 86 | $ok = 0; |
| 87 | + $models[$key]->addError('value', 'Value must be set'); | ||
| 88 | + $modellang[$key][0]->addError('value', 'Value must be set'); | ||
| 79 | } | 89 | } |
| 80 | - foreach($option['lang'] as $lang_id => $lang) { | ||
| 81 | - if(empty($modellang[$key][$lang_id])) { | ||
| 82 | - $modellang[$key][$lang_id] = new OptionLang(); | ||
| 83 | - $modellang[$key][$lang_id]->id = $models[$key]->option_id; | ||
| 84 | - $modellang[$key][$lang_id]->lang_id = $lang_id; | ||
| 85 | - $modellang[$key][$lang_id]->value = $lang; | ||
| 86 | - } else { | ||
| 87 | - $modellang[$key][$lang_id]->value = $lang; | ||
| 88 | - } | ||
| 89 | - if(!$modellang[$key][$lang_id]->save()) { | ||
| 90 | - $ok = 0; | 90 | + if(!empty($option['lang'])) { |
| 91 | + foreach($option['lang'] as $lang_id => $lang) { | ||
| 92 | + if(empty($modellang[$key][$lang_id])) { | ||
| 93 | + $modellang[$key][$lang_id] = new OptionLang(); | ||
| 94 | + $modellang[$key][$lang_id]->id = $models[$key]->option_id; | ||
| 95 | + $modellang[$key][$lang_id]->lang_id = $lang_id; | ||
| 96 | + $modellang[$key][$lang_id]->value = $lang; | ||
| 97 | + } else { | ||
| 98 | + $modellang[$key][$lang_id]->value = $lang; | ||
| 99 | + } | ||
| 100 | + if(!$modellang[$key][$lang_id]->save()) { | ||
| 101 | + $ok = 0; | ||
| 102 | + } | ||
| 91 | } | 103 | } |
| 92 | } | 104 | } |
| 93 | } | 105 | } |
| @@ -125,12 +137,21 @@ class Option extends \yii\db\ActiveRecord | @@ -125,12 +137,21 @@ class Option extends \yii\db\ActiveRecord | ||
| 125 | $models[$index][$key] = new Option(); | 137 | $models[$index][$key] = new Option(); |
| 126 | $models[$index][$key]->model = $post['Option']['model']; | 138 | $models[$index][$key]->model = $post['Option']['model']; |
| 127 | $models[$index][$key]->model_id = $post['Option']['model_id']; | 139 | $models[$index][$key]->model_id = $post['Option']['model_id']; |
| 128 | - $models[$index][$key]->template = $option['template']; | 140 | + $models[$index][$key]->template = $option[$key]['template']; |
| 141 | + $models[$index][$key]->translate = $option[$key]['translate']?1:0; | ||
| 129 | $models[$index][$key]->name = $key; | 142 | $models[$index][$key]->name = $key; |
| 130 | if(!$first) { | 143 | if(!$first) { |
| 131 | $models[$index][$key]->parent_id = $parentid; | 144 | $models[$index][$key]->parent_id = $parentid; |
| 132 | } | 145 | } |
| 133 | $modelslang[$index][$key][0] = new OptionLang(); | 146 | $modelslang[$index][$key][0] = new OptionLang(); |
| 147 | + if(!empty($option['lang'][$key])) { | ||
| 148 | + foreach($option['lang'][$key] as $code => $lang) { | ||
| 149 | + if(!empty($lang)) { | ||
| 150 | + $value = $lang; | ||
| 151 | + break; | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + } | ||
| 134 | if(!empty($value) && $models[$index][$key]->save()) { | 155 | if(!empty($value) && $models[$index][$key]->save()) { |
| 135 | if($first) { | 156 | if($first) { |
| 136 | $parentid = $models[$index][$key]->option_id; | 157 | $parentid = $models[$index][$key]->option_id; |
frontend/views/option/_form.php
| @@ -16,20 +16,37 @@ use yii\widgets\ActiveForm; | @@ -16,20 +16,37 @@ use yii\widgets\ActiveForm; | ||
| 16 | <?php if(empty($models)) { | 16 | <?php if(empty($models)) { |
| 17 | ?> | 17 | ?> |
| 18 | <div class="form-group" id="main_row"> | 18 | <div class="form-group" id="main_row"> |
| 19 | - <?php foreach($fields as $field) { | 19 | + <?php foreach($fields as $index => $field) { |
| 20 | ?> | 20 | ?> |
| 21 | + <div class="fields_block"> | ||
| 21 | <label for="Option[0][<?=$field['name']?>]"><?php echo Yii::t('app', $field['name']); ?></label> | 22 | <label for="Option[0][<?=$field['name']?>]"><?php echo Yii::t('app', $field['name']); ?></label> |
| 22 | - <input type="hidden" name="Option[0][template]" value="<?=$field['template']?>"/> | ||
| 23 | - <input type="<?=$field['template']?>" name="Option[0][value][<?=$field['name']?>]" class="form-control required" required/> | 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/> | ||
| 24 | <?php | 29 | <?php |
| 25 | - foreach($model->getLangs() as $lang) { | 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 | + } | ||
| 26 | ?> | 43 | ?> |
| 27 | - <div class="form-group"> | ||
| 28 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 29 | - <div class="col-xs-11"><input type="<?=$field['template']?>" name="Option[0][lang][<?=$field['name']?>][<?=$lang['language_id']?>]" class="form-control" /></div> | ||
| 30 | </div> | 44 | </div> |
| 31 | <?php | 45 | <?php |
| 32 | } | 46 | } |
| 47 | + ?> | ||
| 48 | + </div> | ||
| 49 | + <?php | ||
| 33 | }?> | 50 | }?> |
| 34 | </div> | 51 | </div> |
| 35 | <?php | 52 | <?php |
| @@ -46,19 +63,30 @@ use yii\widgets\ActiveForm; | @@ -46,19 +63,30 @@ use yii\widgets\ActiveForm; | ||
| 46 | <?php | 63 | <?php |
| 47 | } | 64 | } |
| 48 | ?> | 65 | ?> |
| 66 | + <div class="fields_block"> | ||
| 49 | <label for="Option[0][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> | 67 | <label for="Option[0][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> |
| 50 | <input type="hidden" name="Option[0][template]" value="<?=$value->template?>"/> | 68 | <input type="hidden" name="Option[0][template]" value="<?=$value->template?>"/> |
| 51 | - <input type="<?=$value->template?>" name="Option[0][value][<?=$key?>]" class="form-control required" required value="<?=$modellang[$index][$key][0]->value?>"/> | 69 | + <input type="<?=$value->template?>" name="Option[0][value][<?=$key?>]" class="form-control required main_input" required value="<?=$modellang[$index][$key][0]->value?>"/> |
| 52 | <div class="help-block"><?=$modellang[$index][$key][0]->getFirstError('value')?></div> | 70 | <div class="help-block"><?=$modellang[$index][$key][0]->getFirstError('value')?></div> |
| 53 | <?php | 71 | <?php |
| 54 | - foreach($value->getLangs() as $lang) { | ||
| 55 | - ?> | ||
| 56 | - <div class="form-group"> | ||
| 57 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 58 | - <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> | ||
| 59 | - </div> | ||
| 60 | - <?php | ||
| 61 | - } | 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 | ||
| 62 | if($first) { | 90 | if($first) { |
| 63 | ?> | 91 | ?> |
| 64 | </div> | 92 | </div> |
| @@ -83,6 +111,18 @@ use yii\widgets\ActiveForm; | @@ -83,6 +111,18 @@ use yii\widgets\ActiveForm; | ||
| 83 | $(clone).appendTo('#<?=$form->getId()?>'); | 111 | $(clone).appendTo('#<?=$form->getId()?>'); |
| 84 | $('#<?=$form->getId()?> button[type=submit]').parent().appendTo('#<?=$form->getId()?>'); | 112 | $('#<?=$form->getId()?> button[type=submit]').parent().appendTo('#<?=$form->getId()?>'); |
| 85 | }); | 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 | + }); | ||
| 86 | }); | 126 | }); |
| 87 | </script> | 127 | </script> |
| 88 | </div> | 128 | </div> |
frontend/views/option/_form_edit.php
| @@ -20,14 +20,17 @@ use yii\widgets\ActiveForm; | @@ -20,14 +20,17 @@ use yii\widgets\ActiveForm; | ||
| 20 | <input type="<?=$row->template?>" name="Option[<?=$id?>][value][<?=$row->name?>]" class="form-control required" required value="<?=$modellang[$id][0]->value?>"/> | 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 } ?> | 21 | <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?> |
| 22 | <?php | 22 | <?php |
| 23 | - foreach($row->getLangs() as $lang_id => $lang) { | ||
| 24 | - ?> | ||
| 25 | - <div class="form-group"> | ||
| 26 | - <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 27 | - <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> | ||
| 28 | - </div> | ||
| 29 | - <?php | ||
| 30 | - } | 23 | + if($row->translate) { |
| 24 | + foreach($row->getLangs() as $lang_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 | + | ||
| 31 | }?> | 34 | }?> |
| 32 | 35 | ||
| 33 | <div class="form-group"> | 36 | <div class="form-group"> |
vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/content.php
| 1 | <?php | 1 | <?php |
| 2 | use yii\widgets\Breadcrumbs; | 2 | use yii\widgets\Breadcrumbs; |
| 3 | use dmstr\widgets\Alert; | 3 | use dmstr\widgets\Alert; |
| 4 | +use yii\helpers\Html; | ||
| 4 | 5 | ||
| 5 | ?> | 6 | ?> |
| 6 | <div class="content-wrapper"> | 7 | <div class="content-wrapper"> |
| @@ -226,6 +227,11 @@ use dmstr\widgets\Alert; | @@ -226,6 +227,11 @@ use dmstr\widgets\Alert; | ||
| 226 | </div> | 227 | </div> |
| 227 | <!-- /.form-group --> | 228 | <!-- /.form-group --> |
| 228 | </form> | 229 | </form> |
| 230 | + <?=Html::a( | ||
| 231 | + \Yii::t('app', 'settings'), | ||
| 232 | + ['/language'], | ||
| 233 | + ['data-method' => 'post', 'class' => 'btn btn-default btn-flat'] | ||
| 234 | + )?> | ||
| 229 | </div> | 235 | </div> |
| 230 | <!-- /.tab-pane --> | 236 | <!-- /.tab-pane --> |
| 231 | </div> | 237 | </div> |