Commit fe5be656c6a29aecc5f336c383442ef0d28784c4
Merge branch 'Yarik'
Showing
147 changed files
with
1967 additions
and
744 deletions
Show diff stats
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use backend\models\AdminMenu; | ||
| 7 | +use backend\models\AdminMenuSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * AdminMenuController implements the CRUD actions for AdminMenu model. | ||
| 14 | + */ | ||
| 15 | +class AdminMenuController extends Controller | ||
| 16 | +{ | ||
| 17 | + public $layout = 'settings'; | ||
| 18 | + | ||
| 19 | + public function behaviors() | ||
| 20 | + { | ||
| 21 | + return [ | ||
| 22 | + 'verbs' => [ | ||
| 23 | + 'class' => VerbFilter::className(), | ||
| 24 | + 'actions' => [ | ||
| 25 | + 'delete' => ['post'], | ||
| 26 | + ], | ||
| 27 | + ], | ||
| 28 | + ]; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Lists all AdminMenu models. | ||
| 33 | + * @return mixed | ||
| 34 | + */ | ||
| 35 | + public function actionIndex() | ||
| 36 | + { | ||
| 37 | + $searchModel = new AdminMenuSearch(); | ||
| 38 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 39 | + | ||
| 40 | + return $this->render('index', [ | ||
| 41 | + 'searchModel' => $searchModel, | ||
| 42 | + 'dataProvider' => $dataProvider, | ||
| 43 | + ]); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Displays a single AdminMenu model. | ||
| 48 | + * @param integer $id | ||
| 49 | + * @return mixed | ||
| 50 | + */ | ||
| 51 | + public function actionView($id) | ||
| 52 | + { | ||
| 53 | + return $this->render('view', [ | ||
| 54 | + 'model' => $this->findModel($id), | ||
| 55 | + ]); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Creates a new AdminMenu model. | ||
| 60 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 61 | + * @return mixed | ||
| 62 | + */ | ||
| 63 | + public function actionCreate() | ||
| 64 | + { | ||
| 65 | + $model = new AdminMenu(); | ||
| 66 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 67 | + return $this->redirect(['view', 'id' => $model->admin_menu_id]); | ||
| 68 | + } else { | ||
| 69 | + return $this->render('create', [ | ||
| 70 | + 'model' => $model, | ||
| 71 | + ]); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * Updates an existing AdminMenu model. | ||
| 77 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 78 | + * @param integer $id | ||
| 79 | + * @return mixed | ||
| 80 | + */ | ||
| 81 | + public function actionUpdate($id) | ||
| 82 | + { | ||
| 83 | + $model = $this->findModel($id); | ||
| 84 | + | ||
| 85 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 86 | + return $this->redirect(['view', 'id' => $model->adminmenu_id]); | ||
| 87 | + } else { | ||
| 88 | + return $this->render('update', [ | ||
| 89 | + 'model' => $model, | ||
| 90 | + ]); | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * Deletes an existing AdminMenu model. | ||
| 96 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 97 | + * @param integer $id | ||
| 98 | + * @return mixed | ||
| 99 | + */ | ||
| 100 | + public function actionDelete($id) | ||
| 101 | + { | ||
| 102 | + $this->findModel($id)->delete(); | ||
| 103 | + | ||
| 104 | + return $this->redirect(['index']); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * Finds the AdminMenu model based on its primary key value. | ||
| 109 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 110 | + * @param integer $id | ||
| 111 | + * @return AdminMenu the loaded model | ||
| 112 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 113 | + */ | ||
| 114 | + protected function findModel($id) | ||
| 115 | + { | ||
| 116 | + if (($model = AdminMenu::findOne($id)) !== null) { | ||
| 117 | + return $model; | ||
| 118 | + } else { | ||
| 119 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | +} |
backend/controllers/LanguageController.php
| @@ -54,7 +54,7 @@ class LanguageController extends Controller | @@ -54,7 +54,7 @@ class LanguageController extends Controller | ||
| 54 | { | 54 | { |
| 55 | if(!empty(Yii::$app->request->get('id'))) { | 55 | if(!empty(Yii::$app->request->get('id'))) { |
| 56 | $model = $this->findModel(Yii::$app->request->get('id')); | 56 | $model = $this->findModel(Yii::$app->request->get('id')); |
| 57 | - $model->active = 1; | 57 | + $model->status = 1; |
| 58 | $model->save(); | 58 | $model->save(); |
| 59 | return $this->redirect(['index']); | 59 | return $this->redirect(['index']); |
| 60 | } else { | 60 | } else { |
| @@ -77,7 +77,7 @@ class LanguageController extends Controller | @@ -77,7 +77,7 @@ class LanguageController extends Controller | ||
| 77 | public function actionDelete($id) | 77 | public function actionDelete($id) |
| 78 | { | 78 | { |
| 79 | $model = $this->findModel($id); | 79 | $model = $this->findModel($id); |
| 80 | - $model->active = 0; | 80 | + $model->status = 0; |
| 81 | $model->save(); | 81 | $model->save(); |
| 82 | 82 | ||
| 83 | return $this->redirect(['index']); | 83 | return $this->redirect(['index']); |
| @@ -152,18 +152,18 @@ class LanguageController extends Controller | @@ -152,18 +152,18 @@ class LanguageController extends Controller | ||
| 152 | public function actionDeleteAdress($id) | 152 | public function actionDeleteAdress($id) |
| 153 | { | 153 | { |
| 154 | $model = $this->findModelAdress($id); | 154 | $model = $this->findModelAdress($id); |
| 155 | - $children = $model->hasMany(Option::className(), ['parent_id' => 'option_id'])->all(); | 155 | + $children = $model->hasMany(Option::className(), ['option_pid' => 'option_id'])->all(); |
| 156 | $langs = array(); | 156 | $langs = array(); |
| 157 | if(!empty($children)) { | 157 | if(!empty($children)) { |
| 158 | foreach($children as $child) { | 158 | foreach($children as $child) { |
| 159 | - $langs = OptionLang::findAll(['id' => $child->option_id]); | 159 | + $langs = OptionLang::findAll(['option_language_id' => $child->option_id]); |
| 160 | foreach($langs as $lang) { | 160 | foreach($langs as $lang) { |
| 161 | $lang->delete(); | 161 | $lang->delete(); |
| 162 | } | 162 | } |
| 163 | $child->delete(); | 163 | $child->delete(); |
| 164 | } | 164 | } |
| 165 | } | 165 | } |
| 166 | - $langs = OptionLang::findAll(['id' => $id]); | 166 | + $langs = OptionLang::findAll(['option_language_id' => $id]); |
| 167 | foreach($langs as $lang) { | 167 | foreach($langs as $lang) { |
| 168 | $lang->delete(); | 168 | $lang->delete(); |
| 169 | } | 169 | } |
backend/controllers/MenuController.php
| @@ -118,4 +118,5 @@ class MenuController extends Controller | @@ -118,4 +118,5 @@ class MenuController extends Controller | ||
| 118 | throw new NotFoundHttpException('The requested page does not exist.'); | 118 | throw new NotFoundHttpException('The requested page does not exist.'); |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | + | ||
| 121 | } | 122 | } |
| 1 | +<?php | ||
| 2 | +namespace backend\controllers; | ||
| 3 | + | ||
| 4 | +use Yii; | ||
| 5 | +use yii\filters\AccessControl; | ||
| 6 | +use yii\web\Controller; | ||
| 7 | +use common\models\LoginForm; | ||
| 8 | +use yii\filters\VerbFilter; | ||
| 9 | +use backend\models\Profile; | ||
| 10 | +use common\models\User; | ||
| 11 | +use frontend\models\Option; | ||
| 12 | +use yii\data\ActiveDataProvider; | ||
| 13 | +use yii\validators\BooleanValidator; | ||
| 14 | +use yii\validators\StringValidator; | ||
| 15 | +/** | ||
| 16 | + * Site controller | ||
| 17 | + */ | ||
| 18 | +class SettingsController extends Controller | ||
| 19 | +{ | ||
| 20 | + public $layout = 'settings'; | ||
| 21 | + /** | ||
| 22 | + * @inheritdoc | ||
| 23 | + */ | ||
| 24 | + public function actions() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'error' => [ | ||
| 28 | + 'class' => 'yii\web\ErrorAction', | ||
| 29 | + ], | ||
| 30 | + ]; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public function actionIndex() | ||
| 34 | + { | ||
| 35 | + return $this->render('index'); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
backend/controllers/TerminController.php
| @@ -5,26 +5,24 @@ namespace backend\controllers; | @@ -5,26 +5,24 @@ namespace backend\controllers; | ||
| 5 | use Yii; | 5 | use Yii; |
| 6 | use backend\models\Termin; | 6 | use backend\models\Termin; |
| 7 | use backend\models\TerminSearch; | 7 | use backend\models\TerminSearch; |
| 8 | -use yii\filters\AccessControl; | ||
| 9 | use yii\web\Controller; | 8 | use yii\web\Controller; |
| 10 | use yii\web\NotFoundHttpException; | 9 | use yii\web\NotFoundHttpException; |
| 11 | use yii\filters\VerbFilter; | 10 | use yii\filters\VerbFilter; |
| 12 | use backend\models\TerminLang; | 11 | use backend\models\TerminLang; |
| 13 | use backend\models\TerminStructure; | 12 | use backend\models\TerminStructure; |
| 14 | -use common\models\Language; | ||
| 15 | -use backend\models\TerminRelation; | 13 | +use yii\filters\AccessControl; |
| 16 | 14 | ||
| 17 | /** | 15 | /** |
| 18 | * TerminController implements the CRUD actions for Termin model. | 16 | * TerminController implements the CRUD actions for Termin model. |
| 19 | */ | 17 | */ |
| 20 | class TerminController extends Controller | 18 | class TerminController extends Controller |
| 21 | { | 19 | { |
| 22 | - public function behaviors() | 20 | + public function behaviors() |
| 23 | { | 21 | { |
| 24 | return [ | 22 | return [ |
| 25 | 'access' => [ | 23 | 'access' => [ |
| 26 | 'class' => AccessControl::className(), | 24 | 'class' => AccessControl::className(), |
| 27 | - 'except' => ['login', 'error', 'index', 'create', 'update', 'view', 'form', 'delete'], | 25 | + 'except' => ['login', 'error', 'index', 'create', 'update'], |
| 28 | 'rules' => [ | 26 | 'rules' => [ |
| 29 | [ | 27 | [ |
| 30 | 'allow' => true, | 28 | 'allow' => true, |
| @@ -41,20 +39,6 @@ class TerminController extends Controller | @@ -41,20 +39,6 @@ class TerminController extends Controller | ||
| 41 | ], | 39 | ], |
| 42 | ]; | 40 | ]; |
| 43 | } | 41 | } |
| 44 | - | ||
| 45 | - // ==== AJAX ==== | ||
| 46 | - | ||
| 47 | - public function actionForm($lang_id, $widget_id) | ||
| 48 | - { | ||
| 49 | - if (! $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one()) | ||
| 50 | - { | ||
| 51 | - throw new NotFoundHttpException('Language not found'); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - $article_lang = new TerminLang(); | ||
| 55 | - | ||
| 56 | - return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]); | ||
| 57 | - } | ||
| 58 | 42 | ||
| 59 | /** | 43 | /** |
| 60 | * Lists all Termin models. | 44 | * Lists all Termin models. |
| @@ -90,48 +74,23 @@ class TerminController extends Controller | @@ -90,48 +74,23 @@ class TerminController extends Controller | ||
| 90 | */ | 74 | */ |
| 91 | public function actionCreate() | 75 | public function actionCreate() |
| 92 | { | 76 | { |
| 93 | - $model = new Termin(); | ||
| 94 | - $model_pid = new TerminStructure(); | 77 | + $model = new Termin(); |
| 78 | + $model_lang = new TerminLang(); | ||
| 95 | 79 | ||
| 96 | - // проверяем общие таблицы | ||
| 97 | if ($model->load(Yii::$app->request->post()) | 80 | if ($model->load(Yii::$app->request->post()) |
| 98 | - && $model_pid->load(Yii::$app->request->post()) | ||
| 99 | - ) | ||
| 100 | - { | ||
| 101 | - $model_lang = []; | ||
| 102 | - | ||
| 103 | - foreach (Yii::$app->request->post()['TerminLang'] as $index => $row) | ||
| 104 | - { | ||
| 105 | - $model_lang[$index] = new TerminLang(); | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - if (TerminLang::loadMultiple($model_lang, Yii::$app->request->post()) | ||
| 109 | - && TerminLang::validateMultiple($model_lang)) | ||
| 110 | - { | ||
| 111 | - $model->save(); | ||
| 112 | - $model_pid->termin_id = $model->termin_id; | ||
| 113 | - $model_pid->save(); | ||
| 114 | - | ||
| 115 | - foreach ($model_lang as $post) | ||
| 116 | - { | ||
| 117 | - $post->termin_id = $model->termin_id; | ||
| 118 | - $post->save(false); | ||
| 119 | - } | ||
| 120 | - } | 81 | + && $model_lang->load(Yii::$app->request->post())) |
| 82 | + { | ||
| 83 | + $model->save(); | ||
| 84 | + $model_lang->termin_id = $model->termin_id; | ||
| 85 | + $model_lang->save(); | ||
| 121 | 86 | ||
| 122 | return $this->redirect(['view', 'id' => $model->termin_id]); | 87 | return $this->redirect(['view', 'id' => $model->termin_id]); |
| 123 | } | 88 | } |
| 124 | else | 89 | else |
| 125 | - { | ||
| 126 | - $default_lang = Language::getDefaultLang(); | ||
| 127 | - | ||
| 128 | - $LANG = []; | ||
| 129 | - $LANG[$default_lang->language_id] = new TerminLang(); | ||
| 130 | - | 90 | + { |
| 131 | return $this->render('create', [ | 91 | return $this->render('create', [ |
| 132 | 'model' => $model, | 92 | 'model' => $model, |
| 133 | - 'model_lang' => $LANG, | ||
| 134 | - 'model_pid' => $model_pid, | 93 | + 'model_lang' => $model_lang, |
| 135 | ]); | 94 | ]); |
| 136 | } | 95 | } |
| 137 | } | 96 | } |
| @@ -145,49 +104,22 @@ class TerminController extends Controller | @@ -145,49 +104,22 @@ class TerminController extends Controller | ||
| 145 | public function actionUpdate($id) | 104 | public function actionUpdate($id) |
| 146 | { | 105 | { |
| 147 | $model = $this->findModel($id); | 106 | $model = $this->findModel($id); |
| 148 | - $model_lang = Termin::findOne($id)->getTerminLangs()->indexBy('lang_id')->all(); | ||
| 149 | - $model_pid = TerminStructure::findOne($id); | ||
| 150 | - | ||
| 151 | - // проверяем общие таблицы | 107 | + $model_lang = TerminLang::findOne($id); |
| 108 | + $model_pid = TerminStructure::findOne($id)->getRelation('terminPid')->one(); | ||
| 109 | + | ||
| 110 | + //var_dump(Yii::$app->request->post()); | ||
| 111 | + //var_dump($model_pid->termin->termin_id); die; | ||
| 112 | + | ||
| 152 | if ($model->load(Yii::$app->request->post()) | 113 | if ($model->load(Yii::$app->request->post()) |
| 114 | + && $model_lang->load(Yii::$app->request->post()) | ||
| 153 | && $model_pid->load(Yii::$app->request->post()) | 115 | && $model_pid->load(Yii::$app->request->post()) |
| 154 | ) | 116 | ) |
| 155 | - { | ||
| 156 | -/* | ||
| 157 | - // проверяем таблицы lang | ||
| 158 | - $post_lang = Yii::$app->request->post('TerminLang'); | ||
| 159 | - if (! empty ($post_lang)) | ||
| 160 | - { | ||
| 161 | - foreach ($post_lang as &$row) | ||
| 162 | - { | ||
| 163 | - $row += new TerminLang(); | ||
| 164 | - } | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - var_dump($post_lang); | ||
| 168 | - | ||
| 169 | - die; | ||
| 170 | -*/ | ||
| 171 | - // + появились | ||
| 172 | - | ||
| 173 | - // - удалились | ||
| 174 | - | ||
| 175 | - if (TerminLang::loadMultiple($model_lang, Yii::$app->request->post()) | ||
| 176 | - && TerminLang::validateMultiple($model_lang)) | ||
| 177 | - { | ||
| 178 | - foreach ($model_lang as $post) | ||
| 179 | - { | ||
| 180 | - $post->termin_id = $model->termin_id; | ||
| 181 | - $post->save(false); | ||
| 182 | - } | ||
| 183 | - | ||
| 184 | - $model->save(); | ||
| 185 | - $model_pid->save(); | ||
| 186 | - | ||
| 187 | - return $this->redirect(['view', 'id' => $model->termin_id]); | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - return $this->redirect('index'); | 117 | + { |
| 118 | + $model->save(); | ||
| 119 | + $model_lang->save(); | ||
| 120 | + $model_pid->termin_pid = $model_pid->termin->termin_id; | ||
| 121 | + | ||
| 122 | + return $this->redirect(['view', 'id' => $model->termin_id]); | ||
| 191 | } | 123 | } |
| 192 | else | 124 | else |
| 193 | { | 125 | { |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "admin_menu". | ||
| 9 | + * | ||
| 10 | + * @property integer $admin_menu_id | ||
| 11 | + * @property integer $admin_menu_pid | ||
| 12 | + * @property integer $status | ||
| 13 | + * @property integer $hide_min | ||
| 14 | + * @property integer $sort | ||
| 15 | + * @property string $name | ||
| 16 | + * @property string $path | ||
| 17 | + * @property string $param | ||
| 18 | + * | ||
| 19 | + * @property AdminMenu $parent | ||
| 20 | + * @property AdminMenu[] $adminMenus | ||
| 21 | + * @property AdminMenuAccessGroup[] $adminMenuAccessGroups | ||
| 22 | + * @property AdminMenuAccessUser[] $adminMenuAccessUsers | ||
| 23 | + */ | ||
| 24 | +class AdminMenu extends \yii\db\ActiveRecord | ||
| 25 | +{ | ||
| 26 | + | ||
| 27 | + public $parentt; | ||
| 28 | + /** | ||
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public static function tableName() | ||
| 32 | + { | ||
| 33 | + return 'admin_menu'; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @inheritdoc | ||
| 38 | + */ | ||
| 39 | + public function rules() | ||
| 40 | + { | ||
| 41 | + return [ | ||
| 42 | + [['admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'], | ||
| 43 | + [['name'], 'required'], | ||
| 44 | + [['name', 'path', 'param','parentt'], 'string'] | ||
| 45 | + ]; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * @inheritdoc | ||
| 50 | + */ | ||
| 51 | + public function attributeLabels() | ||
| 52 | + { | ||
| 53 | + return [ | ||
| 54 | + 'admin_menu_id' => Yii::t('app', 'Admin menu ID'), | ||
| 55 | + 'admin_menu_pid' => Yii::t('app', 'Admin menu parent ID'), | ||
| 56 | + 'status' => Yii::t('app', 'Status'), | ||
| 57 | + 'hide_min' => Yii::t('app', 'Hide Min'), | ||
| 58 | + 'sort' => Yii::t('app', 'Sort'), | ||
| 59 | + 'name' => Yii::t('app', 'Name'), | ||
| 60 | + 'path' => Yii::t('app', 'Path'), | ||
| 61 | + 'param' => Yii::t('app', 'Params'), | ||
| 62 | + 'parentt' => Yii::t('app', 'Parent item') | ||
| 63 | + ]; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * @return \yii\db\ActiveQuery | ||
| 68 | + */ | ||
| 69 | + public function getParent() | ||
| 70 | + { | ||
| 71 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_pid']); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * @return \yii\db\ActiveQuery | ||
| 76 | + */ | ||
| 77 | + public function getAdminMenus() | ||
| 78 | + { | ||
| 79 | + return $this->hasMany(AdminMenu::className(), ['admin_menu_pid' => 'admin_menu_id']); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * @return \yii\db\ActiveQuery | ||
| 84 | + */ | ||
| 85 | + public function getAdminMenuAccessGroups() | ||
| 86 | + { | ||
| 87 | + return $this->hasMany(AdminMenuAccessGroup::className(), ['admin_menu_id' => 'admin_menu_id']); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @return \yii\db\ActiveQuery | ||
| 92 | + */ | ||
| 93 | + public function getAdminMenuAccessUsers() | ||
| 94 | + { | ||
| 95 | + return $this->hasMany(AdminMenuAccessUser::className(), ['admin_menu_id' => 'admin_menu_id']); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public static function buildMenu($withValues = false) | ||
| 99 | + { | ||
| 100 | + $result = []; | ||
| 101 | + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all(); | ||
| 102 | + foreach($roots as $root) { | ||
| 103 | + if($root->adminMenus) { | ||
| 104 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'options' => ['class' => 'header']]; | ||
| 105 | + foreach($root->adminMenus as $submenu) { | ||
| 106 | + if($submenu->adminMenus) { | ||
| 107 | + $items = []; | ||
| 108 | + foreach($submenu->adminMenus as $item) { | ||
| 109 | + $items[] = ['label' => Yii::t('app', $item->name), 'id' => $item->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$item->path], \common\models\Tools::parseUrlParams($item->param))]; | ||
| 110 | + } | ||
| 111 | + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items]; | ||
| 112 | + unset($items); | ||
| 113 | + } else { | ||
| 114 | + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->param))]; | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + return $result; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public static function buildMenuSelect() | ||
| 123 | + { | ||
| 124 | + $result = []; | ||
| 125 | + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all(); | ||
| 126 | + foreach($roots as $root) { | ||
| 127 | + if($root->adminMenus) { | ||
| 128 | + $items = []; | ||
| 129 | + foreach($root->adminMenus as $submenu) { | ||
| 130 | + $items[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id]; | ||
| 131 | + } | ||
| 132 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'items' => $items]; | ||
| 133 | + unset($items); | ||
| 134 | + } else { | ||
| 135 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id]; | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + return $result; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public function beforeSave($insert) | ||
| 142 | + { | ||
| 143 | + if (parent::beforeSave($insert)) { | ||
| 144 | + if(!$this->admin_menu_pid) { | ||
| 145 | + $this->admin_menu_pid = NULL; | ||
| 146 | + } | ||
| 147 | + return true; | ||
| 148 | + } else { | ||
| 149 | + return false; | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "admin_menu_access_group". | ||
| 9 | + * | ||
| 10 | + * @property integer $admin_menu_access_group_id | ||
| 11 | + * @property integer $admin_menu_id | ||
| 12 | + * @property string $group | ||
| 13 | + * | ||
| 14 | + * @property AdminMenu $menu | ||
| 15 | + * @property AuthRule $group0 | ||
| 16 | + */ | ||
| 17 | +class AdminMenuAccessGroup extends \yii\db\ActiveRecord | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public static function tableName() | ||
| 23 | + { | ||
| 24 | + return 'admin_menu_access_group'; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @inheritdoc | ||
| 29 | + */ | ||
| 30 | + public function rules() | ||
| 31 | + { | ||
| 32 | + return [ | ||
| 33 | + [['admin_menu_id'], 'integer'], | ||
| 34 | + [['group'], 'string'] | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @inheritdoc | ||
| 40 | + */ | ||
| 41 | + public function attributeLabels() | ||
| 42 | + { | ||
| 43 | + return [ | ||
| 44 | + 'admin_menu_access_group_id' => Yii::t('app', 'Admin Access Group ID'), | ||
| 45 | + 'admin_menu_id' => Yii::t('app', 'Admin Menu ID'), | ||
| 46 | + 'group' => Yii::t('app', 'Group'), | ||
| 47 | + ]; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * @return \yii\db\ActiveQuery | ||
| 52 | + */ | ||
| 53 | + public function getMenu() | ||
| 54 | + { | ||
| 55 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @return \yii\db\ActiveQuery | ||
| 60 | + */ | ||
| 61 | + public function getGroup0() | ||
| 62 | + { | ||
| 63 | + return $this->hasOne(AuthRule::className(), ['name' => 'group']); | ||
| 64 | + } | ||
| 65 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace backend\models; | ||
| 4 | + | ||
| 5 | +use common\models\User; | ||
| 6 | +use Yii; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * This is the model class for table "admin_menu_access_user". | ||
| 10 | + * | ||
| 11 | + * @property integer $admin_menu_id | ||
| 12 | + * @property integer $user_id | ||
| 13 | + * @property integer $admin_menu_access_user_id | ||
| 14 | + * | ||
| 15 | + * @property AdminMenu $menu | ||
| 16 | + * @property User $user | ||
| 17 | + */ | ||
| 18 | +class AdminMenuAccessUser extends \yii\db\ActiveRecord | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * @inheritdoc | ||
| 22 | + */ | ||
| 23 | + public static function tableName() | ||
| 24 | + { | ||
| 25 | + return 'admin_menu_access_user'; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public function rules() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + [['admin_menu_id', 'user_id'], 'integer'] | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @inheritdoc | ||
| 40 | + */ | ||
| 41 | + public function attributeLabels() | ||
| 42 | + { | ||
| 43 | + return [ | ||
| 44 | + 'admin_menu_id' => Yii::t('app', 'Admin Menu ID'), | ||
| 45 | + 'user_id' => Yii::t('app', 'User ID'), | ||
| 46 | + 'admin_menu_access_user_id' => Yii::t('app', 'Admin Menu Access User ID'), | ||
| 47 | + ]; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * @return \yii\db\ActiveQuery | ||
| 52 | + */ | ||
| 53 | + public function getMenu() | ||
| 54 | + { | ||
| 55 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @return \yii\db\ActiveQuery | ||
| 60 | + */ | ||
| 61 | + public function getUser() | ||
| 62 | + { | ||
| 63 | + return $this->hasOne(User::className(), ['id' => 'user_id']); | ||
| 64 | + } | ||
| 65 | +} |
| 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\AdminMenu; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * AdminMenuSearch represents the model behind the search form about `backend\models\AdminMenu`. | ||
| 12 | + */ | ||
| 13 | +class AdminMenuSearch extends AdminMenu | ||
| 14 | +{ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * @inheritdoc | ||
| 19 | + */ | ||
| 20 | + public function rules() | ||
| 21 | + { | ||
| 22 | + return [ | ||
| 23 | + [['admin_menu_id', 'admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'], | ||
| 24 | + [['name', 'path', 'param','parentt'], 'safe'], | ||
| 25 | + ]; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public function scenarios() | ||
| 32 | + { | ||
| 33 | + // bypass scenarios() implementation in the parent class | ||
| 34 | + return Model::scenarios(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Creates data provider instance with search query applied | ||
| 39 | + * | ||
| 40 | + * @param array $params | ||
| 41 | + * | ||
| 42 | + * @return ActiveDataProvider | ||
| 43 | + */ | ||
| 44 | + public function search($params) | ||
| 45 | + { | ||
| 46 | + $query = AdminMenu::find(); | ||
| 47 | + | ||
| 48 | + $dataProvider = new ActiveDataProvider([ | ||
| 49 | + 'query' => $query, | ||
| 50 | + 'pagination' => [ | ||
| 51 | + 'pageSize' => 5 | ||
| 52 | + ], | ||
| 53 | + 'sort' => [ | ||
| 54 | + 'attributes' => [ | ||
| 55 | + 'admin_menu_id', | ||
| 56 | + 'name', | ||
| 57 | + 'path', | ||
| 58 | + 'param', | ||
| 59 | + 'status', | ||
| 60 | + 'hide_min', | ||
| 61 | + 'parentt' => [ | ||
| 62 | + 'asc' => ['name' => SORT_ASC], | ||
| 63 | + 'desc' => ['name' => SORT_DESC], | ||
| 64 | + 'default' => SORT_DESC | ||
| 65 | + ] | ||
| 66 | + ] | ||
| 67 | + ] | ||
| 68 | + ]); | ||
| 69 | + | ||
| 70 | + $this->load($params); | ||
| 71 | + | ||
| 72 | + if (!$this->validate()) { | ||
| 73 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 74 | + // $query->where('0=1'); | ||
| 75 | + return $dataProvider; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + $query->andFilterWhere([ | ||
| 79 | + 'admin_menu_id' => $this->admin_menu_id, | ||
| 80 | + 'admin_menu_pid' => $this->admin_menu_pid, | ||
| 81 | + 'status' => $this->status, | ||
| 82 | + 'hide_min' => $this->hide_min, | ||
| 83 | + 'sort' => $this->sort | ||
| 84 | + ]); | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
| 88 | + ->andFilterWhere(['like', 'path', $this->path]) | ||
| 89 | + ->andFilterWhere(['like', 'param', $this->param]) | ||
| 90 | + ->andFilterWhere(['in', 'admin_menu_pid', $this->find()->select(['admin_menu_id'])->andFilterWhere(['like', 'name', $this->parentt])->column()]); | ||
| 91 | + | ||
| 92 | + return $dataProvider; | ||
| 93 | + } | ||
| 94 | +} |
backend/models/Import.php
| @@ -42,7 +42,7 @@ class Import extends \yii\db\ActiveRecord | @@ -42,7 +42,7 @@ class Import extends \yii\db\ActiveRecord | ||
| 42 | $termin_pid = 8; | 42 | $termin_pid = 8; |
| 43 | // $template_id шаблон каьегорий | 43 | // $template_id шаблон каьегорий |
| 44 | $template_id = 3; | 44 | $template_id = 3; |
| 45 | - $lang_id = 2; | 45 | + $language_id = 2; |
| 46 | $type = 'H'; | 46 | $type = 'H'; |
| 47 | 47 | ||
| 48 | // массив для импортп товаров | 48 | // массив для импортп товаров |
| @@ -69,7 +69,7 @@ class Import extends \yii\db\ActiveRecord | @@ -69,7 +69,7 @@ class Import extends \yii\db\ActiveRecord | ||
| 69 | // массив для поиска/добавления термина | 69 | // массив для поиска/добавления термина |
| 70 | $basic = [ | 70 | $basic = [ |
| 71 | 'type' => $type, | 71 | 'type' => $type, |
| 72 | - 'lang_id' => $lang_id, | 72 | + 'language_id' => $language_id, |
| 73 | 'template_id' => $template_id, | 73 | 'template_id' => $template_id, |
| 74 | ]; | 74 | ]; |
| 75 | 75 |
backend/models/LanguageSearch.php
| @@ -19,8 +19,8 @@ class LanguageSearch extends Language | @@ -19,8 +19,8 @@ class LanguageSearch extends Language | ||
| 19 | { | 19 | { |
| 20 | return [ | 20 | return [ |
| 21 | [['language_id'], 'integer'], | 21 | [['language_id'], 'integer'], |
| 22 | - [['lang_code', 'language_name'], 'safe'], | ||
| 23 | - [['is_default', 'active'], 'boolean'], | 22 | + [['language_code', 'language_name'], 'safe'], |
| 23 | + [['is_default', 'status'], 'boolean'], | ||
| 24 | ]; | 24 | ]; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| @@ -59,12 +59,12 @@ class LanguageSearch extends Language | @@ -59,12 +59,12 @@ class LanguageSearch extends Language | ||
| 59 | $query->andFilterWhere([ | 59 | $query->andFilterWhere([ |
| 60 | 'language_id' => $this->language_id, | 60 | 'language_id' => $this->language_id, |
| 61 | 'is_default' => $this->is_default, | 61 | 'is_default' => $this->is_default, |
| 62 | - 'active' => $this->active, | 62 | + 'status' => $this->status, |
| 63 | ]); | 63 | ]); |
| 64 | 64 | ||
| 65 | - $query->andFilterWhere(['like', 'lang_code', $this->lang_code]) | 65 | + $query->andFilterWhere(['like', 'language_code', $this->language_code]) |
| 66 | ->andFilterWhere(['like', 'language_name', $this->language_name]) | 66 | ->andFilterWhere(['like', 'language_name', $this->language_name]) |
| 67 | - ->andWhere(['active' => '1']) | 67 | + ->andWhere(['status' => '1']) |
| 68 | ->andWhere(['>', 'language_id', '0']); | 68 | ->andWhere(['>', 'language_id', '0']); |
| 69 | 69 | ||
| 70 | return $dataProvider; | 70 | return $dataProvider; |
| @@ -89,12 +89,12 @@ class LanguageSearch extends Language | @@ -89,12 +89,12 @@ class LanguageSearch extends Language | ||
| 89 | $query->andFilterWhere([ | 89 | $query->andFilterWhere([ |
| 90 | 'language_id' => $this->language_id, | 90 | 'language_id' => $this->language_id, |
| 91 | 'is_default' => $this->is_default, | 91 | 'is_default' => $this->is_default, |
| 92 | - 'active' => $this->active, | 92 | + 'status' => $this->status, |
| 93 | ]); | 93 | ]); |
| 94 | 94 | ||
| 95 | - $query->andFilterWhere(['like', 'lang_code', $this->lang_code]) | 95 | + $query->andFilterWhere(['like', 'language_code', $this->language_code]) |
| 96 | ->andFilterWhere(['like', 'language_name', $this->language_name]) | 96 | ->andFilterWhere(['like', 'language_name', $this->language_name]) |
| 97 | - ->andWhere(['active' => '0']); | 97 | + ->andWhere(['status' => '0']); |
| 98 | 98 | ||
| 99 | return $dataProvider; | 99 | return $dataProvider; |
| 100 | } | 100 | } |
backend/models/Menu.php
| @@ -80,7 +80,7 @@ class Menu extends \yii\db\ActiveRecord | @@ -80,7 +80,7 @@ class Menu extends \yii\db\ActiveRecord | ||
| 80 | AND menu_location.menu_location_name = \''.$location_name.'\' | 80 | AND menu_location.menu_location_name = \''.$location_name.'\' |
| 81 | INNER JOIN termin ON termin.termin_id = menu.termin_id | 81 | INNER JOIN termin ON termin.termin_id = menu.termin_id |
| 82 | INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id | 82 | INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id |
| 83 | - AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' | 83 | + AND termin_lang.language_id = '.Yii::$app->params['language_id'].' |
| 84 | ORDER BY menu.level ASC, menu.sortorder ASC | 84 | ORDER BY menu.level ASC, menu.sortorder ASC |
| 85 | ')->queryAll(); | 85 | ')->queryAll(); |
| 86 | /* | 86 | /* |
| @@ -90,8 +90,13 @@ class Menu extends \yii\db\ActiveRecord | @@ -90,8 +90,13 @@ class Menu extends \yii\db\ActiveRecord | ||
| 90 | ->join( | 90 | ->join( |
| 91 | 'INNER JOIN', | 91 | 'INNER JOIN', |
| 92 | 'termin_lang.termin_id = menu.termin_id', | 92 | 'termin_lang.termin_id = menu.termin_id', |
| 93 | - ['lang_id' => yii::$app->params['lang_id']]) | 93 | + ['language_id' => yii::$app->params['language_id']]) |
| 94 | ->all(); | 94 | ->all(); |
| 95 | */ | 95 | */ |
| 96 | } | 96 | } |
| 97 | + | ||
| 98 | + public function getTerminLang() | ||
| 99 | + { | ||
| 100 | + return $this->hasOne(TerminLang::className(), ['termin_id' => 'termin_id']); | ||
| 101 | + } | ||
| 97 | } | 102 | } |
backend/models/MenuLocation.php
| @@ -59,6 +59,6 @@ class MenuLocation extends \yii\db\ActiveRecord | @@ -59,6 +59,6 @@ class MenuLocation extends \yii\db\ActiveRecord | ||
| 59 | */ | 59 | */ |
| 60 | public function getLangs() | 60 | public function getLangs() |
| 61 | { | 61 | { |
| 62 | - return $this->hasMany(Language::className(), ['language_id' => 'lang_id'])->viaTable('menu_location_lang', ['menu_location_id' => 'menu_location_id']); | 62 | + return $this->hasMany(Language::className(), ['language_id' => 'language_id'])->viaTable('menu_location_lang', ['menu_location_id' => 'menu_location_id']); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
backend/models/MenuLocationLang.php
| @@ -9,7 +9,7 @@ use Yii; | @@ -9,7 +9,7 @@ use Yii; | ||
| 9 | * | 9 | * |
| 10 | * @property integer $menu_location_id | 10 | * @property integer $menu_location_id |
| 11 | * @property string $menu_location_title | 11 | * @property string $menu_location_title |
| 12 | - * @property integer $lang_id | 12 | + * @property integer $language_id |
| 13 | * | 13 | * |
| 14 | * @property Language $lang | 14 | * @property Language $lang |
| 15 | * @property MenuLocation $menuLocation | 15 | * @property MenuLocation $menuLocation |
| @@ -30,8 +30,8 @@ class MenuLocationLang extends \yii\db\ActiveRecord | @@ -30,8 +30,8 @@ class MenuLocationLang extends \yii\db\ActiveRecord | ||
| 30 | public function rules() | 30 | public function rules() |
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | - [['menu_location_id', 'menu_location_title', 'lang_id'], 'required'], | ||
| 34 | - [['menu_location_id', 'lang_id'], 'integer'], | 33 | + [['menu_location_id', 'menu_location_title', 'language_id'], 'required'], |
| 34 | + [['menu_location_id', 'language_id'], 'integer'], | ||
| 35 | [['menu_location_title'], 'string', 'max' => 250] | 35 | [['menu_location_title'], 'string', 'max' => 250] |
| 36 | ]; | 36 | ]; |
| 37 | } | 37 | } |
| @@ -44,7 +44,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord | @@ -44,7 +44,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord | ||
| 44 | return [ | 44 | return [ |
| 45 | 'menu_location_id' => Yii::t('app', 'Menu Location ID'), | 45 | 'menu_location_id' => Yii::t('app', 'Menu Location ID'), |
| 46 | 'menu_location_title' => Yii::t('app', 'Menu Location Title'), | 46 | 'menu_location_title' => Yii::t('app', 'Menu Location Title'), |
| 47 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 47 | + 'language_id' => Yii::t('app', 'Lang ID'), |
| 48 | ]; | 48 | ]; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| @@ -53,7 +53,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord | @@ -53,7 +53,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord | ||
| 53 | */ | 53 | */ |
| 54 | public function getLang() | 54 | public function getLang() |
| 55 | { | 55 | { |
| 56 | - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | 56 | + return $this->hasOne(Language::className(), ['language_id' => 'language_id']); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
backend/models/MenuSearch.php
| @@ -49,7 +49,8 @@ class MenuSearch extends Menu | @@ -49,7 +49,8 @@ class MenuSearch extends Menu | ||
| 49 | 49 | ||
| 50 | $this->load($params); | 50 | $this->load($params); |
| 51 | 51 | ||
| 52 | - if (!$this->validate()) { | 52 | + if (! $this->validate()) |
| 53 | + { | ||
| 53 | // uncomment the following line if you do not want to return any records when validation fails | 54 | // uncomment the following line if you do not want to return any records when validation fails |
| 54 | // $query->where('0=1'); | 55 | // $query->where('0=1'); |
| 55 | return $dataProvider; | 56 | return $dataProvider; |
| @@ -67,7 +68,7 @@ class MenuSearch extends Menu | @@ -67,7 +68,7 @@ class MenuSearch extends Menu | ||
| 67 | ]); | 68 | ]); |
| 68 | 69 | ||
| 69 | $query->andFilterWhere(['like', 'name', $this->name]) | 70 | $query->andFilterWhere(['like', 'name', $this->name]) |
| 70 | - ->andFilterWhere(['like', 'url', $this->url]); | 71 | + ->andFilterWhere(['like', 'url', $this->url]); |
| 71 | 72 | ||
| 72 | return $dataProvider; | 73 | return $dataProvider; |
| 73 | } | 74 | } |
backend/models/NewOptionsLang.php
| @@ -9,7 +9,7 @@ use Yii; | @@ -9,7 +9,7 @@ use Yii; | ||
| 9 | * | 9 | * |
| 10 | * @property integer $primary | 10 | * @property integer $primary |
| 11 | * @property integer $id | 11 | * @property integer $id |
| 12 | - * @property integer $lang_id | 12 | + * @property integer $language_id |
| 13 | * @property string $value | 13 | * @property string $value |
| 14 | */ | 14 | */ |
| 15 | class NewOptionsLang extends \yii\db\ActiveRecord | 15 | class NewOptionsLang extends \yii\db\ActiveRecord |
| @@ -32,7 +32,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord | @@ -32,7 +32,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord | ||
| 32 | { | 32 | { |
| 33 | return [ | 33 | return [ |
| 34 | [['id', 'value'], 'required'], | 34 | [['id', 'value'], 'required'], |
| 35 | - [['id', 'lang_id'], 'integer'], | 35 | + [['id', 'language_id'], 'integer'], |
| 36 | [['value'], 'string'] | 36 | [['value'], 'string'] |
| 37 | ]; | 37 | ]; |
| 38 | } | 38 | } |
| @@ -45,7 +45,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord | @@ -45,7 +45,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord | ||
| 45 | return [ | 45 | return [ |
| 46 | 'primary' => Yii::t('app', 'Primary'), | 46 | 'primary' => Yii::t('app', 'Primary'), |
| 47 | 'id' => Yii::t('app', 'ID'), | 47 | 'id' => Yii::t('app', 'ID'), |
| 48 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 48 | + 'language_id' => Yii::t('app', 'Lang ID'), |
| 49 | 'value' => Yii::t('app', 'Value'), | 49 | 'value' => Yii::t('app', 'Value'), |
| 50 | ]; | 50 | ]; |
| 51 | } | 51 | } |
backend/models/NewOptionsLangSearch.php
| @@ -18,7 +18,7 @@ class NewOptionsLangSearch extends NewOptionsLang | @@ -18,7 +18,7 @@ class NewOptionsLangSearch extends NewOptionsLang | ||
| 18 | public function rules() | 18 | public function rules() |
| 19 | { | 19 | { |
| 20 | return [ | 20 | return [ |
| 21 | - [['primary', 'id', 'lang_id'], 'integer'], | 21 | + [['primary', 'id', 'language_id'], 'integer'], |
| 22 | [['value'], 'safe'], | 22 | [['value'], 'safe'], |
| 23 | ]; | 23 | ]; |
| 24 | } | 24 | } |
| @@ -58,7 +58,7 @@ class NewOptionsLangSearch extends NewOptionsLang | @@ -58,7 +58,7 @@ class NewOptionsLangSearch extends NewOptionsLang | ||
| 58 | $query->andFilterWhere([ | 58 | $query->andFilterWhere([ |
| 59 | 'primary' => $this->primary, | 59 | 'primary' => $this->primary, |
| 60 | 'id' => $this->id, | 60 | 'id' => $this->id, |
| 61 | - 'lang_id' => $this->lang_id, | 61 | + 'language_id' => $this->language_id, |
| 62 | ]); | 62 | ]); |
| 63 | 63 | ||
| 64 | $query->andFilterWhere(['like', 'value', $this->value]); | 64 | $query->andFilterWhere(['like', 'value', $this->value]); |
backend/models/Termin.php
| @@ -21,7 +21,6 @@ class Termin extends \yii\db\ActiveRecord | @@ -21,7 +21,6 @@ class Termin extends \yii\db\ActiveRecord | ||
| 21 | { | 21 | { |
| 22 | var $termin_title; | 22 | var $termin_title; |
| 23 | var $termin_pid; | 23 | var $termin_pid; |
| 24 | - var $termin_parent_title; | ||
| 25 | 24 | ||
| 26 | /** | 25 | /** |
| 27 | * @inheritdoc | 26 | * @inheritdoc |
| @@ -38,9 +37,9 @@ class Termin extends \yii\db\ActiveRecord | @@ -38,9 +37,9 @@ class Termin extends \yii\db\ActiveRecord | ||
| 38 | { | 37 | { |
| 39 | return [ | 38 | return [ |
| 40 | [['is_book'], 'integer'], | 39 | [['is_book'], 'integer'], |
| 41 | - [['termin_pid', 'termin_parent_title'], 'safe'], | 40 | + [['termin_pid'], 'safe'], |
| 42 | [['termin_title'], 'string', 'max' => 250], | 41 | [['termin_title'], 'string', 'max' => 250], |
| 43 | - [['termin_name','termin_parent_title'], 'string', 'max' => 250] | 42 | + [['termin_name'], 'string', 'max' => 250] |
| 44 | ]; | 43 | ]; |
| 45 | } | 44 | } |
| 46 | 45 | ||
| @@ -52,15 +51,13 @@ class Termin extends \yii\db\ActiveRecord | @@ -52,15 +51,13 @@ class Termin extends \yii\db\ActiveRecord | ||
| 52 | return [ | 51 | return [ |
| 53 | 'termin_id' => Yii::t('app', 'termin'), | 52 | 'termin_id' => Yii::t('app', 'termin'), |
| 54 | 'termin_name' => Yii::t('app', 'name').' (SYSTEM NAME)', | 53 | 'termin_name' => Yii::t('app', 'name').' (SYSTEM NAME)', |
| 55 | - 'termin_title' => Yii::t('app', 'termin'), | ||
| 56 | - 'termin_parent_title' => Yii::t('app', 'termin').' Parent', | ||
| 57 | 'is_book' => Yii::t('app', 'book'), | 54 | 'is_book' => Yii::t('app', 'book'), |
| 58 | ]; | 55 | ]; |
| 59 | } | 56 | } |
| 60 | 57 | ||
| 61 | /** | 58 | /** |
| 62 | * Выполняет поиск по параметрам | 59 | * Выполняет поиск по параметрам |
| 63 | - * @param array $param принимает [termin_id, lang_id, return_one, return_field, show_all] | 60 | + * @param array $param принимает [termin_id, language_id, return_one, return_field, show_all] |
| 64 | * @return array one | array all | string значение масива | 61 | * @return array one | array all | string значение масива |
| 65 | */ | 62 | */ |
| 66 | public function finInfo (array $params = []) | 63 | public function finInfo (array $params = []) |
| @@ -68,12 +65,11 @@ class Termin extends \yii\db\ActiveRecord | @@ -68,12 +65,11 @@ class Termin extends \yii\db\ActiveRecord | ||
| 68 | Tools::ifNotExist ($params, array ( | 65 | Tools::ifNotExist ($params, array ( |
| 69 | 'termin_id' => false, | 66 | 'termin_id' => false, |
| 70 | 'termin_pid' => false, | 67 | 'termin_pid' => false, |
| 71 | - 'lang_id' => Yii::$app->params['lang_id'], | 68 | + 'language_id' => Yii::$app->params['language_id'], |
| 72 | 'return_one' => false, | 69 | 'return_one' => false, |
| 73 | 'return_field' => false, | 70 | 'return_field' => false, |
| 74 | 'show_all' => false, | 71 | 'show_all' => false, |
| 75 | 'to_array' => true, | 72 | 'to_array' => true, |
| 76 | - 'sql_only' => false, | ||
| 77 | 'pid_title' => false, | 73 | 'pid_title' => false, |
| 78 | )); | 74 | )); |
| 79 | 75 | ||
| @@ -96,9 +92,9 @@ class Termin extends \yii\db\ActiveRecord | @@ -96,9 +92,9 @@ class Termin extends \yii\db\ActiveRecord | ||
| 96 | 'termin.termin_id = termin_lang.termin_id' | 92 | 'termin.termin_id = termin_lang.termin_id' |
| 97 | ); | 93 | ); |
| 98 | 94 | ||
| 99 | - if ($params['lang_id']) | 95 | + if ($params['language_id']) |
| 100 | { | 96 | { |
| 101 | - $WHERE['termin_lang.lang_id'] = $params['lang_id']; | 97 | + $WHERE['termin_lang.language_id'] = $params['language_id']; |
| 102 | } | 98 | } |
| 103 | 99 | ||
| 104 | // структура | 100 | // структура |
| @@ -138,7 +134,7 @@ class Termin extends \yii\db\ActiveRecord | @@ -138,7 +134,7 @@ class Termin extends \yii\db\ActiveRecord | ||
| 138 | { | 134 | { |
| 139 | $query = $query->asArray(); | 135 | $query = $query->asArray(); |
| 140 | } | 136 | } |
| 141 | - | 137 | + |
| 142 | if ($params['return_one'] || $params['return_field']) | 138 | if ($params['return_one'] || $params['return_field']) |
| 143 | { | 139 | { |
| 144 | 140 | ||
| @@ -165,13 +161,16 @@ class Termin extends \yii\db\ActiveRecord | @@ -165,13 +161,16 @@ class Termin extends \yii\db\ActiveRecord | ||
| 165 | */ | 161 | */ |
| 166 | public function getTerminLangs() | 162 | public function getTerminLangs() |
| 167 | { | 163 | { |
| 168 | - return $this->hasOne(TerminLang::className(), ['termin_id' => 'termin_id']); | 164 | + return $this->hasMany(TerminLang::className(), ['termin_id' => 'termin_id']); |
| 169 | } | 165 | } |
| 170 | - | ||
| 171 | - public function getParent() | 166 | + |
| 167 | + /** | ||
| 168 | + * @return \yii\db\ActiveQuery | ||
| 169 | + */ | ||
| 170 | + public function getLangs() | ||
| 172 | { | 171 | { |
| 173 | - return $this->hasOne(Termin::className(),['termin_id'=>'termin_pid']) | ||
| 174 | - ->viaTable(TerminStructure::tableName(), ['termin_id'=>'termin_id']); | 172 | + return $this->hasMany(Language::className(), ['language_id' => 'language_id']) |
| 173 | + ->viaTable('termin_lang', ['termin_id' => 'termin_id']); | ||
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | /** | 176 | /** |
backend/models/TerminLang.php
| @@ -8,7 +8,7 @@ use Yii; | @@ -8,7 +8,7 @@ use Yii; | ||
| 8 | * This is the model class for table "termin_lang". | 8 | * This is the model class for table "termin_lang". |
| 9 | * | 9 | * |
| 10 | * @property integer $termin_id | 10 | * @property integer $termin_id |
| 11 | - * @property integer $lang_id | 11 | + * @property integer $language_id |
| 12 | * @property string $termin_title | 12 | * @property string $termin_title |
| 13 | * @property string $termin_alias | 13 | * @property string $termin_alias |
| 14 | * | 14 | * |
| @@ -31,8 +31,8 @@ class TerminLang extends \yii\db\ActiveRecord | @@ -31,8 +31,8 @@ class TerminLang extends \yii\db\ActiveRecord | ||
| 31 | public function rules() | 31 | public function rules() |
| 32 | { | 32 | { |
| 33 | return [ | 33 | return [ |
| 34 | - [['lang_id'], 'required'], | ||
| 35 | - [['lang_id'], 'integer'], | 34 | + [['language_id'], 'required'], |
| 35 | + [['language_id'], 'integer'], | ||
| 36 | [['termin_title', 'termin_alias'], 'string', 'max' => 250] | 36 | [['termin_title', 'termin_alias'], 'string', 'max' => 250] |
| 37 | ]; | 37 | ]; |
| 38 | } | 38 | } |
| @@ -44,7 +44,7 @@ class TerminLang extends \yii\db\ActiveRecord | @@ -44,7 +44,7 @@ class TerminLang extends \yii\db\ActiveRecord | ||
| 44 | { | 44 | { |
| 45 | return [ | 45 | return [ |
| 46 | 'termin_id' => Yii::t('app', 'Termin ID'), | 46 | 'termin_id' => Yii::t('app', 'Termin ID'), |
| 47 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 47 | + 'language_id' => Yii::t('app', 'Lang ID'), |
| 48 | 'termin_title' => Yii::t('app', 'Termin Title'), | 48 | 'termin_title' => Yii::t('app', 'Termin Title'), |
| 49 | 'termin_alias' => Yii::t('app', 'Termin Alias'), | 49 | 'termin_alias' => Yii::t('app', 'Termin Alias'), |
| 50 | ]; | 50 | ]; |
| @@ -55,7 +55,7 @@ class TerminLang extends \yii\db\ActiveRecord | @@ -55,7 +55,7 @@ class TerminLang extends \yii\db\ActiveRecord | ||
| 55 | */ | 55 | */ |
| 56 | public function getLang() | 56 | public function getLang() |
| 57 | { | 57 | { |
| 58 | - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | 58 | + return $this->hasOne(Language::className(), ['language_id' => 'language_id']); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | /** | 61 | /** |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use backend\models\AdminMenu; | ||
| 4 | +use common\models\Tools; | ||
| 5 | +use yii\helpers\Html; | ||
| 6 | +use yii\widgets\ActiveForm; | ||
| 7 | + | ||
| 8 | +/* @var $this yii\web\View */ | ||
| 9 | +/* @var $model backend\models\AdminMenu */ | ||
| 10 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 11 | +?> | ||
| 12 | + | ||
| 13 | +<div class="admin-menu-form"> | ||
| 14 | + | ||
| 15 | + <?php $form = ActiveForm::begin(); ?> | ||
| 16 | + | ||
| 17 | + <?= $form->field($model, 'name')->textInput() ?> | ||
| 18 | + | ||
| 19 | + <?= $form->field($model, 'status')->checkbox() ?> | ||
| 20 | + | ||
| 21 | + <?= $form->field($model, 'hide_min')->checkbox() ?> | ||
| 22 | + | ||
| 23 | + <?= $form->field($model, 'path')->textInput() ?> | ||
| 24 | + | ||
| 25 | + <?= $form->field($model, 'param')->textInput() ?> | ||
| 26 | + | ||
| 27 | + <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | ||
| 28 | + <div class="panel panel-default"> | ||
| 29 | + <div class="panel-heading" role="tab" id="headingOne"> | ||
| 30 | + <h4 class="panel-title"> | ||
| 31 | + <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> | ||
| 32 | + <?= Yii::t('app', 'Parent menu item') ?> | ||
| 33 | + </a> | ||
| 34 | + </h4> | ||
| 35 | + </div> | ||
| 36 | + <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> | ||
| 37 | + <ul class="list-group checkboxer"> | ||
| 38 | + <?php | ||
| 39 | + $roots = AdminMenu::buildMenuSelect(); | ||
| 40 | + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level0 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => 0, 'uncheck' => null, 'label' => Yii::t('app', 'root'), 'labelOptions' => ['class' => 'checkboxer_label']]); | ||
| 41 | + foreach($roots as $root) { | ||
| 42 | + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level1 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $root['id'], 'uncheck' => null, 'label' => Yii::t('app', $root['label']), 'labelOptions' => ['class' => 'checkboxer_label']]); | ||
| 43 | + if($root['items']) { | ||
| 44 | + foreach($root['items'] as $submenu) { | ||
| 45 | + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level2 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $submenu['id'], 'uncheck' => null, 'label' => Yii::t('app', $submenu['label']), 'labelOptions' => ['class' => 'checkboxer_label']]); | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + ?> | ||
| 50 | + </ul> | ||
| 51 | + </div> | ||
| 52 | + </div> | ||
| 53 | + </div> | ||
| 54 | + | ||
| 55 | + <div class="form-group"> | ||
| 56 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => ($model->isNewRecord ? 'btn btn-success' : 'btn btn-primary') . ' btn-flat']) ?> | ||
| 57 | + </div> | ||
| 58 | + | ||
| 59 | + <?php ActiveForm::end(); ?> | ||
| 60 | + | ||
| 61 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model backend\models\AdminMenuSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="admin-menu-search"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin([ | ||
| 14 | + 'action' => ['index'], | ||
| 15 | + 'method' => 'get', | ||
| 16 | + ]); ?> | ||
| 17 | + | ||
| 18 | + <?= $form->field($model, 'id') ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'parent_id') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'active') ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'hide_min') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'sort') ?> | ||
| 27 | + | ||
| 28 | + <?php // echo $form->field($model, 'name') ?> | ||
| 29 | + | ||
| 30 | + <?php // echo $form->field($model, 'path') ?> | ||
| 31 | + | ||
| 32 | + <?php // echo $form->field($model, 'params') ?> | ||
| 33 | + | ||
| 34 | + <div class="form-group"> | ||
| 35 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
| 36 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
| 37 | + </div> | ||
| 38 | + | ||
| 39 | + <?php ActiveForm::end(); ?> | ||
| 40 | + | ||
| 41 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model backend\models\AdminMenu */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Create Admin Menu'); | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="admin-menu-create"> | ||
| 14 | + <div class="box box-primary"> | ||
| 15 | + <div class="box-body"> | ||
| 16 | + <?= $this->render('_form', [ | ||
| 17 | + 'model' => $model, | ||
| 18 | + ]) ?> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 21 | + | ||
| 22 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\grid\GridView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $searchModel backend\models\AdminMenuSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Admin Menus'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="admin-menu-index box box-primary"> | ||
| 14 | + | ||
| 15 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 16 | + | ||
| 17 | + <?= GridView::widget([ | ||
| 18 | + 'dataProvider' => $dataProvider, | ||
| 19 | + 'filterModel' => $searchModel, | ||
| 20 | + 'showFooter' => true, | ||
| 21 | + 'layout' => "<div class='box-header with-border admin_grid_action'> | ||
| 22 | + <div class='action_link'>" | ||
| 23 | + .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']). | ||
| 24 | + "</div> | ||
| 25 | + <div class='pull-right'> | ||
| 26 | + {pager} | ||
| 27 | + </div> | ||
| 28 | + </div> | ||
| 29 | + <div class='box-body no-padding table-responsive'> | ||
| 30 | + {items} | ||
| 31 | + </div> | ||
| 32 | + <div class='box-footer admin_grid_action'> | ||
| 33 | + <div class='action_link'>" | ||
| 34 | + .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']). | ||
| 35 | + "</div> | ||
| 36 | + <div class='pull-right'> | ||
| 37 | + {pager} | ||
| 38 | + </div> | ||
| 39 | + </div>", | ||
| 40 | + 'columns' => [ | ||
| 41 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 42 | + 'admin_menu_id', | ||
| 43 | + 'name', | ||
| 44 | + 'path', | ||
| 45 | + 'param', | ||
| 46 | + [ | ||
| 47 | + 'format' => 'raw', | ||
| 48 | + 'filter' => [ | ||
| 49 | + '1'=>'Отображаются', | ||
| 50 | + '0'=>'Скрытые', | ||
| 51 | + ], | ||
| 52 | + 'value' => function($data){ | ||
| 53 | + if($data->status){ | ||
| 54 | + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | ||
| 55 | + } else { | ||
| 56 | + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | ||
| 57 | + } | ||
| 58 | + return $status_img; | ||
| 59 | + }, | ||
| 60 | + 'attribute'=>'status', | ||
| 61 | + ], | ||
| 62 | + [ | ||
| 63 | + 'attribute' => 'parentt', | ||
| 64 | + 'content' => | ||
| 65 | + function($model, $key, $index, $column) { | ||
| 66 | + if($model->parent->admin_menu_id) { | ||
| 67 | + return $model->parent->name; | ||
| 68 | + } else { | ||
| 69 | + return '<i class="small">'.Yii::t('app', 'Корневой элемент').'</i>'; | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + ], | ||
| 73 | + [ | ||
| 74 | + 'format' => 'raw', | ||
| 75 | + 'filter' => [ | ||
| 76 | + '1'=>'Отображаются', | ||
| 77 | + '0'=>'Скрытые', | ||
| 78 | + ], | ||
| 79 | + 'value' => function($data){ | ||
| 80 | + if($data->hide_min){ | ||
| 81 | + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | ||
| 82 | + } else { | ||
| 83 | + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | ||
| 84 | + } | ||
| 85 | + return $status_img; | ||
| 86 | + }, | ||
| 87 | + 'attribute'=>'hide_min', | ||
| 88 | + ], | ||
| 89 | + ], | ||
| 90 | + ]); ?> | ||
| 91 | + | ||
| 92 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model backend\models\AdminMenu */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update') . ': ' . $model->name; | ||
| 9 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->admin_menu_id]]; | ||
| 11 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 12 | +?> | ||
| 13 | +<div class="admin-menu-update"> | ||
| 14 | + | ||
| 15 | + <?= $this->render('_form', [ | ||
| 16 | + 'model' => $model, | ||
| 17 | + ]) ?> | ||
| 18 | + | ||
| 19 | +</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\AdminMenu */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Admin Menus').': '.$model->name; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | + | ||
| 14 | +<div class="admin-menu-view box box-primary"> | ||
| 15 | +<?= DetailView::widget([ | ||
| 16 | + 'model' => $model, | ||
| 17 | + 'attributes' => [ | ||
| 18 | + 'admin_menu_id', | ||
| 19 | + 'admin_menu_pid', | ||
| 20 | + 'status', | ||
| 21 | + 'hide_min', | ||
| 22 | + 'sort', | ||
| 23 | + 'name', | ||
| 24 | + 'path', | ||
| 25 | + 'param', | ||
| 26 | + ], | ||
| 27 | + ]) ?> | ||
| 28 | + | ||
| 29 | + <div class="box-footer with-border"> | ||
| 30 | + <p> | ||
| 31 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->admin_menu_id], ['class' => 'btn btn-primary btn-flat']) ?> | ||
| 32 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->admin_menu_id], [ | ||
| 33 | + 'class' => 'btn btn-danger btn-flat', | ||
| 34 | + 'data' => [ | ||
| 35 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | ||
| 36 | + 'method' => 'post', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + <?= Html::a(Yii::t('app', 'Back'), ['index'], ['class' => 'btn btn-default btn-flat']) ?> | ||
| 40 | + </p> | ||
| 41 | + </div> | ||
| 42 | + | ||
| 43 | +</div> | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
backend/views/blog/articles.php
| @@ -21,7 +21,7 @@ echo GridView::widget([ | @@ -21,7 +21,7 @@ echo GridView::widget([ | ||
| 21 | 'class' => Column::className(), | 21 | 'class' => Column::className(), |
| 22 | 'header' => Yii::t('app', 'Name'), | 22 | 'header' => Yii::t('app', 'Name'), |
| 23 | 'content' => function($model, $key, $index, $column) { | 23 | 'content' => function($model, $key, $index, $column) { |
| 24 | - return $model->getArticleLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name; | 24 | + return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name; |
| 25 | } | 25 | } |
| 26 | ], | 26 | ], |
| 27 | [ | 27 | [ |
backend/views/language/_form_adress_edit.php
| @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | ||
| 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 | if($row->translate) { | 23 | if($row->translate) { |
| 24 | - foreach($row->getLangs() as $lang_id => $lang) { | 24 | + foreach($row->getLangs() as $language_id => $lang) { |
| 25 | ?> | 25 | ?> |
| 26 | <div class="form-group"> | 26 | <div class="form-group"> |
| 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> | 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> |
backend/views/language/index.php
| @@ -28,7 +28,7 @@ echo $this->render('layout'); | @@ -28,7 +28,7 @@ echo $this->render('layout'); | ||
| 28 | } | 28 | } |
| 29 | ], | 29 | ], |
| 30 | 'language_name', | 30 | 'language_name', |
| 31 | - 'lang_code', | 31 | + 'language_code', |
| 32 | 'is_default:boolean', | 32 | 'is_default:boolean', |
| 33 | [ | 33 | [ |
| 34 | 'class' => 'yii\grid\ActionColumn', | 34 | 'class' => 'yii\grid\ActionColumn', |
backend/views/language/view_adress.php
| @@ -24,7 +24,7 @@ echo $this->render('layout'); | @@ -24,7 +24,7 @@ echo $this->render('layout'); | ||
| 24 | [ | 24 | [ |
| 25 | 'class' => 'yii\grid\Column', | 25 | 'class' => 'yii\grid\Column', |
| 26 | 'content' => function($model, $key, $index, $column) { | 26 | 'content' => function($model, $key, $index, $column) { |
| 27 | - return OptionLang::find()->select('value')->where(['lang_id' => 0, 'id' => $model->option_id])->scalar(); | 27 | + return OptionLang::find()->select('value')->where(['language_id' => 0, 'id' => $model->option_id])->scalar(); |
| 28 | }, | 28 | }, |
| 29 | 'header' => Yii::t('app', 'adress_name') | 29 | 'header' => Yii::t('app', 'adress_name') |
| 30 | ], | 30 | ], |
backend/views/layouts/header.php
| @@ -23,6 +23,19 @@ $username = Yii::$app->user->identity->firstname.' '.Yii::$app->user->identity-> | @@ -23,6 +23,19 @@ $username = Yii::$app->user->identity->firstname.' '.Yii::$app->user->identity-> | ||
| 23 | 23 | ||
| 24 | <ul class="nav navbar-nav"> | 24 | <ul class="nav navbar-nav"> |
| 25 | 25 | ||
| 26 | + <!-- search form --> | ||
| 27 | + <li class="header-search"> | ||
| 28 | + <form action="#" method="get" class="sidebar-form"> | ||
| 29 | + <div class="input-group"> | ||
| 30 | + <input type="text" name="q" class="form-control" placeholder="Search..."/> | ||
| 31 | + <span class="input-group-btn"> | ||
| 32 | + <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i> | ||
| 33 | + </button> | ||
| 34 | + </span> | ||
| 35 | + </div> | ||
| 36 | + </form> | ||
| 37 | + </li> | ||
| 38 | + <!-- /.search form --> | ||
| 26 | <!-- Messages: style can be found in dropdown.less--> | 39 | <!-- Messages: style can be found in dropdown.less--> |
| 27 | <li class="dropdown messages-menu"> | 40 | <li class="dropdown messages-menu"> |
| 28 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> | 41 | <a href="#" class="dropdown-toggle" data-toggle="dropdown"> |
backend/views/layouts/left.php
| @@ -14,79 +14,15 @@ | @@ -14,79 +14,15 @@ | ||
| 14 | </div> | 14 | </div> |
| 15 | </div> | 15 | </div> |
| 16 | 16 | ||
| 17 | - <!-- search form --> | ||
| 18 | - <form action="#" method="get" class="sidebar-form"> | ||
| 19 | - <div class="input-group"> | ||
| 20 | - <input type="text" name="q" class="form-control" placeholder="Search..."/> | ||
| 21 | - <span class="input-group-btn"> | ||
| 22 | - <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i> | ||
| 23 | - </button> | ||
| 24 | - </span> | ||
| 25 | - </div> | ||
| 26 | - </form> | ||
| 27 | - <!-- /.search form --> | ||
| 28 | - | ||
| 29 | - <?= dmstr\widgets\Menu::widget( | ||
| 30 | - [ | ||
| 31 | - 'options' => ['class' => 'sidebar-menu'], | ||
| 32 | - 'items' => [ | ||
| 33 | - ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']], | ||
| 34 | - //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']], | ||
| 35 | - //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']], | ||
| 36 | - ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']], | ||
| 37 | - ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']], | ||
| 38 | - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], | ||
| 39 | - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], | ||
| 40 | - ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest], | ||
| 41 | - ['label' => 'Пользователи', 'icon' => 'fa fa-file-code-o', 'url' => ['/user/']], | ||
| 42 | - [ | ||
| 43 | - 'label' => Yii::t('app', 'Blog'), | ||
| 44 | - 'icon' => 'fa fa-share', | ||
| 45 | - 'url' => '#', | ||
| 46 | - 'items' => [ | ||
| 47 | - ['label' => Yii::t('app', 'Static pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['blog/articles', 'category_id' => '63'],], | ||
| 48 | - ['label' => Yii::t('app', 'Categories'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/categories'],], | ||
| 49 | - ['label' => Yii::t('app', 'Articles'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/articles'],], | ||
| 50 | - ], | ||
| 51 | - ], | ||
| 52 | - [ | ||
| 53 | - 'label' => 'Роли', | ||
| 54 | - 'icon' => 'fa fa-share', | ||
| 55 | - 'url' => '#', | ||
| 56 | - 'items' => [ | ||
| 57 | - ['label' => 'Управление ролями', 'icon' => 'fa fa-file-code-o', 'url' => ['/permit/access/role'],], | ||
| 58 | - ['label' => 'Управление правами доступа', 'icon' => 'fa fa-dashboard', 'url' => ['/permit/access/permission'],], | ||
| 59 | - ], | ||
| 60 | - ], | ||
| 61 | - [ | ||
| 62 | - 'label' => 'Same tools', | ||
| 63 | - 'icon' => 'fa fa-share', | ||
| 64 | - 'url' => '#', | ||
| 65 | - 'items' => [ | ||
| 66 | - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii'],], | ||
| 67 | - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug'],], | ||
| 68 | - [ | ||
| 69 | - 'label' => 'Level One', | ||
| 70 | - 'icon' => 'fa fa-circle-o', | ||
| 71 | - 'url' => '#', | ||
| 72 | - 'items' => [ | ||
| 73 | - ['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#',], | ||
| 74 | - [ | ||
| 75 | - 'label' => 'Level Two', | ||
| 76 | - 'icon' => 'fa fa-circle-o', | ||
| 77 | - 'url' => '#', | ||
| 78 | - 'items' => [ | ||
| 79 | - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',], | ||
| 80 | - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',], | ||
| 81 | - ], | ||
| 82 | - ], | ||
| 83 | - ], | ||
| 84 | - ], | ||
| 85 | - ], | ||
| 86 | - ], | ||
| 87 | - ], | ||
| 88 | - ] | ||
| 89 | - ) ?> | 17 | + <?= dmstr\widgets\Menu::widget([ |
| 18 | + 'options' => ['class' => 'sidebar-menu'], | ||
| 19 | + 'items' => array_merge( | ||
| 20 | + \backend\models\AdminMenu::buildMenu(), | ||
| 21 | + [ | ||
| 22 | + ['label' => Yii::t('app', 'Settings'), 'url' => ['/settings/index'], 'icon' => 'fa fa-gear'] | ||
| 23 | + ] | ||
| 24 | + ), | ||
| 25 | + ]) ?> | ||
| 90 | 26 | ||
| 91 | </section> | 27 | </section> |
| 92 | 28 |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use dmstr\widgets\Menu; | ||
| 4 | +use yii\widgets\Breadcrumbs; | ||
| 5 | +use yii\helpers\Html; | ||
| 6 | + | ||
| 7 | +/* @var $content string */ | ||
| 8 | +$this->beginContent('@app/views/layouts/main.php'); | ||
| 9 | +?> | ||
| 10 | + <div class="row"> | ||
| 11 | + <div class="col-md-3"> | ||
| 12 | + <div class="box box-solid"> | ||
| 13 | + <div class="box-header with-border"> | ||
| 14 | + <h3 class="box-title"><?=Yii::t('app', 'Settings categories')?></h3> | ||
| 15 | + <div class="box-tools"> | ||
| 16 | + <button type="button" class="btn btn-box-tool" data-widget="collapse"> | ||
| 17 | + <i class="fa fa-minus"></i> | ||
| 18 | + </button> | ||
| 19 | + </div> | ||
| 20 | + </div> | ||
| 21 | + <div class="box-body no-padding"> | ||
| 22 | + <?php | ||
| 23 | + echo Menu::widget([ | ||
| 24 | + 'options' => [ | ||
| 25 | + 'class' => 'nav nav-pills nav-stacked' | ||
| 26 | + ], | ||
| 27 | + 'items' => [ | ||
| 28 | + ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['/admin-menu/index'], 'icon' => 'fa fa-navicon'], | ||
| 29 | + ['label' => Yii::t('app', 'Next menu item'), 'url' => ['#'], 'icon' => 'fa fa-arrow-circle-o-right'], | ||
| 30 | + ], | ||
| 31 | + ]); | ||
| 32 | + ?> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | + <div class="col-md-9"> | ||
| 37 | + <?= $content ?> | ||
| 38 | + </div> | ||
| 39 | + </div> | ||
| 40 | +<?php $this->endContent() ?> | ||
| 0 | \ No newline at end of file | 41 | \ No newline at end of file |
backend/views/menu/index.php
| @@ -28,8 +28,9 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -28,8 +28,9 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 28 | /* | 28 | /* |
| 29 | [ | 29 | [ |
| 30 | 'attribute' => Yii::t('app', 'termin'), | 30 | 'attribute' => Yii::t('app', 'termin'), |
| 31 | - 'value' => function ($model) { | ||
| 32 | - return empty($model->termin_id) ? '-' : $model->termin_lang->termin_title; | 31 | + 'value' => function ($model) |
| 32 | + { | ||
| 33 | + return empty ($model->termin_id) ? '-' : $model->terminLang->termin_title; | ||
| 33 | }, | 34 | }, |
| 34 | ], | 35 | ], |
| 35 | */ | 36 | */ |
backend/views/new-options-lang/_form.php
| @@ -14,7 +14,7 @@ use yii\widgets\ActiveForm; | @@ -14,7 +14,7 @@ use yii\widgets\ActiveForm; | ||
| 14 | 14 | ||
| 15 | <?= $form->field($model, 'id')->textInput() ?> | 15 | <?= $form->field($model, 'id')->textInput() ?> |
| 16 | 16 | ||
| 17 | - <?= $form->field($model, 'lang_id')->textInput() ?> | 17 | + <?= $form->field($model, 'language_id')->textInput() ?> |
| 18 | 18 | ||
| 19 | <?= $form->field($model, 'value')->textarea(['rows' => 6]) ?> | 19 | <?= $form->field($model, 'value')->textarea(['rows' => 6]) ?> |
| 20 | 20 |
backend/views/new-options-lang/_search.php
| @@ -19,7 +19,7 @@ use yii\widgets\ActiveForm; | @@ -19,7 +19,7 @@ use yii\widgets\ActiveForm; | ||
| 19 | 19 | ||
| 20 | <?= $form->field($model, 'id') ?> | 20 | <?= $form->field($model, 'id') ?> |
| 21 | 21 | ||
| 22 | - <?= $form->field($model, 'lang_id') ?> | 22 | + <?= $form->field($model, 'language_id') ?> |
| 23 | 23 | ||
| 24 | <?= $form->field($model, 'value') ?> | 24 | <?= $form->field($model, 'value') ?> |
| 25 | 25 |
backend/views/new-options-lang/index.php
| @@ -27,7 +27,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -27,7 +27,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 27 | 27 | ||
| 28 | 'primary', | 28 | 'primary', |
| 29 | 'id', | 29 | 'id', |
| 30 | - 'lang_id', | 30 | + 'language_id', |
| 31 | 'value:ntext', | 31 | 'value:ntext', |
| 32 | 32 | ||
| 33 | ['class' => 'yii\grid\ActionColumn'], | 33 | ['class' => 'yii\grid\ActionColumn'], |
backend/views/new-options-lang/view.php
| @@ -30,7 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -30,7 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 30 | 'attributes' => [ | 30 | 'attributes' => [ |
| 31 | 'primary', | 31 | 'primary', |
| 32 | 'id', | 32 | 'id', |
| 33 | - 'lang_id', | 33 | + 'language_id', |
| 34 | 'value:ntext', | 34 | 'value:ntext', |
| 35 | ], | 35 | ], |
| 36 | ]) ?> | 36 | ]) ?> |
backend/views/option/_form_edit.php
| @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | ||
| 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 | if($row->translate) { | 23 | if($row->translate) { |
| 24 | - foreach($row->getLangs() as $lang_id => $lang) { | 24 | + foreach($row->getLangs() as $language_id => $lang) { |
| 25 | ?> | 25 | ?> |
| 26 | <div class="form-group"> | 26 | <div class="form-group"> |
| 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> | 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> |
backend/views/site/index.php
| @@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | /* @var $this yii\web\View */ | 3 | /* @var $this yii\web\View */ |
| 4 | 4 | ||
| 5 | +use backend\models\AdminMenu; | ||
| 6 | +use yii\helpers\Url; | ||
| 7 | + | ||
| 5 | $this->title = 'My Yii Application'; | 8 | $this->title = 'My Yii Application'; |
| 6 | ?> | 9 | ?> |
| 7 | <div class="site-index"> | 10 | <div class="site-index"> |
backend/views/termin/_form.php
| @@ -5,34 +5,21 @@ use yii\widgets\ActiveForm; | @@ -5,34 +5,21 @@ use yii\widgets\ActiveForm; | ||
| 5 | use backend\models\Termin; | 5 | use backend\models\Termin; |
| 6 | use kartik\select2\Select2; | 6 | use kartik\select2\Select2; |
| 7 | use yii\helpers\ArrayHelper; | 7 | use yii\helpers\ArrayHelper; |
| 8 | -use common\widgets\Multilang; | ||
| 9 | -use yii\helpers\Url; | ||
| 10 | 8 | ||
| 11 | /* @var $this yii\web\View */ | 9 | /* @var $this yii\web\View */ |
| 12 | /* @var $model backend\models\Termin */ | 10 | /* @var $model backend\models\Termin */ |
| 13 | /* @var $form yii\widgets\ActiveForm */ | 11 | /* @var $form yii\widgets\ActiveForm */ |
| 14 | 12 | ||
| 15 | -echo '<div class="termin-form">'; | 13 | +?> |
| 16 | 14 | ||
| 17 | -$form = ActiveForm::begin(); | 15 | +<div class="termin-form"> |
| 18 | 16 | ||
| 19 | - // ================ | ||
| 20 | - // ==== COMMON ==== | ||
| 21 | - // ================ | ||
| 22 | - | ||
| 23 | - echo $form->field($model_pid, 'termin_pid')->widget( | ||
| 24 | - Select2::classname(), | 17 | + <?php $form = ActiveForm::begin(); ?> |
| 18 | + | ||
| 19 | + <?= $form->field($model_pid->termin, 'termin_pid')->widget(Select2::classname(), | ||
| 25 | [ | 20 | [ |
| 26 | - 'data' => ArrayHelper::map( | ||
| 27 | - [ | ||
| 28 | - [ | ||
| 29 | - 'termin_id' => 0, | ||
| 30 | - 'termin_title' => 'NONE', | ||
| 31 | - ] | ||
| 32 | - ] + | ||
| 33 | - (new Termin)->finInfo([ | 21 | + 'data' => ArrayHelper::map((new Termin)->finInfo([ |
| 34 | 'show_all' => true, | 22 | 'show_all' => true, |
| 35 | - 'to_array' => true, | ||
| 36 | ]), | 23 | ]), |
| 37 | 'termin_id', | 24 | 'termin_id', |
| 38 | 'termin_title' | 25 | 'termin_title' |
| @@ -41,53 +28,23 @@ $form = ActiveForm::begin(); | @@ -41,53 +28,23 @@ $form = ActiveForm::begin(); | ||
| 41 | 'pluginOptions' => [ | 28 | 'pluginOptions' => [ |
| 42 | 'allowClear' => true | 29 | 'allowClear' => true |
| 43 | ], | 30 | ], |
| 44 | - ] | ||
| 45 | - ); | 31 | + ]); |
| 32 | + ?> | ||
| 46 | 33 | ||
| 47 | - echo $form->field($model, 'termin_name')->textInput(['maxlength' => true]); | ||
| 48 | - | ||
| 49 | - // ============== | ||
| 50 | - // ==== LANG ==== | ||
| 51 | - // ============== | ||
| 52 | - | ||
| 53 | - $multilang = Multilang::begin(['ajaxpath' => Url::to(['termin/form']), 'form' => $form, 'data_langs' => $model_lang]); | ||
| 54 | - | ||
| 55 | - $first = 1; | ||
| 56 | - | ||
| 57 | - foreach ($model_lang as $index => $data) | ||
| 58 | - { | ||
| 59 | - echo ' | ||
| 60 | - <div role="" class="tab-pane '.($first ? 'active main-tab' : '') .'" id="'.$multilang->id.'-'.$index.'"> | ||
| 61 | - | ||
| 62 | - '.$form->field($model_lang[$index], '['.$index.']lang_id')->label(false)->hiddenInput(['value' => $index]).' | ||
| 63 | - | ||
| 64 | - '.$form->field($model_lang[$index], '['.$index.']termin_title')->textInput().' | ||
| 65 | - | ||
| 66 | - '.$form->field($model_lang[$index], '['.$index.']termin_alias')->textInput().' | 34 | + <?= $form->field($model, 'termin_name')->textInput(['maxlength' => true]) ?> |
| 35 | + | ||
| 36 | + <?= $form->field($model_lang, 'termin_title')->textInput() ?> | ||
| 37 | + | ||
| 38 | + <?= $form->field($model_lang, 'termin_alias')->textInput() ?> | ||
| 39 | + | ||
| 40 | + <?= Html::activeHiddenInput ($model_lang, 'language_id', [ | ||
| 41 | + 'value' => ($model_lang->language_id != 0 ? $model_lang->language_id : Yii::$app->params['language_id']), | ||
| 42 | + ]) ?> | ||
| 67 | 43 | ||
| 68 | - </div>'; | ||
| 69 | - | ||
| 70 | - $first = 0; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - $multilang->end(); | ||
| 74 | -/* | ||
| 75 | - echo Html::activeHiddenInput ($model_lang, 'lang_id', [ | ||
| 76 | - 'value' => ($model_lang->lang_id != 0 ? $model_lang->lang_id : Yii::$app->params['lang_id']), | ||
| 77 | - ]); | ||
| 78 | -*/ | ||
| 79 | - // ==== BUTTON ==== | ||
| 80 | - | ||
| 81 | - echo ' | ||
| 82 | <div class="form-group"> | 44 | <div class="form-group"> |
| 83 | - '.Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']).' | ||
| 84 | - </div>'; | ||
| 85 | - | ||
| 86 | -ActiveForm::end(); | 45 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
| 46 | + </div> | ||
| 87 | 47 | ||
| 88 | -echo '</div>'; | 48 | + <?php ActiveForm::end(); ?> |
| 89 | 49 | ||
| 90 | -echo ' | ||
| 91 | -<script> | ||
| 92 | - var confirm_message = "'.\Yii::t('app', 'Remove image?').'" | ||
| 93 | -</script>'; | 50 | +</div> |
backend/web/css/site.css
| @@ -89,3 +89,47 @@ a.desc:after { | @@ -89,3 +89,47 @@ a.desc:after { | ||
| 89 | padding: 10px 20px; | 89 | padding: 10px 20px; |
| 90 | margin: 0 0 15px 0; | 90 | margin: 0 0 15px 0; |
| 91 | } | 91 | } |
| 92 | +.header-search { | ||
| 93 | + width: 200px; | ||
| 94 | +} | ||
| 95 | +.skin-blue .sidebar-form { | ||
| 96 | + margin: 5px !important; | ||
| 97 | +} | ||
| 98 | +.checkboxer .list-group-item { | ||
| 99 | + padding: 0; | ||
| 100 | +} | ||
| 101 | +.checkboxer .list-group-item:hover { | ||
| 102 | + background: #ddd; | ||
| 103 | +} | ||
| 104 | +.checkboxer .list-group-item.active, .checkboxer .list-group-item.active:hover { | ||
| 105 | + background: #00a65a; | ||
| 106 | +} | ||
| 107 | +.checkboxer .list-group-item.active label, .checkboxer .list-group-item.active:hover label { | ||
| 108 | + color: white; | ||
| 109 | +} | ||
| 110 | +.checkboxer .list-group-item.level0 { | ||
| 111 | + padding-left: 15px; | ||
| 112 | +} | ||
| 113 | +.checkboxer .list-group-item.level1 { | ||
| 114 | + padding-left: 45px; | ||
| 115 | +} | ||
| 116 | +.checkboxer .list-group-item.level2 { | ||
| 117 | + padding-left: 75px; | ||
| 118 | +} | ||
| 119 | +.checkboxer .checkboxer_label { | ||
| 120 | + padding: 10px 0; | ||
| 121 | + display: block; | ||
| 122 | +} | ||
| 123 | +.checkboxer .checkboxer_label input[type=radio] { | ||
| 124 | + position: absolute; | ||
| 125 | + clip: rect(0,0,0,0); | ||
| 126 | +} | ||
| 127 | +.action_link { | ||
| 128 | + float: left; | ||
| 129 | +} | ||
| 130 | +.admin_grid_action { | ||
| 131 | + padding: 0 20px; | ||
| 132 | +} | ||
| 133 | +.admin_grid_action .pagination { | ||
| 134 | + margin: 0; | ||
| 135 | +} |
backend/web/js/option.js
| @@ -12,6 +12,11 @@ function readURL(input) { | @@ -12,6 +12,11 @@ function readURL(input) { | ||
| 12 | } | 12 | } |
| 13 | return urls; | 13 | return urls; |
| 14 | } | 14 | } |
| 15 | +function checkboxerInit() { | ||
| 16 | + $.each($('.checkboxer input[type=radio]:checked'), function(index, value) { | ||
| 17 | + $(value).trigger('change'); | ||
| 18 | + }); | ||
| 19 | +} | ||
| 15 | $(function() { | 20 | $(function() { |
| 16 | var counter = 0; | 21 | var counter = 0; |
| 17 | $(document).on('click', '.add_row', function() { | 22 | $(document).on('click', '.add_row', function() { |
| @@ -58,12 +63,36 @@ $(function() { | @@ -58,12 +63,36 @@ $(function() { | ||
| 58 | $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); | 63 | $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); |
| 59 | } | 64 | } |
| 60 | }); | 65 | }); |
| 61 | - $(document).on('click', '.dropdown-menu.f32 li a[data-lang]', function() { | 66 | + $(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { |
| 62 | var lang = $(this).data('lang'); | 67 | var lang = $(this).data('lang'); |
| 63 | var flag = $(this).find('span').first().clone(); | 68 | var flag = $(this).find('span').first().clone(); |
| 64 | var el = $(this); | 69 | var el = $(this); |
| 65 | var id = $(this).attr('href').substr(1); | 70 | var id = $(this).attr('href').substr(1); |
| 66 | - $.get(form[id], { lang_id: lang, widget_id: id }, function(data) { | 71 | + var path = form[id].handler; |
| 72 | + var view = form[id].view; | ||
| 73 | + var model = form[id].model; | ||
| 74 | + $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { | ||
| 75 | + $('#'+id+'-tabs li').removeClass('active'); | ||
| 76 | + $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 77 | + $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 78 | + $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 79 | + $('body').append($(data).filter('script')); | ||
| 80 | + $(el).parent().remove(); | ||
| 81 | + if(!$('#lang-'+id+' li').length) { | ||
| 82 | + $('#'+id+'Lang').addClass('disabled'); | ||
| 83 | + } | ||
| 84 | + if($('#'+id+'-tabs li').length > 1) { | ||
| 85 | + $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 86 | + } | ||
| 87 | + }); | ||
| 88 | + }); | ||
| 89 | + $(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) { | ||
| 90 | + e.preventDefault(); | ||
| 91 | + var lang = $(this).data('lang'); | ||
| 92 | + var flag = $(this).find('span').first().clone(); | ||
| 93 | + var el = $(this); | ||
| 94 | + var id = $(this).attr('href').substr(1); | ||
| 95 | + $.get(form[id], { language_id: lang, widget_id: id }, function(data) { | ||
| 67 | $('#'+id+'-tabs li').removeClass('active'); | 96 | $('#'+id+'-tabs li').removeClass('active'); |
| 68 | $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | 97 | $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); |
| 69 | $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | 98 | $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); |
| @@ -93,4 +122,12 @@ $(function() { | @@ -93,4 +122,12 @@ $(function() { | ||
| 93 | $('#'+id+'-tabs>li').first().find('a').tab('show'); | 122 | $('#'+id+'-tabs>li').first().find('a').tab('show'); |
| 94 | } | 123 | } |
| 95 | }); | 124 | }); |
| 125 | + $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() { | ||
| 126 | + $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); | ||
| 127 | + $(this).parents('.checkboxer_container').addClass('active'); | ||
| 128 | + }); | ||
| 129 | + $.each($('.f32'), function(i, val) { | ||
| 130 | + $(val).find('a[role=tab]').first().trigger('click'); | ||
| 131 | + }); | ||
| 132 | + checkboxerInit(); | ||
| 96 | }); | 133 | }); |
| 97 | \ No newline at end of file | 134 | \ No newline at end of file |
common/components/LangRequest.php
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace common\components; | 3 | namespace common\components; |
| 4 | 4 | ||
| 5 | use Yii; | 5 | use Yii; |
| 6 | +use yii\base\InvalidConfigException; | ||
| 6 | use yii\web\Request; | 7 | use yii\web\Request; |
| 7 | use common\models\Language; | 8 | use common\models\Language; |
| 8 | use common\models\Page; | 9 | use common\models\Page; |
| @@ -29,10 +30,10 @@ class LangRequest extends Request | @@ -29,10 +30,10 @@ class LangRequest extends Request | ||
| 29 | 30 | ||
| 30 | Language::setCurrent($lang_url); | 31 | Language::setCurrent($lang_url); |
| 31 | 32 | ||
| 32 | - if ($lang_url !== null && $lang_url === Language::getCurrent()->lang_code | ||
| 33 | - && strpos($this->_lang_url, Language::getCurrent()->lang_code) === 1) | 33 | + if ($lang_url !== null && $lang_url === Language::getCurrent()->language_code |
| 34 | + && strpos($this->_lang_url, Language::getCurrent()->language_code) === 1) | ||
| 34 | { | 35 | { |
| 35 | - $this->_lang_url = substr ($this->_lang_url, strlen (Language::getCurrent()->lang_code) + 1); | 36 | + $this->_lang_url = substr ($this->_lang_url, strlen (Language::getCurrent()->language_code) + 1); |
| 36 | } | 37 | } |
| 37 | } | 38 | } |
| 38 | 39 |
common/components/LangUrlManager.php
| @@ -9,16 +9,16 @@ class LangUrlManager extends UrlManager | @@ -9,16 +9,16 @@ class LangUrlManager extends UrlManager | ||
| 9 | { | 9 | { |
| 10 | public function createUrl ($params) | 10 | public function createUrl ($params) |
| 11 | { | 11 | { |
| 12 | - if (isset ($params['lang_id'])) | 12 | + if (isset ($params['language_id'])) |
| 13 | { | 13 | { |
| 14 | //Если указан идентификатор языка, то делаем попытку найти язык в БД, | 14 | //Если указан идентификатор языка, то делаем попытку найти язык в БД, |
| 15 | //иначе работаем с языком по умолчанию | 15 | //иначе работаем с языком по умолчанию |
| 16 | - if (($lang_code = Language::findOne($params['lang_id'])) === null) | 16 | + if (($lang_code = Language::findOne($params['language_id'])) === null) |
| 17 | { | 17 | { |
| 18 | $lang_code = Language::getDefaultLang(); | 18 | $lang_code = Language::getDefaultLang(); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | - unset ($params['lang_id']); | 21 | + unset ($params['language_id']); |
| 22 | 22 | ||
| 23 | } | 23 | } |
| 24 | else | 24 | else |
common/config/main.php
| @@ -8,6 +8,9 @@ return [ | @@ -8,6 +8,9 @@ return [ | ||
| 8 | 'userClass' => 'common\models\User' | 8 | 'userClass' => 'common\models\User' |
| 9 | ] | 9 | ] |
| 10 | ], | 10 | ], |
| 11 | + 'blog' => [ | ||
| 12 | + 'class' => 'common\modules\blog\Module', | ||
| 13 | + ], | ||
| 11 | ], | 14 | ], |
| 12 | 'components' => [ | 15 | 'components' => [ |
| 13 | 'cache' => [ | 16 | 'cache' => [ |
common/models/Catalog.php
| @@ -23,21 +23,21 @@ class Catalog extends Model | @@ -23,21 +23,21 @@ class Catalog extends Model | ||
| 23 | termin_lang.termin_title | 23 | termin_lang.termin_title |
| 24 | FROM termin_structure | 24 | FROM termin_structure |
| 25 | INNER JOIN termin_lang ON termin_lang.termin_id = termin_structure.termin_id | 25 | INNER JOIN termin_lang ON termin_lang.termin_id = termin_structure.termin_id |
| 26 | - AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].' | 26 | + AND termin_lang.language_id = '.Yii::$app->params['language_id'].' |
| 27 | ORDER BY termin_structure.termin_id ASC, termin_structure.termin_pid ASC | 27 | ORDER BY termin_structure.termin_id ASC, termin_structure.termin_pid ASC |
| 28 | ')->queryAll(); | 28 | ')->queryAll(); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | * Выполняет поиск по параметрам | 32 | * Выполняет поиск по параметрам |
| 33 | - * @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all] | 33 | + * @param array $param принимает [catalog_id, language_id, return_one, return_field, show_all] |
| 34 | * @return array one | array all | string значение масива | 34 | * @return array one | array all | string значение масива |
| 35 | */ | 35 | */ |
| 36 | public function finInfo (array $params = []) | 36 | public function finInfo (array $params = []) |
| 37 | { | 37 | { |
| 38 | Tools::ifNotExist ($params, array ( | 38 | Tools::ifNotExist ($params, array ( |
| 39 | 'catalog_id' => false, | 39 | 'catalog_id' => false, |
| 40 | - 'lang_id' => false, | 40 | + 'language_id' => false, |
| 41 | 'return_one' => false, | 41 | 'return_one' => false, |
| 42 | 'return_field' => false, | 42 | 'return_field' => false, |
| 43 | 'show_all' => false, | 43 | 'show_all' => false, |
| @@ -57,9 +57,9 @@ class Catalog extends Model | @@ -57,9 +57,9 @@ class Catalog extends Model | ||
| 57 | $WHERE['catalog.catalog_id'] = $params['catalog_id']; | 57 | $WHERE['catalog.catalog_id'] = $params['catalog_id']; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | - if ($params['lang_id']) | 60 | + if ($params['language_id']) |
| 61 | { | 61 | { |
| 62 | - $WHERE['catalog_i18n.lang_id'] = $params['lang_id']; | 62 | + $WHERE['catalog_i18n.language_id'] = $params['language_id']; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | if (! empty ($WHERE)) | 65 | if (! empty ($WHERE)) |
| @@ -144,7 +144,7 @@ class Catalog extends Model | @@ -144,7 +144,7 @@ class Catalog extends Model | ||
| 144 | */ | 144 | */ |
| 145 | public function getRelationCatalogLangPlus() | 145 | public function getRelationCatalogLangPlus() |
| 146 | { | 146 | { |
| 147 | - return $this->getRelationCatalogLang()->where(['lang_id' => yii::$app->params['lang_id']]); | 147 | + return $this->getRelationCatalogLang()->where(['language_id' => yii::$app->params['language_id']]); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | /** | 150 | /** |
common/models/Language.php
| @@ -8,7 +8,11 @@ use Yii; | @@ -8,7 +8,11 @@ use Yii; | ||
| 8 | * This is the model class for table "language". | 8 | * This is the model class for table "language". |
| 9 | * | 9 | * |
| 10 | * @property integer $language_id | 10 | * @property integer $language_id |
| 11 | - * @property string $lang_code | 11 | + * @property string $language_code |
| 12 | + * @property string $is_default | ||
| 13 | + * @property string $language_name | ||
| 14 | + * @property string $status | ||
| 15 | + * @property string $country_code | ||
| 12 | */ | 16 | */ |
| 13 | class Language extends \yii\db\ActiveRecord | 17 | class Language extends \yii\db\ActiveRecord |
| 14 | { | 18 | { |
| @@ -32,8 +36,8 @@ class Language extends \yii\db\ActiveRecord | @@ -32,8 +36,8 @@ class Language extends \yii\db\ActiveRecord | ||
| 32 | $language = self::getLangByUrl($lang_code); | 36 | $language = self::getLangByUrl($lang_code); |
| 33 | self::$current = ($language === null) ? self::getDefaultLang() : $language; | 37 | self::$current = ($language === null) ? self::getDefaultLang() : $language; |
| 34 | // задаем | 38 | // задаем |
| 35 | - Yii::$app->language = self::$current->lang_code; | ||
| 36 | - Yii::$app->params['lang_id'] = self::$current->language_id; | 39 | + Yii::$app->language = self::$current->language_code; |
| 40 | + Yii::$app->params['language_id'] = self::$current->language_id; | ||
| 37 | } | 41 | } |
| 38 | 42 | ||
| 39 | //Получения объекта языка по умолчанию | 43 | //Получения объекта языка по умолчанию |
| @@ -48,7 +52,7 @@ class Language extends \yii\db\ActiveRecord | @@ -48,7 +52,7 @@ class Language extends \yii\db\ActiveRecord | ||
| 48 | if ($lang_code === null) { | 52 | if ($lang_code === null) { |
| 49 | return null; | 53 | return null; |
| 50 | } else { | 54 | } else { |
| 51 | - $language = Language::find()->where('lang_code = :what', [':what' => $lang_code])->one(); | 55 | + $language = Language::find()->where('language_code = :what', [':what' => $lang_code])->one(); |
| 52 | return $language === null ? null : $language; | 56 | return $language === null ? null : $language; |
| 53 | } | 57 | } |
| 54 | } | 58 | } |
| @@ -67,8 +71,8 @@ class Language extends \yii\db\ActiveRecord | @@ -67,8 +71,8 @@ class Language extends \yii\db\ActiveRecord | ||
| 67 | public function rules() | 71 | public function rules() |
| 68 | { | 72 | { |
| 69 | return [ | 73 | return [ |
| 70 | - [['lang_code'], 'required'], | ||
| 71 | - [['lang_code'], 'string', 'max' => 4] | 74 | + [['language_code', 'language_name', 'country_code'], 'required'], |
| 75 | + [['language_code', 'country_code'], 'string', 'max' => 4] | ||
| 72 | ]; | 76 | ]; |
| 73 | } | 77 | } |
| 74 | 78 | ||
| @@ -79,13 +83,17 @@ class Language extends \yii\db\ActiveRecord | @@ -79,13 +83,17 @@ class Language extends \yii\db\ActiveRecord | ||
| 79 | { | 83 | { |
| 80 | return [ | 84 | return [ |
| 81 | 'language_id' => Yii::t('app/Lang', 'Language ID'), | 85 | 'language_id' => Yii::t('app/Lang', 'Language ID'), |
| 82 | - 'lang_code' => Yii::t('app/Lang', 'Lang Code'), | 86 | + 'language_code' => Yii::t('app/Lang', 'Lang Code'), |
| 87 | + 'is_default' => Yii::t('app/Lang', 'Default lang'), | ||
| 88 | + 'language_name' => Yii::t('app/Lang', 'Language Name'), | ||
| 89 | + 'status' => Yii::t('app/Lang', 'Language Status'), | ||
| 90 | + 'country_code' => Yii::t('app/Lang', 'Country Code'), | ||
| 83 | ]; | 91 | ]; |
| 84 | } | 92 | } |
| 85 | 93 | ||
| 86 | public static function getActiveLanguages() | 94 | public static function getActiveLanguages() |
| 87 | { | 95 | { |
| 88 | - return Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1])->orderBy('is_default DESC')->indexBy('language_id')->all(); | 96 | + return Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1])->orderBy('is_default DESC')->indexBy('language_id')->all(); |
| 89 | } | 97 | } |
| 90 | 98 | ||
| 91 | } | 99 | } |
common/models/Media.php
| @@ -12,8 +12,9 @@ use yii\web\UploadedFile; | @@ -12,8 +12,9 @@ use yii\web\UploadedFile; | ||
| 12 | /** | 12 | /** |
| 13 | * This is the model class for table "media". | 13 | * This is the model class for table "media". |
| 14 | * | 14 | * |
| 15 | - * @property integer $id | 15 | + * @property integer $media_id |
| 16 | * @property string $hash | 16 | * @property string $hash |
| 17 | + * @property string $extension | ||
| 17 | * | 18 | * |
| 18 | * @property ArticleCategoryMedia[] $articleCategoryMedia | 19 | * @property ArticleCategoryMedia[] $articleCategoryMedia |
| 19 | * @property ArticleMedia[] $articleMedia | 20 | * @property ArticleMedia[] $articleMedia |
| @@ -39,8 +40,8 @@ class Media extends ActiveRecord | @@ -39,8 +40,8 @@ class Media extends ActiveRecord | ||
| 39 | public function rules() | 40 | public function rules() |
| 40 | { | 41 | { |
| 41 | return [ | 42 | return [ |
| 42 | - [['id'], 'integer'], | ||
| 43 | - [['hash'], 'string'], | 43 | + [['media_id'], 'integer'], |
| 44 | + [['hash', 'extension'], 'string'], | ||
| 44 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpeg, jpg', 'skipOnEmpty' => true], | 45 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpeg, jpg', 'skipOnEmpty' => true], |
| 45 | ]; | 46 | ]; |
| 46 | } | 47 | } |
| @@ -51,8 +52,9 @@ class Media extends ActiveRecord | @@ -51,8 +52,9 @@ class Media extends ActiveRecord | ||
| 51 | public function attributeLabels() | 52 | public function attributeLabels() |
| 52 | { | 53 | { |
| 53 | return [ | 54 | return [ |
| 54 | - 'id' => Yii::t('app', 'ID'), | 55 | + 'media_id' => Yii::t('app', 'ID'), |
| 55 | 'hash' => Yii::t('app', 'Hash'), | 56 | 'hash' => Yii::t('app', 'Hash'), |
| 57 | + 'extension' => Yii::t('app', 'Extension'), | ||
| 56 | ]; | 58 | ]; |
| 57 | } | 59 | } |
| 58 | 60 | ||
| @@ -61,7 +63,7 @@ class Media extends ActiveRecord | @@ -61,7 +63,7 @@ class Media extends ActiveRecord | ||
| 61 | */ | 63 | */ |
| 62 | public function getArticleCategoryMedia() | 64 | public function getArticleCategoryMedia() |
| 63 | { | 65 | { |
| 64 | - return $this->hasMany(ArticleCategoryMedia::className(), ['media_id' => 'id']); | 66 | + return $this->hasMany(ArticleCategoryMedia::className(), ['media_id' => 'media_id']); |
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | /** | 69 | /** |
| @@ -69,12 +71,12 @@ class Media extends ActiveRecord | @@ -69,12 +71,12 @@ class Media extends ActiveRecord | ||
| 69 | */ | 71 | */ |
| 70 | public function getArticleMedia() | 72 | public function getArticleMedia() |
| 71 | { | 73 | { |
| 72 | - return $this->hasMany(ArticleMedia::className(), ['media_id' => 'id']); | 74 | + return $this->hasMany(ArticleMedia::className(), ['media_id' => 'media_id']); |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | public function getArticle() | 77 | public function getArticle() |
| 76 | { | 78 | { |
| 77 | - return $this->hasMany(Article::className(), ['id' => 'article_id'])->via('articleMedia'); | 79 | + return $this->hasMany(Article::className(), ['article_id' => 'article_id'])->via('articleMedia'); |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | public function upload() | 82 | public function upload() |
common/models/Tools.php
| @@ -98,4 +98,19 @@ class Tools | @@ -98,4 +98,19 @@ class Tools | ||
| 98 | 98 | ||
| 99 | return $url; | 99 | return $url; |
| 100 | } | 100 | } |
| 101 | + | ||
| 102 | + static function parseUrlParams($params) | ||
| 103 | + { | ||
| 104 | + $params = preg_split('/,\s*/', $params, -1, PREG_SPLIT_NO_EMPTY); | ||
| 105 | + $result = []; | ||
| 106 | + if($params) { | ||
| 107 | + foreach($params as $param) { | ||
| 108 | + $param = preg_split('/\s*=\s*/', $param); | ||
| 109 | + if(!empty($param[0]) && !empty($param[1])) { | ||
| 110 | + $result[$param[0]] = $param[1]; | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + return $result; | ||
| 115 | + } | ||
| 101 | } | 116 | } |
| 102 | \ No newline at end of file | 117 | \ No newline at end of file |
common/modules/blog/controllers/AjaxController.php
| @@ -7,6 +7,7 @@ use common\modules\blog\models\ArticleCategoryLang; | @@ -7,6 +7,7 @@ use common\modules\blog\models\ArticleCategoryLang; | ||
| 7 | use common\modules\blog\models\ArticleCategoryMedia; | 7 | use common\modules\blog\models\ArticleCategoryMedia; |
| 8 | use common\modules\blog\models\ArticleLang; | 8 | use common\modules\blog\models\ArticleLang; |
| 9 | use common\modules\blog\models\ArticleMedia; | 9 | use common\modules\blog\models\ArticleMedia; |
| 10 | +use yii\base\InvalidParamException; | ||
| 10 | use yii\web\Controller; | 11 | use yii\web\Controller; |
| 11 | use yii\web\ForbiddenHttpException; | 12 | use yii\web\ForbiddenHttpException; |
| 12 | use yii\web\NotFoundHttpException; | 13 | use yii\web\NotFoundHttpException; |
| @@ -26,9 +27,9 @@ class AjaxController extends Controller | @@ -26,9 +27,9 @@ class AjaxController extends Controller | ||
| 26 | return true; | 27 | return true; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | - public function actionCategoryForm($lang_id, $widget_id) | 30 | + public function actionCategoryForm($language_id, $widget_id) |
| 30 | { | 31 | { |
| 31 | - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); | 32 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); |
| 32 | if(!$model) { | 33 | if(!$model) { |
| 33 | throw new NotFoundHttpException('Language not found'); | 34 | throw new NotFoundHttpException('Language not found'); |
| 34 | } | 35 | } |
| @@ -36,9 +37,9 @@ class AjaxController extends Controller | @@ -36,9 +37,9 @@ class AjaxController extends Controller | ||
| 36 | return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]); | 37 | return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]); |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | - public function actionArticleForm($lang_id, $widget_id) | 40 | + public function actionArticleForm($language_id, $widget_id) |
| 40 | { | 41 | { |
| 41 | - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); | 42 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); |
| 42 | if(!$model) { | 43 | if(!$model) { |
| 43 | throw new NotFoundHttpException('Language not found'); | 44 | throw new NotFoundHttpException('Language not found'); |
| 44 | } | 45 | } |
| @@ -46,6 +47,32 @@ class AjaxController extends Controller | @@ -46,6 +47,32 @@ class AjaxController extends Controller | ||
| 46 | return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]); | 47 | return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 50 | + public function actionArticleMediaForm($language_id, $widget_id, $type) | ||
| 51 | + { | ||
| 52 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); | ||
| 53 | + if(!$model) { | ||
| 54 | + throw new NotFoundHttpException('Language not found'); | ||
| 55 | + } | ||
| 56 | + if(!in_array($type, ['full', 'preview'])) { | ||
| 57 | + throw new InvalidParamException('Type must only be full/preview'); | ||
| 58 | + } | ||
| 59 | + $article_lang = new ArticleMedia(); | ||
| 60 | + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public function actionArticleCategoryMediaForm($language_id, $widget_id, $type) | ||
| 64 | + { | ||
| 65 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); | ||
| 66 | + if(!$model) { | ||
| 67 | + throw new NotFoundHttpException('Language not found'); | ||
| 68 | + } | ||
| 69 | + if(!in_array($type, ['full', 'preview'])) { | ||
| 70 | + throw new InvalidParamException('Type must only be full/preview'); | ||
| 71 | + } | ||
| 72 | + $article_lang = new ArticleCategoryMedia(); | ||
| 73 | + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); | ||
| 74 | + } | ||
| 75 | + | ||
| 49 | public function actionRemoveImage() | 76 | public function actionRemoveImage() |
| 50 | { | 77 | { |
| 51 | $post = \Yii::$app->request->post(); | 78 | $post = \Yii::$app->request->post(); |
| @@ -63,6 +90,23 @@ class AjaxController extends Controller | @@ -63,6 +90,23 @@ class AjaxController extends Controller | ||
| 63 | } | 90 | } |
| 64 | } | 91 | } |
| 65 | 92 | ||
| 93 | + public function actionRemoveCategoryImage() | ||
| 94 | + { | ||
| 95 | + $post = \Yii::$app->request->post(); | ||
| 96 | + if(!empty($post['category_media_id'])) { | ||
| 97 | + $category_media = ArticleCategoryMedia::findOne($post['category_media_id']); | ||
| 98 | + if($post['remove_media']) { | ||
| 99 | + $media = $category_media->media->delete(); | ||
| 100 | + } | ||
| 101 | + if(!empty($category_media)) { | ||
| 102 | + $category_media->delete(); | ||
| 103 | + } | ||
| 104 | + return true; | ||
| 105 | + } else { | ||
| 106 | + return false; | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 66 | public function actionRemoveImageCategory() | 110 | public function actionRemoveImageCategory() |
| 67 | { | 111 | { |
| 68 | $post = \Yii::$app->request->post(); | 112 | $post = \Yii::$app->request->post(); |
| @@ -79,4 +123,10 @@ class AjaxController extends Controller | @@ -79,4 +123,10 @@ class AjaxController extends Controller | ||
| 79 | return false; | 123 | return false; |
| 80 | } | 124 | } |
| 81 | } | 125 | } |
| 126 | + | ||
| 127 | + public function actionMultilangForm($model, $ajaxView, $widget_id, $language_id = NULL) | ||
| 128 | + { | ||
| 129 | + $model = new $model(['language_id' => $language_id]); | ||
| 130 | + return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]); | ||
| 131 | + } | ||
| 82 | } | 132 | } |
common/modules/blog/controllers/ArticleController.php
| @@ -28,28 +28,31 @@ class ArticleController extends Controller | @@ -28,28 +28,31 @@ class ArticleController extends Controller | ||
| 28 | { | 28 | { |
| 29 | $article_langs = array(); | 29 | $article_langs = array(); |
| 30 | $article = new Article(); | 30 | $article = new Article(); |
| 31 | + $default_lang = Language::getDefaultLang(); | ||
| 31 | $images = array(); | 32 | $images = array(); |
| 32 | - $images['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]); | ||
| 33 | - $images['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]); | ||
| 34 | - $images['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | 33 | + $images[$default_lang->language_id]['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]); |
| 34 | + $images[$default_lang->language_id]['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]); | ||
| 35 | + $images[0]['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | ||
| 35 | $article->loadDefaultValues(); | 36 | $article->loadDefaultValues(); |
| 36 | $langs = Language::getActiveLanguages(); | 37 | $langs = Language::getActiveLanguages(); |
| 37 | - $default_lang = Language::getDefaultLang(); | ||
| 38 | $isValid = false; | 38 | $isValid = false; |
| 39 | if(!empty(\Yii::$app->request->post())) { | 39 | if(!empty(\Yii::$app->request->post())) { |
| 40 | $isValid = true; | 40 | $isValid = true; |
| 41 | $article->load(\Yii::$app->request->post()); | 41 | $article->load(\Yii::$app->request->post()); |
| 42 | - $article->author = \Yii::$app->user->getId(); | 42 | + $article->user_id = \Yii::$app->user->getId(); |
| 43 | $isValid = $article->validate(); | 43 | $isValid = $article->validate(); |
| 44 | - foreach($images as $index => $value) { | ||
| 45 | - $images[$index]->type = $index; | ||
| 46 | - if($index == 'additional') { | ||
| 47 | - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile"); | ||
| 48 | - } else { | ||
| 49 | - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile"); | 44 | + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { |
| 45 | + foreach($value as $type => $fields) { | ||
| 46 | + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); | ||
| 47 | + $images[$lang][$type]->type = $type; | ||
| 48 | + $images[$lang][$type]->language_id = $lang; | ||
| 49 | + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | ||
| 50 | + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | ||
| 50 | } | 51 | } |
| 51 | - $isValid = $images[$index]->validate(['imageFile']) && $isValid; | ||
| 52 | } | 52 | } |
| 53 | + $images[0]['additional']->language_id = 0; | ||
| 54 | + $images[0]['additional']->type = 'additional'; | ||
| 55 | + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); | ||
| 53 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { | 56 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { |
| 54 | $article_langs[$default_lang->language_id] = new ArticleLang(); | 57 | $article_langs[$default_lang->language_id] = new ArticleLang(); |
| 55 | $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; | 58 | $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; |
| @@ -69,18 +72,30 @@ class ArticleController extends Controller | @@ -69,18 +72,30 @@ class ArticleController extends Controller | ||
| 69 | if(!empty($article_categories)) { | 72 | if(!empty($article_categories)) { |
| 70 | foreach($article_categories as $article_category) { | 73 | foreach($article_categories as $article_category) { |
| 71 | $articletocategory[$article_category] = new ArticleToCategory(); | 74 | $articletocategory[$article_category] = new ArticleToCategory(); |
| 72 | - $articletocategory[$article_category]->category_id = $article_category; | 75 | + $articletocategory[$article_category]->article_category_id = $article_category; |
| 73 | $articletocategory[$article_category]->link('article', $article); | 76 | $articletocategory[$article_category]->link('article', $article); |
| 74 | } | 77 | } |
| 75 | } | 78 | } |
| 76 | $first = 1; | 79 | $first = 1; |
| 77 | - foreach($images as $index => $image) { | ||
| 78 | - $images[$index]->upload($article->id); | 80 | + foreach($images as $lang => $value) { |
| 81 | + foreach($value as $type => $fields) { | ||
| 82 | + $images[$lang][$type]->upload($article->article_id); | ||
| 83 | + if($first && $type != 'additional') { | ||
| 84 | + $media_clone = clone $images[$lang][$type]; | ||
| 85 | + $media_clone->setIsNewRecord(true); | ||
| 86 | + unset($media_clone->article_media_id); | ||
| 87 | + $media_clone->language_id = 0; | ||
| 88 | + $media_clone->upload($article->article_id); | ||
| 89 | + unset($media_clone); | ||
| 90 | + $first = 0; | ||
| 91 | + } | ||
| 92 | + } | ||
| 79 | } | 93 | } |
| 94 | + $first = 1; | ||
| 80 | foreach($article_langs as $article_lang) { | 95 | foreach($article_langs as $article_lang) { |
| 81 | if($first) { | 96 | if($first) { |
| 82 | $article_lang_clone = clone $article_lang; | 97 | $article_lang_clone = clone $article_lang; |
| 83 | - $article_lang_clone->lang_id = 0; | 98 | + $article_lang_clone->language_id = 0; |
| 84 | $article_lang_clone->link('article', $article); | 99 | $article_lang_clone->link('article', $article); |
| 85 | unset($article_lang_clone); | 100 | unset($article_lang_clone); |
| 86 | } | 101 | } |
| @@ -102,49 +117,52 @@ class ArticleController extends Controller | @@ -102,49 +117,52 @@ class ArticleController extends Controller | ||
| 102 | public function actionUpdate($id) | 117 | public function actionUpdate($id) |
| 103 | { | 118 | { |
| 104 | $article = Article::findOne($id); | 119 | $article = Article::findOne($id); |
| 105 | - $images = $article->getArticleMedia()->indexBy('type')->all(); | ||
| 106 | - if(!array_key_exists('full', $images)) { | ||
| 107 | - $images['full'] = new ArticleMedia(); | ||
| 108 | - } | ||
| 109 | - if(!array_key_exists('preview', $images)) { | ||
| 110 | - $images['preview'] = new ArticleMedia(); | ||
| 111 | - } | ||
| 112 | - foreach($images as $index => $image) { | ||
| 113 | - $images[$index]->scenario = $index; | 120 | + $imagestack = $article->getArticleMedia()->all(); |
| 121 | + $images = []; | ||
| 122 | + $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | ||
| 123 | + $images[0]['additional'][0]->type = 'additional'; | ||
| 124 | + $images[0]['additional'][0]->language_id = 0; | ||
| 125 | + foreach($imagestack as $image) { | ||
| 126 | + if(in_array($image->type, ['full', 'preview'])) { | ||
| 127 | + $images[$image->language_id][$image->type] = $image; | ||
| 128 | + $images[$image->language_id][$image->type]->scenario = $image->type; | ||
| 129 | + } else { | ||
| 130 | + $images[$image->language_id][$image->type][$image->article_media_id] = $image; | ||
| 131 | + $images[$image->language_id][$image->type][$image->article_media_id]->scenario = $image->type; | ||
| 132 | + } | ||
| 114 | } | 133 | } |
| 115 | - $images['additional'] = array( | ||
| 116 | - 0 => new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]) | ||
| 117 | - ); | ||
| 118 | - $images['additional'] = array_merge($images['additional'], $article->getArticleMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all()); | ||
| 119 | - foreach($images['additional'] as $index => $image) { | ||
| 120 | - $images['additional'][$index]->scenario = 'additional'; | 134 | + foreach($images as $lang => $value) { |
| 135 | + $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | ||
| 121 | } | 136 | } |
| 122 | - $article_langs = $article->getArticleLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all(); | 137 | + $article_langs = $article->getArticleLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all(); |
| 123 | $langs = Language::getActiveLanguages(); | 138 | $langs = Language::getActiveLanguages(); |
| 124 | $default_lang = Language::getDefaultLang(); | 139 | $default_lang = Language::getDefaultLang(); |
| 125 | $isValid = false; | 140 | $isValid = false; |
| 126 | if(!empty(\Yii::$app->request->post())) { | 141 | if(!empty(\Yii::$app->request->post())) { |
| 127 | $isValid = true; | 142 | $isValid = true; |
| 128 | $article->load(\Yii::$app->request->post()); | 143 | $article->load(\Yii::$app->request->post()); |
| 129 | - ArticleToCategory::deleteAll(['article_id' => $article->id]); | 144 | + ArticleToCategory::deleteAll(['article_id' => $article->article_id]); |
| 130 | $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; | 145 | $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; |
| 131 | if(!empty($article_categories)) { | 146 | if(!empty($article_categories)) { |
| 132 | foreach($article_categories as $article_category) { | 147 | foreach($article_categories as $article_category) { |
| 133 | $articletocategory[$article_category] = new ArticleToCategory(); | 148 | $articletocategory[$article_category] = new ArticleToCategory(); |
| 134 | - $articletocategory[$article_category]->category_id = $article_category; | 149 | + $articletocategory[$article_category]->article_category_id = $article_category; |
| 135 | $articletocategory[$article_category]->link('article', $article); | 150 | $articletocategory[$article_category]->link('article', $article); |
| 136 | } | 151 | } |
| 137 | } | 152 | } |
| 138 | $isValid = $article->validate(); | 153 | $isValid = $article->validate(); |
| 139 | - foreach($images as $index => $value) { | ||
| 140 | - if($index == 'additional') { | ||
| 141 | - $images[$index][0]->type = $index; | ||
| 142 | - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile"); | ||
| 143 | - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid; | ||
| 144 | - } else { | ||
| 145 | - $images[$index]->type = $index; | ||
| 146 | - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile"); | ||
| 147 | - $isValid = $images[$index]->validate(['imageFile']) && $isValid; | 154 | + $images[0]['additional'][0]->type = 'additional'; |
| 155 | + $images[0]['additional'][0]->language_id = 0; | ||
| 156 | + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); | ||
| 157 | + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; | ||
| 158 | + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { | ||
| 159 | + foreach($value as $type => $fields) { | ||
| 160 | + if(!in_array($type, ['full', 'preview'])) continue; | ||
| 161 | + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); | ||
| 162 | + $images[$lang][$type]->language_id = $lang; | ||
| 163 | + $images[$lang][$type]->type = $type; | ||
| 164 | + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | ||
| 165 | + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | ||
| 148 | } | 166 | } |
| 149 | } | 167 | } |
| 150 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { | 168 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { |
| @@ -153,7 +171,7 @@ class ArticleController extends Controller | @@ -153,7 +171,7 @@ class ArticleController extends Controller | ||
| 153 | foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { | 171 | foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { |
| 154 | if (!array_key_exists($index, $article_langs)) { | 172 | if (!array_key_exists($index, $article_langs)) { |
| 155 | $article_langs[$index] = new ArticleLang(); | 173 | $article_langs[$index] = new ArticleLang(); |
| 156 | - $article_langs[$index]->article_id = $article->id; | 174 | + $article_langs[$index]->article_id = $article->article_id; |
| 157 | } | 175 | } |
| 158 | } | 176 | } |
| 159 | ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); | 177 | ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); |
| @@ -162,12 +180,14 @@ class ArticleController extends Controller | @@ -162,12 +180,14 @@ class ArticleController extends Controller | ||
| 162 | } | 180 | } |
| 163 | if($isValid) { | 181 | if($isValid) { |
| 164 | $article->save(false); | 182 | $article->save(false); |
| 165 | - foreach($images as $index => $image) { | ||
| 166 | - if($index == 'additional') { | ||
| 167 | - $images[$index][0]->upload($article->id); | ||
| 168 | - } else { | ||
| 169 | - if(!empty($images[$index]->imageFile)) { | ||
| 170 | - $images[$index]->replace($article->id, true); | 183 | + foreach($images as $lang => $value) { |
| 184 | + foreach($value as $type => $fields) { | ||
| 185 | + if($type == 'additional') { | ||
| 186 | + $images[$lang][$type][0]->upload($article->id); | ||
| 187 | + } else { | ||
| 188 | + if(!empty($images[$lang][$type]->imageFile)) { | ||
| 189 | + $images[$lang][$type]->replace($article->article_id); | ||
| 190 | + } | ||
| 171 | } | 191 | } |
| 172 | } | 192 | } |
| 173 | } | 193 | } |
common/modules/blog/controllers/CategoryController.php
| @@ -42,27 +42,30 @@ class CategoryController extends Controller | @@ -42,27 +42,30 @@ class CategoryController extends Controller | ||
| 42 | { | 42 | { |
| 43 | $category_langs = array(); | 43 | $category_langs = array(); |
| 44 | $category = new ArticleCategory(); | 44 | $category = new ArticleCategory(); |
| 45 | + $default_lang = Language::getDefaultLang(); | ||
| 45 | $images = array(); | 46 | $images = array(); |
| 46 | - $images['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]); | ||
| 47 | - $images['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]); | ||
| 48 | - $images['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | 47 | + $images[$default_lang->language_id]['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]); |
| 48 | + $images[$default_lang->language_id]['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]); | ||
| 49 | + $images[0]['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | ||
| 49 | $category->loadDefaultValues(); | 50 | $category->loadDefaultValues(); |
| 50 | $langs = Language::getActiveLanguages(); | 51 | $langs = Language::getActiveLanguages(); |
| 51 | - $default_lang = Language::getDefaultLang(); | ||
| 52 | $isValid = false; | 52 | $isValid = false; |
| 53 | - foreach($images as $index => $value) { | ||
| 54 | - $images[$index]->type = $index; | ||
| 55 | - if($index == 'additional') { | ||
| 56 | - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile"); | ||
| 57 | - } else { | ||
| 58 | - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile"); | ||
| 59 | - } | ||
| 60 | - $isValid = $images[$index]->validate(['imageFile']) && $isValid; | ||
| 61 | - } | ||
| 62 | if(!empty(\Yii::$app->request->post())) { | 53 | if(!empty(\Yii::$app->request->post())) { |
| 63 | $isValid = true; | 54 | $isValid = true; |
| 64 | $category->load(\Yii::$app->request->post()); | 55 | $category->load(\Yii::$app->request->post()); |
| 65 | $isValid = $category->validate(); | 56 | $isValid = $category->validate(); |
| 57 | + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { | ||
| 58 | + foreach($value as $type => $fields) { | ||
| 59 | + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); | ||
| 60 | + $images[$lang][$type]->type = $type; | ||
| 61 | + $images[$lang][$type]->language_id = $lang; | ||
| 62 | + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | ||
| 63 | + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + $images[0]['additional']->language_id = 0; | ||
| 67 | + $images[0]['additional']->type = 'additional'; | ||
| 68 | + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); | ||
| 66 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { | 69 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { |
| 67 | $category_langs[$default_lang->language_id] = new ArticleCategoryLang(); | 70 | $category_langs[$default_lang->language_id] = new ArticleCategoryLang(); |
| 68 | $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; | 71 | $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; |
| @@ -79,13 +82,25 @@ class CategoryController extends Controller | @@ -79,13 +82,25 @@ class CategoryController extends Controller | ||
| 79 | if($isValid) { | 82 | if($isValid) { |
| 80 | $category->save(false); | 83 | $category->save(false); |
| 81 | $first = 1; | 84 | $first = 1; |
| 82 | - foreach($images as $index => $image) { | ||
| 83 | - $images[$index]->upload($category->id); | 85 | + foreach($images as $lang => $value) { |
| 86 | + foreach($value as $type => $fields) { | ||
| 87 | + $images[$lang][$type]->upload($category->article_category_id); | ||
| 88 | + if($first && $type != 'additional') { | ||
| 89 | + $media_clone = clone $images[$lang][$type]; | ||
| 90 | + $media_clone->setIsNewRecord(true); | ||
| 91 | + unset($media_clone->article_category_media_id); | ||
| 92 | + $media_clone->language_id = 0; | ||
| 93 | + $media_clone->upload($category->article_category_id); | ||
| 94 | + unset($media_clone); | ||
| 95 | + $first = 0; | ||
| 96 | + } | ||
| 97 | + } | ||
| 84 | } | 98 | } |
| 99 | + $first = 1; | ||
| 85 | foreach($category_langs as $category_lang) { | 100 | foreach($category_langs as $category_lang) { |
| 86 | if($first) { | 101 | if($first) { |
| 87 | $category_lang_clone = clone $category_lang; | 102 | $category_lang_clone = clone $category_lang; |
| 88 | - $category_lang_clone->lang_id = 0; | 103 | + $category_lang_clone->language_id = 0; |
| 89 | $category_lang_clone->link('category', $category); | 104 | $category_lang_clone->link('category', $category); |
| 90 | unset($category_lang_clone); | 105 | unset($category_lang_clone); |
| 91 | } | 106 | } |
| @@ -107,24 +122,24 @@ class CategoryController extends Controller | @@ -107,24 +122,24 @@ class CategoryController extends Controller | ||
| 107 | public function actionUpdate($id) | 122 | public function actionUpdate($id) |
| 108 | { | 123 | { |
| 109 | $category = ArticleCategory::findOne($id); | 124 | $category = ArticleCategory::findOne($id); |
| 110 | - $images = $category->getArticleCategoryMedia()->indexBy('type')->all(); | ||
| 111 | - if(!array_key_exists('full', $images)) { | ||
| 112 | - $images['full'] = new ArticleCategoryMedia(); | ||
| 113 | - } | ||
| 114 | - if(!array_key_exists('preview', $images)) { | ||
| 115 | - $images['preview'] = new ArticleCategoryMedia(); | ||
| 116 | - } | ||
| 117 | - foreach($images as $index => $image) { | ||
| 118 | - $images[$index]->scenario = $index; | 125 | + $imagestack = $category->getArticleCategoryMedia()->all(); |
| 126 | + $images = []; | ||
| 127 | + $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | ||
| 128 | + $images[0]['additional'][0]->type = 'additional'; | ||
| 129 | + $images[0]['additional'][0]->language_id = 0; | ||
| 130 | + foreach($imagestack as $image) { | ||
| 131 | + if(in_array($image->type, ['full', 'preview'])) { | ||
| 132 | + $images[$image->language_id][$image->type] = $image; | ||
| 133 | + $images[$image->language_id][$image->type]->scenario = $image->type; | ||
| 134 | + } else { | ||
| 135 | + $images[$image->language_id][$image->type][$image->article_category_media_id] = $image; | ||
| 136 | + $images[$image->language_id][$image->type][$image->article_category_media_id]->scenario = $image->type; | ||
| 137 | + } | ||
| 119 | } | 138 | } |
| 120 | - $images['additional'] = array( | ||
| 121 | - 0 => new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]) | ||
| 122 | - ); | ||
| 123 | - $images['additional'] = array_merge($images['additional'], $category->getArticleCategoryMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all()); | ||
| 124 | - foreach($images['additional'] as $index => $image) { | ||
| 125 | - $images['additional'][$index]->scenario = 'additional'; | 139 | + foreach($images as $lang => $value) { |
| 140 | + $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | ||
| 126 | } | 141 | } |
| 127 | - $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all(); | 142 | + $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all(); |
| 128 | $langs = Language::getActiveLanguages(); | 143 | $langs = Language::getActiveLanguages(); |
| 129 | $default_lang = Language::getDefaultLang(); | 144 | $default_lang = Language::getDefaultLang(); |
| 130 | $isValid = false; | 145 | $isValid = false; |
| @@ -132,15 +147,18 @@ class CategoryController extends Controller | @@ -132,15 +147,18 @@ class CategoryController extends Controller | ||
| 132 | $isValid = true; | 147 | $isValid = true; |
| 133 | $category->load(\Yii::$app->request->post()); | 148 | $category->load(\Yii::$app->request->post()); |
| 134 | $isValid = $category->validate(); | 149 | $isValid = $category->validate(); |
| 135 | - foreach($images as $index => $value) { | ||
| 136 | - if($index == 'additional') { | ||
| 137 | - $images[$index][0]->type = $index; | ||
| 138 | - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile"); | ||
| 139 | - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid; | ||
| 140 | - } else { | ||
| 141 | - $images[$index]->type = $index; | ||
| 142 | - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile"); | ||
| 143 | - $isValid = $images[$index]->validate(['imageFile']) && $isValid; | 150 | + $images[0]['additional'][0]->type = 'additional'; |
| 151 | + $images[0]['additional'][0]->language_id = 0; | ||
| 152 | + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); | ||
| 153 | + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; | ||
| 154 | + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { | ||
| 155 | + foreach($value as $type => $fields) { | ||
| 156 | + if(!in_array($type, ['full', 'preview'])) continue; | ||
| 157 | + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); | ||
| 158 | + $images[$lang][$type]->language_id = $lang; | ||
| 159 | + $images[$lang][$type]->type = $type; | ||
| 160 | + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | ||
| 161 | + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | ||
| 144 | } | 162 | } |
| 145 | } | 163 | } |
| 146 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { | 164 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { |
| @@ -149,7 +167,7 @@ class CategoryController extends Controller | @@ -149,7 +167,7 @@ class CategoryController extends Controller | ||
| 149 | foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { | 167 | foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { |
| 150 | if(!array_key_exists($index, $category_langs)) { | 168 | if(!array_key_exists($index, $category_langs)) { |
| 151 | $category_langs[$index] = new ArticleCategoryLang(); | 169 | $category_langs[$index] = new ArticleCategoryLang(); |
| 152 | - $category_langs[$index]->category_id = $category->id; | 170 | + $category_langs[$index]->article_category_id = $category->article_category_id; |
| 153 | } | 171 | } |
| 154 | } | 172 | } |
| 155 | ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); | 173 | ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); |
| @@ -158,12 +176,14 @@ class CategoryController extends Controller | @@ -158,12 +176,14 @@ class CategoryController extends Controller | ||
| 158 | } | 176 | } |
| 159 | if($isValid) { | 177 | if($isValid) { |
| 160 | $category->save(false); | 178 | $category->save(false); |
| 161 | - foreach($images as $index => $image) { | ||
| 162 | - if($index == 'additional') { | ||
| 163 | - $images[$index][0]->upload($category->id); | ||
| 164 | - } else { | ||
| 165 | - if(!empty($images[$index]->imageFile)) { | ||
| 166 | - $images[$index]->replace($category->id, true); | 179 | + foreach($images as $lang => $value) { |
| 180 | + foreach($value as $type => $fields) { | ||
| 181 | + if($type == 'additional') { | ||
| 182 | + $images[$lang][$type][0]->upload($category->article_category_id); | ||
| 183 | + } else { | ||
| 184 | + if(!empty($images[$lang][$type]->imageFile)) { | ||
| 185 | + $images[$lang][$type]->replace($category->article_category_id); | ||
| 186 | + } | ||
| 167 | } | 187 | } |
| 168 | } | 188 | } |
| 169 | } | 189 | } |
common/modules/blog/models/Article.php
| @@ -11,21 +11,21 @@ use yii\db\Query; | @@ -11,21 +11,21 @@ use yii\db\Query; | ||
| 11 | /** | 11 | /** |
| 12 | * This is the model class for table "article". | 12 | * This is the model class for table "article". |
| 13 | * | 13 | * |
| 14 | - * @property integer $id | 14 | + * @property integer $article_id |
| 15 | * @property integer $sort | 15 | * @property integer $sort |
| 16 | - * @property string $create_at | ||
| 17 | - * @property string $update_at | 16 | + * @property string $date_add |
| 17 | + * @property string $date_update | ||
| 18 | * @property string $code | 18 | * @property string $code |
| 19 | - * @property integer $author | ||
| 20 | - * @property string $tags | ||
| 21 | - * @property integer $parent_id | ||
| 22 | - * @property integer $active | ||
| 23 | - * @property integer $comments | ||
| 24 | - * @property integer $voting | 19 | + * @property integer $user_id |
| 20 | + * @property string $tag | ||
| 21 | + * @property integer $article_pid | ||
| 22 | + * @property integer $status | ||
| 23 | + * @property integer $comment | ||
| 24 | + * @property integer $vote | ||
| 25 | * | 25 | * |
| 26 | * @property Article $parent | 26 | * @property Article $parent |
| 27 | * @property Article[] $articles | 27 | * @property Article[] $articles |
| 28 | - * @property User $author0 | 28 | + * @property User $user |
| 29 | * @property ArticleLang[] $articleLangs | 29 | * @property ArticleLang[] $articleLangs |
| 30 | * @property ArticleMedia[] $articleMedia | 30 | * @property ArticleMedia[] $articleMedia |
| 31 | * @property ArticleToCategory[] $articleToCategories | 31 | * @property ArticleToCategory[] $articleToCategories |
| @@ -58,10 +58,10 @@ class Article extends \yii\db\ActiveRecord | @@ -58,10 +58,10 @@ class Article extends \yii\db\ActiveRecord | ||
| 58 | public function rules() | 58 | public function rules() |
| 59 | { | 59 | { |
| 60 | return [ | 60 | return [ |
| 61 | - [['sort', 'parent_id', 'active', 'comments', 'voting'], 'integer'], | ||
| 62 | - [['create_at', 'update_at'], 'safe'], | 61 | + [['sort', 'article_pid', 'status', 'comment', 'vote'], 'integer'], |
| 62 | + [['date_add', 'date_update'], 'safe'], | ||
| 63 | [['code'], 'required'], | 63 | [['code'], 'required'], |
| 64 | - [['code', 'tags'], 'string'] | 64 | + [['code', 'tag'], 'string'] |
| 65 | ]; | 65 | ]; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| @@ -71,17 +71,17 @@ class Article extends \yii\db\ActiveRecord | @@ -71,17 +71,17 @@ class Article extends \yii\db\ActiveRecord | ||
| 71 | public function attributeLabels() | 71 | public function attributeLabels() |
| 72 | { | 72 | { |
| 73 | return [ | 73 | return [ |
| 74 | - 'id' => Yii::t('app', 'ID'), | 74 | + 'article_id' => Yii::t('app', 'ID'), |
| 75 | 'sort' => Yii::t('app', 'Sort'), | 75 | 'sort' => Yii::t('app', 'Sort'), |
| 76 | - 'create_at' => Yii::t('app', 'Create At'), | ||
| 77 | - 'update_at' => Yii::t('app', 'Update At'), | 76 | + 'date_add' => Yii::t('app', 'Create At'), |
| 77 | + 'date_update' => Yii::t('app', 'Update At'), | ||
| 78 | 'code' => Yii::t('app', 'Code'), | 78 | 'code' => Yii::t('app', 'Code'), |
| 79 | - 'author' => Yii::t('app', 'Author'), | ||
| 80 | - 'tags' => Yii::t('app', 'Tags'), | ||
| 81 | - 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 82 | - 'active' => Yii::t('app', 'Active'), | ||
| 83 | - 'comments' => Yii::t('app', 'Comments'), | ||
| 84 | - 'voting' => Yii::t('app', 'Voting'), | 79 | + 'user_id' => Yii::t('app', 'Author'), |
| 80 | + 'tag' => Yii::t('app', 'Tags'), | ||
| 81 | + 'article_pid' => Yii::t('app', 'Parent ID'), | ||
| 82 | + 'status' => Yii::t('app', 'Active'), | ||
| 83 | + 'comment' => Yii::t('app', 'Comments'), | ||
| 84 | + 'vote' => Yii::t('app', 'Voting'), | ||
| 85 | ]; | 85 | ]; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -90,7 +90,7 @@ class Article extends \yii\db\ActiveRecord | @@ -90,7 +90,7 @@ class Article extends \yii\db\ActiveRecord | ||
| 90 | */ | 90 | */ |
| 91 | public function getParent() | 91 | public function getParent() |
| 92 | { | 92 | { |
| 93 | - return $this->hasOne(Article::className(), ['id' => 'parent_id']); | 93 | + return $this->hasOne(Article::className(), ['article_id' => 'article_pid']); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /** | 96 | /** |
| @@ -98,15 +98,15 @@ class Article extends \yii\db\ActiveRecord | @@ -98,15 +98,15 @@ class Article extends \yii\db\ActiveRecord | ||
| 98 | */ | 98 | */ |
| 99 | public function getArticles() | 99 | public function getArticles() |
| 100 | { | 100 | { |
| 101 | - return $this->hasMany(Article::className(), ['parent_id' => 'id']); | 101 | + return $this->hasMany(Article::className(), ['article_pid' => 'article_id']); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | /** | 104 | /** |
| 105 | * @return \yii\db\ActiveQuery | 105 | * @return \yii\db\ActiveQuery |
| 106 | */ | 106 | */ |
| 107 | - public function getAuthor0() | 107 | + public function getUser() |
| 108 | { | 108 | { |
| 109 | - return $this->hasOne(User::className(), ['id' => 'author']); | 109 | + return $this->hasOne(User::className(), ['id' => 'user_id']); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | /** | 112 | /** |
| @@ -114,7 +114,7 @@ class Article extends \yii\db\ActiveRecord | @@ -114,7 +114,7 @@ class Article extends \yii\db\ActiveRecord | ||
| 114 | */ | 114 | */ |
| 115 | public function getArticleLangs() | 115 | public function getArticleLangs() |
| 116 | { | 116 | { |
| 117 | - return $this->hasMany(ArticleLang::className(), ['article_id' => 'id']); | 117 | + return $this->hasMany(ArticleLang::className(), ['article_id' => 'article_id']); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | /** | 120 | /** |
| @@ -122,40 +122,40 @@ class Article extends \yii\db\ActiveRecord | @@ -122,40 +122,40 @@ class Article extends \yii\db\ActiveRecord | ||
| 122 | */ | 122 | */ |
| 123 | public function getArticleMedia() | 123 | public function getArticleMedia() |
| 124 | { | 124 | { |
| 125 | - return $this->hasMany(ArticleMedia::className(), ['article_id' => 'id']); | 125 | + return $this->hasMany(ArticleMedia::className(), ['article_id' => 'article_id']); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | public function getMedia() | 128 | public function getMedia() |
| 129 | { | 129 | { |
| 130 | - return $this->hasMany(Media::className(), ['id' => 'media_id'])->via('articleMedia'); | 130 | + return $this->hasMany(Media::className(), ['article_id' => 'media_id'])->via('articleMedia'); |
| 131 | } | 131 | } |
| 132 | /** | 132 | /** |
| 133 | * @return \yii\db\ActiveQuery | 133 | * @return \yii\db\ActiveQuery |
| 134 | */ | 134 | */ |
| 135 | public function getArticleToCategories() | 135 | public function getArticleToCategories() |
| 136 | { | 136 | { |
| 137 | - return $this->hasMany(ArticleToCategory::className(), ['article_id' => 'id']); | 137 | + return $this->hasMany(ArticleToCategory::className(), ['article_id' => 'article_id']); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | public function getArticleCategories() | 140 | public function getArticleCategories() |
| 141 | { | 141 | { |
| 142 | - return $this->hasMany(ArticleCategory::className(), ['id' => 'category_id'])->viaTable('article_to_category', ['article_id' => 'id']); | 142 | + return $this->hasMany(ArticleCategory::className(), ['article_category_id' => 'article_category_id'])->viaTable('article_to_category', ['article_id' => 'article_category_id']); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | public static function findArticleDropdown($id) | 145 | public static function findArticleDropdown($id) |
| 146 | { | 146 | { |
| 147 | $query = new Query(); | 147 | $query = new Query(); |
| 148 | - return $query->select(['l.name', 'a.id']) | 148 | + return $query->select(['l.name', 'a.article_id']) |
| 149 | ->from(['article a']) | 149 | ->from(['article a']) |
| 150 | - ->leftJoin(['article_lang l'], 'a.id = l.article_id') | ||
| 151 | - ->where(['l.lang_id' => 0, 'a.active' => 1]) | ||
| 152 | - ->andWhere(['not', ['a.id' => $id]]) | ||
| 153 | - ->indexBy('a.id') | 150 | + ->leftJoin(['article_lang l'], 'a.article_id = l.article_id') |
| 151 | + ->where(['l.language_id' => 0, 'a.status' => 1]) | ||
| 152 | + ->andWhere(['not', ['a.article_id' => $id]]) | ||
| 153 | + ->indexBy('article_id') | ||
| 154 | ->column(); | 154 | ->column(); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | public function getArticleCategoriesArray() | 157 | public function getArticleCategoriesArray() |
| 158 | { | 158 | { |
| 159 | - return $this->getArticleToCategories()->select('category_id')->column(); | 159 | + return $this->getArticleToCategories()->select('article_category_id')->column(); |
| 160 | } | 160 | } |
| 161 | } | 161 | } |
common/modules/blog/models/ArticleCategory.php
| @@ -11,14 +11,14 @@ use yii\db\Query; | @@ -11,14 +11,14 @@ use yii\db\Query; | ||
| 11 | /** | 11 | /** |
| 12 | * This is the model class for table "article_category". | 12 | * This is the model class for table "article_category". |
| 13 | * | 13 | * |
| 14 | - * @property integer $id | ||
| 15 | - * @property integer $active | 14 | + * @property integer $article_category_id |
| 15 | + * @property integer $status | ||
| 16 | * @property integer $sort | 16 | * @property integer $sort |
| 17 | * @property string $code | 17 | * @property string $code |
| 18 | - * @property string $created_at | ||
| 19 | - * @property string $updated_at | ||
| 20 | - * @property string $tags | ||
| 21 | - * @property integer $parent_id | 18 | + * @property string $date_add |
| 19 | + * @property string $date_update | ||
| 20 | + * @property string $tag | ||
| 21 | + * @property integer $artucle_category_pid | ||
| 22 | * | 22 | * |
| 23 | * @property Article[] $articles | 23 | * @property Article[] $articles |
| 24 | * @property ArticleCategory $parent | 24 | * @property ArticleCategory $parent |
| @@ -53,11 +53,11 @@ class ArticleCategory extends ActiveRecord | @@ -53,11 +53,11 @@ class ArticleCategory extends ActiveRecord | ||
| 53 | public function rules() | 53 | public function rules() |
| 54 | { | 54 | { |
| 55 | return [ | 55 | return [ |
| 56 | - [['active', 'sort', 'parent_id'], 'integer'], | 56 | + [['status', 'sort', 'article_category_pid'], 'integer'], |
| 57 | [['code'], 'required'], | 57 | [['code'], 'required'], |
| 58 | - [['code', 'tags'], 'string'], | ||
| 59 | - [['created_at', 'updated_at'], 'safe'], | ||
| 60 | - [['active'], 'boolean'], | 58 | + [['code', 'tag'], 'string'], |
| 59 | + [['date_add', 'date_update'], 'safe'], | ||
| 60 | + [['status'], 'boolean'], | ||
| 61 | ]; | 61 | ]; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| @@ -67,14 +67,14 @@ class ArticleCategory extends ActiveRecord | @@ -67,14 +67,14 @@ class ArticleCategory extends ActiveRecord | ||
| 67 | public function attributeLabels() | 67 | public function attributeLabels() |
| 68 | { | 68 | { |
| 69 | return [ | 69 | return [ |
| 70 | - 'id' => Yii::t('app', 'ID'), | ||
| 71 | - 'active' => Yii::t('app', 'Active'), | 70 | + 'article_category_id' => Yii::t('app', 'ID'), |
| 71 | + 'status' => Yii::t('app', 'Active'), | ||
| 72 | 'sort' => Yii::t('app', 'Sort'), | 72 | 'sort' => Yii::t('app', 'Sort'), |
| 73 | 'code' => Yii::t('app', 'Code'), | 73 | 'code' => Yii::t('app', 'Code'), |
| 74 | - 'created_at' => Yii::t('app', 'Created At'), | ||
| 75 | - 'updated_at' => Yii::t('app', 'Updated At'), | ||
| 76 | - 'tags' => Yii::t('app', 'Tags'), | ||
| 77 | - 'parent_id' => Yii::t('app', 'Parent ID'), | 74 | + 'date_add' => Yii::t('app', 'Created At'), |
| 75 | + 'date_update' => Yii::t('app', 'Updated At'), | ||
| 76 | + 'tag' => Yii::t('app', 'Tags'), | ||
| 77 | + 'article_category_pid' => Yii::t('app', 'Parent ID'), | ||
| 78 | ]; | 78 | ]; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| @@ -83,7 +83,7 @@ class ArticleCategory extends ActiveRecord | @@ -83,7 +83,7 @@ class ArticleCategory extends ActiveRecord | ||
| 83 | */ | 83 | */ |
| 84 | public function getArticles() | 84 | public function getArticles() |
| 85 | { | 85 | { |
| 86 | - return $this->hasMany(Article::className(), ['category_id' => 'id']); | 86 | + return $this->hasMany(Article::className(), ['article_id' => 'article_id'])->viaTable('article_to_category', ['article_category_id' => 'article_category_id']) ; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /** | 89 | /** |
| @@ -91,7 +91,7 @@ class ArticleCategory extends ActiveRecord | @@ -91,7 +91,7 @@ class ArticleCategory extends ActiveRecord | ||
| 91 | */ | 91 | */ |
| 92 | public function getParent() | 92 | public function getParent() |
| 93 | { | 93 | { |
| 94 | - return $this->hasOne(ArticleCategory::className(), ['id' => 'parent_id']); | 94 | + return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_pid']); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| @@ -99,7 +99,7 @@ class ArticleCategory extends ActiveRecord | @@ -99,7 +99,7 @@ class ArticleCategory extends ActiveRecord | ||
| 99 | */ | 99 | */ |
| 100 | public function getArticleCategories() | 100 | public function getArticleCategories() |
| 101 | { | 101 | { |
| 102 | - return $this->hasMany(ArticleCategory::className(), ['parent_id' => 'id']); | 102 | + return $this->hasMany(ArticleCategory::className(), ['article_category_pid' => 'article_category_id']); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| @@ -107,7 +107,7 @@ class ArticleCategory extends ActiveRecord | @@ -107,7 +107,7 @@ class ArticleCategory extends ActiveRecord | ||
| 107 | */ | 107 | */ |
| 108 | public function getArticleCategoryLangs() | 108 | public function getArticleCategoryLangs() |
| 109 | { | 109 | { |
| 110 | - return $this->hasMany(ArticleCategoryLang::className(), ['category_id' => 'id']); | 110 | + return $this->hasMany(ArticleCategoryLang::className(), ['article_category_id' => 'article_category_id']); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | /** | 113 | /** |
| @@ -115,18 +115,18 @@ class ArticleCategory extends ActiveRecord | @@ -115,18 +115,18 @@ class ArticleCategory extends ActiveRecord | ||
| 115 | */ | 115 | */ |
| 116 | public function getArticleCategoryMedia() | 116 | public function getArticleCategoryMedia() |
| 117 | { | 117 | { |
| 118 | - return $this->hasMany(ArticleCategoryMedia::className(), ['category_id' => 'id']); | 118 | + return $this->hasMany(ArticleCategoryMedia::className(), ['article_category_id' => 'article_category_id']); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | public static function findArticleCategoryDropdown($id) | 121 | public static function findArticleCategoryDropdown($id) |
| 122 | { | 122 | { |
| 123 | $query = new Query(); | 123 | $query = new Query(); |
| 124 | - return $query->select(['l.name', 'c.id']) | 124 | + return $query->select(['l.name', 'c.article_category_id']) |
| 125 | ->from(['article_category c']) | 125 | ->from(['article_category c']) |
| 126 | - ->leftJoin(['article_category_lang l'], 'c.id = l.category_id') | ||
| 127 | - ->where(['l.lang_id' => 0, 'c.active' => 1]) | ||
| 128 | - ->andWhere(['not', ['c.id' => $id]]) | ||
| 129 | - ->indexBy('id') | 126 | + ->leftJoin(['article_category_lang l'], 'c.article_category_id = l.article_category_id') |
| 127 | + ->where(['l.language_id' => 0, 'c.status' => 1]) | ||
| 128 | + ->andWhere(['not', ['c.article_category_id' => $id]]) | ||
| 129 | + ->indexBy('article_category_id') | ||
| 130 | ->column(); | 130 | ->column(); |
| 131 | } | 131 | } |
| 132 | 132 |
common/modules/blog/models/ArticleCategoryLang.php
| @@ -8,18 +8,18 @@ use Yii; | @@ -8,18 +8,18 @@ use Yii; | ||
| 8 | /** | 8 | /** |
| 9 | * This is the model class for table "article_category_lang". | 9 | * This is the model class for table "article_category_lang". |
| 10 | * | 10 | * |
| 11 | - * @property integer $id | ||
| 12 | - * @property integer $lang_id | ||
| 13 | - * @property integer $category_id | 11 | + * @property integer $article_category_language_id |
| 12 | + * @property integer $language_id | ||
| 13 | + * @property integer $article_category_id | ||
| 14 | * @property string $text | 14 | * @property string $text |
| 15 | * @property string $preview | 15 | * @property string $preview |
| 16 | * @property string $seo_url | 16 | * @property string $seo_url |
| 17 | * @property string $name | 17 | * @property string $name |
| 18 | * @property string $meta_title | 18 | * @property string $meta_title |
| 19 | * @property string $meta_descr | 19 | * @property string $meta_descr |
| 20 | - * @property string $meta_keywords | 20 | + * @property string $meta_keyword |
| 21 | * @property string $h1_tag | 21 | * @property string $h1_tag |
| 22 | - * @property string $tags | 22 | + * @property string $tag |
| 23 | * | 23 | * |
| 24 | * @property ArticleCategory $category | 24 | * @property ArticleCategory $category |
| 25 | * @property Language $lang | 25 | * @property Language $lang |
| @@ -51,9 +51,9 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | @@ -51,9 +51,9 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | ||
| 51 | public function rules() | 51 | public function rules() |
| 52 | { | 52 | { |
| 53 | return [ | 53 | return [ |
| 54 | - [['lang_id', 'category_id'], 'integer'], | 54 | + [['language_id', 'article_category_id'], 'integer'], |
| 55 | [['text', 'name'], 'required'], | 55 | [['text', 'name'], 'required'], |
| 56 | - [['text', 'preview', 'seo_url', 'name', 'meta_title', 'meta_descr', 'meta_keywords', 'h1_tag', 'tags'], 'string'], | 56 | + [['text', 'preview', 'seo_url', 'name', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string'], |
| 57 | ['seo_url', function($attribute, $params) { | 57 | ['seo_url', function($attribute, $params) { |
| 58 | $pattern = "/^[a-zA-Z\d_-]+$/"; | 58 | $pattern = "/^[a-zA-Z\d_-]+$/"; |
| 59 | if(!preg_match($pattern, $this->$attribute)) { | 59 | if(!preg_match($pattern, $this->$attribute)) { |
| @@ -69,18 +69,18 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | @@ -69,18 +69,18 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | ||
| 69 | public function attributeLabels() | 69 | public function attributeLabels() |
| 70 | { | 70 | { |
| 71 | return [ | 71 | return [ |
| 72 | - 'id' => Yii::t('app', 'ID'), | ||
| 73 | - 'lang_id' => Yii::t('app', 'Lang ID'), | ||
| 74 | - 'category_id' => Yii::t('app', 'Category ID'), | 72 | + 'article_category_language_id' => Yii::t('app', 'ID'), |
| 73 | + 'language_id' => Yii::t('app', 'Lang ID'), | ||
| 74 | + 'article_category_id' => Yii::t('app', 'Category ID'), | ||
| 75 | 'text' => Yii::t('app', 'Text'), | 75 | 'text' => Yii::t('app', 'Text'), |
| 76 | 'preview' => Yii::t('app', 'Preview'), | 76 | 'preview' => Yii::t('app', 'Preview'), |
| 77 | 'seo_url' => Yii::t('app', 'Seo Url'), | 77 | 'seo_url' => Yii::t('app', 'Seo Url'), |
| 78 | 'name' => Yii::t('app', 'Name'), | 78 | 'name' => Yii::t('app', 'Name'), |
| 79 | 'meta_title' => Yii::t('app', 'Meta Title'), | 79 | 'meta_title' => Yii::t('app', 'Meta Title'), |
| 80 | 'meta_descr' => Yii::t('app', 'Meta Descr'), | 80 | 'meta_descr' => Yii::t('app', 'Meta Descr'), |
| 81 | - 'meta_keywords' => Yii::t('app', 'Meta Keywords'), | 81 | + 'meta_keyword' => Yii::t('app', 'Meta Keywords'), |
| 82 | 'h1_tag' => Yii::t('app', 'H1 Tag'), | 82 | 'h1_tag' => Yii::t('app', 'H1 Tag'), |
| 83 | - 'tags' => Yii::t('app', 'Tags'), | 83 | + 'tag' => Yii::t('app', 'Tags'), |
| 84 | ]; | 84 | ]; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -89,7 +89,7 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | @@ -89,7 +89,7 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | ||
| 89 | */ | 89 | */ |
| 90 | public function getCategory() | 90 | public function getCategory() |
| 91 | { | 91 | { |
| 92 | - return $this->hasOne(ArticleCategory::className(), ['id' => 'category_id']); | 92 | + return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /** | 95 | /** |
| @@ -97,6 +97,6 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | @@ -97,6 +97,6 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord | ||
| 97 | */ | 97 | */ |
| 98 | public function getLang() | 98 | public function getLang() |
| 99 | { | 99 | { |
| 100 | - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | 100 | + return $this->hasOne(Language::className(), ['language_id' => 'language_id']); |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
common/modules/blog/models/ArticleCategoryMedia.php
| @@ -8,16 +8,18 @@ use Yii; | @@ -8,16 +8,18 @@ use Yii; | ||
| 8 | /** | 8 | /** |
| 9 | * This is the model class for table "article_category_media". | 9 | * This is the model class for table "article_category_media". |
| 10 | * | 10 | * |
| 11 | - * @property integer $id | ||
| 12 | - * @property integer $category_id | 11 | + * @property integer $article_category_media_id |
| 12 | + * @property integer $article_category_id | ||
| 13 | * @property integer $media_id | 13 | * @property integer $media_id |
| 14 | * @property string $media_alt | 14 | * @property string $media_alt |
| 15 | * @property string $media_title | 15 | * @property string $media_title |
| 16 | * @property string $media_caption | 16 | * @property string $media_caption |
| 17 | * @property string $type | 17 | * @property string $type |
| 18 | + * @property string $language_id | ||
| 18 | * | 19 | * |
| 19 | * @property ArticleCategory $category | 20 | * @property ArticleCategory $category |
| 20 | * @property Media $media | 21 | * @property Media $media |
| 22 | + * @property Language $lang | ||
| 21 | */ | 23 | */ |
| 22 | class ArticleCategoryMedia extends \yii\db\ActiveRecord | 24 | class ArticleCategoryMedia extends \yii\db\ActiveRecord |
| 23 | { | 25 | { |
| @@ -36,9 +38,9 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -36,9 +38,9 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 36 | public function scenarios() | 38 | public function scenarios() |
| 37 | { | 39 | { |
| 38 | $scenarios = parent::scenarios(); | 40 | $scenarios = parent::scenarios(); |
| 39 | - $scenarios[self::SCENARIO_FULL] = ['id', 'category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; | ||
| 40 | - $scenarios[self::SCENARIO_PREVIEW] = ['id', 'category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; | ||
| 41 | - $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'category_id', 'media_id', 'type', 'imageFile']; | 41 | + $scenarios[self::SCENARIO_FULL] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; |
| 42 | + $scenarios[self::SCENARIO_PREVIEW] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; | ||
| 43 | + $scenarios[self::SCENARIO_ADDITIONAL] = ['article_category_media_id', 'article_category_id', 'media_id', 'type', 'imageFile']; | ||
| 42 | return $scenarios; | 44 | return $scenarios; |
| 43 | } | 45 | } |
| 44 | 46 | ||
| @@ -48,8 +50,8 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -48,8 +50,8 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 48 | public function rules() | 50 | public function rules() |
| 49 | { | 51 | { |
| 50 | return [ | 52 | return [ |
| 51 | - [['category_id', 'media_id'], 'required'], | ||
| 52 | - [['category_id', 'media_id'], 'integer'], | 53 | + [['article_category_id', 'media_id'], 'required'], |
| 54 | + [['article_category_id', 'media_id'], 'integer'], | ||
| 53 | [['media_alt', 'media_title', 'media_caption'], 'string'], | 55 | [['media_alt', 'media_title', 'media_caption'], 'string'], |
| 54 | [['type'], 'string', 'max' => 10], | 56 | [['type'], 'string', 'max' => 10], |
| 55 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], | 57 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], |
| @@ -64,14 +66,15 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -64,14 +66,15 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 64 | public function attributeLabels() | 66 | public function attributeLabels() |
| 65 | { | 67 | { |
| 66 | return [ | 68 | return [ |
| 67 | - 'id' => Yii::t('app', 'ID'), | ||
| 68 | - 'category_id' => Yii::t('app', 'Category ID'), | 69 | + 'article_category_media_id' => Yii::t('app', 'ID'), |
| 70 | + 'article_category_id' => Yii::t('app', 'Category ID'), | ||
| 69 | 'media_id' => Yii::t('app', 'Media ID'), | 71 | 'media_id' => Yii::t('app', 'Media ID'), |
| 70 | 'media_alt' => Yii::t('app', 'Media Alt'), | 72 | 'media_alt' => Yii::t('app', 'Media Alt'), |
| 71 | 'media_title' => Yii::t('app', 'Media Title'), | 73 | 'media_title' => Yii::t('app', 'Media Title'), |
| 72 | 'media_caption' => Yii::t('app', 'Media Caption'), | 74 | 'media_caption' => Yii::t('app', 'Media Caption'), |
| 73 | 'type' => Yii::t('app', 'Type'), | 75 | 'type' => Yii::t('app', 'Type'), |
| 74 | 'imageFile' => Yii::t('app', 'Image File'), | 76 | 'imageFile' => Yii::t('app', 'Image File'), |
| 77 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
| 75 | ]; | 78 | ]; |
| 76 | } | 79 | } |
| 77 | 80 | ||
| @@ -80,7 +83,7 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -80,7 +83,7 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 80 | */ | 83 | */ |
| 81 | public function getCategory() | 84 | public function getCategory() |
| 82 | { | 85 | { |
| 83 | - return $this->hasOne(ArticleCategory::className(), ['id' => 'category_id']); | 86 | + return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); |
| 84 | } | 87 | } |
| 85 | 88 | ||
| 86 | /** | 89 | /** |
| @@ -88,12 +91,12 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -88,12 +91,12 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 88 | */ | 91 | */ |
| 89 | public function getMedia() | 92 | public function getMedia() |
| 90 | { | 93 | { |
| 91 | - return $this->hasOne(Media::className(), ['id' => 'media_id']); | 94 | + return $this->hasOne(Media::className(), ['media_id' => 'media_id']); |
| 92 | } | 95 | } |
| 93 | 96 | ||
| 94 | public function upload($category_id) | 97 | public function upload($category_id) |
| 95 | { | 98 | { |
| 96 | - $this->category_id = $category_id; | 99 | + $this->article_category_id = $category_id; |
| 97 | if(is_array($this->imageFile)) { | 100 | if(is_array($this->imageFile)) { |
| 98 | $ok = true; | 101 | $ok = true; |
| 99 | foreach($this->imageFile as $image) { | 102 | foreach($this->imageFile as $image) { |
| @@ -101,7 +104,7 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -101,7 +104,7 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 101 | $media = new Media(); | 104 | $media = new Media(); |
| 102 | $media->imageFile = $image; | 105 | $media->imageFile = $image; |
| 103 | $media->upload(); | 106 | $media->upload(); |
| 104 | - $media_category->media_id = $media->id; | 107 | + $media_category->media_id = $media->media_id; |
| 105 | $ok = $media_category->save() && $ok; | 108 | $ok = $media_category->save() && $ok; |
| 106 | unset($media_category); | 109 | unset($media_category); |
| 107 | } | 110 | } |
| @@ -110,19 +113,19 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -110,19 +113,19 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 110 | $media = new Media(); | 113 | $media = new Media(); |
| 111 | $media->imageFile = $this->imageFile; | 114 | $media->imageFile = $this->imageFile; |
| 112 | $media->upload(); | 115 | $media->upload(); |
| 113 | - $this->media_id = $media->id; | 116 | + $this->media_id = $media->media_id; |
| 114 | return $this->save(); | 117 | return $this->save(); |
| 115 | } | 118 | } |
| 116 | } | 119 | } |
| 117 | 120 | ||
| 118 | public function replace($category_id, $removeMedia = false) | 121 | public function replace($category_id, $removeMedia = false) |
| 119 | { | 122 | { |
| 120 | - $this->category_id = $category_id; | 123 | + $this->article_category_id = $category_id; |
| 121 | if($removeMedia) { | 124 | if($removeMedia) { |
| 122 | - $category_media = ArticleCategoryMedia::find()->select('media_id')->where(['category_id' => $this->category_id, 'type' => $this->type])->column(); | 125 | + $category_media = ArticleCategoryMedia::find()->select('media_id')->where(['article_category_id' => $this->article_category_id, 'type' => $this->type])->column(); |
| 123 | $media = array(); | 126 | $media = array(); |
| 124 | foreach($category_media as $media_id) { | 127 | foreach($category_media as $media_id) { |
| 125 | - $media[] = Media::findOne(['id' => $media_id]); | 128 | + $media[] = Media::findOne(['media_id' => $media_id]); |
| 126 | } | 129 | } |
| 127 | $media = array_unique($media); | 130 | $media = array_unique($media); |
| 128 | foreach($media as $one_media) { | 131 | foreach($media as $one_media) { |
| @@ -140,17 +143,17 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | @@ -140,17 +143,17 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord | ||
| 140 | $media = new Media(); | 143 | $media = new Media(); |
| 141 | $media->imageFile = $image; | 144 | $media->imageFile = $image; |
| 142 | $media->upload(); | 145 | $media->upload(); |
| 143 | - $media_category->media_id = $media->id; | 146 | + $media_category->media_id = $media->media_id; |
| 144 | $ok = $media_category->save() && $ok; | 147 | $ok = $media_category->save() && $ok; |
| 145 | unset($media_category); | 148 | unset($media_category); |
| 146 | } | 149 | } |
| 147 | return $ok; | 150 | return $ok; |
| 148 | } elseif(!empty($this->imageFile)) { | 151 | } elseif(!empty($this->imageFile)) { |
| 149 | - ArticleCategoryMedia::deleteAll(['category_id' => $this->category_id, 'type' => $this->type]); | 152 | + ArticleCategoryMedia::deleteAll(['category_id' => $this->article_category_id, 'type' => $this->type]); |
| 150 | $media = new Media(); | 153 | $media = new Media(); |
| 151 | $media->imageFile = $this->imageFile; | 154 | $media->imageFile = $this->imageFile; |
| 152 | $media->upload(); | 155 | $media->upload(); |
| 153 | - $this->media_id = $media->id; | 156 | + $this->media_id = $media->media_id; |
| 154 | $this->setIsNewRecord(true); | 157 | $this->setIsNewRecord(true); |
| 155 | return $this->save(); | 158 | return $this->save(); |
| 156 | } | 159 | } |
common/modules/blog/models/ArticleLang.php
| @@ -8,8 +8,8 @@ use common\models\Language; | @@ -8,8 +8,8 @@ use common\models\Language; | ||
| 8 | /** | 8 | /** |
| 9 | * This is the model class for table "article_lang". | 9 | * This is the model class for table "article_lang". |
| 10 | * | 10 | * |
| 11 | - * @property integer $id | ||
| 12 | - * @property integer $lang_id | 11 | + * @property integer $article_language_id |
| 12 | + * @property integer $language_id | ||
| 13 | * @property integer $article_id | 13 | * @property integer $article_id |
| 14 | * @property string $text | 14 | * @property string $text |
| 15 | * @property string $seo_url | 15 | * @property string $seo_url |
| @@ -17,9 +17,9 @@ use common\models\Language; | @@ -17,9 +17,9 @@ use common\models\Language; | ||
| 17 | * @property string $preview | 17 | * @property string $preview |
| 18 | * @property string $meta_title | 18 | * @property string $meta_title |
| 19 | * @property string $meta_descr | 19 | * @property string $meta_descr |
| 20 | - * @property string $meta_keywords | 20 | + * @property string $meta_keyword |
| 21 | * @property string $h1_tag | 21 | * @property string $h1_tag |
| 22 | - * @property string $tags | 22 | + * @property string $tag |
| 23 | * | 23 | * |
| 24 | * @property Article $article | 24 | * @property Article $article |
| 25 | * @property Language $lang | 25 | * @property Language $lang |
| @@ -40,9 +40,9 @@ class ArticleLang extends \yii\db\ActiveRecord | @@ -40,9 +40,9 @@ class ArticleLang extends \yii\db\ActiveRecord | ||
| 40 | public function rules() | 40 | public function rules() |
| 41 | { | 41 | { |
| 42 | return [ | 42 | return [ |
| 43 | - [['lang_id', 'text', 'name'], 'required'], | ||
| 44 | - [['lang_id', 'article_id'], 'integer'], | ||
| 45 | - [['text', 'seo_url', 'name', 'preview', 'meta_title', 'meta_descr', 'meta_keywords', 'h1_tag', 'tags'], 'string'] | 43 | + [['language_id', 'text', 'name'], 'required'], |
| 44 | + [['language_id', 'article_id'], 'integer'], | ||
| 45 | + [['text', 'seo_url', 'name', 'preview', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string'] | ||
| 46 | ]; | 46 | ]; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| @@ -52,8 +52,8 @@ class ArticleLang extends \yii\db\ActiveRecord | @@ -52,8 +52,8 @@ class ArticleLang extends \yii\db\ActiveRecord | ||
| 52 | public function attributeLabels() | 52 | public function attributeLabels() |
| 53 | { | 53 | { |
| 54 | return [ | 54 | return [ |
| 55 | - 'id' => Yii::t('app', 'ID'), | ||
| 56 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 55 | + 'article_language_id' => Yii::t('app', 'ID'), |
| 56 | + 'language_id' => Yii::t('app', 'Lang ID'), | ||
| 57 | 'article_id' => Yii::t('app', 'Article ID'), | 57 | 'article_id' => Yii::t('app', 'Article ID'), |
| 58 | 'text' => Yii::t('app', 'Text'), | 58 | 'text' => Yii::t('app', 'Text'), |
| 59 | 'seo_url' => Yii::t('app', 'Seo Url'), | 59 | 'seo_url' => Yii::t('app', 'Seo Url'), |
| @@ -61,9 +61,9 @@ class ArticleLang extends \yii\db\ActiveRecord | @@ -61,9 +61,9 @@ class ArticleLang extends \yii\db\ActiveRecord | ||
| 61 | 'preview' => Yii::t('app', 'Preview'), | 61 | 'preview' => Yii::t('app', 'Preview'), |
| 62 | 'meta_title' => Yii::t('app', 'Meta Title'), | 62 | 'meta_title' => Yii::t('app', 'Meta Title'), |
| 63 | 'meta_descr' => Yii::t('app', 'Meta Descr'), | 63 | 'meta_descr' => Yii::t('app', 'Meta Descr'), |
| 64 | - 'meta_keywords' => Yii::t('app', 'Meta Keywords'), | 64 | + 'meta_keyword' => Yii::t('app', 'Meta Keywords'), |
| 65 | 'h1_tag' => Yii::t('app', 'H1 Tag'), | 65 | 'h1_tag' => Yii::t('app', 'H1 Tag'), |
| 66 | - 'tags' => Yii::t('app', 'Tags'), | 66 | + 'tag' => Yii::t('app', 'Tags'), |
| 67 | ]; | 67 | ]; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -72,7 +72,7 @@ class ArticleLang extends \yii\db\ActiveRecord | @@ -72,7 +72,7 @@ class ArticleLang extends \yii\db\ActiveRecord | ||
| 72 | */ | 72 | */ |
| 73 | public function getArticle() | 73 | public function getArticle() |
| 74 | { | 74 | { |
| 75 | - return $this->hasOne(Article::className(), ['id' => 'article_id']); | 75 | + return $this->hasOne(Article::className(), ['article_id' => 'article_id']); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| @@ -80,6 +80,6 @@ class ArticleLang extends \yii\db\ActiveRecord | @@ -80,6 +80,6 @@ class ArticleLang extends \yii\db\ActiveRecord | ||
| 80 | */ | 80 | */ |
| 81 | public function getLang() | 81 | public function getLang() |
| 82 | { | 82 | { |
| 83 | - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); | 83 | + return $this->hasOne(Language::className(), ['language_id' => 'language_id']); |
| 84 | } | 84 | } |
| 85 | } | 85 | } |
common/modules/blog/models/ArticleMedia.php
| @@ -9,13 +9,14 @@ use yii\web\UploadedFile; | @@ -9,13 +9,14 @@ use yii\web\UploadedFile; | ||
| 9 | /** | 9 | /** |
| 10 | * This is the model class for table "article_media". | 10 | * This is the model class for table "article_media". |
| 11 | * | 11 | * |
| 12 | - * @property integer $id | 12 | + * @property integer $article_media_id |
| 13 | * @property integer $article_id | 13 | * @property integer $article_id |
| 14 | * @property integer $media_id | 14 | * @property integer $media_id |
| 15 | * @property string $type | 15 | * @property string $type |
| 16 | * @property string $media_alt | 16 | * @property string $media_alt |
| 17 | * @property string $media_title | 17 | * @property string $media_title |
| 18 | * @property string $media_caption | 18 | * @property string $media_caption |
| 19 | + * @property integer $language_id | ||
| 19 | * | 20 | * |
| 20 | * @property Article $article | 21 | * @property Article $article |
| 21 | * @property Media $media | 22 | * @property Media $media |
| @@ -37,9 +38,9 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -37,9 +38,9 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 37 | public function scenarios() | 38 | public function scenarios() |
| 38 | { | 39 | { |
| 39 | $scenarios = parent::scenarios(); | 40 | $scenarios = parent::scenarios(); |
| 40 | - $scenarios[self::SCENARIO_FULL] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; | ||
| 41 | - $scenarios[self::SCENARIO_PREVIEW] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile']; | ||
| 42 | - $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'article_id', 'media_id', 'type', 'imageFile']; | 41 | + $scenarios[self::SCENARIO_FULL] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id']; |
| 42 | + $scenarios[self::SCENARIO_PREVIEW] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id']; | ||
| 43 | + $scenarios[self::SCENARIO_ADDITIONAL] = ['article_media_id', 'article_id', 'media_id', 'type', 'imageFile', 'language_id']; | ||
| 43 | return $scenarios; | 44 | return $scenarios; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| @@ -50,7 +51,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -50,7 +51,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 50 | { | 51 | { |
| 51 | return [ | 52 | return [ |
| 52 | [['article_id', 'media_id'], 'required'], | 53 | [['article_id', 'media_id'], 'required'], |
| 53 | - [['article_id', 'media_id'], 'integer'], | 54 | + [['article_id', 'media_id', 'language_id'], 'integer'], |
| 54 | [['media_alt', 'media_title', 'media_caption'], 'string'], | 55 | [['media_alt', 'media_title', 'media_caption'], 'string'], |
| 55 | [['type'], 'string', 'max' => 10], | 56 | [['type'], 'string', 'max' => 10], |
| 56 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], | 57 | [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], |
| @@ -65,7 +66,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -65,7 +66,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 65 | public function attributeLabels() | 66 | public function attributeLabels() |
| 66 | { | 67 | { |
| 67 | return [ | 68 | return [ |
| 68 | - 'id' => Yii::t('app', 'ID'), | 69 | + 'article_media_id' => Yii::t('app', 'ID'), |
| 69 | 'article_id' => Yii::t('app', 'Article ID'), | 70 | 'article_id' => Yii::t('app', 'Article ID'), |
| 70 | 'media_id' => Yii::t('app', 'Media ID'), | 71 | 'media_id' => Yii::t('app', 'Media ID'), |
| 71 | 'type' => Yii::t('app', 'Type'), | 72 | 'type' => Yii::t('app', 'Type'), |
| @@ -81,7 +82,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -81,7 +82,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 81 | */ | 82 | */ |
| 82 | public function getArticle() | 83 | public function getArticle() |
| 83 | { | 84 | { |
| 84 | - return $this->hasOne(Article::className(), ['id' => 'article_id']); | 85 | + return $this->hasOne(Article::className(), ['article_id' => 'article_id']); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | /** | 88 | /** |
| @@ -89,7 +90,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -89,7 +90,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 89 | */ | 90 | */ |
| 90 | public function getMedia() | 91 | public function getMedia() |
| 91 | { | 92 | { |
| 92 | - return $this->hasOne(Media::className(), ['id' => 'media_id']); | 93 | + return $this->hasOne(Media::className(), ['media_id' => 'media_id']); |
| 93 | } | 94 | } |
| 94 | 95 | ||
| 95 | public function upload($article_id) | 96 | public function upload($article_id) |
| @@ -102,7 +103,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -102,7 +103,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 102 | $media = new Media(); | 103 | $media = new Media(); |
| 103 | $media->imageFile = $image; | 104 | $media->imageFile = $image; |
| 104 | $media->upload(); | 105 | $media->upload(); |
| 105 | - $media_article->media_id = $media->id; | 106 | + $media_article->media_id = $media->media_id; |
| 106 | $ok = $media_article->save() && $ok; | 107 | $ok = $media_article->save() && $ok; |
| 107 | unset($media_article); | 108 | unset($media_article); |
| 108 | } | 109 | } |
| @@ -111,7 +112,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -111,7 +112,7 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 111 | $media = new Media(); | 112 | $media = new Media(); |
| 112 | $media->imageFile = $this->imageFile; | 113 | $media->imageFile = $this->imageFile; |
| 113 | $media->upload(); | 114 | $media->upload(); |
| 114 | - $this->media_id = $media->id; | 115 | + $this->media_id = $media->media_id; |
| 115 | return $this->save(); | 116 | return $this->save(); |
| 116 | } | 117 | } |
| 117 | } | 118 | } |
| @@ -119,11 +120,11 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -119,11 +120,11 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 119 | public function replace($article_id, $removeMedia = false) | 120 | public function replace($article_id, $removeMedia = false) |
| 120 | { | 121 | { |
| 121 | $this->article_id = $article_id; | 122 | $this->article_id = $article_id; |
| 122 | - if($removeMedia) { | ||
| 123 | - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type])->column(); | 123 | + if($removeMedia && !$this->getIsNewRecord()) { |
| 124 | + $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id])->column(); | ||
| 124 | $media = array(); | 125 | $media = array(); |
| 125 | foreach($article_media as $media_id) { | 126 | foreach($article_media as $media_id) { |
| 126 | - $media[] = Media::findOne(['id' => $media_id]); | 127 | + $media[] = Media::findOne(['media_id' => $media_id]); |
| 127 | } | 128 | } |
| 128 | $media = array_unique($media); | 129 | $media = array_unique($media); |
| 129 | foreach($media as $one_media) { | 130 | foreach($media as $one_media) { |
| @@ -141,17 +142,17 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -141,17 +142,17 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 141 | $media = new Media(); | 142 | $media = new Media(); |
| 142 | $media->imageFile = $image; | 143 | $media->imageFile = $image; |
| 143 | $media->upload(); | 144 | $media->upload(); |
| 144 | - $media_article->media_id = $media->id; | 145 | + $media_article->media_id = $media->media_id; |
| 145 | $ok = $media_article->save() && $ok; | 146 | $ok = $media_article->save() && $ok; |
| 146 | unset($media_article); | 147 | unset($media_article); |
| 147 | } | 148 | } |
| 148 | return $ok; | 149 | return $ok; |
| 149 | } elseif(!empty($this->imageFile)) { | 150 | } elseif(!empty($this->imageFile)) { |
| 150 | - ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type]); | 151 | + ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id]); |
| 151 | $media = new Media(); | 152 | $media = new Media(); |
| 152 | $media->imageFile = $this->imageFile; | 153 | $media->imageFile = $this->imageFile; |
| 153 | $media->upload(); | 154 | $media->upload(); |
| 154 | - $this->media_id = $media->id; | 155 | + $this->media_id = $media->media_id; |
| 155 | $this->setIsNewRecord(true); | 156 | $this->setIsNewRecord(true); |
| 156 | return $this->save(); | 157 | return $this->save(); |
| 157 | } | 158 | } |
common/modules/blog/models/ArticleToCategory.php
| @@ -8,7 +8,7 @@ use Yii; | @@ -8,7 +8,7 @@ use Yii; | ||
| 8 | * This is the model class for table "article_to_category". | 8 | * This is the model class for table "article_to_category". |
| 9 | * | 9 | * |
| 10 | * @property integer $article_id | 10 | * @property integer $article_id |
| 11 | - * @property integer $category_id | 11 | + * @property integer $article_category_id |
| 12 | * | 12 | * |
| 13 | * @property Article $article | 13 | * @property Article $article |
| 14 | * @property ArticleCategory $category | 14 | * @property ArticleCategory $category |
| @@ -29,7 +29,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | @@ -29,7 +29,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | ||
| 29 | public function rules() | 29 | public function rules() |
| 30 | { | 30 | { |
| 31 | return [ | 31 | return [ |
| 32 | - [['article_id', 'category_id'], 'integer'] | 32 | + [['article_id', 'article_category_id'], 'integer'] |
| 33 | ]; | 33 | ]; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -40,7 +40,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | @@ -40,7 +40,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | ||
| 40 | { | 40 | { |
| 41 | return [ | 41 | return [ |
| 42 | 'article_id' => Yii::t('app', 'Article ID'), | 42 | 'article_id' => Yii::t('app', 'Article ID'), |
| 43 | - 'category_id' => Yii::t('app', 'Category ID'), | 43 | + 'article_category_id' => Yii::t('app', 'Category ID'), |
| 44 | ]; | 44 | ]; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| @@ -49,7 +49,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | @@ -49,7 +49,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord | ||
| 49 | */ | 49 | */ |
| 50 | public function getArticle() | 50 | public function getArticle() |
| 51 | { | 51 | { |
| 52 | - return $this->hasOne(Article::className(), ['id' => 'article_id']); | 52 | + return $this->hasOne(Article::className(), ['article_id' => 'article_id']); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /** | 55 | /** |
| @@ -57,6 +57,6 @@ class ArticleToCategory extends \yii\db\ActiveRecord | @@ -57,6 +57,6 @@ class ArticleToCategory extends \yii\db\ActiveRecord | ||
| 57 | */ | 57 | */ |
| 58 | public function getCategory() | 58 | public function getCategory() |
| 59 | { | 59 | { |
| 60 | - return $this->hasOne(ArticleCategory::className(), ['id' => 'category_id']); | 60 | + return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
common/modules/blog/views/ajax/_article_form.php
| @@ -3,31 +3,36 @@ | @@ -3,31 +3,36 @@ | ||
| 3 | use yii\bootstrap\ActiveField; | 3 | use yii\bootstrap\ActiveField; |
| 4 | use mihaildev\ckeditor\CKEditor; | 4 | use mihaildev\ckeditor\CKEditor; |
| 5 | 5 | ||
| 6 | -$form = \yii\bootstrap\ActiveForm::begin(); | 6 | +if(empty($form)) { |
| 7 | + $new_form = true; | ||
| 8 | + $form = \yii\bootstrap\ActiveForm::begin(); | ||
| 9 | +} | ||
| 7 | ?> | 10 | ?> |
| 8 | <div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> | 11 | <div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> |
| 9 | 12 | ||
| 10 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]lang_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> | 13 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> |
| 11 | 14 | ||
| 12 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> | 15 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> |
| 13 | 16 | ||
| 14 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> | 17 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> |
| 15 | 18 | ||
| 16 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?> | 19 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?> |
| 17 | 20 | ||
| 18 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]name"]))->textInput() ?> | 21 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]name"]))->textInput() ?> |
| 19 | 22 | ||
| 20 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?> | 23 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?> |
| 21 | 24 | ||
| 22 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> | 25 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> |
| 23 | 26 | ||
| 24 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]meta_keywords"]))->textInput() ?> | 27 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?> |
| 25 | 28 | ||
| 26 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> | 29 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> |
| 27 | 30 | ||
| 28 | - <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]tags"]))->textInput() ?> | 31 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]tag"]))->textInput() ?> |
| 29 | 32 | ||
| 30 | </div> | 33 | </div> |
| 31 | <?php | 34 | <?php |
| 32 | -$form->end(); | 35 | + if($new_form) { |
| 36 | + $form->end(); | ||
| 37 | + } | ||
| 33 | ?> | 38 | ?> |
common/modules/blog/views/ajax/_article_media_form.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\bootstrap\ActiveField; | ||
| 4 | +use mihaildev\ckeditor\CKEditor; | ||
| 5 | + | ||
| 6 | +$form = \yii\bootstrap\ActiveForm::begin(); | ||
| 7 | +?> | ||
| 8 | +<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> | ||
| 9 | + | ||
| 10 | + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> | ||
| 11 | + | ||
| 12 | + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?> | ||
| 13 | + | ||
| 14 | +</div> | ||
| 15 | +<?php | ||
| 16 | +$form->end(); | ||
| 17 | +?> |
common/modules/blog/views/ajax/_category_form.php
| @@ -7,7 +7,7 @@ $form = \yii\bootstrap\ActiveForm::begin(); | @@ -7,7 +7,7 @@ $form = \yii\bootstrap\ActiveForm::begin(); | ||
| 7 | ?> | 7 | ?> |
| 8 | <div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> | 8 | <div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> |
| 9 | 9 | ||
| 10 | - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]lang_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> | 10 | + <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> |
| 11 | 11 | ||
| 12 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> | 12 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> |
| 13 | 13 | ||
| @@ -21,11 +21,11 @@ $form = \yii\bootstrap\ActiveForm::begin(); | @@ -21,11 +21,11 @@ $form = \yii\bootstrap\ActiveForm::begin(); | ||
| 21 | 21 | ||
| 22 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> | 22 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> |
| 23 | 23 | ||
| 24 | - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_keywords"]))->textInput() ?> | 24 | + <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?> |
| 25 | 25 | ||
| 26 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> | 26 | <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> |
| 27 | 27 | ||
| 28 | - <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]tags"]))->textInput() ?> | 28 | + <?= (new ActiveField(['model' => $category_lang, 'attribute' => "[$model->language_id]tag"]))->textInput() ?> |
| 29 | 29 | ||
| 30 | </div> | 30 | </div> |
| 31 | <?php | 31 | <?php |
common/modules/blog/views/article/_form.php
| 1 | <?php | 1 | <?php |
| 2 | use common\modules\blog\models\ArticleCategory; | 2 | use common\modules\blog\models\ArticleCategory; |
| 3 | +use common\modules\blog\models\ArticleMedia; | ||
| 3 | use common\widgets\Multilang; | 4 | use common\widgets\Multilang; |
| 4 | -use yii\bootstrap\ActiveForm; | 5 | + use common\widgets\Multilanguage; |
| 6 | + use yii\bootstrap\ActiveForm; | ||
| 5 | use common\modules\blog\models\Article; | 7 | use common\modules\blog\models\Article; |
| 6 | use yii\bootstrap\Html; | 8 | use yii\bootstrap\Html; |
| 7 | use mihaildev\ckeditor\CKEditor; | 9 | use mihaildev\ckeditor\CKEditor; |
| @@ -18,70 +20,108 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -18,70 +20,108 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 18 | 20 | ||
| 19 | <?= $form->field($article, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> | 21 | <?= $form->field($article, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> |
| 20 | 22 | ||
| 21 | - <?= $form->field($article, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> | 23 | + <?= $form->field($article, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> |
| 22 | 24 | ||
| 23 | <?= $form->field($article, 'sort')->input('number') ?> | 25 | <?= $form->field($article, 'sort')->input('number') ?> |
| 24 | 26 | ||
| 25 | - <?= $form->field($article, 'parent_id') | ||
| 26 | - ->dropDownList(Article::findArticleDropdown($article->id), ['prompt' => Yii::t('app', 'Select parent')]) ?> | 27 | + <?= $form->field($article, 'article_pid') |
| 28 | + ->dropDownList(Article::findArticleDropdown($article->article_id), ['prompt' => Yii::t('app', 'Select parent')]) ?> | ||
| 27 | 29 | ||
| 28 | <?= $form->field($article, 'articleCategoriesArray') | 30 | <?= $form->field($article, 'articleCategoriesArray') |
| 29 | ->dropDownList(ArticleCategory::findArticleCategoryDropdown(NULL), ['multiple' => 'multiple'])->label(\Yii::t('app', 'Article Categories Array')); ?> | 31 | ->dropDownList(ArticleCategory::findArticleCategoryDropdown(NULL), ['multiple' => 'multiple'])->label(\Yii::t('app', 'Article Categories Array')); ?> |
| 30 | 32 | ||
| 31 | - <?= $form->field($article, 'active')->checkbox() ?> | 33 | + <?= $form->field($article, 'status')->checkbox() ?> |
| 32 | 34 | ||
| 33 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> | 35 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> |
| 34 | - <?php | ||
| 35 | - $first = 1; | ||
| 36 | - foreach($images as $index => $image) { | ||
| 37 | - ?> | ||
| 38 | - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li> | ||
| 39 | - <?php | ||
| 40 | - $first = 0; | ||
| 41 | - } | ||
| 42 | - ?> | 36 | + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li> |
| 37 | + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li> | ||
| 38 | + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li> | ||
| 43 | </ul> | 39 | </ul> |
| 44 | <div class="tab-content image-tab-content"> | 40 | <div class="tab-content image-tab-content"> |
| 45 | - <?php | ||
| 46 | - $first = 1; | ||
| 47 | - foreach($images as $index => $image) { | 41 | + <div role="" class="tab-pane active main-tab" id="image-full"> |
| 42 | + <?php | ||
| 43 | + $imagelang = Multilang::begin([ | ||
| 44 | + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']), | ||
| 45 | + 'form' => $form, | ||
| 46 | + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'full'])->indexBy('language_id')->all() | ||
| 47 | + ]); | ||
| 48 | + $first = 1; | ||
| 49 | + foreach($images as $lang => $value) { | ||
| 50 | + if(!array_key_exists('full', $value)) continue; | ||
| 51 | + ?> | ||
| 52 | + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | ||
| 53 | + <?php | ||
| 54 | + echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]); | ||
| 55 | + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 56 | + if(!empty($images[$lang]['full']->article_media_id)) { | ||
| 57 | + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; | ||
| 58 | + } | ||
| 59 | + ?> | ||
| 60 | + </div> | ||
| 61 | + <?php | ||
| 62 | + $first = 0; | ||
| 63 | + } | ||
| 64 | + $imagelang->end(); | ||
| 48 | ?> | 65 | ?> |
| 49 | - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>"> | ||
| 50 | - <?php if($index == 'additional') { | ||
| 51 | - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); | ||
| 52 | - if(is_array($image) && count($image) > 1) { | ||
| 53 | - foreach($image as $oneindex => $oneimage) { | ||
| 54 | - if($oneindex) { | ||
| 55 | - ?> | ||
| 56 | - <div class="additional_image_container"> | ||
| 57 | - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'> | ||
| 58 | - <a | ||
| 59 | - href="<?= Url::to(['ajax/remove-image']) ?>" | ||
| 60 | - class="remove_image glyphicon glyphicon-remove-circle" | ||
| 61 | - data-params='<?= Json::encode(['article_media_id' => $oneimage->id, 'remove_media' => true]) ?>', | ||
| 62 | - ></a> | ||
| 63 | - </div> | ||
| 64 | - <?php | ||
| 65 | - } | ||
| 66 | - } | 66 | + </div> |
| 67 | + <div role="" class="tab-pane" id="image-preview"> | ||
| 68 | + <?php | ||
| 69 | + $imagelang = Multilang::begin([ | ||
| 70 | + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']), | ||
| 71 | + 'form' => $form, | ||
| 72 | + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'preview'])->indexBy('language_id')->all() | ||
| 73 | + ]); | ||
| 74 | + $first = 1; | ||
| 75 | + foreach($images as $lang => $value) { | ||
| 76 | + if(!array_key_exists('preview', $value)) continue; | ||
| 77 | + ?> | ||
| 78 | + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | ||
| 79 | + <?php | ||
| 80 | + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]); | ||
| 81 | + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 82 | + if(!empty($images[$lang]['preview']->article_media_id)) { | ||
| 83 | + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; | ||
| 67 | } | 84 | } |
| 68 | - } else { | ||
| 69 | - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 70 | - if(!empty($image->id)) { | ||
| 71 | - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>"; | 85 | + ?> |
| 86 | + </div> | ||
| 87 | + <?php | ||
| 88 | + $first = 0; | ||
| 89 | + } | ||
| 90 | + $imagelang->end(); | ||
| 91 | + ?> | ||
| 92 | + </div> | ||
| 93 | + <div role="" class="tab-pane" id="image-additional"> | ||
| 94 | + <?php | ||
| 95 | + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); | ||
| 96 | + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) { | ||
| 97 | + foreach($images[0]['additional'] as $onefield => $oneimage) { | ||
| 98 | + if($onefield) { | ||
| 99 | + ?> | ||
| 100 | + <div class="additional_image_container"> | ||
| 101 | + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'> | ||
| 102 | + <a | ||
| 103 | + href="<?= Url::to(['ajax/remove-image']) ?>" | ||
| 104 | + class="remove_image glyphicon glyphicon-remove-circle" | ||
| 105 | + data-params='<?= Json::encode(['article_media_id' => $oneimage->article_media_id, 'remove_media' => true]) ?>', | ||
| 106 | + ></a> | ||
| 107 | + </div> | ||
| 108 | + <?php | ||
| 72 | } | 109 | } |
| 73 | } | 110 | } |
| 74 | - ?> | ||
| 75 | - </div> | ||
| 76 | - <?php | ||
| 77 | - $first = 0; | ||
| 78 | - } | ||
| 79 | - ?> | 111 | + } |
| 112 | + ?> | ||
| 113 | + </div> | ||
| 80 | </div> | 114 | </div> |
| 81 | 115 | ||
| 82 | <hr> | 116 | <hr> |
| 83 | 117 | ||
| 84 | <?php | 118 | <?php |
| 119 | + echo Multilanguage::widget([ | ||
| 120 | + 'data' => $article_langs, | ||
| 121 | + 'form' => $form, | ||
| 122 | + 'ajaxView' => '@common/modules/blog/views/ajax/_article_form', | ||
| 123 | + ]); | ||
| 124 | + /* | ||
| 85 | $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/article-form']), 'form' => $form, 'data_langs' => $article_langs]); | 125 | $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/article-form']), 'form' => $form, 'data_langs' => $article_langs]); |
| 86 | ?> | 126 | ?> |
| 87 | <?php | 127 | <?php |
| @@ -90,7 +130,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -90,7 +130,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 90 | ?> | 130 | ?> |
| 91 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$multilang->id?>-<?=$index?>"> | 131 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$multilang->id?>-<?=$index?>"> |
| 92 | 132 | ||
| 93 | - <?= $form->field($article_langs[$index], "[$index]lang_id")->label(false)->hiddenInput(['value' => $index]) ?> | 133 | + <?= $form->field($article_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?> |
| 94 | 134 | ||
| 95 | <?= $form->field($article_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> | 135 | <?= $form->field($article_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> |
| 96 | 136 | ||
| @@ -117,6 +157,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -117,6 +157,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 117 | ?> | 157 | ?> |
| 118 | <?php | 158 | <?php |
| 119 | $multilang->end(); | 159 | $multilang->end(); |
| 160 | + */ | ||
| 120 | ?> | 161 | ?> |
| 121 | 162 | ||
| 122 | <div class="form-group"> | 163 | <div class="form-group"> |
common/modules/blog/views/article/index.php
| @@ -8,12 +8,12 @@ use common\models\Language; | @@ -8,12 +8,12 @@ use common\models\Language; | ||
| 8 | echo GridView::widget([ | 8 | echo GridView::widget([ |
| 9 | 'dataProvider' => $dataProvider, | 9 | 'dataProvider' => $dataProvider, |
| 10 | 'columns' => [ | 10 | 'columns' => [ |
| 11 | - 'id', | 11 | + 'article_id', |
| 12 | 'code', | 12 | 'code', |
| 13 | - 'create_at', | 13 | + 'date_add', |
| 14 | [ | 14 | [ |
| 15 | 'value' => function($data) { | 15 | 'value' => function($data) { |
| 16 | - return $data->author0->firstname.' '.$data->author0->lastname; | 16 | + return $data->user->firstname.' '.$data->user->lastname; |
| 17 | }, | 17 | }, |
| 18 | 'header' => Yii::t('app', 'Author') | 18 | 'header' => Yii::t('app', 'Author') |
| 19 | ], | 19 | ], |
| @@ -21,7 +21,7 @@ echo GridView::widget([ | @@ -21,7 +21,7 @@ echo GridView::widget([ | ||
| 21 | 'class' => Column::className(), | 21 | 'class' => Column::className(), |
| 22 | 'header' => Yii::t('app', 'Name'), | 22 | 'header' => Yii::t('app', 'Name'), |
| 23 | 'content' => function($model, $key, $index, $column) { | 23 | 'content' => function($model, $key, $index, $column) { |
| 24 | - return $model->getArticleLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name; | 24 | + return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name; |
| 25 | } | 25 | } |
| 26 | ], | 26 | ], |
| 27 | [ | 27 | [ |
common/modules/blog/views/category/_form.php
| 1 | <?php | 1 | <?php |
| 2 | +use common\modules\blog\models\ArticleCategoryMedia; | ||
| 2 | use common\widgets\Multilang; | 3 | use common\widgets\Multilang; |
| 3 | use yii\bootstrap\ActiveForm; | 4 | use yii\bootstrap\ActiveForm; |
| 4 | use common\modules\blog\models\ArticleCategory; | 5 | use common\modules\blog\models\ArticleCategory; |
| @@ -16,62 +17,94 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -16,62 +17,94 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 16 | 17 | ||
| 17 | <?= $form->field($category, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> | 18 | <?= $form->field($category, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> |
| 18 | 19 | ||
| 19 | - <?= $form->field($category, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> | 20 | + <?= $form->field($category, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> |
| 20 | 21 | ||
| 21 | <?= $form->field($category, 'sort')->input('number') ?> | 22 | <?= $form->field($category, 'sort')->input('number') ?> |
| 22 | 23 | ||
| 23 | - <?= $form->field($category, 'parent_id') | ||
| 24 | - ->dropDownList(ArticleCategory::findArticleCategoryDropdown($category->id), ['prompt' => Yii::t('app', 'Select parent')]) ?> | 24 | + <?= $form->field($category, 'article_category_pid') |
| 25 | + ->dropDownList(ArticleCategory::findArticleCategoryDropdown($category->article_category_id), ['prompt' => Yii::t('app', 'Select parent')]) ?> | ||
| 25 | 26 | ||
| 26 | - <?= $form->field($category, 'active')->checkbox() ?> | 27 | + <?= $form->field($category, 'status')->checkbox() ?> |
| 27 | 28 | ||
| 28 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> | 29 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> |
| 29 | - <?php | ||
| 30 | - $first = 1; | ||
| 31 | - foreach($images as $index => $image) { | ||
| 32 | - ?> | ||
| 33 | - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li> | ||
| 34 | - <?php | ||
| 35 | - $first = 0; | ||
| 36 | - } | ||
| 37 | - ?> | 30 | + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li> |
| 31 | + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li> | ||
| 32 | + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li> | ||
| 38 | </ul> | 33 | </ul> |
| 39 | <div class="tab-content image-tab-content"> | 34 | <div class="tab-content image-tab-content"> |
| 40 | - <?php | ||
| 41 | - $first = 1; | ||
| 42 | - foreach($images as $index => $image) { | 35 | + <div role="" class="tab-pane active main-tab" id="image-full"> |
| 36 | + <?php | ||
| 37 | + $imagelang = Multilang::begin([ | ||
| 38 | + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']), | ||
| 39 | + 'form' => $form, | ||
| 40 | + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'full'])->indexBy('language_id')->all() | ||
| 41 | + ]); | ||
| 42 | + $first = 1; | ||
| 43 | + foreach($images as $lang => $value) { | ||
| 44 | + if(!array_key_exists('full', $value)) continue; | ||
| 45 | + ?> | ||
| 46 | + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | ||
| 47 | + <?php | ||
| 48 | + echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]); | ||
| 49 | + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 50 | + if(!empty($images[$lang]['full']->article_category_media_id)) { | ||
| 51 | + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; | ||
| 52 | + } | ||
| 53 | + ?> | ||
| 54 | + </div> | ||
| 55 | + <?php | ||
| 56 | + $first = 0; | ||
| 57 | + } | ||
| 58 | + $imagelang->end(); | ||
| 43 | ?> | 59 | ?> |
| 44 | - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>"> | ||
| 45 | - <?php if($index == 'additional') { | ||
| 46 | - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); | ||
| 47 | - if(is_array($image) && count($image) > 1) { | ||
| 48 | - foreach($image as $oneindex => $oneimage) { | ||
| 49 | - if($oneindex) { | ||
| 50 | - ?> | ||
| 51 | - <div class="additional_image_container"> | ||
| 52 | - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'> | ||
| 53 | - <a | ||
| 54 | - href="<?= Url::to(['ajax/remove-image-category']) ?>" | ||
| 55 | - class="remove_image glyphicon glyphicon-remove-circle" | ||
| 56 | - data-params='<?= Json::encode(['category_media_id' => $oneimage->id, 'remove_media' => true]) ?>', | ||
| 57 | - ></a> | ||
| 58 | - </div> | ||
| 59 | - <?php | ||
| 60 | - } | ||
| 61 | - } | 60 | + </div> |
| 61 | + <div role="" class="tab-pane" id="image-preview"> | ||
| 62 | + <?php | ||
| 63 | + $imagelang = Multilang::begin([ | ||
| 64 | + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']), | ||
| 65 | + 'form' => $form, | ||
| 66 | + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'preview'])->indexBy('language_id')->all() | ||
| 67 | + ]); | ||
| 68 | + $first = 1; | ||
| 69 | + foreach($images as $lang => $value) { | ||
| 70 | + if(!array_key_exists('preview', $value)) continue; | ||
| 71 | + ?> | ||
| 72 | + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | ||
| 73 | + <?php | ||
| 74 | + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]); | ||
| 75 | + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 76 | + if(!empty($images[$lang]['preview']->article_category_media_id)) { | ||
| 77 | + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; | ||
| 62 | } | 78 | } |
| 63 | - } else { | ||
| 64 | - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']); | ||
| 65 | - if(!empty($image->id)) { | ||
| 66 | - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>"; | 79 | + ?> |
| 80 | + </div> | ||
| 81 | + <?php | ||
| 82 | + $first = 0; | ||
| 83 | + } | ||
| 84 | + $imagelang->end(); | ||
| 85 | + ?> | ||
| 86 | + </div> | ||
| 87 | + <div role="" class="tab-pane" id="image-additional"> | ||
| 88 | + <?php | ||
| 89 | + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); | ||
| 90 | + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) { | ||
| 91 | + foreach($images[0]['additional'] as $onefield => $oneimage) { | ||
| 92 | + if($onefield) { | ||
| 93 | + ?> | ||
| 94 | + <div class="additional_image_container"> | ||
| 95 | + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'> | ||
| 96 | + <a | ||
| 97 | + href="<?= Url::to(['ajax/remove-image']) ?>" | ||
| 98 | + class="remove_image glyphicon glyphicon-remove-circle" | ||
| 99 | + data-params='<?= Json::encode(['article_category_media_id' => $oneimage->article_category_media_id, 'remove_media' => true]) ?>', | ||
| 100 | + ></a> | ||
| 101 | + </div> | ||
| 102 | + <?php | ||
| 67 | } | 103 | } |
| 68 | } | 104 | } |
| 69 | - ?> | ||
| 70 | - </div> | ||
| 71 | - <?php | ||
| 72 | - $first = 0; | ||
| 73 | - } | ||
| 74 | - ?> | 105 | + } |
| 106 | + ?> | ||
| 107 | + </div> | ||
| 75 | </div> | 108 | </div> |
| 76 | 109 | ||
| 77 | <hr> | 110 | <hr> |
| @@ -84,7 +117,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -84,7 +117,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 84 | foreach($category_langs as $index => $category_lang) { | 117 | foreach($category_langs as $index => $category_lang) { |
| 85 | ?> | 118 | ?> |
| 86 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="lang-<?=$index?>"> | 119 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="lang-<?=$index?>"> |
| 87 | - <?= $form->field($category_langs[$index], "[$index]lang_id")->label(false)->hiddenInput(['value' => $index]) ?> | 120 | + <?= $form->field($category_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?> |
| 88 | 121 | ||
| 89 | <?= $form->field($category_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> | 122 | <?= $form->field($category_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> |
| 90 | 123 | ||
| @@ -98,11 +131,11 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -98,11 +131,11 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 98 | 131 | ||
| 99 | <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?> | 132 | <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?> |
| 100 | 133 | ||
| 101 | - <?= $form->field($category_langs[$index], "[$index]meta_keywords")->textInput() ?> | 134 | + <?= $form->field($category_langs[$index], "[$index]meta_keyword")->textInput() ?> |
| 102 | 135 | ||
| 103 | <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?> | 136 | <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?> |
| 104 | 137 | ||
| 105 | - <?= $form->field($category_langs[$index], "[$index]tags")->textInput() ?> | 138 | + <?= $form->field($category_langs[$index], "[$index]tag")->textInput() ?> |
| 106 | 139 | ||
| 107 | </div> | 140 | </div> |
| 108 | <?php | 141 | <?php |
common/modules/blog/views/category/index.php
| @@ -7,15 +7,15 @@ use common\models\Language; | @@ -7,15 +7,15 @@ use common\models\Language; | ||
| 7 | echo GridView::widget([ | 7 | echo GridView::widget([ |
| 8 | 'dataProvider' => $dataProvider, | 8 | 'dataProvider' => $dataProvider, |
| 9 | 'columns' => [ | 9 | 'columns' => [ |
| 10 | - 'id', | 10 | + 'article_category_id', |
| 11 | 'code', | 11 | 'code', |
| 12 | - 'created_at', | ||
| 13 | - 'updated_at', | 12 | + 'date_add', |
| 13 | + 'date_update', | ||
| 14 | [ | 14 | [ |
| 15 | 'class' => Column::className(), | 15 | 'class' => Column::className(), |
| 16 | 'header' => Yii::t('app', 'Name'), | 16 | 'header' => Yii::t('app', 'Name'), |
| 17 | 'content' => function($model, $key, $index, $column) { | 17 | 'content' => function($model, $key, $index, $column) { |
| 18 | - return $model->getArticleCategoryLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name; | 18 | + return $model->getArticleCategoryLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name; |
| 19 | } | 19 | } |
| 20 | ], | 20 | ], |
| 21 | [ | 21 | [ |
common/modules/blog/views/default/index.php
common/translation/ru/app.php
| @@ -58,9 +58,23 @@ return [ | @@ -58,9 +58,23 @@ return [ | ||
| 58 | 'Category update' => 'Редактирование категории', | 58 | 'Category update' => 'Редактирование категории', |
| 59 | 'Article create' => 'Создание статьи', | 59 | 'Article create' => 'Создание статьи', |
| 60 | 'Update category' => 'Редактирование категории', | 60 | 'Update category' => 'Редактирование категории', |
| 61 | - 'Select parent' => 'Выберать родителя', | 61 | + 'Select parent' => 'Выбрать родителя', |
| 62 | 'Blog' => 'Блог', | 62 | 'Blog' => 'Блог', |
| 63 | 'Static pages' => 'Статические страницы', | 63 | 'Static pages' => 'Статические страницы', |
| 64 | + 'Create Admin Menu' => 'Создать элемент меню', | ||
| 65 | + 'Admin Menus' => 'Административное меню', | ||
| 66 | + 'Hide Min' => 'Спрятать в свернутом', | ||
| 67 | + 'Path' => 'Путь', | ||
| 68 | + 'Params' => 'Параметры', | ||
| 69 | + 'Parent item' => 'Родительский элемент', | ||
| 70 | + 'Active Menu' => 'Активный', | ||
| 71 | + 'Not Active Menu' => 'Неактивный', | ||
| 72 | + 'Show Menu Min' => 'Отобразить', | ||
| 73 | + 'Hide Menu Min' => 'Спрятать', | ||
| 74 | + 'Update' => 'Редактировать', | ||
| 75 | + 'Delete' => 'Удалить', | ||
| 76 | + 'Settings categories' => 'Разделы настроек', | ||
| 77 | + 'Back' => 'Назад', | ||
| 64 | 78 | ||
| 65 | // Вова | 79 | // Вова |
| 66 | 'page' => 'Страница', | 80 | 'page' => 'Страница', |
| @@ -72,7 +86,7 @@ return [ | @@ -72,7 +86,7 @@ return [ | ||
| 72 | 'meta_description' => 'Meta Description', | 86 | 'meta_description' => 'Meta Description', |
| 73 | 'text' => 'Текст', | 87 | 'text' => 'Текст', |
| 74 | 'page_alias' => 'alias', | 88 | 'page_alias' => 'alias', |
| 75 | - 'lang_id' => 'ID языка', | 89 | + 'language_id' => 'ID языка', |
| 76 | 'common' => 'Общее', | 90 | 'common' => 'Общее', |
| 77 | 'lang' => 'Языковые переменные', | 91 | 'lang' => 'Языковые переменные', |
| 78 | 'termin' => 'Термин', | 92 | 'termin' => 'Термин', |
common/translation/uk/app.php
| @@ -14,7 +14,7 @@ return [ | @@ -14,7 +14,7 @@ return [ | ||
| 14 | 'meta_description' => 'Meta Description', | 14 | 'meta_description' => 'Meta Description', |
| 15 | 'text' => 'Текст', | 15 | 'text' => 'Текст', |
| 16 | 'page_alias' => 'alias', | 16 | 'page_alias' => 'alias', |
| 17 | - 'lang_id' => 'ID мови', | 17 | + 'language_id' => 'ID мови', |
| 18 | 'common' => 'Загальне', | 18 | 'common' => 'Загальне', |
| 19 | 'lang' => 'Мовні змінні', | 19 | 'lang' => 'Мовні змінні', |
| 20 | 'termin' => 'Термін', | 20 | 'termin' => 'Термін', |
| 1 | +<?php | ||
| 2 | +namespace common\widgets; | ||
| 3 | +use common\models\Language; | ||
| 4 | +use common\modules\blog\controllers\AjaxController; | ||
| 5 | +use yii\base\InvalidParamException; | ||
| 6 | +use yii\base\Widget; | ||
| 7 | +use yii\bootstrap\ActiveForm; | ||
| 8 | + | ||
| 9 | +class Multilanguage extends Widget | ||
| 10 | +{ | ||
| 11 | + public $id; | ||
| 12 | + | ||
| 13 | + public $model_name; | ||
| 14 | + | ||
| 15 | + public $table_name; | ||
| 16 | + | ||
| 17 | + public $langs; | ||
| 18 | + | ||
| 19 | + public $default_lang; | ||
| 20 | + | ||
| 21 | + public $data; | ||
| 22 | + | ||
| 23 | + public $handler = '/blog/ajax/multilang-form'; | ||
| 24 | + | ||
| 25 | + public $form; | ||
| 26 | + | ||
| 27 | + public $ajaxView; | ||
| 28 | + | ||
| 29 | + public function init() | ||
| 30 | + { | ||
| 31 | + parent::init(); | ||
| 32 | + $this->default_lang = Language::getDefaultLang(); | ||
| 33 | + if(empty($this->langs)) { | ||
| 34 | + $this->langs = Language::getActiveLanguages(); | ||
| 35 | + } | ||
| 36 | + if(empty($this->form)) { | ||
| 37 | + throw new InvalidParamException('Form must be set'); | ||
| 38 | + } | ||
| 39 | + if(empty($this->ajaxView)) { | ||
| 40 | + throw new InvalidParamException('Ajaxview must be set'); | ||
| 41 | + } | ||
| 42 | + if(empty($this->data) || !is_array($this->data)) { | ||
| 43 | + throw new InvalidParamException('Data must be set and be array'); | ||
| 44 | + } else { | ||
| 45 | + $first = 1; | ||
| 46 | + foreach ($this->data as $lang => $item) { | ||
| 47 | + if ($first) { | ||
| 48 | + $this->model_name = $item->className(); | ||
| 49 | + $this->table_name = $item->tableName(); | ||
| 50 | + $first = 0; | ||
| 51 | + } else { | ||
| 52 | + if($item->className() !== $this->model_name || $item->tableName() !== $this->table_name) { | ||
| 53 | + throw new InvalidParamException('Every data element must have the same class and table'); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public function run() | ||
| 61 | + { | ||
| 62 | + echo $this->render('multilanguage-begin', [ | ||
| 63 | + 'id' => $this->id, | ||
| 64 | + 'model_name' => $this->model_name, | ||
| 65 | + 'table_name' => $this->table_name, | ||
| 66 | + 'data' => $this->data, | ||
| 67 | + 'langs' => $this->langs, | ||
| 68 | + 'handler' => $this->handler, | ||
| 69 | + 'default_lang' => $this->default_lang, | ||
| 70 | + 'ajaxView' => $this->ajaxView, | ||
| 71 | + ]); | ||
| 72 | + foreach($this->data as $lang => $item) { | ||
| 73 | + $item->language_id = $lang; | ||
| 74 | + echo $this->render($this->ajaxView, ['model' => $item, 'form' => $this->form, 'widget_id' => $this->id]); | ||
| 75 | + } | ||
| 76 | + echo $this->render('multilanguage-end', [ | ||
| 77 | + 'id' => $this->id, | ||
| 78 | + 'model_name' => $this->model_name, | ||
| 79 | + 'table_name' => $this->table_name, | ||
| 80 | + 'data' => $this->data, | ||
| 81 | + 'langs' => $this->langs, | ||
| 82 | + 'handler' => $this->handler, | ||
| 83 | + 'default_lang' => $this->default_lang, | ||
| 84 | + 'ajaxView' => $this->ajaxView, | ||
| 85 | + ]); | ||
| 86 | + } | ||
| 87 | +} | ||
| 0 | \ No newline at end of file | 88 | \ No newline at end of file |
common/widgets/views/multilang-begin.php
| @@ -6,7 +6,7 @@ use yii\helpers\Url; | @@ -6,7 +6,7 @@ use yii\helpers\Url; | ||
| 6 | <?= Yii::t('app', 'Add language') ?> | 6 | <?= Yii::t('app', 'Add language') ?> |
| 7 | <span class="caret"></span> | 7 | <span class="caret"></span> |
| 8 | </button> | 8 | </button> |
| 9 | - <ul class="dropdown-menu f32" id="lang-<?=$id?>" aria-labelledby="<?=$id?>Menu"> | 9 | + <ul class="dropdown-menu f32 old" id="lang-<?=$id?>" aria-labelledby="<?=$id?>Menu"> |
| 10 | <?php foreach($langs as $index => $lang) { | 10 | <?php foreach($langs as $index => $lang) { |
| 11 | if(in_array($index, array_keys($data_langs))) continue; | 11 | if(in_array($index, array_keys($data_langs))) continue; |
| 12 | ?> | 12 | ?> |
| @@ -18,6 +18,7 @@ use yii\helpers\Url; | @@ -18,6 +18,7 @@ use yii\helpers\Url; | ||
| 18 | <?php | 18 | <?php |
| 19 | $first = 1; | 19 | $first = 1; |
| 20 | foreach($data_langs as $index => $data_lang) { | 20 | foreach($data_langs as $index => $data_lang) { |
| 21 | + if(!$index) continue; | ||
| 21 | ?> | 22 | ?> |
| 22 | <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#<?=$id?>-<?=$index?>" aria-controls="<?=$id?>-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li> | 23 | <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#<?=$id?>-<?=$index?>" aria-controls="<?=$id?>-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li> |
| 23 | <?php | 24 | <?php |
| 1 | +<?php | ||
| 2 | +use yii\helpers\Url; | ||
| 3 | +?> | ||
| 4 | +<div class="dropdown pull-right"> | ||
| 5 | + <button class="btn btn-default dropdown-toggle" type="button" id="<?=$id?>Lang" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> | ||
| 6 | + <?= Yii::t('app', 'Add language') ?> | ||
| 7 | + <span class="caret"></span> | ||
| 8 | + </button> | ||
| 9 | + <ul class="dropdown-menu f32" id="lang-<?=$id?>" aria-labelledby="<?=$id?>Menu"> | ||
| 10 | + <?php foreach($langs as $index => $lang) { | ||
| 11 | + if(in_array($index, array_keys($data))) continue; | ||
| 12 | + ?> | ||
| 13 | + <li><a href="#<?=$id?>" data-lang="<?=$lang->language_id?>"><span class="flag <?=$lang->country_code?>"></span></a></li> | ||
| 14 | + <?php } ?> | ||
| 15 | + </ul> | ||
| 16 | +</div> | ||
| 17 | +<ul class="nav nav-tabs f32" id="<?=$id?>-tabs" role="tablist"> | ||
| 18 | + <?php | ||
| 19 | + foreach($data as $index => $data_lang) { | ||
| 20 | + if(!$index) continue; | ||
| 21 | + ?> | ||
| 22 | + <li role="lang_inputs" data-lang="<?=$index?>"><a href="#<?=$id?>-<?=$index?>" aria-controls="<?=$id?>-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li> | ||
| 23 | + <?php | ||
| 24 | + } | ||
| 25 | + ?> | ||
| 26 | +</ul> | ||
| 27 | +<div class="tab-content lang-tab-content" id="tab-content-<?=$id?>"> | ||
| 28 | + |
| 1 | +<?php | ||
| 2 | +use yii\helpers\Url; | ||
| 3 | +?> | ||
| 4 | +</div> | ||
| 5 | +<script> | ||
| 6 | + if(typeof form === 'undefined') { | ||
| 7 | + var form = []; | ||
| 8 | + } | ||
| 9 | + form['<?=$id?>'] = {handler:'<?=$handler?>', view:'<?=$ajaxView?>', model: '<?=str_replace("\\", "\\\\", $model_name)?>'}; | ||
| 10 | +</script> | ||
| 0 | \ No newline at end of file | 11 | \ No newline at end of file |
db-migration/artbox_db.backup deleted
No preview for this file type
db-migration/yarik/db.zip deleted
No preview for this file type
No preview for this file type
No preview for this file type
db-migration/yarik/public.backup
No preview for this file type
frontend/config/main.php
| @@ -16,9 +16,7 @@ return [ | @@ -16,9 +16,7 @@ return [ | ||
| 16 | 'bootstrap' => ['log'], | 16 | 'bootstrap' => ['log'], |
| 17 | 'controllerNamespace' => 'frontend\controllers', | 17 | 'controllerNamespace' => 'frontend\controllers', |
| 18 | 'modules' => [ | 18 | 'modules' => [ |
| 19 | - 'blog' => [ | ||
| 20 | - 'class' => 'common\modules\blog\Module', | ||
| 21 | - ], | 19 | + |
| 22 | ], | 20 | ], |
| 23 | 'components' => [ | 21 | 'components' => [ |
| 24 | //'PageController'=>[ | 22 | //'PageController'=>[ |
frontend/controllers/OptionValuesController.php
| @@ -68,7 +68,7 @@ class OptionValuesController extends Controller | @@ -68,7 +68,7 @@ class OptionValuesController extends Controller | ||
| 68 | foreach($post['OptionValues']['option_value_text'] as $lang => $value) { | 68 | foreach($post['OptionValues']['option_value_text'] as $lang => $value) { |
| 69 | $models[$lang] = new OptionValues(); | 69 | $models[$lang] = new OptionValues(); |
| 70 | $models[$lang]->load(Yii::$app->request->post()); | 70 | $models[$lang]->load(Yii::$app->request->post()); |
| 71 | - $models[$lang]->option_lang_id = $lang; | 71 | + $models[$lang]->option_language_id = $lang; |
| 72 | $models[$lang]->option_value_text = $value; | 72 | $models[$lang]->option_value_text = $value; |
| 73 | if($first && $id) { | 73 | if($first && $id) { |
| 74 | $models[$lang]->option_value_parent = $id; | 74 | $models[$lang]->option_value_parent = $id; |
frontend/controllers/SiteController.php
| @@ -36,7 +36,7 @@ class SiteController extends Controller | @@ -36,7 +36,7 @@ class SiteController extends Controller | ||
| 36 | return [ | 36 | return [ |
| 37 | 'access' => [ | 37 | 'access' => [ |
| 38 | 'class' => AccessControl::className(), | 38 | 'class' => AccessControl::className(), |
| 39 | - 'only' => ['logout', 'signup'], | 39 | + 'only' => ['logout', 'signup', 'index'], |
| 40 | 'rules' => [ | 40 | 'rules' => [ |
| 41 | [ | 41 | [ |
| 42 | 'actions' => ['signup'], | 42 | 'actions' => ['signup'], |
| @@ -48,6 +48,11 @@ class SiteController extends Controller | @@ -48,6 +48,11 @@ class SiteController extends Controller | ||
| 48 | 'allow' => true, | 48 | 'allow' => true, |
| 49 | 'roles' => ['@'], | 49 | 'roles' => ['@'], |
| 50 | ], | 50 | ], |
| 51 | + [ | ||
| 52 | + 'actions' => ['index'], | ||
| 53 | + 'allow' => true, | ||
| 54 | + 'roles' => ['@'], | ||
| 55 | + ] | ||
| 51 | ], | 56 | ], |
| 52 | ], | 57 | ], |
| 53 | 'verbs' => [ | 58 | 'verbs' => [ |
| @@ -298,10 +303,10 @@ class SiteController extends Controller | @@ -298,10 +303,10 @@ class SiteController extends Controller | ||
| 298 | $option_values[$key] = new OptionValues(); | 303 | $option_values[$key] = new OptionValues(); |
| 299 | $option_values[$key]['option_value_id'] = $options_to_values[$key]->getAttribute('option_value_id'); | 304 | $option_values[$key]['option_value_id'] = $options_to_values[$key]->getAttribute('option_value_id'); |
| 300 | $option_values[$key]['option_value_text'] = $val['option_value']; | 305 | $option_values[$key]['option_value_text'] = $val['option_value']; |
| 301 | - if($options_to_values[$key]->option->getAttribute('option_translatable') == 0 || empty($val['option_lang_id'])) { | ||
| 302 | - $option_values[$key]['option_lang_id'] = 0; | 306 | + if($options_to_values[$key]->option->getAttribute('option_translatable') == 0 || empty($val['option_language_id'])) { |
| 307 | + $option_values[$key]['option_language_id'] = 0; | ||
| 303 | } else { | 308 | } else { |
| 304 | - $option_values[$key]['option_lang_id'] = $val['option_lang_id']; | 309 | + $option_values[$key]['option_language_id'] = $val['option_language_id']; |
| 305 | } | 310 | } |
| 306 | if(!$option_values[$key]->save()) { | 311 | if(!$option_values[$key]->save()) { |
| 307 | $options_to_values[$key]->delete(); | 312 | $options_to_values[$key]->delete(); |
frontend/models/Language.php
| @@ -61,6 +61,6 @@ class Language extends \yii\db\ActiveRecord | @@ -61,6 +61,6 @@ class Language extends \yii\db\ActiveRecord | ||
| 61 | */ | 61 | */ |
| 62 | public function getOptionValues() | 62 | public function getOptionValues() |
| 63 | { | 63 | { |
| 64 | - return $this->hasMany(OptionValues::className(), ['option_lang_id' => 'language_id']); | 64 | + return $this->hasMany(OptionValues::className(), ['option_language_id' => 'language_id']); |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
frontend/models/LanguageLang.php
| @@ -9,7 +9,7 @@ use Yii; | @@ -9,7 +9,7 @@ use Yii; | ||
| 9 | * | 9 | * |
| 10 | * @property integer $language_id | 10 | * @property integer $language_id |
| 11 | * @property string $lang_title | 11 | * @property string $lang_title |
| 12 | - * @property integer $lang_id | 12 | + * @property integer $language_id |
| 13 | * | 13 | * |
| 14 | * @property Language $language | 14 | * @property Language $language |
| 15 | */ | 15 | */ |
| @@ -43,7 +43,7 @@ class LanguageLang extends \yii\db\ActiveRecord | @@ -43,7 +43,7 @@ class LanguageLang extends \yii\db\ActiveRecord | ||
| 43 | return [ | 43 | return [ |
| 44 | 'language_id' => Yii::t('app', 'Language ID'), | 44 | 'language_id' => Yii::t('app', 'Language ID'), |
| 45 | 'lang_title' => Yii::t('app', 'Lang Title'), | 45 | 'lang_title' => Yii::t('app', 'Lang Title'), |
| 46 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 46 | + 'language_id' => Yii::t('app', 'Lang ID'), |
| 47 | ]; | 47 | ]; |
| 48 | } | 48 | } |
| 49 | 49 |
frontend/models/Option.php
| @@ -31,7 +31,7 @@ class Option extends \yii\db\ActiveRecord | @@ -31,7 +31,7 @@ class Option extends \yii\db\ActiveRecord | ||
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | [['model', 'model_id', 'name', 'template'], 'required'], | 33 | [['model', 'model_id', 'name', 'template'], 'required'], |
| 34 | - [['model_id', 'parent_id'], 'integer'], | 34 | + [['model_id', 'option_pid'], 'integer'], |
| 35 | [['model', 'name', 'template'], 'string', 'max' => 200] | 35 | [['model', 'name', 'template'], 'string', 'max' => 200] |
| 36 | ]; | 36 | ]; |
| 37 | } | 37 | } |
| @@ -47,29 +47,30 @@ class Option extends \yii\db\ActiveRecord | @@ -47,29 +47,30 @@ class Option extends \yii\db\ActiveRecord | ||
| 47 | 'model_id' => Yii::t('app', 'Model ID'), | 47 | 'model_id' => Yii::t('app', 'Model ID'), |
| 48 | 'name' => Yii::t('app', 'Name'), | 48 | 'name' => Yii::t('app', 'Name'), |
| 49 | 'template' => Yii::t('app', 'Template'), | 49 | 'template' => Yii::t('app', 'Template'), |
| 50 | - 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 51 | - 'created_at' => Yii::t('app', 'Date created'), | 50 | + 'option_pid' => Yii::t('app', 'Parent ID'), |
| 51 | + 'date_add' => Yii::t('app', 'Date created'), | ||
| 52 | + 'translate' => Yii::t('app', 'Translatable'), | ||
| 52 | ]; | 53 | ]; |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | public function getLangs() { | 56 | public function getLangs() { |
| 56 | - return (new Language())->find()->where(['>', 'language_id', 0])->andWhere(['active' => 1])->asArray()->all(); | 57 | + return (new Language())->find()->where(['>', 'language_id', 0])->andWhere(['status' => 1])->asArray()->all(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | public static function change($id, $post, $modeldb, $model_id) { | 60 | public static function change($id, $post, $modeldb, $model_id) { |
| 60 | $models[$id] = Option::findOne($id); | 61 | $models[$id] = Option::findOne($id); |
| 61 | $modellang[$id] = array(); | 62 | $modellang[$id] = array(); |
| 62 | - $langs = OptionLang::findAll(['id' => $id]); | 63 | + $langs = OptionLang::findAll(['option_language_id' => $id]); |
| 63 | foreach($langs as $lang) { | 64 | foreach($langs as $lang) { |
| 64 | - $modellang[$id][$lang->lang_id] = $lang; | 65 | + $modellang[$id][$lang->language_id] = $lang; |
| 65 | } | 66 | } |
| 66 | - $children = (new Option())->find()->where(['parent_id' => $id])->all(); | 67 | + $children = (new Option())->find()->where(['option_pid' => $id])->all(); |
| 67 | foreach($children as $child) { | 68 | foreach($children as $child) { |
| 68 | $models[$child->option_id] = $child; | 69 | $models[$child->option_id] = $child; |
| 69 | $modellang[$child->option_id] = array(); | 70 | $modellang[$child->option_id] = array(); |
| 70 | - $langs = OptionLang::findAll(['id' =>$child->option_id]); | 71 | + $langs = OptionLang::findAll(['option_id' =>$child->option_id]); |
| 71 | foreach($langs as $lang) { | 72 | foreach($langs as $lang) { |
| 72 | - $modellang[$child->option_id][$lang->lang_id] = $lang; | 73 | + $modellang[$child->option_id][$lang->language_id] = $lang; |
| 73 | } | 74 | } |
| 74 | } | 75 | } |
| 75 | $ok = 1; | 76 | $ok = 1; |
| @@ -77,7 +78,7 @@ class Option extends \yii\db\ActiveRecord | @@ -77,7 +78,7 @@ class Option extends \yii\db\ActiveRecord | ||
| 77 | foreach($post['Option'] as $key => $option) { | 78 | foreach($post['Option'] as $key => $option) { |
| 78 | if(in_array($key, array('model', 'model_id'))) { continue; } | 79 | if(in_array($key, array('model', 'model_id'))) { continue; } |
| 79 | if(empty($option['value'][$models[$key]->name]) && !empty($option['lang'])) { | 80 | if(empty($option['value'][$models[$key]->name]) && !empty($option['lang'])) { |
| 80 | - foreach($option['lang'] as $lang_id => $lang) { | 81 | + foreach($option['lang'] as $language_id => $lang) { |
| 81 | if(!empty($lang)) { | 82 | if(!empty($lang)) { |
| 82 | $option['value'][$models[$key]->name] = $lang; | 83 | $option['value'][$models[$key]->name] = $lang; |
| 83 | break; | 84 | break; |
| @@ -91,16 +92,16 @@ class Option extends \yii\db\ActiveRecord | @@ -91,16 +92,16 @@ class Option extends \yii\db\ActiveRecord | ||
| 91 | $modellang[$key][0]->addError('value', 'Value must be set'); | 92 | $modellang[$key][0]->addError('value', 'Value must be set'); |
| 92 | } | 93 | } |
| 93 | if(!empty($option['lang'])) { | 94 | if(!empty($option['lang'])) { |
| 94 | - foreach($option['lang'] as $lang_id => $lang) { | ||
| 95 | - if(empty($modellang[$key][$lang_id])) { | ||
| 96 | - $modellang[$key][$lang_id] = new OptionLang(); | ||
| 97 | - $modellang[$key][$lang_id]->id = $models[$key]->option_id; | ||
| 98 | - $modellang[$key][$lang_id]->lang_id = $lang_id; | ||
| 99 | - $modellang[$key][$lang_id]->value = $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; | ||
| 100 | } else { | 101 | } else { |
| 101 | - $modellang[$key][$lang_id]->value = $lang; | 102 | + $modellang[$key][$language_id]->value = $lang; |
| 102 | } | 103 | } |
| 103 | - if(!$modellang[$key][$lang_id]->save()) { | 104 | + if(!$modellang[$key][$language_id]->save()) { |
| 104 | $ok = 0; | 105 | $ok = 0; |
| 105 | } | 106 | } |
| 106 | } | 107 | } |
| @@ -146,7 +147,7 @@ class Option extends \yii\db\ActiveRecord | @@ -146,7 +147,7 @@ class Option extends \yii\db\ActiveRecord | ||
| 146 | $models[$index][$key]->translate = $option[$key]['translate']?1:0; | 147 | $models[$index][$key]->translate = $option[$key]['translate']?1:0; |
| 147 | $models[$index][$key]->name = $key; | 148 | $models[$index][$key]->name = $key; |
| 148 | if(!$first) { | 149 | if(!$first) { |
| 149 | - $models[$index][$key]->parent_id = $parentid; | 150 | + $models[$index][$key]->option_pid = $parentid; |
| 150 | } | 151 | } |
| 151 | $modelslang[$index][$key][0] = new OptionLang(); | 152 | $modelslang[$index][$key][0] = new OptionLang(); |
| 152 | if(!empty($option['lang'][$key])) { | 153 | if(!empty($option['lang'][$key])) { |
| @@ -161,16 +162,16 @@ class Option extends \yii\db\ActiveRecord | @@ -161,16 +162,16 @@ class Option extends \yii\db\ActiveRecord | ||
| 161 | if($first) { | 162 | if($first) { |
| 162 | $parentid = $models[$index][$key]->option_id; | 163 | $parentid = $models[$index][$key]->option_id; |
| 163 | } | 164 | } |
| 164 | - $modelslang[$index][$key][0]->id = $models[$index][$key]->option_id; | ||
| 165 | - $modelslang[$index][$key][0]->lang_id = 0; | 165 | + $modelslang[$index][$key][0]->option_id = $models[$index][$key]->option_id; |
| 166 | + $modelslang[$index][$key][0]->language_id = 0; | ||
| 166 | $modelslang[$index][$key][0]->value = $value; | 167 | $modelslang[$index][$key][0]->value = $value; |
| 167 | if($modelslang[$index][$key][0]->save()) { | 168 | if($modelslang[$index][$key][0]->save()) { |
| 168 | if(!empty($option['lang'][$key])) { | 169 | if(!empty($option['lang'][$key])) { |
| 169 | foreach($option['lang'][$key] as $code => $lang) { | 170 | foreach($option['lang'][$key] as $code => $lang) { |
| 170 | if(!empty($lang)) { | 171 | if(!empty($lang)) { |
| 171 | $modelslang[$index][$key][$code] = new OptionLang(); | 172 | $modelslang[$index][$key][$code] = new OptionLang(); |
| 172 | - $modelslang[$index][$key][$code]->id = $models[$index][$key]->option_id; | ||
| 173 | - $modelslang[$index][$key][$code]->lang_id = $code; | 173 | + $modelslang[$index][$key][$code]->option_id = $models[$index][$key]->option_id; |
| 174 | + $modelslang[$index][$key][$code]->language_id = $code; | ||
| 174 | $modelslang[$index][$key][$code]->value = $lang; | 175 | $modelslang[$index][$key][$code]->value = $lang; |
| 175 | if(!$modelslang[$index][$key][$code]->save()) { | 176 | if(!$modelslang[$index][$key][$code]->save()) { |
| 176 | $ok = 0; | 177 | $ok = 0; |
| @@ -187,8 +188,8 @@ class Option extends \yii\db\ActiveRecord | @@ -187,8 +188,8 @@ class Option extends \yii\db\ActiveRecord | ||
| 187 | foreach($option['lang'][$key] as $code => $lang) { | 188 | foreach($option['lang'][$key] as $code => $lang) { |
| 188 | if(!empty($lang)) { | 189 | if(!empty($lang)) { |
| 189 | $modelslang[$index][$key][$code] = new OptionLang(); | 190 | $modelslang[$index][$key][$code] = new OptionLang(); |
| 190 | - $modelslang[$index][$key][$code]->id = $models[$index][$key]->option_id; | ||
| 191 | - $modelslang[$index][$key][$code]->lang_id = $code; | 191 | + $modelslang[$index][$key][$code]->option_id = $models[$index][$key]->option_id; |
| 192 | + $modelslang[$index][$key][$code]->language_id = $code; | ||
| 192 | $modelslang[$index][$key][$code]->value = $lang; | 193 | $modelslang[$index][$key][$code]->value = $lang; |
| 193 | } | 194 | } |
| 194 | } | 195 | } |
| @@ -205,12 +206,12 @@ class Option extends \yii\db\ActiveRecord | @@ -205,12 +206,12 @@ class Option extends \yii\db\ActiveRecord | ||
| 205 | $newflag->model_id = $model_id; | 206 | $newflag->model_id = $model_id; |
| 206 | $newflag->name = 'is_new'; | 207 | $newflag->name = 'is_new'; |
| 207 | $newflag->template = 'checkbox'; | 208 | $newflag->template = 'checkbox'; |
| 208 | - $newflag->parent_id = $parentid; | 209 | + $newflag->option_pid = $parentid; |
| 209 | $newflag->translate = 0; | 210 | $newflag->translate = 0; |
| 210 | if($newflag->save()) { | 211 | if($newflag->save()) { |
| 211 | $newflaglang = new OptionLang(); | 212 | $newflaglang = new OptionLang(); |
| 212 | - $newflaglang->id = $newflag->option_id; | ||
| 213 | - $newflaglang->lang_id = 0; | 213 | + $newflaglang->option_id = $newflag->option_id; |
| 214 | + $newflaglang->language_id = 0; | ||
| 214 | $newflaglang->value = '1'; | 215 | $newflaglang->value = '1'; |
| 215 | if(!$newflaglang->save()) { | 216 | if(!$newflaglang->save()) { |
| 216 | $newflag->delete(); | 217 | $newflag->delete(); |
| @@ -242,19 +243,19 @@ class Option extends \yii\db\ActiveRecord | @@ -242,19 +243,19 @@ class Option extends \yii\db\ActiveRecord | ||
| 242 | } | 243 | } |
| 243 | 244 | ||
| 244 | public function getOptions() { | 245 | public function getOptions() { |
| 245 | - return $this->hasMany(Option::className(), ['parent_id' => 'option_id'])->indexBy('name'); | 246 | + return $this->hasMany(Option::className(), ['option_pid' => 'option_id'])->indexBy('name'); |
| 246 | } | 247 | } |
| 247 | 248 | ||
| 248 | public function getOption() { | 249 | public function getOption() { |
| 249 | - return $this->hasOne(Option::className(), ['option_id' => 'parent_id']); | 250 | + return $this->hasOne(Option::className(), ['option_id' => 'option_pid']); |
| 250 | } | 251 | } |
| 251 | 252 | ||
| 252 | public function getOptionLangs() { | 253 | public function getOptionLangs() { |
| 253 | - return $this->hasMany(OptionLang::className(), ['id' => 'option_id']); | 254 | + return $this->hasMany(OptionLang::className(), ['option_id' => 'option_id']); |
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | public function getOptionDefaultLang($array = false) { | 257 | public function getOptionDefaultLang($array = false) { |
| 257 | - $query = $this->getOptionLangs()->where(['lang_id' => 0]); | 258 | + $query = $this->getOptionLangs()->where(['language_id' => 0]); |
| 258 | if($array) { | 259 | if($array) { |
| 259 | $query->asArray(); | 260 | $query->asArray(); |
| 260 | } | 261 | } |
frontend/models/OptionLang.php
| @@ -8,7 +8,7 @@ use Yii; | @@ -8,7 +8,7 @@ use Yii; | ||
| 8 | * This is the model class for table "option_lang". | 8 | * This is the model class for table "option_lang". |
| 9 | * | 9 | * |
| 10 | * @property integer $id | 10 | * @property integer $id |
| 11 | - * @property integer $lang_id | 11 | + * @property integer $language_id |
| 12 | * @property string $value | 12 | * @property string $value |
| 13 | */ | 13 | */ |
| 14 | class OptionLang extends \yii\db\ActiveRecord | 14 | class OptionLang extends \yii\db\ActiveRecord |
| @@ -27,8 +27,8 @@ class OptionLang extends \yii\db\ActiveRecord | @@ -27,8 +27,8 @@ class OptionLang extends \yii\db\ActiveRecord | ||
| 27 | public function rules() | 27 | public function rules() |
| 28 | { | 28 | { |
| 29 | return [ | 29 | return [ |
| 30 | - [['id', 'lang_id'], 'required'], | ||
| 31 | - [['id', 'lang_id'], 'integer'], | 30 | + [['option_id', 'language_id'], 'required'], |
| 31 | + [['option_id', 'language_id'], 'integer'], | ||
| 32 | [['value'], 'string'] | 32 | [['value'], 'string'] |
| 33 | ]; | 33 | ]; |
| 34 | } | 34 | } |
| @@ -39,8 +39,8 @@ class OptionLang extends \yii\db\ActiveRecord | @@ -39,8 +39,8 @@ class OptionLang extends \yii\db\ActiveRecord | ||
| 39 | public function attributeLabels() | 39 | public function attributeLabels() |
| 40 | { | 40 | { |
| 41 | return [ | 41 | return [ |
| 42 | - 'id' => Yii::t('app', 'ID'), | ||
| 43 | - 'lang_id' => Yii::t('app', 'Lang ID'), | 42 | + 'option_id' => Yii::t('app', 'ID'), |
| 43 | + 'language_id' => Yii::t('app', 'Lang ID'), | ||
| 44 | 'value' => Yii::t('app', 'Value'), | 44 | 'value' => Yii::t('app', 'Value'), |
| 45 | ]; | 45 | ]; |
| 46 | } | 46 | } |
frontend/models/OptionLangSearch.php
| @@ -18,7 +18,7 @@ class OptionLangSearch extends OptionLang | @@ -18,7 +18,7 @@ class OptionLangSearch extends OptionLang | ||
| 18 | public function rules() | 18 | public function rules() |
| 19 | { | 19 | { |
| 20 | return [ | 20 | return [ |
| 21 | - [['primary', 'id', 'lang_id'], 'integer'], | 21 | + [['option_language_id', 'option_id', 'language_id'], 'integer'], |
| 22 | [['value'], 'safe'], | 22 | [['value'], 'safe'], |
| 23 | ]; | 23 | ]; |
| 24 | } | 24 | } |
| @@ -56,9 +56,9 @@ class OptionLangSearch extends OptionLang | @@ -56,9 +56,9 @@ class OptionLangSearch extends OptionLang | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | $query->andFilterWhere([ | 58 | $query->andFilterWhere([ |
| 59 | - 'primary' => $this->primary, | ||
| 60 | - 'id' => $this->id, | ||
| 61 | - 'lang_id' => $this->lang_id, | 59 | + 'option_language_id' => $this->option_language_id, |
| 60 | + 'option_id' => $this->option_id, | ||
| 61 | + 'language_id' => $this->language_id, | ||
| 62 | ]); | 62 | ]); |
| 63 | 63 | ||
| 64 | $query->andFilterWhere(['like', 'value', $this->value]); | 64 | $query->andFilterWhere(['like', 'value', $this->value]); |
frontend/models/OptionSearch.php
| @@ -18,7 +18,7 @@ class OptionSearch extends Option | @@ -18,7 +18,7 @@ class OptionSearch extends Option | ||
| 18 | public function rules() | 18 | public function rules() |
| 19 | { | 19 | { |
| 20 | return [ | 20 | return [ |
| 21 | - [['option_id', 'model_id', 'parent_id'], 'integer'], | 21 | + [['option_id', 'model_id', 'option_pid'], 'integer'], |
| 22 | [['model', 'name', 'template'], 'safe'], | 22 | [['model', 'name', 'template'], 'safe'], |
| 23 | ]; | 23 | ]; |
| 24 | } | 24 | } |
| @@ -60,12 +60,12 @@ class OptionSearch extends Option | @@ -60,12 +60,12 @@ class OptionSearch extends Option | ||
| 60 | return $dataProvider; | 60 | return $dataProvider; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | - $query->andWhere(['parent_id' => null]); | 63 | + $query->andWhere(['option_pid' => null]); |
| 64 | 64 | ||
| 65 | $query->andFilterWhere([ | 65 | $query->andFilterWhere([ |
| 66 | 'option_id' => $this->option_id, | 66 | 'option_id' => $this->option_id, |
| 67 | 'model_id' => $this->model_id, | 67 | 'model_id' => $this->model_id, |
| 68 | - 'parent_id' => $this->parent_id, | 68 | + 'option_pid' => $this->option_pid, |
| 69 | ]); | 69 | ]); |
| 70 | 70 | ||
| 71 | $query->andFilterWhere(['like', 'model', $this->model]) | 71 | $query->andFilterWhere(['like', 'model', $this->model]) |
frontend/models/OptionValues.php
| @@ -10,7 +10,7 @@ use Yii; | @@ -10,7 +10,7 @@ use Yii; | ||
| 10 | * @property integer $option_value_id | 10 | * @property integer $option_value_id |
| 11 | * @property string $option_key | 11 | * @property string $option_key |
| 12 | * @property string $option_value_text | 12 | * @property string $option_value_text |
| 13 | - * @property integer $option_lang_id | 13 | + * @property integer $option_language_id |
| 14 | * @property integer $option_value_parent | 14 | * @property integer $option_value_parent |
| 15 | * @property integer $option_user | 15 | * @property integer $option_user |
| 16 | * | 16 | * |
| @@ -33,7 +33,7 @@ class OptionValues extends \yii\db\ActiveRecord | @@ -33,7 +33,7 @@ class OptionValues extends \yii\db\ActiveRecord | ||
| 33 | { | 33 | { |
| 34 | return [ | 34 | return [ |
| 35 | [['option_key', 'option_value_text'], 'required'], | 35 | [['option_key', 'option_value_text'], 'required'], |
| 36 | - [['option_lang_id', 'option_value_parent', 'option_user'], 'integer'], | 36 | + [['option_language_id', 'option_value_parent', 'option_user'], 'integer'], |
| 37 | [['option_key'], 'string', 'max' => 200] | 37 | [['option_key'], 'string', 'max' => 200] |
| 38 | ]; | 38 | ]; |
| 39 | } | 39 | } |
| @@ -47,7 +47,7 @@ class OptionValues extends \yii\db\ActiveRecord | @@ -47,7 +47,7 @@ class OptionValues extends \yii\db\ActiveRecord | ||
| 47 | 'option_value_id' => Yii::t('app', 'Option Value ID'), | 47 | 'option_value_id' => Yii::t('app', 'Option Value ID'), |
| 48 | 'option_key' => Yii::t('app', 'Option Key'), | 48 | 'option_key' => Yii::t('app', 'Option Key'), |
| 49 | 'option_value_text' => Yii::t('app', 'Option Value Text'), | 49 | 'option_value_text' => Yii::t('app', 'Option Value Text'), |
| 50 | - 'option_lang_id' => Yii::t('app', 'Option Lang ID'), | 50 | + 'option_language_id' => Yii::t('app', 'Option Lang ID'), |
| 51 | 'option_value_parent' => Yii::t('app', 'Option Value Parent'), | 51 | 'option_value_parent' => Yii::t('app', 'Option Value Parent'), |
| 52 | 'option_user' => Yii::t('app', 'Option User'), | 52 | 'option_user' => Yii::t('app', 'Option User'), |
| 53 | ]; | 53 | ]; |
| @@ -58,7 +58,7 @@ class OptionValues extends \yii\db\ActiveRecord | @@ -58,7 +58,7 @@ class OptionValues extends \yii\db\ActiveRecord | ||
| 58 | */ | 58 | */ |
| 59 | public function getOptionLang() | 59 | public function getOptionLang() |
| 60 | { | 60 | { |
| 61 | - return $this->hasOne(Language::className(), ['language_id' => 'option_lang_id']); | 61 | + return $this->hasOne(Language::className(), ['language_id' => 'option_language_id']); |
| 62 | } | 62 | } |
| 63 | public function getLanguages() { | 63 | public function getLanguages() { |
| 64 | return (new LanguageLang())->find()->orderBy('language_id ASC')->asArray()->all(); | 64 | return (new LanguageLang())->find()->orderBy('language_id ASC')->asArray()->all(); |
frontend/models/OptionValuesSearch.php
| @@ -18,7 +18,7 @@ class OptionValuesSearch extends OptionValues | @@ -18,7 +18,7 @@ class OptionValuesSearch extends OptionValues | ||
| 18 | public function rules() | 18 | public function rules() |
| 19 | { | 19 | { |
| 20 | return [ | 20 | return [ |
| 21 | - [['option_value_id', 'option_lang_id', 'option_value_parent', 'option_user'], 'integer'], | 21 | + [['option_value_id', 'option_language_id', 'option_value_parent', 'option_user'], 'integer'], |
| 22 | [['option_key', 'option_value_text'], 'safe'], | 22 | [['option_key', 'option_value_text'], 'safe'], |
| 23 | ]; | 23 | ]; |
| 24 | } | 24 | } |
| @@ -57,7 +57,7 @@ class OptionValuesSearch extends OptionValues | @@ -57,7 +57,7 @@ class OptionValuesSearch extends OptionValues | ||
| 57 | 57 | ||
| 58 | $query->andFilterWhere([ | 58 | $query->andFilterWhere([ |
| 59 | 'option_value_id' => $this->option_value_id, | 59 | 'option_value_id' => $this->option_value_id, |
| 60 | - 'option_lang_id' => $this->option_lang_id, | 60 | + 'option_language_id' => $this->option_language_id, |
| 61 | 'option_value_parent' => $this->option_value_parent, | 61 | 'option_value_parent' => $this->option_value_parent, |
| 62 | 'option_user' => $this->option_user, | 62 | 'option_user' => $this->option_user, |
| 63 | ]); | 63 | ]); |
frontend/views/option-values/_form.php
| @@ -17,7 +17,7 @@ use yii\widgets\ActiveForm; | @@ -17,7 +17,7 @@ use yii\widgets\ActiveForm; | ||
| 17 | <div class="optionvalues-option_value_text-active"> | 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() ?> | 18 | <?= $form->field($model, 'option_value_text', ['enableClientValidation' => false])->label($model->getAttributeLabel('option_key').' | <span class="glyphicon glyphicon-globe add-langs"></span>')->textInput() ?> |
| 19 | 19 | ||
| 20 | - <?= $form->field($model, 'option_lang_id')->dropDownList($model->getDropDownArray()) ?> | 20 | + <?= $form->field($model, 'option_language_id')->dropDownList($model->getDropDownArray()) ?> |
| 21 | </div> | 21 | </div> |
| 22 | 22 | ||
| 23 | <?= $form->field($model, 'option_value_parent')->dropDownList($model->getUserOptionsArray()) ?> | 23 | <?= $form->field($model, 'option_value_parent')->dropDownList($model->getUserOptionsArray()) ?> |
| @@ -46,7 +46,7 @@ use yii\widgets\ActiveForm; | @@ -46,7 +46,7 @@ use yii\widgets\ActiveForm; | ||
| 46 | $(document).on('click', '.add-langs', function() { | 46 | $(document).on('click', '.add-langs', function() { |
| 47 | var group = $(this).parent().attr('for'); | 47 | var group = $(this).parent().attr('for'); |
| 48 | $(this).parent().parent().appendTo('.reserved_inputs'); | 48 | $(this).parent().parent().appendTo('.reserved_inputs'); |
| 49 | - $('.field-optionvalues-option_lang_id').appendTo('.reserved_inputs'); | 49 | + $('.field-optionvalues-option_language_id').appendTo('.reserved_inputs'); |
| 50 | $('.'+group+'-lang').appendTo('.'+group+'-active'); | 50 | $('.'+group+'-lang').appendTo('.'+group+'-active'); |
| 51 | }); | 51 | }); |
| 52 | $(document).on('click', '.remove-langs', function() { | 52 | $(document).on('click', '.remove-langs', function() { |
| @@ -54,7 +54,7 @@ use yii\widgets\ActiveForm; | @@ -54,7 +54,7 @@ use yii\widgets\ActiveForm; | ||
| 54 | $(this).parent().parent().appendTo('.reserved_inputs'); | 54 | $(this).parent().parent().appendTo('.reserved_inputs'); |
| 55 | console.log('field-'+group); | 55 | console.log('field-'+group); |
| 56 | $('.reserved_inputs .field-'+group).appendTo('.'+group+'-active'); | 56 | $('.reserved_inputs .field-'+group).appendTo('.'+group+'-active'); |
| 57 | - $('.field-optionvalues-option_lang_id').appendTo('.'+group+'-active'); | 57 | + $('.field-optionvalues-option_language_id').appendTo('.'+group+'-active'); |
| 58 | }); | 58 | }); |
| 59 | }); | 59 | }); |
| 60 | </script> | 60 | </script> |
| 61 | \ No newline at end of file | 61 | \ No newline at end of file |
frontend/views/option-values/_search.php
| @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | ||
| 21 | 21 | ||
| 22 | <?= $form->field($model, 'option_value_text') ?> | 22 | <?= $form->field($model, 'option_value_text') ?> |
| 23 | 23 | ||
| 24 | - <?= $form->field($model, 'option_lang_id') ?> | 24 | + <?= $form->field($model, 'option_language_id') ?> |
| 25 | 25 | ||
| 26 | <?= $form->field($model, 'option_value_parent') ?> | 26 | <?= $form->field($model, 'option_value_parent') ?> |
| 27 | 27 |
frontend/views/option-values/index.php
| @@ -28,7 +28,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -28,7 +28,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 28 | 'option_value_id', | 28 | 'option_value_id', |
| 29 | 'option_key', | 29 | 'option_key', |
| 30 | 'option_value_text:ntext', | 30 | 'option_value_text:ntext', |
| 31 | - 'option_lang_id', | 31 | + 'option_language_id', |
| 32 | 'option_value_parent', | 32 | 'option_value_parent', |
| 33 | // 'option_user', | 33 | // 'option_user', |
| 34 | 34 |
frontend/views/option-values/view.php
| @@ -31,7 +31,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -31,7 +31,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 31 | 'option_value_id', | 31 | 'option_value_id', |
| 32 | 'option_key', | 32 | 'option_key', |
| 33 | 'option_value_text:ntext', | 33 | 'option_value_text:ntext', |
| 34 | - 'option_lang_id', | 34 | + 'option_language_id', |
| 35 | 'option_value_parent', | 35 | 'option_value_parent', |
| 36 | 'option_user', | 36 | 'option_user', |
| 37 | ], | 37 | ], |
frontend/views/option/_form_edit.php
| @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm; | ||
| 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 | if($row->translate) { | 23 | if($row->translate) { |
| 24 | - foreach($row->getLangs() as $lang_id => $lang) { | 24 | + foreach($row->getLangs() as $language_id => $lang) { |
| 25 | ?> | 25 | ?> |
| 26 | <div class="form-group"> | 26 | <div class="form-group"> |
| 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> | 27 | <div class="col-xs-1"><?=$lang['lang_code']?></div> |
frontend/web/images/upload/0ba9d6a23ce996f8f6894545721a9417ZKA-O/original.jpg
0 → 100644
80.2 KB
frontend/web/images/upload/1882770d9bde9932666c75b63da8a55bA5OLs/original.jpg
0 → 100644
90 KB
frontend/web/images/upload/1882770d9bde9932666c75b63da8a55bAGkF2/original.jpg
0 → 100644
90 KB
frontend/web/images/upload/1882770d9bde9932666c75b63da8a55bNqFYc/original.jpg
0 → 100644
90 KB
frontend/web/images/upload/1882770d9bde9932666c75b63da8a55bcdvDU/original.jpg
0 → 100644
90 KB
frontend/web/images/upload/2d5d104fda828bd7122f1372ffe941cdM1XGy/original.jpg
0 → 100644
95.8 KB
frontend/web/images/upload/2d5d104fda828bd7122f1372ffe941cdMO2On/original.jpg
0 → 100644
95.8 KB
frontend/web/images/upload/416becfedaed921abc6ca696e2ff51dbIxY64/original.jpg
0 → 100644
122 KB
frontend/web/images/upload/416becfedaed921abc6ca696e2ff51dbNCozs/original.jpg
0 → 100644
122 KB
frontend/web/images/upload/5ee447f553cd4b615e0107772e72469ccmchQ/original.jpg
0 → 100644
45.3 KB
frontend/web/images/upload/68ea5e978068f52504ba9f2f10a3eca8Nj3zD/original.jpg
0 → 100644
46.1 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71-NXzA/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f717ntFu/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71O4IC7/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71Qkhxq/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71iN0HJ/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71r-uW4/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7b3166bbb0497ab11649b502f98a9f71v4k-p/original.jpg
0 → 100644
77.3 KB
frontend/web/images/upload/7c0beac302dbe743c2fec948bd232d7dFPPuQ/original.jpg
0 → 100644
14.9 KB
frontend/web/images/upload/7da01e1c36c2ddb3140557dc087012510LVuC/original.jpg
0 → 100644
55 KB
frontend/web/images/upload/954377695246c868d41932f4d4ad6bdc4H6Sa/original.jpg
0 → 100644
142 KB
frontend/web/images/upload/954377695246c868d41932f4d4ad6bdcYQ6Gt/original.jpg
0 → 100644
142 KB
frontend/web/images/upload/998f255851230d82d29c7a218cfdb104AsZKg/original.png
0 → 100644
214 KB
frontend/web/images/upload/998f255851230d82d29c7a218cfdb104oT-cN/original.png
0 → 100644
214 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e0853tHa/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e085W3TX/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e086mNnr/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e089XVmJ/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08HLPep/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08HlucN/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08K3ZX-/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08O4h7I/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08Ru9T4/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08Vr17d/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08aHlil/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08ajC__/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08eTlWW/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08f_eyp/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08kGamn/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08pgbJ2/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08twxWX/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/b8d32a4542d55ba60684bb1c2d486e08xitCT/original.jpg
0 → 100644
51.7 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67HOooH/original.jpg
0 → 100644
21.4 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67IJ5q7/original.jpg
0 → 100644
21.4 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67JnlT_/original.jpg
0 → 100644
21.4 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67VrxQl/original.jpg
0 → 100644
21.4 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67dgBqI/original.jpg
0 → 100644
21.4 KB
frontend/web/images/upload/bcdc328db35813ea7b1a4b85a71def67qv-lM/original.jpg
0 → 100644
21.4 KB
frontend/web/js/option.js
| @@ -12,6 +12,12 @@ function readURL(input) { | @@ -12,6 +12,12 @@ function readURL(input) { | ||
| 12 | } | 12 | } |
| 13 | return urls; | 13 | return urls; |
| 14 | } | 14 | } |
| 15 | +function checkboxerInit() { | ||
| 16 | + $.each($('.checkboxer input[type=radio]:checked'), function(index, value) { | ||
| 17 | + console.log(value); | ||
| 18 | + $(value).trigger('change'); | ||
| 19 | + }); | ||
| 20 | +} | ||
| 15 | $(function() { | 21 | $(function() { |
| 16 | var counter = 0; | 22 | var counter = 0; |
| 17 | $(document).on('click', '.add_row', function() { | 23 | $(document).on('click', '.add_row', function() { |
| @@ -58,12 +64,35 @@ $(function() { | @@ -58,12 +64,35 @@ $(function() { | ||
| 58 | $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); | 64 | $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>'); |
| 59 | } | 65 | } |
| 60 | }); | 66 | }); |
| 61 | - $(document).on('click', '.dropdown-menu.f32 li a[data-lang]', function() { | 67 | + $(document).on('click', '.dropdown-menu.f32:not(.old) li a[data-lang]', function() { |
| 68 | + var lang = $(this).data('lang'); | ||
| 69 | + var flag = $(this).find('span').first().clone(); | ||
| 70 | + var el = $(this); | ||
| 71 | + var id = $(this).attr('href').substr(1); | ||
| 72 | + var path = form[id].handler; | ||
| 73 | + var view = form[id].view; | ||
| 74 | + var model = form[id].model; | ||
| 75 | + $.get(path, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) { | ||
| 76 | + $('#'+id+'-tabs li').removeClass('active'); | ||
| 77 | + $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | ||
| 78 | + $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | ||
| 79 | + $('#tab-content-'+id).append($(data).find('.ajax-loaded').first()); | ||
| 80 | + $('body').append($(data).filter('script')); | ||
| 81 | + $(el).parent().remove(); | ||
| 82 | + if(!$('#lang-'+id+' li').length) { | ||
| 83 | + $('#'+id+'Lang').addClass('disabled'); | ||
| 84 | + } | ||
| 85 | + if($('#'+id+'-tabs li').length > 1) { | ||
| 86 | + $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>') | ||
| 87 | + } | ||
| 88 | + }); | ||
| 89 | + }); | ||
| 90 | + $(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function() { | ||
| 62 | var lang = $(this).data('lang'); | 91 | var lang = $(this).data('lang'); |
| 63 | var flag = $(this).find('span').first().clone(); | 92 | var flag = $(this).find('span').first().clone(); |
| 64 | var el = $(this); | 93 | var el = $(this); |
| 65 | var id = $(this).attr('href').substr(1); | 94 | var id = $(this).attr('href').substr(1); |
| 66 | - $.get(form[id], { lang_id: lang, widget_id: id }, function(data) { | 95 | + $.get(form[id], { language_id: lang, widget_id: id }, function(data) { |
| 67 | $('#'+id+'-tabs li').removeClass('active'); | 96 | $('#'+id+'-tabs li').removeClass('active'); |
| 68 | $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); | 97 | $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>'); |
| 69 | $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); | 98 | $('#tab-content-'+id+' .tab-pane.active').removeClass('active'); |
| @@ -93,4 +122,13 @@ $(function() { | @@ -93,4 +122,13 @@ $(function() { | ||
| 93 | $('#'+id+'-tabs>li').first().find('a').tab('show'); | 122 | $('#'+id+'-tabs>li').first().find('a').tab('show'); |
| 94 | } | 123 | } |
| 95 | }); | 124 | }); |
| 125 | + $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() { | ||
| 126 | + console.log($(this).val()); | ||
| 127 | + $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); | ||
| 128 | + $(this).parents('.checkboxer_container').addClass('active'); | ||
| 129 | + }); | ||
| 130 | + $.each($('.f32'), function(i, val) { | ||
| 131 | + $(val).find('a[role=tab]').first().trigger('click'); | ||
| 132 | + }); | ||
| 133 | + checkboxerInit(); | ||
| 96 | }); | 134 | }); |
| 97 | \ No newline at end of file | 135 | \ No newline at end of file |