Commit e3105834f75a6ef4b2a9de2853745d4dd53e0d1c
1 parent
172683d7
Стандартизация
Showing
42 changed files
with
575 additions
and
356 deletions
Show diff stats
backend/controllers/AdminMenuController.php
| @@ -64,7 +64,7 @@ class AdminMenuController extends Controller | @@ -64,7 +64,7 @@ class AdminMenuController extends Controller | ||
| 64 | { | 64 | { |
| 65 | $model = new AdminMenu(); | 65 | $model = new AdminMenu(); |
| 66 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 66 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 67 | - return $this->redirect(['view', 'id' => $model->id]); | 67 | + return $this->redirect(['view', 'id' => $model->admin_menu_id]); |
| 68 | } else { | 68 | } else { |
| 69 | return $this->render('create', [ | 69 | return $this->render('create', [ |
| 70 | 'model' => $model, | 70 | 'model' => $model, |
| @@ -83,7 +83,7 @@ class AdminMenuController extends Controller | @@ -83,7 +83,7 @@ class AdminMenuController extends Controller | ||
| 83 | $model = $this->findModel($id); | 83 | $model = $this->findModel($id); |
| 84 | 84 | ||
| 85 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 85 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 86 | - return $this->redirect(['view', 'id' => $model->id]); | 86 | + return $this->redirect(['view', 'id' => $model->adminmenu_id]); |
| 87 | } else { | 87 | } else { |
| 88 | return $this->render('update', [ | 88 | return $this->render('update', [ |
| 89 | 'model' => $model, | 89 | 'model' => $model, |
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_lang_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_lang_id' => $id]); |
| 167 | foreach($langs as $lang) { | 167 | foreach($langs as $lang) { |
| 168 | $lang->delete(); | 168 | $lang->delete(); |
| 169 | } | 169 | } |
backend/models/AdminMenu.php
| @@ -7,14 +7,14 @@ use Yii; | @@ -7,14 +7,14 @@ use Yii; | ||
| 7 | /** | 7 | /** |
| 8 | * This is the model class for table "admin_menu". | 8 | * This is the model class for table "admin_menu". |
| 9 | * | 9 | * |
| 10 | - * @property integer $id | ||
| 11 | - * @property integer $parent_id | ||
| 12 | - * @property integer $active | 10 | + * @property integer $admin_menu_id |
| 11 | + * @property integer $admin_menu_pid | ||
| 12 | + * @property integer $status | ||
| 13 | * @property integer $hide_min | 13 | * @property integer $hide_min |
| 14 | * @property integer $sort | 14 | * @property integer $sort |
| 15 | * @property string $name | 15 | * @property string $name |
| 16 | * @property string $path | 16 | * @property string $path |
| 17 | - * @property string $params | 17 | + * @property string $param |
| 18 | * | 18 | * |
| 19 | * @property AdminMenu $parent | 19 | * @property AdminMenu $parent |
| 20 | * @property AdminMenu[] $adminMenus | 20 | * @property AdminMenu[] $adminMenus |
| @@ -39,9 +39,9 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -39,9 +39,9 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 39 | public function rules() | 39 | public function rules() |
| 40 | { | 40 | { |
| 41 | return [ | 41 | return [ |
| 42 | - [['parent_id', 'active', 'hide_min', 'sort'], 'integer'], | 42 | + [['admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'], |
| 43 | [['name'], 'required'], | 43 | [['name'], 'required'], |
| 44 | - [['name', 'path', 'params','parentt'], 'string'] | 44 | + [['name', 'path', 'param','parentt'], 'string'] |
| 45 | ]; | 45 | ]; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| @@ -51,14 +51,14 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -51,14 +51,14 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 51 | public function attributeLabels() | 51 | public function attributeLabels() |
| 52 | { | 52 | { |
| 53 | return [ | 53 | return [ |
| 54 | - 'id' => Yii::t('app', 'ID'), | ||
| 55 | - 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 56 | - 'active' => Yii::t('app', 'Active'), | 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'), | 57 | 'hide_min' => Yii::t('app', 'Hide Min'), |
| 58 | 'sort' => Yii::t('app', 'Sort'), | 58 | 'sort' => Yii::t('app', 'Sort'), |
| 59 | 'name' => Yii::t('app', 'Name'), | 59 | 'name' => Yii::t('app', 'Name'), |
| 60 | 'path' => Yii::t('app', 'Path'), | 60 | 'path' => Yii::t('app', 'Path'), |
| 61 | - 'params' => Yii::t('app', 'Params'), | 61 | + 'param' => Yii::t('app', 'Params'), |
| 62 | 'parentt' => Yii::t('app', 'Parent item') | 62 | 'parentt' => Yii::t('app', 'Parent item') |
| 63 | ]; | 63 | ]; |
| 64 | } | 64 | } |
| @@ -68,7 +68,7 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -68,7 +68,7 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 68 | */ | 68 | */ |
| 69 | public function getParent() | 69 | public function getParent() |
| 70 | { | 70 | { |
| 71 | - return $this->hasOne(AdminMenu::className(), ['id' => 'parent_id']); | 71 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_pid']); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /** | 74 | /** |
| @@ -76,7 +76,7 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -76,7 +76,7 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 76 | */ | 76 | */ |
| 77 | public function getAdminMenus() | 77 | public function getAdminMenus() |
| 78 | { | 78 | { |
| 79 | - return $this->hasMany(AdminMenu::className(), ['parent_id' => 'id']); | 79 | + return $this->hasMany(AdminMenu::className(), ['admin_menu_pid' => 'admin_menu_id']); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| @@ -84,7 +84,7 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -84,7 +84,7 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 84 | */ | 84 | */ |
| 85 | public function getAdminMenuAccessGroups() | 85 | public function getAdminMenuAccessGroups() |
| 86 | { | 86 | { |
| 87 | - return $this->hasMany(AdminMenuAccessGroup::className(), ['menu_id' => 'id']); | 87 | + return $this->hasMany(AdminMenuAccessGroup::className(), ['admin_menu_id' => 'admin_menu_id']); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | /** | 90 | /** |
| @@ -92,26 +92,26 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -92,26 +92,26 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 92 | */ | 92 | */ |
| 93 | public function getAdminMenuAccessUsers() | 93 | public function getAdminMenuAccessUsers() |
| 94 | { | 94 | { |
| 95 | - return $this->hasMany(AdminMenuAccessUser::className(), ['menu_id' => 'id']); | 95 | + return $this->hasMany(AdminMenuAccessUser::className(), ['admin_menu_id' => 'admin_menu_id']); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | public static function buildMenu($withValues = false) | 98 | public static function buildMenu($withValues = false) |
| 99 | { | 99 | { |
| 100 | $result = []; | 100 | $result = []; |
| 101 | - $roots = self::find()->where(['parent_id' => NULL])->with(['adminMenus'])->all(); | 101 | + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all(); |
| 102 | foreach($roots as $root) { | 102 | foreach($roots as $root) { |
| 103 | if($root->adminMenus) { | 103 | if($root->adminMenus) { |
| 104 | - $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id, 'options' => ['class' => 'header']]; | 104 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'options' => ['class' => 'header']]; |
| 105 | foreach($root->adminMenus as $submenu) { | 105 | foreach($root->adminMenus as $submenu) { |
| 106 | if($submenu->adminMenus) { | 106 | if($submenu->adminMenus) { |
| 107 | $items = []; | 107 | $items = []; |
| 108 | foreach($submenu->adminMenus as $item) { | 108 | foreach($submenu->adminMenus as $item) { |
| 109 | - $items[] = ['label' => Yii::t('app', $item->name), 'id' => $item->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$item->path], \common\models\Tools::parseUrlParams($item->params))]; | 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 | } | 110 | } |
| 111 | - $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items]; | 111 | + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items]; |
| 112 | unset($items); | 112 | unset($items); |
| 113 | } else { | 113 | } else { |
| 114 | - $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->params))]; | 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 | } | 115 | } |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| @@ -122,17 +122,17 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -122,17 +122,17 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 122 | public static function buildMenuSelect() | 122 | public static function buildMenuSelect() |
| 123 | { | 123 | { |
| 124 | $result = []; | 124 | $result = []; |
| 125 | - $roots = self::find()->where(['parent_id' => NULL])->with(['adminMenus'])->all(); | 125 | + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all(); |
| 126 | foreach($roots as $root) { | 126 | foreach($roots as $root) { |
| 127 | if($root->adminMenus) { | 127 | if($root->adminMenus) { |
| 128 | $items = []; | 128 | $items = []; |
| 129 | foreach($root->adminMenus as $submenu) { | 129 | foreach($root->adminMenus as $submenu) { |
| 130 | - $items[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id]; | 130 | + $items[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id]; |
| 131 | } | 131 | } |
| 132 | - $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id, 'items' => $items]; | 132 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'items' => $items]; |
| 133 | unset($items); | 133 | unset($items); |
| 134 | } else { | 134 | } else { |
| 135 | - $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id]; | 135 | + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id]; |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | return $result; | 138 | return $result; |
| @@ -141,8 +141,8 @@ class AdminMenu extends \yii\db\ActiveRecord | @@ -141,8 +141,8 @@ class AdminMenu extends \yii\db\ActiveRecord | ||
| 141 | public function beforeSave($insert) | 141 | public function beforeSave($insert) |
| 142 | { | 142 | { |
| 143 | if (parent::beforeSave($insert)) { | 143 | if (parent::beforeSave($insert)) { |
| 144 | - if(!$this->parent_id) { | ||
| 145 | - $this->parent_id = NULL; | 144 | + if(!$this->admin_menu_pid) { |
| 145 | + $this->admin_menu_pid = NULL; | ||
| 146 | } | 146 | } |
| 147 | return true; | 147 | return true; |
| 148 | } else { | 148 | } else { |
backend/models/AdminMenuAccessGroup.php
| @@ -7,8 +7,8 @@ use Yii; | @@ -7,8 +7,8 @@ use Yii; | ||
| 7 | /** | 7 | /** |
| 8 | * This is the model class for table "admin_menu_access_group". | 8 | * This is the model class for table "admin_menu_access_group". |
| 9 | * | 9 | * |
| 10 | - * @property integer $id | ||
| 11 | - * @property integer $menu_id | 10 | + * @property integer $admin_menu_access_group_id |
| 11 | + * @property integer $admin_menu_id | ||
| 12 | * @property string $group | 12 | * @property string $group |
| 13 | * | 13 | * |
| 14 | * @property AdminMenu $menu | 14 | * @property AdminMenu $menu |
| @@ -30,7 +30,7 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | @@ -30,7 +30,7 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | ||
| 30 | public function rules() | 30 | public function rules() |
| 31 | { | 31 | { |
| 32 | return [ | 32 | return [ |
| 33 | - [['menu_id'], 'integer'], | 33 | + [['admin_menu_id'], 'integer'], |
| 34 | [['group'], 'string'] | 34 | [['group'], 'string'] |
| 35 | ]; | 35 | ]; |
| 36 | } | 36 | } |
| @@ -41,8 +41,8 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | @@ -41,8 +41,8 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | ||
| 41 | public function attributeLabels() | 41 | public function attributeLabels() |
| 42 | { | 42 | { |
| 43 | return [ | 43 | return [ |
| 44 | - 'id' => Yii::t('app', 'ID'), | ||
| 45 | - 'menu_id' => Yii::t('app', 'Menu ID'), | 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'), | 46 | 'group' => Yii::t('app', 'Group'), |
| 47 | ]; | 47 | ]; |
| 48 | } | 48 | } |
| @@ -52,7 +52,7 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | @@ -52,7 +52,7 @@ class AdminMenuAccessGroup extends \yii\db\ActiveRecord | ||
| 52 | */ | 52 | */ |
| 53 | public function getMenu() | 53 | public function getMenu() |
| 54 | { | 54 | { |
| 55 | - return $this->hasOne(AdminMenu::className(), ['id' => 'menu_id']); | 55 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | /** | 58 | /** |
backend/models/AdminMenuAccessUser.php
| @@ -2,14 +2,15 @@ | @@ -2,14 +2,15 @@ | ||
| 2 | 2 | ||
| 3 | namespace backend\models; | 3 | namespace backend\models; |
| 4 | 4 | ||
| 5 | +use common\models\User; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * This is the model class for table "admin_menu_access_user". | 9 | * This is the model class for table "admin_menu_access_user". |
| 9 | * | 10 | * |
| 10 | - * @property integer $menu_id | 11 | + * @property integer $admin_menu_id |
| 11 | * @property integer $user_id | 12 | * @property integer $user_id |
| 12 | - * @property integer $id | 13 | + * @property integer $admin_menu_access_user_id |
| 13 | * | 14 | * |
| 14 | * @property AdminMenu $menu | 15 | * @property AdminMenu $menu |
| 15 | * @property User $user | 16 | * @property User $user |
| @@ -30,7 +31,7 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | @@ -30,7 +31,7 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | ||
| 30 | public function rules() | 31 | public function rules() |
| 31 | { | 32 | { |
| 32 | return [ | 33 | return [ |
| 33 | - [['menu_id', 'user_id'], 'integer'] | 34 | + [['admin_menu_id', 'user_id'], 'integer'] |
| 34 | ]; | 35 | ]; |
| 35 | } | 36 | } |
| 36 | 37 | ||
| @@ -40,9 +41,9 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | @@ -40,9 +41,9 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | ||
| 40 | public function attributeLabels() | 41 | public function attributeLabels() |
| 41 | { | 42 | { |
| 42 | return [ | 43 | return [ |
| 43 | - 'menu_id' => Yii::t('app', 'Menu ID'), | 44 | + 'admin_menu_id' => Yii::t('app', 'Admin Menu ID'), |
| 44 | 'user_id' => Yii::t('app', 'User ID'), | 45 | 'user_id' => Yii::t('app', 'User ID'), |
| 45 | - 'id' => Yii::t('app', 'ID'), | 46 | + 'admin_menu_access_user_id' => Yii::t('app', 'Admin Menu Access User ID'), |
| 46 | ]; | 47 | ]; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| @@ -51,7 +52,7 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | @@ -51,7 +52,7 @@ class AdminMenuAccessUser extends \yii\db\ActiveRecord | ||
| 51 | */ | 52 | */ |
| 52 | public function getMenu() | 53 | public function getMenu() |
| 53 | { | 54 | { |
| 54 | - return $this->hasOne(AdminMenu::className(), ['id' => 'menu_id']); | 55 | + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | /** | 58 | /** |
backend/models/AdminMenuSearch.php
| @@ -20,8 +20,8 @@ class AdminMenuSearch extends AdminMenu | @@ -20,8 +20,8 @@ class AdminMenuSearch extends AdminMenu | ||
| 20 | public function rules() | 20 | public function rules() |
| 21 | { | 21 | { |
| 22 | return [ | 22 | return [ |
| 23 | - [['id', 'parent_id', 'active', 'hide_min', 'sort'], 'integer'], | ||
| 24 | - [['name', 'path', 'params','parentt'], 'safe'], | 23 | + [['admin_menu_id', 'admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'], |
| 24 | + [['name', 'path', 'param','parentt'], 'safe'], | ||
| 25 | ]; | 25 | ]; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -52,11 +52,11 @@ class AdminMenuSearch extends AdminMenu | @@ -52,11 +52,11 @@ class AdminMenuSearch extends AdminMenu | ||
| 52 | ], | 52 | ], |
| 53 | 'sort' => [ | 53 | 'sort' => [ |
| 54 | 'attributes' => [ | 54 | 'attributes' => [ |
| 55 | - 'id', | 55 | + 'admin_menu_id', |
| 56 | 'name', | 56 | 'name', |
| 57 | 'path', | 57 | 'path', |
| 58 | - 'params', | ||
| 59 | - 'active', | 58 | + 'param', |
| 59 | + 'status', | ||
| 60 | 'hide_min', | 60 | 'hide_min', |
| 61 | 'parentt' => [ | 61 | 'parentt' => [ |
| 62 | 'asc' => ['name' => SORT_ASC], | 62 | 'asc' => ['name' => SORT_ASC], |
| @@ -76,9 +76,9 @@ class AdminMenuSearch extends AdminMenu | @@ -76,9 +76,9 @@ class AdminMenuSearch extends AdminMenu | ||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | $query->andFilterWhere([ | 78 | $query->andFilterWhere([ |
| 79 | - 'id' => $this->id, | ||
| 80 | - 'parent_id' => $this->parent_id, | ||
| 81 | - 'active' => $this->active, | 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, | 82 | 'hide_min' => $this->hide_min, |
| 83 | 'sort' => $this->sort | 83 | 'sort' => $this->sort |
| 84 | ]); | 84 | ]); |
| @@ -86,8 +86,8 @@ class AdminMenuSearch extends AdminMenu | @@ -86,8 +86,8 @@ class AdminMenuSearch extends AdminMenu | ||
| 86 | 86 | ||
| 87 | $query->andFilterWhere(['like', 'name', $this->name]) | 87 | $query->andFilterWhere(['like', 'name', $this->name]) |
| 88 | ->andFilterWhere(['like', 'path', $this->path]) | 88 | ->andFilterWhere(['like', 'path', $this->path]) |
| 89 | - ->andFilterWhere(['like', 'params', $this->params]) | ||
| 90 | - ->andFilterWhere(['in', 'parent_id', $this->find()->select(['id'])->andFilterWhere(['like', 'name', $this->parentt])->column()]); | 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 | 91 | ||
| 92 | return $dataProvider; | 92 | return $dataProvider; |
| 93 | } | 93 | } |
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/views/admin-menu/_form.php
| @@ -16,13 +16,13 @@ use yii\widgets\ActiveForm; | @@ -16,13 +16,13 @@ use yii\widgets\ActiveForm; | ||
| 16 | 16 | ||
| 17 | <?= $form->field($model, 'name')->textInput() ?> | 17 | <?= $form->field($model, 'name')->textInput() ?> |
| 18 | 18 | ||
| 19 | - <?= $form->field($model, 'active')->checkbox() ?> | 19 | + <?= $form->field($model, 'status')->checkbox() ?> |
| 20 | 20 | ||
| 21 | <?= $form->field($model, 'hide_min')->checkbox() ?> | 21 | <?= $form->field($model, 'hide_min')->checkbox() ?> |
| 22 | 22 | ||
| 23 | <?= $form->field($model, 'path')->textInput() ?> | 23 | <?= $form->field($model, 'path')->textInput() ?> |
| 24 | 24 | ||
| 25 | - <?= $form->field($model, 'params')->textInput() ?> | 25 | + <?= $form->field($model, 'param')->textInput() ?> |
| 26 | 26 | ||
| 27 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | 27 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> |
| 28 | <div class="panel panel-default"> | 28 | <div class="panel panel-default"> |
| @@ -37,12 +37,12 @@ use yii\widgets\ActiveForm; | @@ -37,12 +37,12 @@ use yii\widgets\ActiveForm; | ||
| 37 | <ul class="list-group checkboxer"> | 37 | <ul class="list-group checkboxer"> |
| 38 | <?php | 38 | <?php |
| 39 | $roots = AdminMenu::buildMenuSelect(); | 39 | $roots = AdminMenu::buildMenuSelect(); |
| 40 | - echo $form->field($model, 'parent_id', ['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']]); | 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) { | 41 | foreach($roots as $root) { |
| 42 | - echo $form->field($model, 'parent_id', ['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']]); | 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']) { | 43 | if($root['items']) { |
| 44 | foreach($root['items'] as $submenu) { | 44 | foreach($root['items'] as $submenu) { |
| 45 | - echo $form->field($model, 'parent_id', ['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']]); | 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 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
backend/views/admin-menu/index.php
| @@ -39,10 +39,10 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -39,10 +39,10 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 39 | </div>", | 39 | </div>", |
| 40 | 'columns' => [ | 40 | 'columns' => [ |
| 41 | ['class' => 'yii\grid\ActionColumn'], | 41 | ['class' => 'yii\grid\ActionColumn'], |
| 42 | - 'id', | 42 | + 'admin_menu_id', |
| 43 | 'name', | 43 | 'name', |
| 44 | 'path', | 44 | 'path', |
| 45 | - 'params', | 45 | + 'param', |
| 46 | [ | 46 | [ |
| 47 | 'format' => 'raw', | 47 | 'format' => 'raw', |
| 48 | 'filter' => [ | 48 | 'filter' => [ |
| @@ -50,20 +50,20 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -50,20 +50,20 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 50 | '0'=>'Скрытые', | 50 | '0'=>'Скрытые', |
| 51 | ], | 51 | ], |
| 52 | 'value' => function($data){ | 52 | 'value' => function($data){ |
| 53 | - if($data->active){ | 53 | + if($data->status){ |
| 54 | $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; | 54 | $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>'; |
| 55 | } else { | 55 | } else { |
| 56 | $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; | 56 | $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>'; |
| 57 | } | 57 | } |
| 58 | return $status_img; | 58 | return $status_img; |
| 59 | }, | 59 | }, |
| 60 | - 'attribute'=>'active', | 60 | + 'attribute'=>'status', |
| 61 | ], | 61 | ], |
| 62 | [ | 62 | [ |
| 63 | 'attribute' => 'parentt', | 63 | 'attribute' => 'parentt', |
| 64 | 'content' => | 64 | 'content' => |
| 65 | function($model, $key, $index, $column) { | 65 | function($model, $key, $index, $column) { |
| 66 | - if($model->parent->id) { | 66 | + if($model->parent->admin_menu_id) { |
| 67 | return $model->parent->name; | 67 | return $model->parent->name; |
| 68 | } else { | 68 | } else { |
| 69 | return '<i class="small">'.Yii::t('app', 'Корневой элемент').'</i>'; | 69 | return '<i class="small">'.Yii::t('app', 'Корневой элемент').'</i>'; |
backend/views/admin-menu/update.php
| @@ -7,7 +7,7 @@ use yii\helpers\Html; | @@ -7,7 +7,7 @@ use yii\helpers\Html; | ||
| 7 | 7 | ||
| 8 | $this->title = Yii::t('app', 'Update') . ': ' . $model->name; | 8 | $this->title = Yii::t('app', 'Update') . ': ' . $model->name; |
| 9 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; | 9 | $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; |
| 10 | -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; | 10 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->admin_menu_id]]; |
| 11 | $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | 11 | $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); |
| 12 | ?> | 12 | ?> |
| 13 | <div class="admin-menu-update"> | 13 | <div class="admin-menu-update"> |
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/web/js/option.js
| @@ -14,7 +14,6 @@ function readURL(input) { | @@ -14,7 +14,6 @@ function readURL(input) { | ||
| 14 | } | 14 | } |
| 15 | function checkboxerInit() { | 15 | function checkboxerInit() { |
| 16 | $.each($('.checkboxer input[type=radio]:checked'), function(index, value) { | 16 | $.each($('.checkboxer input[type=radio]:checked'), function(index, value) { |
| 17 | - console.log(value); | ||
| 18 | $(value).trigger('change'); | 17 | $(value).trigger('change'); |
| 19 | }); | 18 | }); |
| 20 | } | 19 | } |
| @@ -64,7 +63,31 @@ $(function() { | @@ -64,7 +63,31 @@ $(function() { | ||
| 64 | $(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>'); |
| 65 | } | 64 | } |
| 66 | }); | 65 | }); |
| 67 | - $(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() { |
| 67 | + var lang = $(this).data('lang'); | ||
| 68 | + var flag = $(this).find('span').first().clone(); | ||
| 69 | + var el = $(this); | ||
| 70 | + var id = $(this).attr('href').substr(1); | ||
| 71 | + var path = form[id].handler; | ||
| 72 | + var view = form[id].view; | ||
| 73 | + var model = form[id].model; | ||
| 74 | + $.get(path, { lang_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(); | ||
| 68 | var lang = $(this).data('lang'); | 91 | var lang = $(this).data('lang'); |
| 69 | var flag = $(this).find('span').first().clone(); | 92 | var flag = $(this).find('span').first().clone(); |
| 70 | var el = $(this); | 93 | var el = $(this); |
| @@ -100,9 +123,11 @@ $(function() { | @@ -100,9 +123,11 @@ $(function() { | ||
| 100 | } | 123 | } |
| 101 | }); | 124 | }); |
| 102 | $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() { | 125 | $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() { |
| 103 | - console.log($(this).val()); | ||
| 104 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); | 126 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); |
| 105 | $(this).parents('.checkboxer_container').addClass('active'); | 127 | $(this).parents('.checkboxer_container').addClass('active'); |
| 106 | }); | 128 | }); |
| 129 | + $.each($('.f32'), function(i, val) { | ||
| 130 | + $(val).find('a[role=tab]').first().trigger('click'); | ||
| 131 | + }); | ||
| 107 | checkboxerInit(); | 132 | checkboxerInit(); |
| 108 | }); | 133 | }); |
| 109 | \ 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/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/modules/blog/controllers/AjaxController.php
| @@ -29,7 +29,7 @@ class AjaxController extends Controller | @@ -29,7 +29,7 @@ class AjaxController extends Controller | ||
| 29 | 29 | ||
| 30 | public function actionCategoryForm($lang_id, $widget_id) | 30 | public function actionCategoryForm($lang_id, $widget_id) |
| 31 | { | 31 | { |
| 32 | - $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' => $lang_id])->one(); |
| 33 | if(!$model) { | 33 | if(!$model) { |
| 34 | throw new NotFoundHttpException('Language not found'); | 34 | throw new NotFoundHttpException('Language not found'); |
| 35 | } | 35 | } |
| @@ -39,7 +39,7 @@ class AjaxController extends Controller | @@ -39,7 +39,7 @@ class AjaxController extends Controller | ||
| 39 | 39 | ||
| 40 | public function actionArticleForm($lang_id, $widget_id) | 40 | public function actionArticleForm($lang_id, $widget_id) |
| 41 | { | 41 | { |
| 42 | - $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' => $lang_id])->one(); |
| 43 | if(!$model) { | 43 | if(!$model) { |
| 44 | throw new NotFoundHttpException('Language not found'); | 44 | throw new NotFoundHttpException('Language not found'); |
| 45 | } | 45 | } |
| @@ -49,7 +49,7 @@ class AjaxController extends Controller | @@ -49,7 +49,7 @@ class AjaxController extends Controller | ||
| 49 | 49 | ||
| 50 | public function actionArticleMediaForm($lang_id, $widget_id, $type) | 50 | public function actionArticleMediaForm($lang_id, $widget_id, $type) |
| 51 | { | 51 | { |
| 52 | - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); | 52 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $lang_id])->one(); |
| 53 | if(!$model) { | 53 | if(!$model) { |
| 54 | throw new NotFoundHttpException('Language not found'); | 54 | throw new NotFoundHttpException('Language not found'); |
| 55 | } | 55 | } |
| @@ -62,7 +62,7 @@ class AjaxController extends Controller | @@ -62,7 +62,7 @@ class AjaxController extends Controller | ||
| 62 | 62 | ||
| 63 | public function actionArticleCategoryMediaForm($lang_id, $widget_id, $type) | 63 | public function actionArticleCategoryMediaForm($lang_id, $widget_id, $type) |
| 64 | { | 64 | { |
| 65 | - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one(); | 65 | + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $lang_id])->one(); |
| 66 | if(!$model) { | 66 | if(!$model) { |
| 67 | throw new NotFoundHttpException('Language not found'); | 67 | throw new NotFoundHttpException('Language not found'); |
| 68 | } | 68 | } |
| @@ -123,4 +123,10 @@ class AjaxController extends Controller | @@ -123,4 +123,10 @@ class AjaxController extends Controller | ||
| 123 | return false; | 123 | return false; |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | + | ||
| 127 | + public function actionMultilangForm($model, $ajaxView, $widget_id, $lang_id = NULL) | ||
| 128 | + { | ||
| 129 | + $model = new $model(['language_id' => $lang_id]); | ||
| 130 | + return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]); | ||
| 131 | + } | ||
| 126 | } | 132 | } |
common/modules/blog/controllers/ArticleController.php
| @@ -39,18 +39,18 @@ class ArticleController extends Controller | @@ -39,18 +39,18 @@ class ArticleController extends Controller | ||
| 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(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { | 44 | foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { |
| 45 | foreach($value as $type => $fields) { | 45 | foreach($value as $type => $fields) { |
| 46 | $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); | 46 | $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); |
| 47 | $images[$lang][$type]->type = $type; | 47 | $images[$lang][$type]->type = $type; |
| 48 | - $images[$lang][$type]->lang_id = $lang; | 48 | + $images[$lang][$type]->language_id = $lang; |
| 49 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | 49 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); |
| 50 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | 50 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | - $images[0]['additional']->lang_id = 0; | 53 | + $images[0]['additional']->language_id = 0; |
| 54 | $images[0]['additional']->type = 'additional'; | 54 | $images[0]['additional']->type = 'additional'; |
| 55 | $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); | 55 | $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); |
| 56 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { | 56 | if(empty(\Yii::$app->request->post()['ArticleLang'])) { |
| @@ -72,20 +72,20 @@ class ArticleController extends Controller | @@ -72,20 +72,20 @@ class ArticleController extends Controller | ||
| 72 | if(!empty($article_categories)) { | 72 | if(!empty($article_categories)) { |
| 73 | foreach($article_categories as $article_category) { | 73 | foreach($article_categories as $article_category) { |
| 74 | $articletocategory[$article_category] = new ArticleToCategory(); | 74 | $articletocategory[$article_category] = new ArticleToCategory(); |
| 75 | - $articletocategory[$article_category]->category_id = $article_category; | 75 | + $articletocategory[$article_category]->article_category_id = $article_category; |
| 76 | $articletocategory[$article_category]->link('article', $article); | 76 | $articletocategory[$article_category]->link('article', $article); |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | $first = 1; | 79 | $first = 1; |
| 80 | foreach($images as $lang => $value) { | 80 | foreach($images as $lang => $value) { |
| 81 | foreach($value as $type => $fields) { | 81 | foreach($value as $type => $fields) { |
| 82 | - $images[$lang][$type]->upload($article->id); | 82 | + $images[$lang][$type]->upload($article->article_id); |
| 83 | if($first && $type != 'additional') { | 83 | if($first && $type != 'additional') { |
| 84 | $media_clone = clone $images[$lang][$type]; | 84 | $media_clone = clone $images[$lang][$type]; |
| 85 | $media_clone->setIsNewRecord(true); | 85 | $media_clone->setIsNewRecord(true); |
| 86 | - unset($media_clone->id); | ||
| 87 | - $media_clone->lang_id = 0; | ||
| 88 | - $media_clone->upload($article->id); | 86 | + unset($media_clone->article_media_id); |
| 87 | + $media_clone->language_id = 0; | ||
| 88 | + $media_clone->upload($article->article_id); | ||
| 89 | unset($media_clone); | 89 | unset($media_clone); |
| 90 | $first = 0; | 90 | $first = 0; |
| 91 | } | 91 | } |
| @@ -95,7 +95,7 @@ class ArticleController extends Controller | @@ -95,7 +95,7 @@ class ArticleController extends Controller | ||
| 95 | foreach($article_langs as $article_lang) { | 95 | foreach($article_langs as $article_lang) { |
| 96 | if($first) { | 96 | if($first) { |
| 97 | $article_lang_clone = clone $article_lang; | 97 | $article_lang_clone = clone $article_lang; |
| 98 | - $article_lang_clone->lang_id = 0; | 98 | + $article_lang_clone->language_id = 0; |
| 99 | $article_lang_clone->link('article', $article); | 99 | $article_lang_clone->link('article', $article); |
| 100 | unset($article_lang_clone); | 100 | unset($article_lang_clone); |
| 101 | } | 101 | } |
| @@ -121,45 +121,45 @@ class ArticleController extends Controller | @@ -121,45 +121,45 @@ class ArticleController extends Controller | ||
| 121 | $images = []; | 121 | $images = []; |
| 122 | $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | 122 | $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); |
| 123 | $images[0]['additional'][0]->type = 'additional'; | 123 | $images[0]['additional'][0]->type = 'additional'; |
| 124 | - $images[0]['additional'][0]->lang_id = 0; | 124 | + $images[0]['additional'][0]->language_id = 0; |
| 125 | foreach($imagestack as $image) { | 125 | foreach($imagestack as $image) { |
| 126 | if(in_array($image->type, ['full', 'preview'])) { | 126 | if(in_array($image->type, ['full', 'preview'])) { |
| 127 | - $images[$image->lang_id][$image->type] = $image; | ||
| 128 | - $images[$image->lang_id][$image->type]->scenario = $image->type; | 127 | + $images[$image->language_id][$image->type] = $image; |
| 128 | + $images[$image->language_id][$image->type]->scenario = $image->type; | ||
| 129 | } else { | 129 | } else { |
| 130 | - $images[$image->lang_id][$image->type][$image->id] = $image; | ||
| 131 | - $images[$image->lang_id][$image->type][$image->id]->scenario = $image->type; | 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 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | foreach($images as $lang => $value) { | 134 | foreach($images as $lang => $value) { |
| 135 | $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); | 135 | $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); |
| 136 | } | 136 | } |
| 137 | - $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(); |
| 138 | $langs = Language::getActiveLanguages(); | 138 | $langs = Language::getActiveLanguages(); |
| 139 | $default_lang = Language::getDefaultLang(); | 139 | $default_lang = Language::getDefaultLang(); |
| 140 | $isValid = false; | 140 | $isValid = false; |
| 141 | if(!empty(\Yii::$app->request->post())) { | 141 | if(!empty(\Yii::$app->request->post())) { |
| 142 | $isValid = true; | 142 | $isValid = true; |
| 143 | $article->load(\Yii::$app->request->post()); | 143 | $article->load(\Yii::$app->request->post()); |
| 144 | - ArticleToCategory::deleteAll(['article_id' => $article->id]); | 144 | + ArticleToCategory::deleteAll(['article_id' => $article->article_id]); |
| 145 | $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; | 145 | $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; |
| 146 | if(!empty($article_categories)) { | 146 | if(!empty($article_categories)) { |
| 147 | foreach($article_categories as $article_category) { | 147 | foreach($article_categories as $article_category) { |
| 148 | $articletocategory[$article_category] = new ArticleToCategory(); | 148 | $articletocategory[$article_category] = new ArticleToCategory(); |
| 149 | - $articletocategory[$article_category]->category_id = $article_category; | 149 | + $articletocategory[$article_category]->article_category_id = $article_category; |
| 150 | $articletocategory[$article_category]->link('article', $article); | 150 | $articletocategory[$article_category]->link('article', $article); |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
| 153 | $isValid = $article->validate(); | 153 | $isValid = $article->validate(); |
| 154 | $images[0]['additional'][0]->type = 'additional'; | 154 | $images[0]['additional'][0]->type = 'additional'; |
| 155 | - $images[0]['additional'][0]->lang_id = 0; | 155 | + $images[0]['additional'][0]->language_id = 0; |
| 156 | $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); | 156 | $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); |
| 157 | $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; | 157 | $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; |
| 158 | foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { | 158 | foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { |
| 159 | foreach($value as $type => $fields) { | 159 | foreach($value as $type => $fields) { |
| 160 | if(!in_array($type, ['full', 'preview'])) continue; | 160 | if(!in_array($type, ['full', 'preview'])) continue; |
| 161 | $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); | 161 | $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); |
| 162 | - $images[$lang][$type]->lang_id = $lang; | 162 | + $images[$lang][$type]->language_id = $lang; |
| 163 | $images[$lang][$type]->type = $type; | 163 | $images[$lang][$type]->type = $type; |
| 164 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | 164 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); |
| 165 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | 165 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; |
| @@ -171,7 +171,7 @@ class ArticleController extends Controller | @@ -171,7 +171,7 @@ class ArticleController extends Controller | ||
| 171 | foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { | 171 | foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { |
| 172 | if (!array_key_exists($index, $article_langs)) { | 172 | if (!array_key_exists($index, $article_langs)) { |
| 173 | $article_langs[$index] = new ArticleLang(); | 173 | $article_langs[$index] = new ArticleLang(); |
| 174 | - $article_langs[$index]->article_id = $article->id; | 174 | + $article_langs[$index]->article_id = $article->article_id; |
| 175 | } | 175 | } |
| 176 | } | 176 | } |
| 177 | ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); | 177 | ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); |
| @@ -186,7 +186,7 @@ class ArticleController extends Controller | @@ -186,7 +186,7 @@ class ArticleController extends Controller | ||
| 186 | $images[$lang][$type][0]->upload($article->id); | 186 | $images[$lang][$type][0]->upload($article->id); |
| 187 | } else { | 187 | } else { |
| 188 | if(!empty($images[$lang][$type]->imageFile)) { | 188 | if(!empty($images[$lang][$type]->imageFile)) { |
| 189 | - $images[$lang][$type]->replace($article->id); | 189 | + $images[$lang][$type]->replace($article->article_id); |
| 190 | } | 190 | } |
| 191 | } | 191 | } |
| 192 | } | 192 | } |
common/modules/blog/controllers/CategoryController.php
| @@ -58,12 +58,12 @@ class CategoryController extends Controller | @@ -58,12 +58,12 @@ class CategoryController extends Controller | ||
| 58 | foreach($value as $type => $fields) { | 58 | foreach($value as $type => $fields) { |
| 59 | $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); | 59 | $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); |
| 60 | $images[$lang][$type]->type = $type; | 60 | $images[$lang][$type]->type = $type; |
| 61 | - $images[$lang][$type]->lang_id = $lang; | 61 | + $images[$lang][$type]->language_id = $lang; |
| 62 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | 62 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); |
| 63 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | 63 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | - $images[0]['additional']->lang_id = 0; | 66 | + $images[0]['additional']->language_id = 0; |
| 67 | $images[0]['additional']->type = 'additional'; | 67 | $images[0]['additional']->type = 'additional'; |
| 68 | $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); | 68 | $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); |
| 69 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { | 69 | if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { |
| @@ -84,13 +84,13 @@ class CategoryController extends Controller | @@ -84,13 +84,13 @@ class CategoryController extends Controller | ||
| 84 | $first = 1; | 84 | $first = 1; |
| 85 | foreach($images as $lang => $value) { | 85 | foreach($images as $lang => $value) { |
| 86 | foreach($value as $type => $fields) { | 86 | foreach($value as $type => $fields) { |
| 87 | - $images[$lang][$type]->upload($category->id); | 87 | + $images[$lang][$type]->upload($category->article_category_id); |
| 88 | if($first && $type != 'additional') { | 88 | if($first && $type != 'additional') { |
| 89 | $media_clone = clone $images[$lang][$type]; | 89 | $media_clone = clone $images[$lang][$type]; |
| 90 | $media_clone->setIsNewRecord(true); | 90 | $media_clone->setIsNewRecord(true); |
| 91 | - unset($media_clone->id); | ||
| 92 | - $media_clone->lang_id = 0; | ||
| 93 | - $media_clone->upload($category->id); | 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); | 94 | unset($media_clone); |
| 95 | $first = 0; | 95 | $first = 0; |
| 96 | } | 96 | } |
| @@ -100,7 +100,7 @@ class CategoryController extends Controller | @@ -100,7 +100,7 @@ class CategoryController extends Controller | ||
| 100 | foreach($category_langs as $category_lang) { | 100 | foreach($category_langs as $category_lang) { |
| 101 | if($first) { | 101 | if($first) { |
| 102 | $category_lang_clone = clone $category_lang; | 102 | $category_lang_clone = clone $category_lang; |
| 103 | - $category_lang_clone->lang_id = 0; | 103 | + $category_lang_clone->language_id = 0; |
| 104 | $category_lang_clone->link('category', $category); | 104 | $category_lang_clone->link('category', $category); |
| 105 | unset($category_lang_clone); | 105 | unset($category_lang_clone); |
| 106 | } | 106 | } |
| @@ -126,20 +126,20 @@ class CategoryController extends Controller | @@ -126,20 +126,20 @@ class CategoryController extends Controller | ||
| 126 | $images = []; | 126 | $images = []; |
| 127 | $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | 127 | $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); |
| 128 | $images[0]['additional'][0]->type = 'additional'; | 128 | $images[0]['additional'][0]->type = 'additional'; |
| 129 | - $images[0]['additional'][0]->lang_id = 0; | 129 | + $images[0]['additional'][0]->language_id = 0; |
| 130 | foreach($imagestack as $image) { | 130 | foreach($imagestack as $image) { |
| 131 | if(in_array($image->type, ['full', 'preview'])) { | 131 | if(in_array($image->type, ['full', 'preview'])) { |
| 132 | - $images[$image->lang_id][$image->type] = $image; | ||
| 133 | - $images[$image->lang_id][$image->type]->scenario = $image->type; | 132 | + $images[$image->language_id][$image->type] = $image; |
| 133 | + $images[$image->language_id][$image->type]->scenario = $image->type; | ||
| 134 | } else { | 134 | } else { |
| 135 | - $images[$image->lang_id][$image->type][$image->id] = $image; | ||
| 136 | - $images[$image->lang_id][$image->type][$image->id]->scenario = $image->type; | 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 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | foreach($images as $lang => $value) { | 139 | foreach($images as $lang => $value) { |
| 140 | $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); | 140 | $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); |
| 141 | } | 141 | } |
| 142 | - $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(); |
| 143 | $langs = Language::getActiveLanguages(); | 143 | $langs = Language::getActiveLanguages(); |
| 144 | $default_lang = Language::getDefaultLang(); | 144 | $default_lang = Language::getDefaultLang(); |
| 145 | $isValid = false; | 145 | $isValid = false; |
| @@ -148,14 +148,14 @@ class CategoryController extends Controller | @@ -148,14 +148,14 @@ class CategoryController extends Controller | ||
| 148 | $category->load(\Yii::$app->request->post()); | 148 | $category->load(\Yii::$app->request->post()); |
| 149 | $isValid = $category->validate(); | 149 | $isValid = $category->validate(); |
| 150 | $images[0]['additional'][0]->type = 'additional'; | 150 | $images[0]['additional'][0]->type = 'additional'; |
| 151 | - $images[0]['additional'][0]->lang_id = 0; | 151 | + $images[0]['additional'][0]->language_id = 0; |
| 152 | $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); | 152 | $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); |
| 153 | $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; | 153 | $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; |
| 154 | foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { | 154 | foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { |
| 155 | foreach($value as $type => $fields) { | 155 | foreach($value as $type => $fields) { |
| 156 | if(!in_array($type, ['full', 'preview'])) continue; | 156 | if(!in_array($type, ['full', 'preview'])) continue; |
| 157 | $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); | 157 | $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); |
| 158 | - $images[$lang][$type]->lang_id = $lang; | 158 | + $images[$lang][$type]->language_id = $lang; |
| 159 | $images[$lang][$type]->type = $type; | 159 | $images[$lang][$type]->type = $type; |
| 160 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); | 160 | $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); |
| 161 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; | 161 | $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; |
| @@ -167,7 +167,7 @@ class CategoryController extends Controller | @@ -167,7 +167,7 @@ class CategoryController extends Controller | ||
| 167 | foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { | 167 | foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { |
| 168 | if(!array_key_exists($index, $category_langs)) { | 168 | if(!array_key_exists($index, $category_langs)) { |
| 169 | $category_langs[$index] = new ArticleCategoryLang(); | 169 | $category_langs[$index] = new ArticleCategoryLang(); |
| 170 | - $category_langs[$index]->category_id = $category->id; | 170 | + $category_langs[$index]->article_category_id = $category->article_category_id; |
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); | 173 | ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); |
| @@ -179,10 +179,10 @@ class CategoryController extends Controller | @@ -179,10 +179,10 @@ class CategoryController extends Controller | ||
| 179 | foreach($images as $lang => $value) { | 179 | foreach($images as $lang => $value) { |
| 180 | foreach($value as $type => $fields) { | 180 | foreach($value as $type => $fields) { |
| 181 | if($type == 'additional') { | 181 | if($type == 'additional') { |
| 182 | - $images[$lang][$type][0]->upload($category->id); | 182 | + $images[$lang][$type][0]->upload($category->article_category_id); |
| 183 | } else { | 183 | } else { |
| 184 | if(!empty($images[$lang][$type]->imageFile)) { | 184 | if(!empty($images[$lang][$type]->imageFile)) { |
| 185 | - $images[$lang][$type]->replace($category->id); | 185 | + $images[$lang][$type]->replace($category->article_category_id); |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | } | 188 | } |
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_lang_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_lang_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_lang_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_lang_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', 'lang_id']; | ||
| 41 | - $scenarios[self::SCENARIO_PREVIEW] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'lang_id']; | ||
| 42 | - $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'article_id', 'media_id', 'type', 'imageFile', 'lang_id']; | 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', 'lang_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 | } |
| @@ -120,10 +121,10 @@ class ArticleMedia extends \yii\db\ActiveRecord | @@ -120,10 +121,10 @@ class ArticleMedia extends \yii\db\ActiveRecord | ||
| 120 | { | 121 | { |
| 121 | $this->article_id = $article_id; | 122 | $this->article_id = $article_id; |
| 122 | if($removeMedia && !$this->getIsNewRecord()) { | 123 | if($removeMedia && !$this->getIsNewRecord()) { |
| 123 | - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'lang_id' => $this->lang_id])->column(); | 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, 'lang_id' => $this->lang_id]); | 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
| @@ -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' => $article_lang, 'attribute' => "[$model->language_id][$type]lang_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> | 10 | + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> |
| 11 | 11 | ||
| 12 | <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?> | 12 | <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?> |
| 13 | 13 |
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
| @@ -2,7 +2,8 @@ | @@ -2,7 +2,8 @@ | ||
| 2 | use common\modules\blog\models\ArticleCategory; | 2 | use common\modules\blog\models\ArticleCategory; |
| 3 | use common\modules\blog\models\ArticleMedia; | 3 | use common\modules\blog\models\ArticleMedia; |
| 4 | use common\widgets\Multilang; | 4 | use common\widgets\Multilang; |
| 5 | -use yii\bootstrap\ActiveForm; | 5 | + use common\widgets\Multilanguage; |
| 6 | + use yii\bootstrap\ActiveForm; | ||
| 6 | use common\modules\blog\models\Article; | 7 | use common\modules\blog\models\Article; |
| 7 | use yii\bootstrap\Html; | 8 | use yii\bootstrap\Html; |
| 8 | use mihaildev\ckeditor\CKEditor; | 9 | use mihaildev\ckeditor\CKEditor; |
| @@ -19,17 +20,17 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -19,17 +20,17 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 19 | 20 | ||
| 20 | <?= $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() ?> |
| 21 | 22 | ||
| 22 | - <?= $form->field($article, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> | 23 | + <?= $form->field($article, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> |
| 23 | 24 | ||
| 24 | <?= $form->field($article, 'sort')->input('number') ?> | 25 | <?= $form->field($article, 'sort')->input('number') ?> |
| 25 | 26 | ||
| 26 | - <?= $form->field($article, 'parent_id') | ||
| 27 | - ->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')]) ?> | ||
| 28 | 29 | ||
| 29 | <?= $form->field($article, 'articleCategoriesArray') | 30 | <?= $form->field($article, 'articleCategoriesArray') |
| 30 | ->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')); ?> |
| 31 | 32 | ||
| 32 | - <?= $form->field($article, 'active')->checkbox() ?> | 33 | + <?= $form->field($article, 'status')->checkbox() ?> |
| 33 | 34 | ||
| 34 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> | 35 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> |
| 35 | <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> | 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> |
| @@ -42,7 +43,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -42,7 +43,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 42 | $imagelang = Multilang::begin([ | 43 | $imagelang = Multilang::begin([ |
| 43 | 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']), | 44 | 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']), |
| 44 | 'form' => $form, | 45 | 'form' => $form, |
| 45 | - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->id, 'type' => 'full'])->indexBy('lang_id')->all() | 46 | + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'full'])->indexBy('language_id')->all() |
| 46 | ]); | 47 | ]); |
| 47 | $first = 1; | 48 | $first = 1; |
| 48 | foreach($images as $lang => $value) { | 49 | foreach($images as $lang => $value) { |
| @@ -50,9 +51,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -50,9 +51,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 50 | ?> | 51 | ?> |
| 51 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | 52 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> |
| 52 | <?php | 53 | <?php |
| 53 | - echo $form->field($images[$lang]['full'], "[{$lang}][full]lang_id")->label(false)->hiddenInput(['value' => $lang]); | 54 | + echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]); |
| 54 | echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); | 55 | echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); |
| 55 | - if(!empty($images[$lang]['full']->id)) { | 56 | + if(!empty($images[$lang]['full']->article_media_id)) { |
| 56 | echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; | 57 | echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; |
| 57 | } | 58 | } |
| 58 | ?> | 59 | ?> |
| @@ -68,7 +69,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -68,7 +69,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 68 | $imagelang = Multilang::begin([ | 69 | $imagelang = Multilang::begin([ |
| 69 | 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']), | 70 | 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']), |
| 70 | 'form' => $form, | 71 | 'form' => $form, |
| 71 | - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->id, 'type' => 'preview'])->indexBy('lang_id')->all() | 72 | + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'preview'])->indexBy('language_id')->all() |
| 72 | ]); | 73 | ]); |
| 73 | $first = 1; | 74 | $first = 1; |
| 74 | foreach($images as $lang => $value) { | 75 | foreach($images as $lang => $value) { |
| @@ -76,9 +77,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -76,9 +77,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 76 | ?> | 77 | ?> |
| 77 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | 78 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> |
| 78 | <?php | 79 | <?php |
| 79 | - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]lang_id")->label(false)->hiddenInput(['value' => $lang]); | 80 | + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]); |
| 80 | echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); | 81 | echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); |
| 81 | - if(!empty($images[$lang]['preview']->id)) { | 82 | + if(!empty($images[$lang]['preview']->article_media_id)) { |
| 82 | echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; | 83 | echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; |
| 83 | } | 84 | } |
| 84 | ?> | 85 | ?> |
| @@ -101,7 +102,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -101,7 +102,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 101 | <a | 102 | <a |
| 102 | href="<?= Url::to(['ajax/remove-image']) ?>" | 103 | href="<?= Url::to(['ajax/remove-image']) ?>" |
| 103 | class="remove_image glyphicon glyphicon-remove-circle" | 104 | class="remove_image glyphicon glyphicon-remove-circle" |
| 104 | - data-params='<?= Json::encode(['article_media_id' => $oneimage->id, 'remove_media' => true]) ?>', | 105 | + data-params='<?= Json::encode(['article_media_id' => $oneimage->article_media_id, 'remove_media' => true]) ?>', |
| 105 | ></a> | 106 | ></a> |
| 106 | </div> | 107 | </div> |
| 107 | <?php | 108 | <?php |
| @@ -115,6 +116,12 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -115,6 +116,12 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 115 | <hr> | 116 | <hr> |
| 116 | 117 | ||
| 117 | <?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 | + /* | ||
| 118 | $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]); |
| 119 | ?> | 126 | ?> |
| 120 | <?php | 127 | <?php |
| @@ -150,6 +157,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -150,6 +157,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 150 | ?> | 157 | ?> |
| 151 | <?php | 158 | <?php |
| 152 | $multilang->end(); | 159 | $multilang->end(); |
| 160 | + */ | ||
| 153 | ?> | 161 | ?> |
| 154 | 162 | ||
| 155 | <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
| @@ -17,14 +17,14 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -17,14 +17,14 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 17 | 17 | ||
| 18 | <?= $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() ?> |
| 19 | 19 | ||
| 20 | - <?= $form->field($category, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> | 20 | + <?= $form->field($category, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> |
| 21 | 21 | ||
| 22 | <?= $form->field($category, 'sort')->input('number') ?> | 22 | <?= $form->field($category, 'sort')->input('number') ?> |
| 23 | 23 | ||
| 24 | - <?= $form->field($category, 'parent_id') | ||
| 25 | - ->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')]) ?> | ||
| 26 | 26 | ||
| 27 | - <?= $form->field($category, 'active')->checkbox() ?> | 27 | + <?= $form->field($category, 'status')->checkbox() ?> |
| 28 | 28 | ||
| 29 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> | 29 | <ul class="nav nav-tabs" id="image-tabs" role="tablist"> |
| 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> | 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> |
| @@ -37,7 +37,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -37,7 +37,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 37 | $imagelang = Multilang::begin([ | 37 | $imagelang = Multilang::begin([ |
| 38 | 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']), | 38 | 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']), |
| 39 | 'form' => $form, | 39 | 'form' => $form, |
| 40 | - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['category_id' => $category->id, 'type' => 'full'])->indexBy('lang_id')->all() | 40 | + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'full'])->indexBy('language_id')->all() |
| 41 | ]); | 41 | ]); |
| 42 | $first = 1; | 42 | $first = 1; |
| 43 | foreach($images as $lang => $value) { | 43 | foreach($images as $lang => $value) { |
| @@ -45,9 +45,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -45,9 +45,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 45 | ?> | 45 | ?> |
| 46 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | 46 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> |
| 47 | <?php | 47 | <?php |
| 48 | - echo $form->field($images[$lang]['full'], "[{$lang}][full]lang_id")->label(false)->hiddenInput(['value' => $lang]); | 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']); | 49 | echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); |
| 50 | - if(!empty($images[$lang]['full']->id)) { | 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'>"; | 51 | echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; |
| 52 | } | 52 | } |
| 53 | ?> | 53 | ?> |
| @@ -63,7 +63,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -63,7 +63,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 63 | $imagelang = Multilang::begin([ | 63 | $imagelang = Multilang::begin([ |
| 64 | 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']), | 64 | 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']), |
| 65 | 'form' => $form, | 65 | 'form' => $form, |
| 66 | - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['category_id' => $category->id, 'type' => 'preview'])->indexBy('lang_id')->all() | 66 | + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'preview'])->indexBy('language_id')->all() |
| 67 | ]); | 67 | ]); |
| 68 | $first = 1; | 68 | $first = 1; |
| 69 | foreach($images as $lang => $value) { | 69 | foreach($images as $lang => $value) { |
| @@ -71,9 +71,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -71,9 +71,9 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 71 | ?> | 71 | ?> |
| 72 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> | 72 | <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>"> |
| 73 | <?php | 73 | <?php |
| 74 | - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]lang_id")->label(false)->hiddenInput(['value' => $lang]); | 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']); | 75 | echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); |
| 76 | - if(!empty($images[$lang]['preview']->id)) { | 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'>"; | 77 | echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; |
| 78 | } | 78 | } |
| 79 | ?> | 79 | ?> |
| @@ -96,7 +96,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -96,7 +96,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 96 | <a | 96 | <a |
| 97 | href="<?= Url::to(['ajax/remove-image']) ?>" | 97 | href="<?= Url::to(['ajax/remove-image']) ?>" |
| 98 | class="remove_image glyphicon glyphicon-remove-circle" | 98 | class="remove_image glyphicon glyphicon-remove-circle" |
| 99 | - data-params='<?= Json::encode(['category_media_id' => $oneimage->id, 'remove_media' => true]) ?>', | 99 | + data-params='<?= Json::encode(['article_category_media_id' => $oneimage->article_category_media_id, 'remove_media' => true]) ?>', |
| 100 | ></a> | 100 | ></a> |
| 101 | </div> | 101 | </div> |
| 102 | <?php | 102 | <?php |
| @@ -117,7 +117,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -117,7 +117,7 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 117 | foreach($category_langs as $index => $category_lang) { | 117 | foreach($category_langs as $index => $category_lang) { |
| 118 | ?> | 118 | ?> |
| 119 | <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?>"> |
| 120 | - <?= $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]) ?> |
| 121 | 121 | ||
| 122 | <?= $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, ], ]); ?> |
| 123 | 123 | ||
| @@ -131,11 +131,11 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | @@ -131,11 +131,11 @@ $uploaddir = \Yii::getAlias('@saveImageDir'); | ||
| 131 | 131 | ||
| 132 | <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?> | 132 | <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?> |
| 133 | 133 | ||
| 134 | - <?= $form->field($category_langs[$index], "[$index]meta_keywords")->textInput() ?> | 134 | + <?= $form->field($category_langs[$index], "[$index]meta_keyword")->textInput() ?> |
| 135 | 135 | ||
| 136 | <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?> | 136 | <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?> |
| 137 | 137 | ||
| 138 | - <?= $form->field($category_langs[$index], "[$index]tags")->textInput() ?> | 138 | + <?= $form->field($category_langs[$index], "[$index]tag")->textInput() ?> |
| 139 | 139 | ||
| 140 | </div> | 140 | </div> |
| 141 | <?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 | [ |
| 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 | ?> |
| 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/yarik/public.backup
No preview for this file type
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_lang_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; |
| @@ -94,8 +95,8 @@ class Option extends \yii\db\ActiveRecord | @@ -94,8 +95,8 @@ class Option extends \yii\db\ActiveRecord | ||
| 94 | foreach($option['lang'] as $lang_id => $lang) { | 95 | foreach($option['lang'] as $lang_id => $lang) { |
| 95 | if(empty($modellang[$key][$lang_id])) { | 96 | if(empty($modellang[$key][$lang_id])) { |
| 96 | $modellang[$key][$lang_id] = new OptionLang(); | 97 | $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; | 98 | + $modellang[$key][$lang_id]->option_id = $models[$key]->option_id; |
| 99 | + $modellang[$key][$lang_id]->language_id = $lang_id; | ||
| 99 | $modellang[$key][$lang_id]->value = $lang; | 100 | $modellang[$key][$lang_id]->value = $lang; |
| 100 | } else { | 101 | } else { |
| 101 | $modellang[$key][$lang_id]->value = $lang; | 102 | $modellang[$key][$lang_id]->value = $lang; |
| @@ -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
| @@ -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_lang_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_lang_id' => $this->option_lang_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/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,7 +64,30 @@ $(function() { | @@ -58,7 +64,30 @@ $(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, { lang_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); |
| @@ -98,4 +127,8 @@ $(function() { | @@ -98,4 +127,8 @@ $(function() { | ||
| 98 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); | 127 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); |
| 99 | $(this).parents('.checkboxer_container').addClass('active'); | 128 | $(this).parents('.checkboxer_container').addClass('active'); |
| 100 | }); | 129 | }); |
| 130 | + $.each($('.f32'), function(i, val) { | ||
| 131 | + $(val).find('a[role=tab]').first().trigger('click'); | ||
| 132 | + }); | ||
| 133 | + checkboxerInit(); | ||
| 101 | }); | 134 | }); |
| 102 | \ No newline at end of file | 135 | \ No newline at end of file |