Commit a559e91458c5bbb5a5ae3b32bc6d14b0fecc3376

Authored by andryeyev
2 parents 4cd4defc fe5be656

Merge branch 'master' into Dmitryi

Showing 157 changed files with 2125 additions and 925 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 157 files are displayed.

backend/controllers/AdminMenuController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use backend\models\AdminMenu;
  7 +use backend\models\AdminMenuSearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +
  12 +/**
  13 + * AdminMenuController implements the CRUD actions for AdminMenu model.
  14 + */
  15 +class AdminMenuController extends Controller
  16 +{
  17 + public $layout = 'settings';
  18 +
  19 + public function behaviors()
  20 + {
  21 + return [
  22 + 'verbs' => [
  23 + 'class' => VerbFilter::className(),
  24 + 'actions' => [
  25 + 'delete' => ['post'],
  26 + ],
  27 + ],
  28 + ];
  29 + }
  30 +
  31 + /**
  32 + * Lists all AdminMenu models.
  33 + * @return mixed
  34 + */
  35 + public function actionIndex()
  36 + {
  37 + $searchModel = new AdminMenuSearch();
  38 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  39 +
  40 + return $this->render('index', [
  41 + 'searchModel' => $searchModel,
  42 + 'dataProvider' => $dataProvider,
  43 + ]);
  44 + }
  45 +
  46 + /**
  47 + * Displays a single AdminMenu model.
  48 + * @param integer $id
  49 + * @return mixed
  50 + */
  51 + public function actionView($id)
  52 + {
  53 + return $this->render('view', [
  54 + 'model' => $this->findModel($id),
  55 + ]);
  56 + }
  57 +
  58 + /**
  59 + * Creates a new AdminMenu model.
  60 + * If creation is successful, the browser will be redirected to the 'view' page.
  61 + * @return mixed
  62 + */
  63 + public function actionCreate()
  64 + {
  65 + $model = new AdminMenu();
  66 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  67 + return $this->redirect(['view', 'id' => $model->admin_menu_id]);
  68 + } else {
  69 + return $this->render('create', [
  70 + 'model' => $model,
  71 + ]);
  72 + }
  73 + }
  74 +
  75 + /**
  76 + * Updates an existing AdminMenu model.
  77 + * If update is successful, the browser will be redirected to the 'view' page.
  78 + * @param integer $id
  79 + * @return mixed
  80 + */
  81 + public function actionUpdate($id)
  82 + {
  83 + $model = $this->findModel($id);
  84 +
  85 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  86 + return $this->redirect(['view', 'id' => $model->adminmenu_id]);
  87 + } else {
  88 + return $this->render('update', [
  89 + 'model' => $model,
  90 + ]);
  91 + }
  92 + }
  93 +
  94 + /**
  95 + * Deletes an existing AdminMenu model.
  96 + * If deletion is successful, the browser will be redirected to the 'index' page.
  97 + * @param integer $id
  98 + * @return mixed
  99 + */
  100 + public function actionDelete($id)
  101 + {
  102 + $this->findModel($id)->delete();
  103 +
  104 + return $this->redirect(['index']);
  105 + }
  106 +
  107 + /**
  108 + * Finds the AdminMenu model based on its primary key value.
  109 + * If the model is not found, a 404 HTTP exception will be thrown.
  110 + * @param integer $id
  111 + * @return AdminMenu the loaded model
  112 + * @throws NotFoundHttpException if the model cannot be found
  113 + */
  114 + protected function findModel($id)
  115 + {
  116 + if (($model = AdminMenu::findOne($id)) !== null) {
  117 + return $model;
  118 + } else {
  119 + throw new NotFoundHttpException('The requested page does not exist.');
  120 + }
  121 + }
  122 +
  123 +}
... ...
backend/controllers/LanguageController.php
... ... @@ -54,7 +54,7 @@ class LanguageController extends Controller
54 54 {
55 55 if(!empty(Yii::$app->request->get('id'))) {
56 56 $model = $this->findModel(Yii::$app->request->get('id'));
57   - $model->active = 1;
  57 + $model->status = 1;
58 58 $model->save();
59 59 return $this->redirect(['index']);
60 60 } else {
... ... @@ -77,7 +77,7 @@ class LanguageController extends Controller
77 77 public function actionDelete($id)
78 78 {
79 79 $model = $this->findModel($id);
80   - $model->active = 0;
  80 + $model->status = 0;
81 81 $model->save();
82 82  
83 83 return $this->redirect(['index']);
... ... @@ -152,18 +152,18 @@ class LanguageController extends Controller
152 152 public function actionDeleteAdress($id)
153 153 {
154 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 156 $langs = array();
157 157 if(!empty($children)) {
158 158 foreach($children as $child) {
159   - $langs = OptionLang::findAll(['id' => $child->option_id]);
  159 + $langs = OptionLang::findAll(['option_language_id' => $child->option_id]);
160 160 foreach($langs as $lang) {
161 161 $lang->delete();
162 162 }
163 163 $child->delete();
164 164 }
165 165 }
166   - $langs = OptionLang::findAll(['id' => $id]);
  166 + $langs = OptionLang::findAll(['option_language_id' => $id]);
167 167 foreach($langs as $lang) {
168 168 $lang->delete();
169 169 }
... ...
backend/controllers/MenuController.php
... ... @@ -118,4 +118,5 @@ class MenuController extends Controller
118 118 throw new NotFoundHttpException('The requested page does not exist.');
119 119 }
120 120 }
  121 +
121 122 }
... ...
backend/controllers/MenuLocationController.php
... ... @@ -4,7 +4,7 @@ namespace backend\controllers;
4 4  
5 5 use Yii;
6 6 use backend\models\MenuLocation;
7   -use backend\models\MenuSearchLocation;
  7 +use backend\models\MenuLocationSearch;
8 8 use yii\web\Controller;
9 9 use yii\web\NotFoundHttpException;
10 10 use yii\filters\VerbFilter;
... ... @@ -32,7 +32,7 @@ class MenuLocationController extends Controller
32 32 */
33 33 public function actionIndex()
34 34 {
35   - $searchModel = new MenuSearchLocation();
  35 + $searchModel = new MenuLocationSearch();
36 36 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
37 37  
38 38 return $this->render('index', [
... ...
backend/controllers/SettingsController.php 0 → 100644
  1 +<?php
  2 +namespace backend\controllers;
  3 +
  4 +use Yii;
  5 +use yii\filters\AccessControl;
  6 +use yii\web\Controller;
  7 +use common\models\LoginForm;
  8 +use yii\filters\VerbFilter;
  9 +use backend\models\Profile;
  10 +use common\models\User;
  11 +use frontend\models\Option;
  12 +use yii\data\ActiveDataProvider;
  13 +use yii\validators\BooleanValidator;
  14 +use yii\validators\StringValidator;
  15 +/**
  16 + * Site controller
  17 + */
  18 +class SettingsController extends Controller
  19 +{
  20 + public $layout = 'settings';
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public function actions()
  25 + {
  26 + return [
  27 + 'error' => [
  28 + 'class' => 'yii\web\ErrorAction',
  29 + ],
  30 + ];
  31 + }
  32 +
  33 + public function actionIndex()
  34 + {
  35 + return $this->render('index');
  36 + }
  37 +
  38 +}
... ...
backend/controllers/SiteController.php
... ... @@ -57,7 +57,19 @@ class SiteController extends Controller
57 57  
58 58 public function actionIndex()
59 59 {
60   - return $this->render('index');
  60 +/*
  61 + if (Yii::$app->user->can('site/index'))
  62 + {
  63 +
  64 + }
  65 + else
  66 + {
  67 + Yii::$app->getSession()->setFlash('error', 'Доступ закрыт..');
  68 +
  69 + return $this->redirect('/');
  70 + }
  71 +*/
  72 + return $this->render('index');
61 73 }
62 74  
63 75 public function actionLogin()
... ...
backend/controllers/TerminController.php
... ... @@ -10,6 +10,7 @@ use yii\web\NotFoundHttpException;
10 10 use yii\filters\VerbFilter;
11 11 use backend\models\TerminLang;
12 12 use backend\models\TerminStructure;
  13 +use yii\filters\AccessControl;
13 14  
14 15 /**
15 16 * TerminController implements the CRUD actions for Termin model.
... ...
backend/models/AdminMenu.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "admin_menu".
  9 + *
  10 + * @property integer $admin_menu_id
  11 + * @property integer $admin_menu_pid
  12 + * @property integer $status
  13 + * @property integer $hide_min
  14 + * @property integer $sort
  15 + * @property string $name
  16 + * @property string $path
  17 + * @property string $param
  18 + *
  19 + * @property AdminMenu $parent
  20 + * @property AdminMenu[] $adminMenus
  21 + * @property AdminMenuAccessGroup[] $adminMenuAccessGroups
  22 + * @property AdminMenuAccessUser[] $adminMenuAccessUsers
  23 + */
  24 +class AdminMenu extends \yii\db\ActiveRecord
  25 +{
  26 +
  27 + public $parentt;
  28 + /**
  29 + * @inheritdoc
  30 + */
  31 + public static function tableName()
  32 + {
  33 + return 'admin_menu';
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function rules()
  40 + {
  41 + return [
  42 + [['admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'],
  43 + [['name'], 'required'],
  44 + [['name', 'path', 'param','parentt'], 'string']
  45 + ];
  46 + }
  47 +
  48 + /**
  49 + * @inheritdoc
  50 + */
  51 + public function attributeLabels()
  52 + {
  53 + return [
  54 + 'admin_menu_id' => Yii::t('app', 'Admin menu ID'),
  55 + 'admin_menu_pid' => Yii::t('app', 'Admin menu parent ID'),
  56 + 'status' => Yii::t('app', 'Status'),
  57 + 'hide_min' => Yii::t('app', 'Hide Min'),
  58 + 'sort' => Yii::t('app', 'Sort'),
  59 + 'name' => Yii::t('app', 'Name'),
  60 + 'path' => Yii::t('app', 'Path'),
  61 + 'param' => Yii::t('app', 'Params'),
  62 + 'parentt' => Yii::t('app', 'Parent item')
  63 + ];
  64 + }
  65 +
  66 + /**
  67 + * @return \yii\db\ActiveQuery
  68 + */
  69 + public function getParent()
  70 + {
  71 + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_pid']);
  72 + }
  73 +
  74 + /**
  75 + * @return \yii\db\ActiveQuery
  76 + */
  77 + public function getAdminMenus()
  78 + {
  79 + return $this->hasMany(AdminMenu::className(), ['admin_menu_pid' => 'admin_menu_id']);
  80 + }
  81 +
  82 + /**
  83 + * @return \yii\db\ActiveQuery
  84 + */
  85 + public function getAdminMenuAccessGroups()
  86 + {
  87 + return $this->hasMany(AdminMenuAccessGroup::className(), ['admin_menu_id' => 'admin_menu_id']);
  88 + }
  89 +
  90 + /**
  91 + * @return \yii\db\ActiveQuery
  92 + */
  93 + public function getAdminMenuAccessUsers()
  94 + {
  95 + return $this->hasMany(AdminMenuAccessUser::className(), ['admin_menu_id' => 'admin_menu_id']);
  96 + }
  97 +
  98 + public static function buildMenu($withValues = false)
  99 + {
  100 + $result = [];
  101 + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all();
  102 + foreach($roots as $root) {
  103 + if($root->adminMenus) {
  104 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'options' => ['class' => 'header']];
  105 + foreach($root->adminMenus as $submenu) {
  106 + if($submenu->adminMenus) {
  107 + $items = [];
  108 + foreach($submenu->adminMenus as $item) {
  109 + $items[] = ['label' => Yii::t('app', $item->name), 'id' => $item->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$item->path], \common\models\Tools::parseUrlParams($item->param))];
  110 + }
  111 + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items];
  112 + unset($items);
  113 + } else {
  114 + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->param))];
  115 + }
  116 + }
  117 + }
  118 + }
  119 + return $result;
  120 + }
  121 +
  122 + public static function buildMenuSelect()
  123 + {
  124 + $result = [];
  125 + $roots = self::find()->where(['admin_menu_pid' => NULL])->with(['adminMenus'])->all();
  126 + foreach($roots as $root) {
  127 + if($root->adminMenus) {
  128 + $items = [];
  129 + foreach($root->adminMenus as $submenu) {
  130 + $items[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->admin_menu_id];
  131 + }
  132 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id, 'items' => $items];
  133 + unset($items);
  134 + } else {
  135 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->admin_menu_id];
  136 + }
  137 + }
  138 + return $result;
  139 + }
  140 +
  141 + public function beforeSave($insert)
  142 + {
  143 + if (parent::beforeSave($insert)) {
  144 + if(!$this->admin_menu_pid) {
  145 + $this->admin_menu_pid = NULL;
  146 + }
  147 + return true;
  148 + } else {
  149 + return false;
  150 + }
  151 + }
  152 +}
... ...
backend/models/AdminMenuAccessGroup.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "admin_menu_access_group".
  9 + *
  10 + * @property integer $admin_menu_access_group_id
  11 + * @property integer $admin_menu_id
  12 + * @property string $group
  13 + *
  14 + * @property AdminMenu $menu
  15 + * @property AuthRule $group0
  16 + */
  17 +class AdminMenuAccessGroup extends \yii\db\ActiveRecord
  18 +{
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public static function tableName()
  23 + {
  24 + return 'admin_menu_access_group';
  25 + }
  26 +
  27 + /**
  28 + * @inheritdoc
  29 + */
  30 + public function rules()
  31 + {
  32 + return [
  33 + [['admin_menu_id'], 'integer'],
  34 + [['group'], 'string']
  35 + ];
  36 + }
  37 +
  38 + /**
  39 + * @inheritdoc
  40 + */
  41 + public function attributeLabels()
  42 + {
  43 + return [
  44 + 'admin_menu_access_group_id' => Yii::t('app', 'Admin Access Group ID'),
  45 + 'admin_menu_id' => Yii::t('app', 'Admin Menu ID'),
  46 + 'group' => Yii::t('app', 'Group'),
  47 + ];
  48 + }
  49 +
  50 + /**
  51 + * @return \yii\db\ActiveQuery
  52 + */
  53 + public function getMenu()
  54 + {
  55 + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']);
  56 + }
  57 +
  58 + /**
  59 + * @return \yii\db\ActiveQuery
  60 + */
  61 + public function getGroup0()
  62 + {
  63 + return $this->hasOne(AuthRule::className(), ['name' => 'group']);
  64 + }
  65 +}
... ...
backend/models/AdminMenuAccessUser.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use common\models\User;
  6 +use Yii;
  7 +
  8 +/**
  9 + * This is the model class for table "admin_menu_access_user".
  10 + *
  11 + * @property integer $admin_menu_id
  12 + * @property integer $user_id
  13 + * @property integer $admin_menu_access_user_id
  14 + *
  15 + * @property AdminMenu $menu
  16 + * @property User $user
  17 + */
  18 +class AdminMenuAccessUser extends \yii\db\ActiveRecord
  19 +{
  20 + /**
  21 + * @inheritdoc
  22 + */
  23 + public static function tableName()
  24 + {
  25 + return 'admin_menu_access_user';
  26 + }
  27 +
  28 + /**
  29 + * @inheritdoc
  30 + */
  31 + public function rules()
  32 + {
  33 + return [
  34 + [['admin_menu_id', 'user_id'], 'integer']
  35 + ];
  36 + }
  37 +
  38 + /**
  39 + * @inheritdoc
  40 + */
  41 + public function attributeLabels()
  42 + {
  43 + return [
  44 + 'admin_menu_id' => Yii::t('app', 'Admin Menu ID'),
  45 + 'user_id' => Yii::t('app', 'User ID'),
  46 + 'admin_menu_access_user_id' => Yii::t('app', 'Admin Menu Access User ID'),
  47 + ];
  48 + }
  49 +
  50 + /**
  51 + * @return \yii\db\ActiveQuery
  52 + */
  53 + public function getMenu()
  54 + {
  55 + return $this->hasOne(AdminMenu::className(), ['admin_menu_id' => 'admin_menu_id']);
  56 + }
  57 +
  58 + /**
  59 + * @return \yii\db\ActiveQuery
  60 + */
  61 + public function getUser()
  62 + {
  63 + return $this->hasOne(User::className(), ['id' => 'user_id']);
  64 + }
  65 +}
... ...
backend/models/AdminMenuSearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use backend\models\AdminMenu;
  9 +
  10 +/**
  11 + * AdminMenuSearch represents the model behind the search form about `backend\models\AdminMenu`.
  12 + */
  13 +class AdminMenuSearch extends AdminMenu
  14 +{
  15 +
  16 +
  17 + /**
  18 + * @inheritdoc
  19 + */
  20 + public function rules()
  21 + {
  22 + return [
  23 + [['admin_menu_id', 'admin_menu_pid', 'status', 'hide_min', 'sort'], 'integer'],
  24 + [['name', 'path', 'param','parentt'], 'safe'],
  25 + ];
  26 + }
  27 +
  28 + /**
  29 + * @inheritdoc
  30 + */
  31 + public function scenarios()
  32 + {
  33 + // bypass scenarios() implementation in the parent class
  34 + return Model::scenarios();
  35 + }
  36 +
  37 + /**
  38 + * Creates data provider instance with search query applied
  39 + *
  40 + * @param array $params
  41 + *
  42 + * @return ActiveDataProvider
  43 + */
  44 + public function search($params)
  45 + {
  46 + $query = AdminMenu::find();
  47 +
  48 + $dataProvider = new ActiveDataProvider([
  49 + 'query' => $query,
  50 + 'pagination' => [
  51 + 'pageSize' => 5
  52 + ],
  53 + 'sort' => [
  54 + 'attributes' => [
  55 + 'admin_menu_id',
  56 + 'name',
  57 + 'path',
  58 + 'param',
  59 + 'status',
  60 + 'hide_min',
  61 + 'parentt' => [
  62 + 'asc' => ['name' => SORT_ASC],
  63 + 'desc' => ['name' => SORT_DESC],
  64 + 'default' => SORT_DESC
  65 + ]
  66 + ]
  67 + ]
  68 + ]);
  69 +
  70 + $this->load($params);
  71 +
  72 + if (!$this->validate()) {
  73 + // uncomment the following line if you do not want to return any records when validation fails
  74 + // $query->where('0=1');
  75 + return $dataProvider;
  76 + }
  77 +
  78 + $query->andFilterWhere([
  79 + 'admin_menu_id' => $this->admin_menu_id,
  80 + 'admin_menu_pid' => $this->admin_menu_pid,
  81 + 'status' => $this->status,
  82 + 'hide_min' => $this->hide_min,
  83 + 'sort' => $this->sort
  84 + ]);
  85 +
  86 +
  87 + $query->andFilterWhere(['like', 'name', $this->name])
  88 + ->andFilterWhere(['like', 'path', $this->path])
  89 + ->andFilterWhere(['like', 'param', $this->param])
  90 + ->andFilterWhere(['in', 'admin_menu_pid', $this->find()->select(['admin_menu_id'])->andFilterWhere(['like', 'name', $this->parentt])->column()]);
  91 +
  92 + return $dataProvider;
  93 + }
  94 +}
... ...
backend/models/Import.php
... ... @@ -42,7 +42,7 @@ class Import extends \yii\db\ActiveRecord
42 42 $termin_pid = 8;
43 43 // $template_id шаблон каьегорий
44 44 $template_id = 3;
45   - $lang_id = 2;
  45 + $language_id = 2;
46 46 $type = 'H';
47 47  
48 48 // массив для импортп товаров
... ... @@ -69,7 +69,7 @@ class Import extends \yii\db\ActiveRecord
69 69 // массив для поиска/добавления термина
70 70 $basic = [
71 71 'type' => $type,
72   - 'lang_id' => $lang_id,
  72 + 'language_id' => $language_id,
73 73 'template_id' => $template_id,
74 74 ];
75 75  
... ...
backend/models/LanguageSearch.php
... ... @@ -19,8 +19,8 @@ class LanguageSearch extends Language
19 19 {
20 20 return [
21 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 59 $query->andFilterWhere([
60 60 'language_id' => $this->language_id,
61 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 66 ->andFilterWhere(['like', 'language_name', $this->language_name])
67   - ->andWhere(['active' => '1'])
  67 + ->andWhere(['status' => '1'])
68 68 ->andWhere(['>', 'language_id', '0']);
69 69  
70 70 return $dataProvider;
... ... @@ -89,12 +89,12 @@ class LanguageSearch extends Language
89 89 $query->andFilterWhere([
90 90 'language_id' => $this->language_id,
91 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 96 ->andFilterWhere(['like', 'language_name', $this->language_name])
97   - ->andWhere(['active' => '0']);
  97 + ->andWhere(['status' => '0']);
98 98  
99 99 return $dataProvider;
100 100 }
... ...
backend/models/Menu.php
... ... @@ -80,7 +80,7 @@ class Menu extends \yii\db\ActiveRecord
80 80 AND menu_location.menu_location_name = \''.$location_name.'\'
81 81 INNER JOIN termin ON termin.termin_id = menu.termin_id
82 82 INNER JOIN termin_lang ON termin_lang.termin_id = menu.termin_id
83   - AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].'
  83 + AND termin_lang.language_id = '.Yii::$app->params['language_id'].'
84 84 ORDER BY menu.level ASC, menu.sortorder ASC
85 85 ')->queryAll();
86 86 /*
... ... @@ -90,8 +90,13 @@ class Menu extends \yii\db\ActiveRecord
90 90 ->join(
91 91 'INNER JOIN',
92 92 'termin_lang.termin_id = menu.termin_id',
93   - ['lang_id' => yii::$app->params['lang_id']])
  93 + ['language_id' => yii::$app->params['language_id']])
94 94 ->all();
95 95 */
96 96 }
  97 +
  98 + public function getTerminLang()
  99 + {
  100 + return $this->hasOne(TerminLang::className(), ['termin_id' => 'termin_id']);
  101 + }
97 102 }
... ...
backend/models/MenuLocation.php
... ... @@ -59,6 +59,6 @@ class MenuLocation extends \yii\db\ActiveRecord
59 59 */
60 60 public function getLangs()
61 61 {
62   - return $this->hasMany(Language::className(), ['language_id' => 'lang_id'])->viaTable('menu_location_lang', ['menu_location_id' => 'menu_location_id']);
  62 + return $this->hasMany(Language::className(), ['language_id' => 'language_id'])->viaTable('menu_location_lang', ['menu_location_id' => 'menu_location_id']);
63 63 }
64 64 }
... ...
backend/models/MenuLocationLang.php
... ... @@ -9,7 +9,7 @@ use Yii;
9 9 *
10 10 * @property integer $menu_location_id
11 11 * @property string $menu_location_title
12   - * @property integer $lang_id
  12 + * @property integer $language_id
13 13 *
14 14 * @property Language $lang
15 15 * @property MenuLocation $menuLocation
... ... @@ -30,8 +30,8 @@ class MenuLocationLang extends \yii\db\ActiveRecord
30 30 public function rules()
31 31 {
32 32 return [
33   - [['menu_location_id', 'menu_location_title', 'lang_id'], 'required'],
34   - [['menu_location_id', 'lang_id'], 'integer'],
  33 + [['menu_location_id', 'menu_location_title', 'language_id'], 'required'],
  34 + [['menu_location_id', 'language_id'], 'integer'],
35 35 [['menu_location_title'], 'string', 'max' => 250]
36 36 ];
37 37 }
... ... @@ -44,7 +44,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord
44 44 return [
45 45 'menu_location_id' => Yii::t('app', 'Menu Location ID'),
46 46 'menu_location_title' => Yii::t('app', 'Menu Location Title'),
47   - 'lang_id' => Yii::t('app', 'Lang ID'),
  47 + 'language_id' => Yii::t('app', 'Lang ID'),
48 48 ];
49 49 }
50 50  
... ... @@ -53,7 +53,7 @@ class MenuLocationLang extends \yii\db\ActiveRecord
53 53 */
54 54 public function getLang()
55 55 {
56   - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']);
  56 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
57 57 }
58 58  
59 59 /**
... ...
backend/models/MenuSearch.php
... ... @@ -49,7 +49,8 @@ class MenuSearch extends Menu
49 49  
50 50 $this->load($params);
51 51  
52   - if (!$this->validate()) {
  52 + if (! $this->validate())
  53 + {
53 54 // uncomment the following line if you do not want to return any records when validation fails
54 55 // $query->where('0=1');
55 56 return $dataProvider;
... ... @@ -67,7 +68,7 @@ class MenuSearch extends Menu
67 68 ]);
68 69  
69 70 $query->andFilterWhere(['like', 'name', $this->name])
70   - ->andFilterWhere(['like', 'url', $this->url]);
  71 + ->andFilterWhere(['like', 'url', $this->url]);
71 72  
72 73 return $dataProvider;
73 74 }
... ...
backend/models/NewOptionsLang.php
... ... @@ -9,7 +9,7 @@ use Yii;
9 9 *
10 10 * @property integer $primary
11 11 * @property integer $id
12   - * @property integer $lang_id
  12 + * @property integer $language_id
13 13 * @property string $value
14 14 */
15 15 class NewOptionsLang extends \yii\db\ActiveRecord
... ... @@ -32,7 +32,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord
32 32 {
33 33 return [
34 34 [['id', 'value'], 'required'],
35   - [['id', 'lang_id'], 'integer'],
  35 + [['id', 'language_id'], 'integer'],
36 36 [['value'], 'string']
37 37 ];
38 38 }
... ... @@ -45,7 +45,7 @@ class NewOptionsLang extends \yii\db\ActiveRecord
45 45 return [
46 46 'primary' => Yii::t('app', 'Primary'),
47 47 'id' => Yii::t('app', 'ID'),
48   - 'lang_id' => Yii::t('app', 'Lang ID'),
  48 + 'language_id' => Yii::t('app', 'Lang ID'),
49 49 'value' => Yii::t('app', 'Value'),
50 50 ];
51 51 }
... ...
backend/models/NewOptionsLangSearch.php
... ... @@ -18,7 +18,7 @@ class NewOptionsLangSearch extends NewOptionsLang
18 18 public function rules()
19 19 {
20 20 return [
21   - [['primary', 'id', 'lang_id'], 'integer'],
  21 + [['primary', 'id', 'language_id'], 'integer'],
22 22 [['value'], 'safe'],
23 23 ];
24 24 }
... ... @@ -58,7 +58,7 @@ class NewOptionsLangSearch extends NewOptionsLang
58 58 $query->andFilterWhere([
59 59 'primary' => $this->primary,
60 60 'id' => $this->id,
61   - 'lang_id' => $this->lang_id,
  61 + 'language_id' => $this->language_id,
62 62 ]);
63 63  
64 64 $query->andFilterWhere(['like', 'value', $this->value]);
... ...
backend/models/Termin.php
... ... @@ -57,7 +57,7 @@ class Termin extends \yii\db\ActiveRecord
57 57  
58 58 /**
59 59 * Выполняет поиск по параметрам
60   - * @param array $param принимает [termin_id, lang_id, return_one, return_field, show_all]
  60 + * @param array $param принимает [termin_id, language_id, return_one, return_field, show_all]
61 61 * @return array one | array all | string значение масива
62 62 */
63 63 public function finInfo (array $params = [])
... ... @@ -65,7 +65,7 @@ class Termin extends \yii\db\ActiveRecord
65 65 Tools::ifNotExist ($params, array (
66 66 'termin_id' => false,
67 67 'termin_pid' => false,
68   - 'lang_id' => Yii::$app->params['lang_id'],
  68 + 'language_id' => Yii::$app->params['language_id'],
69 69 'return_one' => false,
70 70 'return_field' => false,
71 71 'show_all' => false,
... ... @@ -92,9 +92,9 @@ class Termin extends \yii\db\ActiveRecord
92 92 'termin.termin_id = termin_lang.termin_id'
93 93 );
94 94  
95   - if ($params['lang_id'])
  95 + if ($params['language_id'])
96 96 {
97   - $WHERE['termin_lang.lang_id'] = $params['lang_id'];
  97 + $WHERE['termin_lang.language_id'] = $params['language_id'];
98 98 }
99 99  
100 100 // структура
... ... @@ -169,7 +169,7 @@ class Termin extends \yii\db\ActiveRecord
169 169 */
170 170 public function getLangs()
171 171 {
172   - return $this->hasMany(Language::className(), ['language_id' => 'lang_id'])
  172 + return $this->hasMany(Language::className(), ['language_id' => 'language_id'])
173 173 ->viaTable('termin_lang', ['termin_id' => 'termin_id']);
174 174 }
175 175  
... ...
backend/models/TerminLang.php
... ... @@ -8,7 +8,7 @@ use Yii;
8 8 * This is the model class for table "termin_lang".
9 9 *
10 10 * @property integer $termin_id
11   - * @property integer $lang_id
  11 + * @property integer $language_id
12 12 * @property string $termin_title
13 13 * @property string $termin_alias
14 14 *
... ... @@ -31,8 +31,8 @@ class TerminLang extends \yii\db\ActiveRecord
31 31 public function rules()
32 32 {
33 33 return [
34   - [['lang_id'], 'required'],
35   - [['lang_id'], 'integer'],
  34 + [['language_id'], 'required'],
  35 + [['language_id'], 'integer'],
36 36 [['termin_title', 'termin_alias'], 'string', 'max' => 250]
37 37 ];
38 38 }
... ... @@ -44,7 +44,7 @@ class TerminLang extends \yii\db\ActiveRecord
44 44 {
45 45 return [
46 46 'termin_id' => Yii::t('app', 'Termin ID'),
47   - 'lang_id' => Yii::t('app', 'Lang ID'),
  47 + 'language_id' => Yii::t('app', 'Lang ID'),
48 48 'termin_title' => Yii::t('app', 'Termin Title'),
49 49 'termin_alias' => Yii::t('app', 'Termin Alias'),
50 50 ];
... ... @@ -55,7 +55,7 @@ class TerminLang extends \yii\db\ActiveRecord
55 55 */
56 56 public function getLang()
57 57 {
58   - return $this->hasOne(Language::className(), ['language_id' => 'lang_id']);
  58 + return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
59 59 }
60 60  
61 61 /**
... ...
backend/models/TerminSearch.php
... ... @@ -19,7 +19,7 @@ class TerminSearch extends Termin
19 19 {
20 20 return [
21 21 [['termin_id', 'is_book'], 'integer'],
22   - [['termin_name'], 'safe'],
  22 + [['termin_name', 'termin_title', 'termin_parent_title'], 'safe'],
23 23 ];
24 24 }
25 25  
... ... @@ -42,6 +42,7 @@ class TerminSearch extends Termin
42 42 public function search($params)
43 43 {
44 44 $query = Termin::find();
  45 + $query->select('*');
45 46  
46 47 $dataProvider = new ActiveDataProvider([
47 48 'query' => $query,
... ... @@ -53,7 +54,9 @@ class TerminSearch extends Termin
53 54 // uncomment the following line if you do not want to return any records when validation fails
54 55 // $query->where('0=1');
55 56 return $dataProvider;
56   - }
  57 + }
  58 +
  59 + $query->joinWith(['terminLangs', 'terminStructures']);
57 60  
58 61 $query->andFilterWhere([
59 62 'termin_id' => $this->termin_id,
... ... @@ -61,6 +64,8 @@ class TerminSearch extends Termin
61 64 ]);
62 65  
63 66 $query->andFilterWhere(['like', 'termin_name', $this->termin_name]);
  67 + $query->andFilterWhere(['like', TerminLang::tableName().'.termin_title', $this->termin_title]);
  68 + //$query->andFilterWhere(['like', 'termin_title', $this->termin_title]);
64 69  
65 70 return $dataProvider;
66 71 }
... ...
backend/models/TerminStructure.php
... ... @@ -51,7 +51,7 @@ class TerminStructure extends \yii\db\ActiveRecord
51 51 {
52 52 return $this->hasOne(Termin::className(), ['termin_id' => 'termin_id']);
53 53 }
54   -
  54 +
55 55 /**
56 56 * @return \yii\db\ActiveQuery
57 57 */
... ...
backend/views/admin-menu/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use backend\models\AdminMenu;
  4 +use common\models\Tools;
  5 +use yii\helpers\Html;
  6 +use yii\widgets\ActiveForm;
  7 +
  8 +/* @var $this yii\web\View */
  9 +/* @var $model backend\models\AdminMenu */
  10 +/* @var $form yii\widgets\ActiveForm */
  11 +?>
  12 +
  13 +<div class="admin-menu-form">
  14 +
  15 + <?php $form = ActiveForm::begin(); ?>
  16 +
  17 + <?= $form->field($model, 'name')->textInput() ?>
  18 +
  19 + <?= $form->field($model, 'status')->checkbox() ?>
  20 +
  21 + <?= $form->field($model, 'hide_min')->checkbox() ?>
  22 +
  23 + <?= $form->field($model, 'path')->textInput() ?>
  24 +
  25 + <?= $form->field($model, 'param')->textInput() ?>
  26 +
  27 + <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
  28 + <div class="panel panel-default">
  29 + <div class="panel-heading" role="tab" id="headingOne">
  30 + <h4 class="panel-title">
  31 + <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
  32 + <?= Yii::t('app', 'Parent menu item') ?>
  33 + </a>
  34 + </h4>
  35 + </div>
  36 + <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
  37 + <ul class="list-group checkboxer">
  38 + <?php
  39 + $roots = AdminMenu::buildMenuSelect();
  40 + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level0 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => 0, 'uncheck' => null, 'label' => Yii::t('app', 'root'), 'labelOptions' => ['class' => 'checkboxer_label']]);
  41 + foreach($roots as $root) {
  42 + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level1 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $root['id'], 'uncheck' => null, 'label' => Yii::t('app', $root['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);
  43 + if($root['items']) {
  44 + foreach($root['items'] as $submenu) {
  45 + echo $form->field($model, 'admin_menu_pid', ['options' => ['class' => 'form-group list-group-item level2 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $submenu['id'], 'uncheck' => null, 'label' => Yii::t('app', $submenu['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);
  46 + }
  47 + }
  48 + }
  49 + ?>
  50 + </ul>
  51 + </div>
  52 + </div>
  53 + </div>
  54 +
  55 + <div class="form-group">
  56 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => ($model->isNewRecord ? 'btn btn-success' : 'btn btn-primary') . ' btn-flat']) ?>
  57 + </div>
  58 +
  59 + <?php ActiveForm::end(); ?>
  60 +
  61 +</div>
... ...
backend/views/admin-menu/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model backend\models\AdminMenuSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="admin-menu-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'id') ?>
  19 +
  20 + <?= $form->field($model, 'parent_id') ?>
  21 +
  22 + <?= $form->field($model, 'active') ?>
  23 +
  24 + <?= $form->field($model, 'hide_min') ?>
  25 +
  26 + <?= $form->field($model, 'sort') ?>
  27 +
  28 + <?php // echo $form->field($model, 'name') ?>
  29 +
  30 + <?php // echo $form->field($model, 'path') ?>
  31 +
  32 + <?php // echo $form->field($model, 'params') ?>
  33 +
  34 + <div class="form-group">
  35 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  36 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  37 + </div>
  38 +
  39 + <?php ActiveForm::end(); ?>
  40 +
  41 +</div>
... ...
backend/views/admin-menu/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model backend\models\AdminMenu */
  8 +
  9 +$this->title = Yii::t('app', 'Create Admin Menu');
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="admin-menu-create">
  14 + <div class="box box-primary">
  15 + <div class="box-body">
  16 + <?= $this->render('_form', [
  17 + 'model' => $model,
  18 + ]) ?>
  19 + </div>
  20 + </div>
  21 +
  22 +</div>
... ...
backend/views/admin-menu/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $searchModel backend\models\AdminMenuSearch */
  8 +/* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 +$this->title = Yii::t('app', 'Admin Menus');
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="admin-menu-index box box-primary">
  14 +
  15 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  16 +
  17 + <?= GridView::widget([
  18 + 'dataProvider' => $dataProvider,
  19 + 'filterModel' => $searchModel,
  20 + 'showFooter' => true,
  21 + 'layout' => "<div class='box-header with-border admin_grid_action'>
  22 + <div class='action_link'>"
  23 + .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']).
  24 + "</div>
  25 + <div class='pull-right'>
  26 + {pager}
  27 + </div>
  28 + </div>
  29 + <div class='box-body no-padding table-responsive'>
  30 + {items}
  31 + </div>
  32 + <div class='box-footer admin_grid_action'>
  33 + <div class='action_link'>"
  34 + .Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success btn-flat']).
  35 + "</div>
  36 + <div class='pull-right'>
  37 + {pager}
  38 + </div>
  39 + </div>",
  40 + 'columns' => [
  41 + ['class' => 'yii\grid\ActionColumn'],
  42 + 'admin_menu_id',
  43 + 'name',
  44 + 'path',
  45 + 'param',
  46 + [
  47 + 'format' => 'raw',
  48 + 'filter' => [
  49 + '1'=>'Отображаются',
  50 + '0'=>'Скрытые',
  51 + ],
  52 + 'value' => function($data){
  53 + if($data->status){
  54 + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>';
  55 + } else {
  56 + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>';
  57 + }
  58 + return $status_img;
  59 + },
  60 + 'attribute'=>'status',
  61 + ],
  62 + [
  63 + 'attribute' => 'parentt',
  64 + 'content' =>
  65 + function($model, $key, $index, $column) {
  66 + if($model->parent->admin_menu_id) {
  67 + return $model->parent->name;
  68 + } else {
  69 + return '<i class="small">'.Yii::t('app', 'Корневой элемент').'</i>';
  70 + }
  71 + }
  72 + ],
  73 + [
  74 + 'format' => 'raw',
  75 + 'filter' => [
  76 + '1'=>'Отображаются',
  77 + '0'=>'Скрытые',
  78 + ],
  79 + 'value' => function($data){
  80 + if($data->hide_min){
  81 + $status_img = '<i style="color: #008000" class="glyphicon glyphicon-ok"></i>';
  82 + } else {
  83 + $status_img = '<i style="color: red" class="glyphicon glyphicon-remove"></i>';
  84 + }
  85 + return $status_img;
  86 + },
  87 + 'attribute'=>'hide_min',
  88 + ],
  89 + ],
  90 + ]); ?>
  91 +
  92 +</div>
... ...
backend/views/admin-menu/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model backend\models\AdminMenu */
  7 +
  8 +$this->title = Yii::t('app', 'Update') . ': ' . $model->name;
  9 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']];
  10 +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->admin_menu_id]];
  11 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  12 +?>
  13 +<div class="admin-menu-update">
  14 +
  15 + <?= $this->render('_form', [
  16 + 'model' => $model,
  17 + ]) ?>
  18 +
  19 +</div>
... ...
backend/views/admin-menu/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model backend\models\AdminMenu */
  8 +
  9 +$this->title = Yii::t('app', 'Admin Menus').': '.$model->name;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +
  14 +<div class="admin-menu-view box box-primary">
  15 +<?= DetailView::widget([
  16 + 'model' => $model,
  17 + 'attributes' => [
  18 + 'admin_menu_id',
  19 + 'admin_menu_pid',
  20 + 'status',
  21 + 'hide_min',
  22 + 'sort',
  23 + 'name',
  24 + 'path',
  25 + 'param',
  26 + ],
  27 + ]) ?>
  28 +
  29 + <div class="box-footer with-border">
  30 + <p>
  31 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->admin_menu_id], ['class' => 'btn btn-primary btn-flat']) ?>
  32 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->admin_menu_id], [
  33 + 'class' => 'btn btn-danger btn-flat',
  34 + 'data' => [
  35 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  36 + 'method' => 'post',
  37 + ],
  38 + ]) ?>
  39 + <?= Html::a(Yii::t('app', 'Back'), ['index'], ['class' => 'btn btn-default btn-flat']) ?>
  40 + </p>
  41 + </div>
  42 +
  43 +</div>
0 44 \ No newline at end of file
... ...
backend/views/blog/articles.php
... ... @@ -21,7 +21,7 @@ echo GridView::widget([
21 21 'class' => Column::className(),
22 22 'header' => Yii::t('app', 'Name'),
23 23 'content' => function($model, $key, $index, $column) {
24   - return $model->getArticleLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name;
  24 + return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name;
25 25 }
26 26 ],
27 27 [
... ...
backend/views/language/_form_adress_edit.php
... ... @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm;
21 21 <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?>
22 22 <?php
23 23 if($row->translate) {
24   - foreach($row->getLangs() as $lang_id => $lang) {
  24 + foreach($row->getLangs() as $language_id => $lang) {
25 25 ?>
26 26 <div class="form-group">
27 27 <div class="col-xs-1"><?=$lang['lang_code']?></div>
... ...
backend/views/language/index.php
... ... @@ -28,7 +28,7 @@ echo $this-&gt;render(&#39;layout&#39;);
28 28 }
29 29 ],
30 30 'language_name',
31   - 'lang_code',
  31 + 'language_code',
32 32 'is_default:boolean',
33 33 [
34 34 'class' => 'yii\grid\ActionColumn',
... ...
backend/views/language/view_adress.php
... ... @@ -24,7 +24,7 @@ echo $this-&gt;render(&#39;layout&#39;);
24 24 [
25 25 'class' => 'yii\grid\Column',
26 26 'content' => function($model, $key, $index, $column) {
27   - return OptionLang::find()->select('value')->where(['lang_id' => 0, 'id' => $model->option_id])->scalar();
  27 + return OptionLang::find()->select('value')->where(['language_id' => 0, 'id' => $model->option_id])->scalar();
28 28 },
29 29 'header' => Yii::t('app', 'adress_name')
30 30 ],
... ...
backend/views/layouts/header.php
... ... @@ -23,6 +23,19 @@ $username = Yii::$app-&gt;user-&gt;identity-&gt;firstname.&#39; &#39;.Yii::$app-&gt;user-&gt;identity-&gt;
23 23  
24 24 <ul class="nav navbar-nav">
25 25  
  26 + <!-- search form -->
  27 + <li class="header-search">
  28 + <form action="#" method="get" class="sidebar-form">
  29 + <div class="input-group">
  30 + <input type="text" name="q" class="form-control" placeholder="Search..."/>
  31 + <span class="input-group-btn">
  32 + <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
  33 + </button>
  34 + </span>
  35 + </div>
  36 + </form>
  37 + </li>
  38 + <!-- /.search form -->
26 39 <!-- Messages: style can be found in dropdown.less-->
27 40 <li class="dropdown messages-menu">
28 41 <a href="#" class="dropdown-toggle" data-toggle="dropdown">
... ...
backend/views/layouts/left.php
... ... @@ -14,79 +14,15 @@
14 14 </div>
15 15 </div>
16 16  
17   - <!-- search form -->
18   - <form action="#" method="get" class="sidebar-form">
19   - <div class="input-group">
20   - <input type="text" name="q" class="form-control" placeholder="Search..."/>
21   - <span class="input-group-btn">
22   - <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
23   - </button>
24   - </span>
25   - </div>
26   - </form>
27   - <!-- /.search form -->
28   -
29   - <?= dmstr\widgets\Menu::widget(
30   - [
31   - 'options' => ['class' => 'sidebar-menu'],
32   - 'items' => [
33   - ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']],
34   - //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']],
35   - //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']],
36   - ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']],
37   - ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']],
38   - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']],
39   - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']],
40   - ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
41   - ['label' => 'Пользователи', 'icon' => 'fa fa-file-code-o', 'url' => ['/user/']],
42   - [
43   - 'label' => Yii::t('app', 'Blog'),
44   - 'icon' => 'fa fa-share',
45   - 'url' => '#',
46   - 'items' => [
47   - ['label' => Yii::t('app', 'Static pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['blog/articles', 'category_id' => '63'],],
48   - ['label' => Yii::t('app', 'Categories'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/categories'],],
49   - ['label' => Yii::t('app', 'Articles'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/articles'],],
50   - ],
51   - ],
52   - [
53   - 'label' => 'Роли',
54   - 'icon' => 'fa fa-share',
55   - 'url' => '#',
56   - 'items' => [
57   - ['label' => 'Управление ролями', 'icon' => 'fa fa-file-code-o', 'url' => ['/permit/access/role'],],
58   - ['label' => 'Управление правами доступа', 'icon' => 'fa fa-dashboard', 'url' => ['/permit/access/permission'],],
59   - ],
60   - ],
61   - [
62   - 'label' => 'Same tools',
63   - 'icon' => 'fa fa-share',
64   - 'url' => '#',
65   - 'items' => [
66   - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii'],],
67   - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug'],],
68   - [
69   - 'label' => 'Level One',
70   - 'icon' => 'fa fa-circle-o',
71   - 'url' => '#',
72   - 'items' => [
73   - ['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#',],
74   - [
75   - 'label' => 'Level Two',
76   - 'icon' => 'fa fa-circle-o',
77   - 'url' => '#',
78   - 'items' => [
79   - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',],
80   - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',],
81   - ],
82   - ],
83   - ],
84   - ],
85   - ],
86   - ],
87   - ],
88   - ]
89   - ) ?>
  17 + <?= dmstr\widgets\Menu::widget([
  18 + 'options' => ['class' => 'sidebar-menu'],
  19 + 'items' => array_merge(
  20 + \backend\models\AdminMenu::buildMenu(),
  21 + [
  22 + ['label' => Yii::t('app', 'Settings'), 'url' => ['/settings/index'], 'icon' => 'fa fa-gear']
  23 + ]
  24 + ),
  25 + ]) ?>
90 26  
91 27 </section>
92 28  
... ...
backend/views/layouts/settings.php 0 → 100644
  1 +<?php
  2 +
  3 +use dmstr\widgets\Menu;
  4 +use yii\widgets\Breadcrumbs;
  5 +use yii\helpers\Html;
  6 +
  7 +/* @var $content string */
  8 +$this->beginContent('@app/views/layouts/main.php');
  9 +?>
  10 + <div class="row">
  11 + <div class="col-md-3">
  12 + <div class="box box-solid">
  13 + <div class="box-header with-border">
  14 + <h3 class="box-title"><?=Yii::t('app', 'Settings categories')?></h3>
  15 + <div class="box-tools">
  16 + <button type="button" class="btn btn-box-tool" data-widget="collapse">
  17 + <i class="fa fa-minus"></i>
  18 + </button>
  19 + </div>
  20 + </div>
  21 + <div class="box-body no-padding">
  22 + <?php
  23 + echo Menu::widget([
  24 + 'options' => [
  25 + 'class' => 'nav nav-pills nav-stacked'
  26 + ],
  27 + 'items' => [
  28 + ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['/admin-menu/index'], 'icon' => 'fa fa-navicon'],
  29 + ['label' => Yii::t('app', 'Next menu item'), 'url' => ['#'], 'icon' => 'fa fa-arrow-circle-o-right'],
  30 + ],
  31 + ]);
  32 + ?>
  33 + </div>
  34 + </div>
  35 + </div>
  36 + <div class="col-md-9">
  37 + <?= $content ?>
  38 + </div>
  39 + </div>
  40 +<?php $this->endContent() ?>
0 41 \ No newline at end of file
... ...
backend/views/menu/index.php
... ... @@ -25,13 +25,15 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
25 25 'filterModel' => $searchModel,
26 26 'columns' => [
27 27 ['class' => 'yii\grid\SerialColumn'],
28   -
  28 +/*
29 29 [
30 30 'attribute' => Yii::t('app', 'termin'),
31   - 'value' => function ($model) {
32   - return empty($model->termin_id) ? '-' : $model->termin_lang->termin_title;
  31 + 'value' => function ($model)
  32 + {
  33 + return empty ($model->termin_id) ? '-' : $model->terminLang->termin_title;
33 34 },
34   - ],
  35 + ],
  36 + */
35 37 'menu_pid',
36 38 'level',
37 39 // 'sortorder',
... ...
backend/views/new-options-lang/_form.php
... ... @@ -14,7 +14,7 @@ use yii\widgets\ActiveForm;
14 14  
15 15 <?= $form->field($model, 'id')->textInput() ?>
16 16  
17   - <?= $form->field($model, 'lang_id')->textInput() ?>
  17 + <?= $form->field($model, 'language_id')->textInput() ?>
18 18  
19 19 <?= $form->field($model, 'value')->textarea(['rows' => 6]) ?>
20 20  
... ...
backend/views/new-options-lang/_search.php
... ... @@ -19,7 +19,7 @@ use yii\widgets\ActiveForm;
19 19  
20 20 <?= $form->field($model, 'id') ?>
21 21  
22   - <?= $form->field($model, 'lang_id') ?>
  22 + <?= $form->field($model, 'language_id') ?>
23 23  
24 24 <?= $form->field($model, 'value') ?>
25 25  
... ...
backend/views/new-options-lang/index.php
... ... @@ -27,7 +27,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
27 27  
28 28 'primary',
29 29 'id',
30   - 'lang_id',
  30 + 'language_id',
31 31 'value:ntext',
32 32  
33 33 ['class' => 'yii\grid\ActionColumn'],
... ...
backend/views/new-options-lang/view.php
... ... @@ -30,7 +30,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
30 30 'attributes' => [
31 31 'primary',
32 32 'id',
33   - 'lang_id',
  33 + 'language_id',
34 34 'value:ntext',
35 35 ],
36 36 ]) ?>
... ...
backend/views/option/_form_edit.php
... ... @@ -21,7 +21,7 @@ use yii\widgets\ActiveForm;
21 21 <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?>
22 22 <?php
23 23 if($row->translate) {
24   - foreach($row->getLangs() as $lang_id => $lang) {
  24 + foreach($row->getLangs() as $language_id => $lang) {
25 25 ?>
26 26 <div class="form-group">
27 27 <div class="col-xs-1"><?=$lang['lang_code']?></div>
... ...
backend/views/settings/index.php 0 → 100644
  1 +<?php
  2 +
  3 +/* @var $this yii\web\View */
  4 +
  5 +use backend\models\AdminMenu;
  6 +use dmstr\widgets\Menu;
  7 +use yii\helpers\Url;
  8 +
  9 +$this->title = Yii::t('app', 'Settings');
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
... ...
backend/views/site/index.php
... ... @@ -2,6 +2,9 @@
2 2  
3 3 /* @var $this yii\web\View */
4 4  
  5 +use backend\models\AdminMenu;
  6 +use yii\helpers\Url;
  7 +
5 8 $this->title = 'My Yii Application';
6 9 ?>
7 10 <div class="site-index">
... ...
backend/views/termin/_article_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\bootstrap\ActiveField;
  4 +use mihaildev\ckeditor\CKEditor;
  5 +
  6 +$form = \yii\bootstrap\ActiveForm::begin();
  7 +?>
  8 +<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
  9 +
  10 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]lang_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
  11 +
  12 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]termin_title"]))->textInput() ?>
  13 +
  14 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id]termin_alias"]))->textInput() ?>
  15 +
  16 +</div>
  17 +<?php
  18 +$form->end();
  19 +?>
... ...
backend/views/termin/_form.php
... ... @@ -37,8 +37,8 @@ use yii\helpers\ArrayHelper;
37 37  
38 38 <?= $form->field($model_lang, 'termin_alias')->textInput() ?>
39 39  
40   - <?= Html::activeHiddenInput ($model_lang, 'lang_id', [
41   - 'value' => ($model_lang->lang_id != 0 ? $model_lang->lang_id : Yii::$app->params['lang_id']),
  40 + <?= Html::activeHiddenInput ($model_lang, 'language_id', [
  41 + 'value' => ($model_lang->language_id != 0 ? $model_lang->language_id : Yii::$app->params['language_id']),
42 42 ]) ?>
43 43  
44 44 <div class="form-group">
... ...
backend/views/termin/create.php
... ... @@ -17,6 +17,7 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
17 17 <?= $this->render('_form', [
18 18 'model' => $model,
19 19 'model_lang' => $model_lang,
  20 + 'model_pid' => $model_pid,
20 21 ]) ?>
21 22  
22 23 </div>
... ...
backend/views/termin/index.php
... ... @@ -19,17 +19,20 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
19 19 <?= Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']) ?>
20 20 </p>
21 21  
  22 +
22 23 <?= GridView::widget([
23 24 'dataProvider' => $dataProvider,
24 25 'filterModel' => $searchModel,
25 26 'columns' => [
26 27 ['class' => 'yii\grid\SerialColumn'],
27 28 [
28   - 'attribute' => Yii::t('app', 'termin'),
29   - 'value' => function ($model) {
30   - return $model->terminLangs[0]->termin_title;
31   - },
32   - ],
  29 + 'attribute' => 'termin_title',
  30 + 'value' => 'terminLangs.termin_title'
  31 + ],
  32 + [
  33 + 'attribute' => 'termin_parent_title',
  34 + 'value' => 'parent.terminLangs.termin_title'
  35 + ],
33 36 'termin_name',
34 37 'is_book',
35 38  
... ...
backend/web/css/site.css
... ... @@ -89,3 +89,47 @@ a.desc:after {
89 89 padding: 10px 20px;
90 90 margin: 0 0 15px 0;
91 91 }
  92 +.header-search {
  93 + width: 200px;
  94 +}
  95 +.skin-blue .sidebar-form {
  96 + margin: 5px !important;
  97 +}
  98 +.checkboxer .list-group-item {
  99 + padding: 0;
  100 +}
  101 +.checkboxer .list-group-item:hover {
  102 + background: #ddd;
  103 +}
  104 +.checkboxer .list-group-item.active, .checkboxer .list-group-item.active:hover {
  105 + background: #00a65a;
  106 +}
  107 +.checkboxer .list-group-item.active label, .checkboxer .list-group-item.active:hover label {
  108 + color: white;
  109 +}
  110 +.checkboxer .list-group-item.level0 {
  111 + padding-left: 15px;
  112 +}
  113 +.checkboxer .list-group-item.level1 {
  114 + padding-left: 45px;
  115 +}
  116 +.checkboxer .list-group-item.level2 {
  117 + padding-left: 75px;
  118 +}
  119 +.checkboxer .checkboxer_label {
  120 + padding: 10px 0;
  121 + display: block;
  122 +}
  123 +.checkboxer .checkboxer_label input[type=radio] {
  124 + position: absolute;
  125 + clip: rect(0,0,0,0);
  126 +}
  127 +.action_link {
  128 + float: left;
  129 +}
  130 +.admin_grid_action {
  131 + padding: 0 20px;
  132 +}
  133 +.admin_grid_action .pagination {
  134 + margin: 0;
  135 +}
... ...
backend/web/js/option.js
... ... @@ -12,6 +12,11 @@ function readURL(input) {
12 12 }
13 13 return urls;
14 14 }
  15 +function checkboxerInit() {
  16 + $.each($('.checkboxer input[type=radio]:checked'), function(index, value) {
  17 + $(value).trigger('change');
  18 + });
  19 +}
15 20 $(function() {
16 21 var counter = 0;
17 22 $(document).on('click', '.add_row', function() {
... ... @@ -36,57 +41,93 @@ $(function() {
36 41 $(document).on('click', '.remove_lang', function() {
37 42 $(this).parents('.form-wrapper').remove();
38 43 });
39   - if($('#lang-tabs li').length > 1) {
40   - $('#lang-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')
41   - }
42   - $(document).on('click', '#lang-dropdown li a[data-lang]', function() {
  44 + $(document).on('change', '.image_inputs_field', function() {
  45 + readURL(this);
  46 + });
  47 + $('a.remove_image').on('click', function(e) {
  48 + var el = $(this);
  49 + e.preventDefault();
  50 + if(confirm(confirm_message)) {
  51 + $.ajax({
  52 + type: 'post',
  53 + url: $(this).attr('href'),
  54 + data: $(this).data('params')
  55 + }).done(function() {
  56 + $(el).parents('.additional_image_container').remove();
  57 + });
  58 + }
  59 + return false;
  60 + });
  61 + $.each($('.nav-tabs.f32'), function(key, value) {
  62 + if($(value).find('li').length > 1) {
  63 + $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>');
  64 + }
  65 + });
  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, { language_id: lang, widget_id: id, ajaxView: view, model: model }, function(data) {
  75 + $('#'+id+'-tabs li').removeClass('active');
  76 + $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>');
  77 + $('#tab-content-'+id+' .tab-pane.active').removeClass('active');
  78 + $('#tab-content-'+id).append($(data).find('.ajax-loaded').first());
  79 + $('body').append($(data).filter('script'));
  80 + $(el).parent().remove();
  81 + if(!$('#lang-'+id+' li').length) {
  82 + $('#'+id+'Lang').addClass('disabled');
  83 + }
  84 + if($('#'+id+'-tabs li').length > 1) {
  85 + $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')
  86 + }
  87 + });
  88 + });
  89 + $(document).on('click', '.dropdown-menu.f32.old li a[data-lang]', function(e) {
  90 + e.preventDefault();
43 91 var lang = $(this).data('lang');
44 92 var flag = $(this).find('span').first().clone();
45 93 var el = $(this);
46   - $.get('/blog/ajax/category-form', { lang_id: lang }, function(data) {
47   - $('#lang-tabs li').removeClass('active');
48   - $('#lang-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#lang-'+lang+'" aria-controls="lang-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>');
49   - $('.lang-tab-content .tab-pane.active').removeClass('active');
50   - $('.lang-tab-content').append($(data).find('.ajax-loaded').first());
  94 + var id = $(this).attr('href').substr(1);
  95 + $.get(form[id], { language_id: lang, widget_id: id }, function(data) {
  96 + $('#'+id+'-tabs li').removeClass('active');
  97 + $('#'+id+'-tabs').append('<li role="lang_inputs" class="active" data-lang="'+lang+'"><a href="#'+id+'-'+lang+'" aria-controls="'+id+'-'+lang+'" role="tab" data-toggle="tab">'+$('<p>').append($(flag)).html()+'</a></li>');
  98 + $('#tab-content-'+id+' .tab-pane.active').removeClass('active');
  99 + $('#tab-content-'+id).append($(data).find('.ajax-loaded').first());
51 100 $('body').append($(data).filter('script'));
52 101 $(el).parent().remove();
53   - if(!$('#lang-dropdown li').length) {
54   - $('#dropdownLang').addClass('disabled');
  102 + if(!$('#lang-'+id+' li').length) {
  103 + $('#'+id+'Lang').addClass('disabled');
55 104 }
56   - if($('#lang-tabs li').length > 1) {
57   - $('#lang-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')
  105 + if($('#'+id+'-tabs li').length > 1) {
  106 + $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')
58 107 }
59 108 });
60 109 });
61 110 $(document).on('click', '.remove-lang', function() {
62 111 var lang = $(this).parent().data('lang');
63 112 var flag = $(this).parent().find('span.flag').first().clone();
64   - $('#lang-'+lang).remove();
65   - $('#lang-dropdown').append('<li><a href="#lang-tabs" data-lang="'+lang+'">'+$('<p>').append($(flag)).html()+'</a></li>');
66   - $('#dropdownLang').removeClass('disabled');
  113 + var id = $(this).parent().find('a[aria-controls]').first().attr('aria-controls').substr(0,8);
  114 + $('#'+id+'-'+lang).remove();
  115 + $('#lang-'+id).append('<li><a href="#'+id+'" data-lang="'+lang+'">'+$('<p>').append($(flag)).html()+'</a></li>');
  116 + $('#'+id+'Lang').removeClass('disabled');
67 117 $(this).parent().remove();
68   - if($('#lang-tabs li').length <= 1) {
69   - $('#lang-tabs li').find('.remove-lang').remove();
  118 + if($('#'+id+'-tabs li').length <= 1) {
  119 + $('#'+id+'-tabs li').find('.remove-lang').remove();
70 120 }
71   - if(!$('#lang-tabs>li.active').length) {
72   - $('#lang-tabs>li').first().find('a').tab('show');
  121 + if(!$('#'+id+'-tabs>li.active').length) {
  122 + $('#'+id+'-tabs>li').first().find('a').tab('show');
73 123 }
74 124 });
75   - $(document).on('change', '.image_inputs_field', function() {
76   - readURL(this);
  125 + $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() {
  126 + $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active');
  127 + $(this).parents('.checkboxer_container').addClass('active');
77 128 });
78   - $('a.remove_image').on('click', function(e) {
79   - var el = $(this);
80   - e.preventDefault();
81   - if(confirm(confirm_message)) {
82   - $.ajax({
83   - type: 'post',
84   - url: $(this).attr('href'),
85   - data: $(this).data('params')
86   - }).done(function() {
87   - $(el).parents('.additional_image_container').remove();
88   - });
89   - }
90   - return false;
  129 + $.each($('.f32'), function(i, val) {
  130 + $(val).find('a[role=tab]').first().trigger('click');
91 131 });
  132 + checkboxerInit();
92 133 });
93 134 \ No newline at end of file
... ...
common/components/LangRequest.php
... ... @@ -3,6 +3,7 @@
3 3 namespace common\components;
4 4  
5 5 use Yii;
  6 +use yii\base\InvalidConfigException;
6 7 use yii\web\Request;
7 8 use common\models\Language;
8 9 use common\models\Page;
... ... @@ -29,10 +30,10 @@ class LangRequest extends Request
29 30  
30 31 Language::setCurrent($lang_url);
31 32  
32   - if ($lang_url !== null && $lang_url === Language::getCurrent()->lang_code
33   - && strpos($this->_lang_url, Language::getCurrent()->lang_code) === 1)
  33 + if ($lang_url !== null && $lang_url === Language::getCurrent()->language_code
  34 + && strpos($this->_lang_url, Language::getCurrent()->language_code) === 1)
34 35 {
35   - $this->_lang_url = substr ($this->_lang_url, strlen (Language::getCurrent()->lang_code) + 1);
  36 + $this->_lang_url = substr ($this->_lang_url, strlen (Language::getCurrent()->language_code) + 1);
36 37 }
37 38 }
38 39  
... ...
common/components/LangUrlManager.php
... ... @@ -9,16 +9,16 @@ class LangUrlManager extends UrlManager
9 9 {
10 10 public function createUrl ($params)
11 11 {
12   - if (isset ($params['lang_id']))
  12 + if (isset ($params['language_id']))
13 13 {
14 14 //Если указан идентификатор языка, то делаем попытку найти язык в БД,
15 15 //иначе работаем с языком по умолчанию
16   - if (($lang_code = Language::findOne($params['lang_id'])) === null)
  16 + if (($lang_code = Language::findOne($params['language_id'])) === null)
17 17 {
18 18 $lang_code = Language::getDefaultLang();
19 19 }
20 20  
21   - unset ($params['lang_id']);
  21 + unset ($params['language_id']);
22 22  
23 23 }
24 24 else
... ...
common/config/main.php
... ... @@ -8,6 +8,9 @@ return [
8 8 'userClass' => 'common\models\User'
9 9 ]
10 10 ],
  11 + 'blog' => [
  12 + 'class' => 'common\modules\blog\Module',
  13 + ],
11 14 ],
12 15 'components' => [
13 16 'cache' => [
... ...
common/models/Catalog.php
... ... @@ -23,21 +23,21 @@ class Catalog extends Model
23 23 termin_lang.termin_title
24 24 FROM termin_structure
25 25 INNER JOIN termin_lang ON termin_lang.termin_id = termin_structure.termin_id
26   - AND termin_lang.lang_id = '.Yii::$app->params['lang_id'].'
  26 + AND termin_lang.language_id = '.Yii::$app->params['language_id'].'
27 27 ORDER BY termin_structure.termin_id ASC, termin_structure.termin_pid ASC
28 28 ')->queryAll();
29 29 }
30 30  
31 31 /**
32 32 * Выполняет поиск по параметрам
33   - * @param array $param принимает [catalog_id, lang_id, return_one, return_field, show_all]
  33 + * @param array $param принимает [catalog_id, language_id, return_one, return_field, show_all]
34 34 * @return array one | array all | string значение масива
35 35 */
36 36 public function finInfo (array $params = [])
37 37 {
38 38 Tools::ifNotExist ($params, array (
39 39 'catalog_id' => false,
40   - 'lang_id' => false,
  40 + 'language_id' => false,
41 41 'return_one' => false,
42 42 'return_field' => false,
43 43 'show_all' => false,
... ... @@ -57,9 +57,9 @@ class Catalog extends Model
57 57 $WHERE['catalog.catalog_id'] = $params['catalog_id'];
58 58 }
59 59  
60   - if ($params['lang_id'])
  60 + if ($params['language_id'])
61 61 {
62   - $WHERE['catalog_i18n.lang_id'] = $params['lang_id'];
  62 + $WHERE['catalog_i18n.language_id'] = $params['language_id'];
63 63 }
64 64  
65 65 if (! empty ($WHERE))
... ... @@ -144,7 +144,7 @@ class Catalog extends Model
144 144 */
145 145 public function getRelationCatalogLangPlus()
146 146 {
147   - return $this->getRelationCatalogLang()->where(['lang_id' => yii::$app->params['lang_id']]);
  147 + return $this->getRelationCatalogLang()->where(['language_id' => yii::$app->params['language_id']]);
148 148 }
149 149  
150 150 /**
... ...
common/models/Language.php
... ... @@ -8,7 +8,11 @@ use Yii;
8 8 * This is the model class for table "language".
9 9 *
10 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 17 class Language extends \yii\db\ActiveRecord
14 18 {
... ... @@ -32,8 +36,8 @@ class Language extends \yii\db\ActiveRecord
32 36 $language = self::getLangByUrl($lang_code);
33 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 52 if ($lang_code === null) {
49 53 return null;
50 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 56 return $language === null ? null : $language;
53 57 }
54 58 }
... ... @@ -67,8 +71,8 @@ class Language extends \yii\db\ActiveRecord
67 71 public function rules()
68 72 {
69 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 83 {
80 84 return [
81 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 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 12 /**
13 13 * This is the model class for table "media".
14 14 *
15   - * @property integer $id
  15 + * @property integer $media_id
16 16 * @property string $hash
  17 + * @property string $extension
17 18 *
18 19 * @property ArticleCategoryMedia[] $articleCategoryMedia
19 20 * @property ArticleMedia[] $articleMedia
... ... @@ -39,8 +40,8 @@ class Media extends ActiveRecord
39 40 public function rules()
40 41 {
41 42 return [
42   - [['id'], 'integer'],
43   - [['hash'], 'string'],
  43 + [['media_id'], 'integer'],
  44 + [['hash', 'extension'], 'string'],
44 45 [['imageFile'], 'file', 'extensions' => 'png, gif, jpeg, jpg', 'skipOnEmpty' => true],
45 46 ];
46 47 }
... ... @@ -51,8 +52,9 @@ class Media extends ActiveRecord
51 52 public function attributeLabels()
52 53 {
53 54 return [
54   - 'id' => Yii::t('app', 'ID'),
  55 + 'media_id' => Yii::t('app', 'ID'),
55 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 63 */
62 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 71 */
70 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 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 82 public function upload()
... ...
common/models/Tools.php
... ... @@ -98,4 +98,19 @@ class Tools
98 98  
99 99 return $url;
100 100 }
  101 +
  102 + static function parseUrlParams($params)
  103 + {
  104 + $params = preg_split('/,\s*/', $params, -1, PREG_SPLIT_NO_EMPTY);
  105 + $result = [];
  106 + if($params) {
  107 + foreach($params as $param) {
  108 + $param = preg_split('/\s*=\s*/', $param);
  109 + if(!empty($param[0]) && !empty($param[1])) {
  110 + $result[$param[0]] = $param[1];
  111 + }
  112 + }
  113 + }
  114 + return $result;
  115 + }
101 116 }
102 117 \ No newline at end of file
... ...
common/modules/blog/controllers/AjaxController.php
... ... @@ -7,6 +7,7 @@ use common\modules\blog\models\ArticleCategoryLang;
7 7 use common\modules\blog\models\ArticleCategoryMedia;
8 8 use common\modules\blog\models\ArticleLang;
9 9 use common\modules\blog\models\ArticleMedia;
  10 +use yii\base\InvalidParamException;
10 11 use yii\web\Controller;
11 12 use yii\web\ForbiddenHttpException;
12 13 use yii\web\NotFoundHttpException;
... ... @@ -26,24 +27,50 @@ class AjaxController extends Controller
26 27 return true;
27 28 }
28 29  
29   - public function actionCategoryForm($lang_id)
  30 + public function actionCategoryForm($language_id, $widget_id)
30 31 {
31   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one();
  32 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
32 33 if(!$model) {
33 34 throw new NotFoundHttpException('Language not found');
34 35 }
35 36 $category_lang = new ArticleCategoryLang();
36   - return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang]);
  37 + return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]);
37 38 }
38 39  
39   - public function actionArticleForm($lang_id)
  40 + public function actionArticleForm($language_id, $widget_id)
40 41 {
41   - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['active' => 1, 'language_id' => $lang_id])->one();
  42 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
42 43 if(!$model) {
43 44 throw new NotFoundHttpException('Language not found');
44 45 }
45 46 $article_lang = new ArticleLang();
46   - return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang]);
  47 + return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]);
  48 + }
  49 +
  50 + public function actionArticleMediaForm($language_id, $widget_id, $type)
  51 + {
  52 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
  53 + if(!$model) {
  54 + throw new NotFoundHttpException('Language not found');
  55 + }
  56 + if(!in_array($type, ['full', 'preview'])) {
  57 + throw new InvalidParamException('Type must only be full/preview');
  58 + }
  59 + $article_lang = new ArticleMedia();
  60 + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
  61 + }
  62 +
  63 + public function actionArticleCategoryMediaForm($language_id, $widget_id, $type)
  64 + {
  65 + $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one();
  66 + if(!$model) {
  67 + throw new NotFoundHttpException('Language not found');
  68 + }
  69 + if(!in_array($type, ['full', 'preview'])) {
  70 + throw new InvalidParamException('Type must only be full/preview');
  71 + }
  72 + $article_lang = new ArticleCategoryMedia();
  73 + return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]);
47 74 }
48 75  
49 76 public function actionRemoveImage()
... ... @@ -63,6 +90,23 @@ class AjaxController extends Controller
63 90 }
64 91 }
65 92  
  93 + public function actionRemoveCategoryImage()
  94 + {
  95 + $post = \Yii::$app->request->post();
  96 + if(!empty($post['category_media_id'])) {
  97 + $category_media = ArticleCategoryMedia::findOne($post['category_media_id']);
  98 + if($post['remove_media']) {
  99 + $media = $category_media->media->delete();
  100 + }
  101 + if(!empty($category_media)) {
  102 + $category_media->delete();
  103 + }
  104 + return true;
  105 + } else {
  106 + return false;
  107 + }
  108 + }
  109 +
66 110 public function actionRemoveImageCategory()
67 111 {
68 112 $post = \Yii::$app->request->post();
... ... @@ -79,4 +123,10 @@ class AjaxController extends Controller
79 123 return false;
80 124 }
81 125 }
  126 +
  127 + public function actionMultilangForm($model, $ajaxView, $widget_id, $language_id = NULL)
  128 + {
  129 + $model = new $model(['language_id' => $language_id]);
  130 + return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]);
  131 + }
82 132 }
... ...
common/modules/blog/controllers/ArticleController.php
... ... @@ -28,28 +28,31 @@ class ArticleController extends Controller
28 28 {
29 29 $article_langs = array();
30 30 $article = new Article();
  31 + $default_lang = Language::getDefaultLang();
31 32 $images = array();
32   - $images['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]);
33   - $images['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]);
34   - $images['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
  33 + $images[$default_lang->language_id]['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]);
  34 + $images[$default_lang->language_id]['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]);
  35 + $images[0]['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
35 36 $article->loadDefaultValues();
36 37 $langs = Language::getActiveLanguages();
37   - $default_lang = Language::getDefaultLang();
38 38 $isValid = false;
39 39 if(!empty(\Yii::$app->request->post())) {
40 40 $isValid = true;
41 41 $article->load(\Yii::$app->request->post());
42   - $article->author = \Yii::$app->user->getId();
  42 + $article->user_id = \Yii::$app->user->getId();
43 43 $isValid = $article->validate();
44   - foreach($images as $index => $value) {
45   - $images[$index]->type = $index;
46   - if($index == 'additional') {
47   - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile");
48   - } else {
49   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
  44 + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
  45 + foreach($value as $type => $fields) {
  46 + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
  47 + $images[$lang][$type]->type = $type;
  48 + $images[$lang][$type]->language_id = $lang;
  49 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  50 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
50 51 }
51   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
52 52 }
  53 + $images[0]['additional']->language_id = 0;
  54 + $images[0]['additional']->type = 'additional';
  55 + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
53 56 if(empty(\Yii::$app->request->post()['ArticleLang'])) {
54 57 $article_langs[$default_lang->language_id] = new ArticleLang();
55 58 $isValid = ArticleLang::validateMultiple($article_langs) && $isValid;
... ... @@ -69,18 +72,30 @@ class ArticleController extends Controller
69 72 if(!empty($article_categories)) {
70 73 foreach($article_categories as $article_category) {
71 74 $articletocategory[$article_category] = new ArticleToCategory();
72   - $articletocategory[$article_category]->category_id = $article_category;
  75 + $articletocategory[$article_category]->article_category_id = $article_category;
73 76 $articletocategory[$article_category]->link('article', $article);
74 77 }
75 78 }
76 79 $first = 1;
77   - foreach($images as $index => $image) {
78   - $images[$index]->upload($article->id);
  80 + foreach($images as $lang => $value) {
  81 + foreach($value as $type => $fields) {
  82 + $images[$lang][$type]->upload($article->article_id);
  83 + if($first && $type != 'additional') {
  84 + $media_clone = clone $images[$lang][$type];
  85 + $media_clone->setIsNewRecord(true);
  86 + unset($media_clone->article_media_id);
  87 + $media_clone->language_id = 0;
  88 + $media_clone->upload($article->article_id);
  89 + unset($media_clone);
  90 + $first = 0;
  91 + }
  92 + }
79 93 }
  94 + $first = 1;
80 95 foreach($article_langs as $article_lang) {
81 96 if($first) {
82 97 $article_lang_clone = clone $article_lang;
83   - $article_lang_clone->lang_id = 0;
  98 + $article_lang_clone->language_id = 0;
84 99 $article_lang_clone->link('article', $article);
85 100 unset($article_lang_clone);
86 101 }
... ... @@ -102,49 +117,52 @@ class ArticleController extends Controller
102 117 public function actionUpdate($id)
103 118 {
104 119 $article = Article::findOne($id);
105   - $images = $article->getArticleMedia()->indexBy('type')->all();
106   - if(!array_key_exists('full', $images)) {
107   - $images['full'] = new ArticleMedia();
108   - }
109   - if(!array_key_exists('preview', $images)) {
110   - $images['preview'] = new ArticleMedia();
111   - }
112   - foreach($images as $index => $image) {
113   - $images[$index]->scenario = $index;
  120 + $imagestack = $article->getArticleMedia()->all();
  121 + $images = [];
  122 + $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
  123 + $images[0]['additional'][0]->type = 'additional';
  124 + $images[0]['additional'][0]->language_id = 0;
  125 + foreach($imagestack as $image) {
  126 + if(in_array($image->type, ['full', 'preview'])) {
  127 + $images[$image->language_id][$image->type] = $image;
  128 + $images[$image->language_id][$image->type]->scenario = $image->type;
  129 + } else {
  130 + $images[$image->language_id][$image->type][$image->article_media_id] = $image;
  131 + $images[$image->language_id][$image->type][$image->article_media_id]->scenario = $image->type;
  132 + }
114 133 }
115   - $images['additional'] = array(
116   - 0 => new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL])
117   - );
118   - $images['additional'] = array_merge($images['additional'], $article->getArticleMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all());
119   - foreach($images['additional'] as $index => $image) {
120   - $images['additional'][$index]->scenario = 'additional';
  134 + foreach($images as $lang => $value) {
  135 + $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]);
121 136 }
122   - $article_langs = $article->getArticleLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all();
  137 + $article_langs = $article->getArticleLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all();
123 138 $langs = Language::getActiveLanguages();
124 139 $default_lang = Language::getDefaultLang();
125 140 $isValid = false;
126 141 if(!empty(\Yii::$app->request->post())) {
127 142 $isValid = true;
128 143 $article->load(\Yii::$app->request->post());
129   - ArticleToCategory::deleteAll(['article_id' => $article->id]);
  144 + ArticleToCategory::deleteAll(['article_id' => $article->article_id]);
130 145 $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray'];
131 146 if(!empty($article_categories)) {
132 147 foreach($article_categories as $article_category) {
133 148 $articletocategory[$article_category] = new ArticleToCategory();
134   - $articletocategory[$article_category]->category_id = $article_category;
  149 + $articletocategory[$article_category]->article_category_id = $article_category;
135 150 $articletocategory[$article_category]->link('article', $article);
136 151 }
137 152 }
138 153 $isValid = $article->validate();
139   - foreach($images as $index => $value) {
140   - if($index == 'additional') {
141   - $images[$index][0]->type = $index;
142   - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile");
143   - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid;
144   - } else {
145   - $images[$index]->type = $index;
146   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
147   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
  154 + $images[0]['additional'][0]->type = 'additional';
  155 + $images[0]['additional'][0]->language_id = 0;
  156 + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
  157 + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
  158 + foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) {
  159 + foreach($value as $type => $fields) {
  160 + if(!in_array($type, ['full', 'preview'])) continue;
  161 + $images[$lang][$type] = new ArticleMedia(['scenario' => $type]);
  162 + $images[$lang][$type]->language_id = $lang;
  163 + $images[$lang][$type]->type = $type;
  164 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  165 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
148 166 }
149 167 }
150 168 if(empty(\Yii::$app->request->post()['ArticleLang'])) {
... ... @@ -153,7 +171,7 @@ class ArticleController extends Controller
153 171 foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) {
154 172 if (!array_key_exists($index, $article_langs)) {
155 173 $article_langs[$index] = new ArticleLang();
156   - $article_langs[$index]->article_id = $article->id;
  174 + $article_langs[$index]->article_id = $article->article_id;
157 175 }
158 176 }
159 177 ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post());
... ... @@ -162,12 +180,14 @@ class ArticleController extends Controller
162 180 }
163 181 if($isValid) {
164 182 $article->save(false);
165   - foreach($images as $index => $image) {
166   - if($index == 'additional') {
167   - $images[$index][0]->upload($article->id);
168   - } else {
169   - if(!empty($images[$index]->imageFile)) {
170   - $images[$index]->replace($article->id, true);
  183 + foreach($images as $lang => $value) {
  184 + foreach($value as $type => $fields) {
  185 + if($type == 'additional') {
  186 + $images[$lang][$type][0]->upload($article->id);
  187 + } else {
  188 + if(!empty($images[$lang][$type]->imageFile)) {
  189 + $images[$lang][$type]->replace($article->article_id);
  190 + }
171 191 }
172 192 }
173 193 }
... ...
common/modules/blog/controllers/CategoryController.php
... ... @@ -42,27 +42,30 @@ class CategoryController extends Controller
42 42 {
43 43 $category_langs = array();
44 44 $category = new ArticleCategory();
  45 + $default_lang = Language::getDefaultLang();
45 46 $images = array();
46   - $images['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]);
47   - $images['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]);
48   - $images['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
  47 + $images[$default_lang->language_id]['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]);
  48 + $images[$default_lang->language_id]['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]);
  49 + $images[0]['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
49 50 $category->loadDefaultValues();
50 51 $langs = Language::getActiveLanguages();
51   - $default_lang = Language::getDefaultLang();
52 52 $isValid = false;
53   - foreach($images as $index => $value) {
54   - $images[$index]->type = $index;
55   - if($index == 'additional') {
56   - $images[$index]->imageFile = UploadedFile::getInstances($images[$index], "[{$index}]imageFile");
57   - } else {
58   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
59   - }
60   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
61   - }
62 53 if(!empty(\Yii::$app->request->post())) {
63 54 $isValid = true;
64 55 $category->load(\Yii::$app->request->post());
65 56 $isValid = $category->validate();
  57 + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
  58 + foreach($value as $type => $fields) {
  59 + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
  60 + $images[$lang][$type]->type = $type;
  61 + $images[$lang][$type]->language_id = $lang;
  62 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  63 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
  64 + }
  65 + }
  66 + $images[0]['additional']->language_id = 0;
  67 + $images[0]['additional']->type = 'additional';
  68 + $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile");
66 69 if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
67 70 $category_langs[$default_lang->language_id] = new ArticleCategoryLang();
68 71 $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid;
... ... @@ -79,13 +82,25 @@ class CategoryController extends Controller
79 82 if($isValid) {
80 83 $category->save(false);
81 84 $first = 1;
82   - foreach($images as $index => $image) {
83   - $images[$index]->upload($category->id);
  85 + foreach($images as $lang => $value) {
  86 + foreach($value as $type => $fields) {
  87 + $images[$lang][$type]->upload($category->article_category_id);
  88 + if($first && $type != 'additional') {
  89 + $media_clone = clone $images[$lang][$type];
  90 + $media_clone->setIsNewRecord(true);
  91 + unset($media_clone->article_category_media_id);
  92 + $media_clone->language_id = 0;
  93 + $media_clone->upload($category->article_category_id);
  94 + unset($media_clone);
  95 + $first = 0;
  96 + }
  97 + }
84 98 }
  99 + $first = 1;
85 100 foreach($category_langs as $category_lang) {
86 101 if($first) {
87 102 $category_lang_clone = clone $category_lang;
88   - $category_lang_clone->lang_id = 0;
  103 + $category_lang_clone->language_id = 0;
89 104 $category_lang_clone->link('category', $category);
90 105 unset($category_lang_clone);
91 106 }
... ... @@ -107,24 +122,24 @@ class CategoryController extends Controller
107 122 public function actionUpdate($id)
108 123 {
109 124 $category = ArticleCategory::findOne($id);
110   - $images = $category->getArticleCategoryMedia()->indexBy('type')->all();
111   - if(!array_key_exists('full', $images)) {
112   - $images['full'] = new ArticleCategoryMedia();
113   - }
114   - if(!array_key_exists('preview', $images)) {
115   - $images['preview'] = new ArticleCategoryMedia();
116   - }
117   - foreach($images as $index => $image) {
118   - $images[$index]->scenario = $index;
  125 + $imagestack = $category->getArticleCategoryMedia()->all();
  126 + $images = [];
  127 + $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
  128 + $images[0]['additional'][0]->type = 'additional';
  129 + $images[0]['additional'][0]->language_id = 0;
  130 + foreach($imagestack as $image) {
  131 + if(in_array($image->type, ['full', 'preview'])) {
  132 + $images[$image->language_id][$image->type] = $image;
  133 + $images[$image->language_id][$image->type]->scenario = $image->type;
  134 + } else {
  135 + $images[$image->language_id][$image->type][$image->article_category_media_id] = $image;
  136 + $images[$image->language_id][$image->type][$image->article_category_media_id]->scenario = $image->type;
  137 + }
119 138 }
120   - $images['additional'] = array(
121   - 0 => new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL])
122   - );
123   - $images['additional'] = array_merge($images['additional'], $category->getArticleCategoryMedia()->andWhere(['type' => 'additional'])->indexBy('id')->all());
124   - foreach($images['additional'] as $index => $image) {
125   - $images['additional'][$index]->scenario = 'additional';
  139 + foreach($images as $lang => $value) {
  140 + $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]);
126 141 }
127   - $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'lang_id', '1'])->indexBy('lang_id')->all();
  142 + $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all();
128 143 $langs = Language::getActiveLanguages();
129 144 $default_lang = Language::getDefaultLang();
130 145 $isValid = false;
... ... @@ -132,15 +147,18 @@ class CategoryController extends Controller
132 147 $isValid = true;
133 148 $category->load(\Yii::$app->request->post());
134 149 $isValid = $category->validate();
135   - foreach($images as $index => $value) {
136   - if($index == 'additional') {
137   - $images[$index][0]->type = $index;
138   - $images[$index][0]->imageFile = UploadedFile::getInstances($images[$index][0], "[{$index}]imageFile");
139   - $isValid = $images[$index][0]->validate(['imageFile']) && $isValid;
140   - } else {
141   - $images[$index]->type = $index;
142   - $images[$index]->imageFile = UploadedFile::getInstance($images[$index], "[{$index}]imageFile");
143   - $isValid = $images[$index]->validate(['imageFile']) && $isValid;
  150 + $images[0]['additional'][0]->type = 'additional';
  151 + $images[0]['additional'][0]->language_id = 0;
  152 + $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile");
  153 + $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid;
  154 + foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) {
  155 + foreach($value as $type => $fields) {
  156 + if(!in_array($type, ['full', 'preview'])) continue;
  157 + $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]);
  158 + $images[$lang][$type]->language_id = $lang;
  159 + $images[$lang][$type]->type = $type;
  160 + $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile");
  161 + $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid;
144 162 }
145 163 }
146 164 if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) {
... ... @@ -149,7 +167,7 @@ class CategoryController extends Controller
149 167 foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) {
150 168 if(!array_key_exists($index, $category_langs)) {
151 169 $category_langs[$index] = new ArticleCategoryLang();
152   - $category_langs[$index]->category_id = $category->id;
  170 + $category_langs[$index]->article_category_id = $category->article_category_id;
153 171 }
154 172 }
155 173 ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post());
... ... @@ -158,12 +176,14 @@ class CategoryController extends Controller
158 176 }
159 177 if($isValid) {
160 178 $category->save(false);
161   - foreach($images as $index => $image) {
162   - if($index == 'additional') {
163   - $images[$index][0]->upload($category->id);
164   - } else {
165   - if(!empty($images[$index]->imageFile)) {
166   - $images[$index]->replace($category->id, true);
  179 + foreach($images as $lang => $value) {
  180 + foreach($value as $type => $fields) {
  181 + if($type == 'additional') {
  182 + $images[$lang][$type][0]->upload($category->article_category_id);
  183 + } else {
  184 + if(!empty($images[$lang][$type]->imageFile)) {
  185 + $images[$lang][$type]->replace($category->article_category_id);
  186 + }
167 187 }
168 188 }
169 189 }
... ...
common/modules/blog/models/Article.php
... ... @@ -11,21 +11,21 @@ use yii\db\Query;
11 11 /**
12 12 * This is the model class for table "article".
13 13 *
14   - * @property integer $id
  14 + * @property integer $article_id
15 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 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 26 * @property Article $parent
27 27 * @property Article[] $articles
28   - * @property User $author0
  28 + * @property User $user
29 29 * @property ArticleLang[] $articleLangs
30 30 * @property ArticleMedia[] $articleMedia
31 31 * @property ArticleToCategory[] $articleToCategories
... ... @@ -58,10 +58,10 @@ class Article extends \yii\db\ActiveRecord
58 58 public function rules()
59 59 {
60 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 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 71 public function attributeLabels()
72 72 {
73 73 return [
74   - 'id' => Yii::t('app', 'ID'),
  74 + 'article_id' => Yii::t('app', 'ID'),
75 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 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 90 */
91 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 98 */
99 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 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 114 */
115 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 122 */
123 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 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 133 * @return \yii\db\ActiveQuery
134 134 */
135 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 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 145 public static function findArticleDropdown($id)
146 146 {
147 147 $query = new Query();
148   - return $query->select(['l.name', 'a.id'])
  148 + return $query->select(['l.name', 'a.article_id'])
149 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 154 ->column();
155 155 }
156 156  
157 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 11 /**
12 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 16 * @property integer $sort
17 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 23 * @property Article[] $articles
24 24 * @property ArticleCategory $parent
... ... @@ -53,11 +53,11 @@ class ArticleCategory extends ActiveRecord
53 53 public function rules()
54 54 {
55 55 return [
56   - [['active', 'sort', 'parent_id'], 'integer'],
  56 + [['status', 'sort', 'article_category_pid'], 'integer'],
57 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 67 public function attributeLabels()
68 68 {
69 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 72 'sort' => Yii::t('app', 'Sort'),
73 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 83 */
84 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 91 */
92 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 99 */
100 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 107 */
108 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 115 */
116 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 121 public static function findArticleCategoryDropdown($id)
122 122 {
123 123 $query = new Query();
124   - return $query->select(['l.name', 'c.id'])
  124 + return $query->select(['l.name', 'c.article_category_id'])
125 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 130 ->column();
131 131 }
132 132  
... ...
common/modules/blog/models/ArticleCategoryLang.php
... ... @@ -8,18 +8,18 @@ use Yii;
8 8 /**
9 9 * This is the model class for table "article_category_lang".
10 10 *
11   - * @property integer $id
12   - * @property integer $lang_id
13   - * @property integer $category_id
  11 + * @property integer $article_category_language_id
  12 + * @property integer $language_id
  13 + * @property integer $article_category_id
14 14 * @property string $text
15 15 * @property string $preview
16 16 * @property string $seo_url
17 17 * @property string $name
18 18 * @property string $meta_title
19 19 * @property string $meta_descr
20   - * @property string $meta_keywords
  20 + * @property string $meta_keyword
21 21 * @property string $h1_tag
22   - * @property string $tags
  22 + * @property string $tag
23 23 *
24 24 * @property ArticleCategory $category
25 25 * @property Language $lang
... ... @@ -51,9 +51,9 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord
51 51 public function rules()
52 52 {
53 53 return [
54   - [['lang_id', 'category_id'], 'integer'],
  54 + [['language_id', 'article_category_id'], 'integer'],
55 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 57 ['seo_url', function($attribute, $params) {
58 58 $pattern = "/^[a-zA-Z\d_-]+$/";
59 59 if(!preg_match($pattern, $this->$attribute)) {
... ... @@ -69,18 +69,18 @@ class ArticleCategoryLang extends \yii\db\ActiveRecord
69 69 public function attributeLabels()
70 70 {
71 71 return [
72   - 'id' => Yii::t('app', 'ID'),
73   - 'lang_id' => Yii::t('app', 'Lang ID'),
74   - 'category_id' => Yii::t('app', 'Category ID'),
  72 + 'article_category_language_id' => Yii::t('app', 'ID'),
  73 + 'language_id' => Yii::t('app', 'Lang ID'),
  74 + 'article_category_id' => Yii::t('app', 'Category ID'),
75 75 'text' => Yii::t('app', 'Text'),
76 76 'preview' => Yii::t('app', 'Preview'),
77 77 'seo_url' => Yii::t('app', 'Seo Url'),
78 78 'name' => Yii::t('app', 'Name'),
79 79 'meta_title' => Yii::t('app', 'Meta Title'),
80 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 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 89 */
90 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 97 */
98 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 8 /**
9 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 13 * @property integer $media_id
14 14 * @property string $media_alt
15 15 * @property string $media_title
16 16 * @property string $media_caption
17 17 * @property string $type
  18 + * @property string $language_id
18 19 *
19 20 * @property ArticleCategory $category
20 21 * @property Media $media
  22 + * @property Language $lang
21 23 */
22 24 class ArticleCategoryMedia extends \yii\db\ActiveRecord
23 25 {
... ... @@ -36,9 +38,9 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord
36 38 public function scenarios()
37 39 {
38 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 44 return $scenarios;
43 45 }
44 46  
... ... @@ -48,8 +50,8 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord
48 50 public function rules()
49 51 {
50 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 55 [['media_alt', 'media_title', 'media_caption'], 'string'],
54 56 [['type'], 'string', 'max' => 10],
55 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 66 public function attributeLabels()
65 67 {
66 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 71 'media_id' => Yii::t('app', 'Media ID'),
70 72 'media_alt' => Yii::t('app', 'Media Alt'),
71 73 'media_title' => Yii::t('app', 'Media Title'),
72 74 'media_caption' => Yii::t('app', 'Media Caption'),
73 75 'type' => Yii::t('app', 'Type'),
74 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 83 */
81 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 91 */
89 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 97 public function upload($category_id)
95 98 {
96   - $this->category_id = $category_id;
  99 + $this->article_category_id = $category_id;
97 100 if(is_array($this->imageFile)) {
98 101 $ok = true;
99 102 foreach($this->imageFile as $image) {
... ... @@ -101,7 +104,7 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord
101 104 $media = new Media();
102 105 $media->imageFile = $image;
103 106 $media->upload();
104   - $media_category->media_id = $media->id;
  107 + $media_category->media_id = $media->media_id;
105 108 $ok = $media_category->save() && $ok;
106 109 unset($media_category);
107 110 }
... ... @@ -110,19 +113,19 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord
110 113 $media = new Media();
111 114 $media->imageFile = $this->imageFile;
112 115 $media->upload();
113   - $this->media_id = $media->id;
  116 + $this->media_id = $media->media_id;
114 117 return $this->save();
115 118 }
116 119 }
117 120  
118 121 public function replace($category_id, $removeMedia = false)
119 122 {
120   - $this->category_id = $category_id;
  123 + $this->article_category_id = $category_id;
121 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 126 $media = array();
124 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 130 $media = array_unique($media);
128 131 foreach($media as $one_media) {
... ... @@ -140,17 +143,17 @@ class ArticleCategoryMedia extends \yii\db\ActiveRecord
140 143 $media = new Media();
141 144 $media->imageFile = $image;
142 145 $media->upload();
143   - $media_category->media_id = $media->id;
  146 + $media_category->media_id = $media->media_id;
144 147 $ok = $media_category->save() && $ok;
145 148 unset($media_category);
146 149 }
147 150 return $ok;
148 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 153 $media = new Media();
151 154 $media->imageFile = $this->imageFile;
152 155 $media->upload();
153   - $this->media_id = $media->id;
  156 + $this->media_id = $media->media_id;
154 157 $this->setIsNewRecord(true);
155 158 return $this->save();
156 159 }
... ...
common/modules/blog/models/ArticleLang.php
... ... @@ -8,8 +8,8 @@ use common\models\Language;
8 8 /**
9 9 * This is the model class for table "article_lang".
10 10 *
11   - * @property integer $id
12   - * @property integer $lang_id
  11 + * @property integer $article_language_id
  12 + * @property integer $language_id
13 13 * @property integer $article_id
14 14 * @property string $text
15 15 * @property string $seo_url
... ... @@ -17,9 +17,9 @@ use common\models\Language;
17 17 * @property string $preview
18 18 * @property string $meta_title
19 19 * @property string $meta_descr
20   - * @property string $meta_keywords
  20 + * @property string $meta_keyword
21 21 * @property string $h1_tag
22   - * @property string $tags
  22 + * @property string $tag
23 23 *
24 24 * @property Article $article
25 25 * @property Language $lang
... ... @@ -40,9 +40,9 @@ class ArticleLang extends \yii\db\ActiveRecord
40 40 public function rules()
41 41 {
42 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 52 public function attributeLabels()
53 53 {
54 54 return [
55   - 'id' => Yii::t('app', 'ID'),
56   - 'lang_id' => Yii::t('app', 'Lang ID'),
  55 + 'article_language_id' => Yii::t('app', 'ID'),
  56 + 'language_id' => Yii::t('app', 'Lang ID'),
57 57 'article_id' => Yii::t('app', 'Article ID'),
58 58 'text' => Yii::t('app', 'Text'),
59 59 'seo_url' => Yii::t('app', 'Seo Url'),
... ... @@ -61,9 +61,9 @@ class ArticleLang extends \yii\db\ActiveRecord
61 61 'preview' => Yii::t('app', 'Preview'),
62 62 'meta_title' => Yii::t('app', 'Meta Title'),
63 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 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 72 */
73 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 80 */
81 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 9 /**
10 10 * This is the model class for table "article_media".
11 11 *
12   - * @property integer $id
  12 + * @property integer $article_media_id
13 13 * @property integer $article_id
14 14 * @property integer $media_id
15 15 * @property string $type
16 16 * @property string $media_alt
17 17 * @property string $media_title
18 18 * @property string $media_caption
  19 + * @property integer $language_id
19 20 *
20 21 * @property Article $article
21 22 * @property Media $media
... ... @@ -37,9 +38,9 @@ class ArticleMedia extends \yii\db\ActiveRecord
37 38 public function scenarios()
38 39 {
39 40 $scenarios = parent::scenarios();
40   - $scenarios[self::SCENARIO_FULL] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
41   - $scenarios[self::SCENARIO_PREVIEW] = ['id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile'];
42   - $scenarios[self::SCENARIO_ADDITIONAL] = ['id', 'article_id', 'media_id', 'type', 'imageFile'];
  41 + $scenarios[self::SCENARIO_FULL] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id'];
  42 + $scenarios[self::SCENARIO_PREVIEW] = ['article_media_id', 'article_id', 'media_id', 'type', 'media_alt', 'media_title', 'media_caption', 'imageFile', 'language_id'];
  43 + $scenarios[self::SCENARIO_ADDITIONAL] = ['article_media_id', 'article_id', 'media_id', 'type', 'imageFile', 'language_id'];
43 44 return $scenarios;
44 45 }
45 46  
... ... @@ -50,7 +51,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
50 51 {
51 52 return [
52 53 [['article_id', 'media_id'], 'required'],
53   - [['article_id', 'media_id'], 'integer'],
  54 + [['article_id', 'media_id', 'language_id'], 'integer'],
54 55 [['media_alt', 'media_title', 'media_caption'], 'string'],
55 56 [['type'], 'string', 'max' => 10],
56 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 66 public function attributeLabels()
66 67 {
67 68 return [
68   - 'id' => Yii::t('app', 'ID'),
  69 + 'article_media_id' => Yii::t('app', 'ID'),
69 70 'article_id' => Yii::t('app', 'Article ID'),
70 71 'media_id' => Yii::t('app', 'Media ID'),
71 72 'type' => Yii::t('app', 'Type'),
... ... @@ -81,7 +82,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
81 82 */
82 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 90 */
90 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 96 public function upload($article_id)
... ... @@ -102,7 +103,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
102 103 $media = new Media();
103 104 $media->imageFile = $image;
104 105 $media->upload();
105   - $media_article->media_id = $media->id;
  106 + $media_article->media_id = $media->media_id;
106 107 $ok = $media_article->save() && $ok;
107 108 unset($media_article);
108 109 }
... ... @@ -111,7 +112,7 @@ class ArticleMedia extends \yii\db\ActiveRecord
111 112 $media = new Media();
112 113 $media->imageFile = $this->imageFile;
113 114 $media->upload();
114   - $this->media_id = $media->id;
  115 + $this->media_id = $media->media_id;
115 116 return $this->save();
116 117 }
117 118 }
... ... @@ -119,11 +120,11 @@ class ArticleMedia extends \yii\db\ActiveRecord
119 120 public function replace($article_id, $removeMedia = false)
120 121 {
121 122 $this->article_id = $article_id;
122   - if($removeMedia) {
123   - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type])->column();
  123 + if($removeMedia && !$this->getIsNewRecord()) {
  124 + $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id])->column();
124 125 $media = array();
125 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 129 $media = array_unique($media);
129 130 foreach($media as $one_media) {
... ... @@ -141,17 +142,17 @@ class ArticleMedia extends \yii\db\ActiveRecord
141 142 $media = new Media();
142 143 $media->imageFile = $image;
143 144 $media->upload();
144   - $media_article->media_id = $media->id;
  145 + $media_article->media_id = $media->media_id;
145 146 $ok = $media_article->save() && $ok;
146 147 unset($media_article);
147 148 }
148 149 return $ok;
149 150 } elseif(!empty($this->imageFile)) {
150   - ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type]);
  151 + ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id]);
151 152 $media = new Media();
152 153 $media->imageFile = $this->imageFile;
153 154 $media->upload();
154   - $this->media_id = $media->id;
  155 + $this->media_id = $media->media_id;
155 156 $this->setIsNewRecord(true);
156 157 return $this->save();
157 158 }
... ...
common/modules/blog/models/ArticleToCategory.php
... ... @@ -8,7 +8,7 @@ use Yii;
8 8 * This is the model class for table "article_to_category".
9 9 *
10 10 * @property integer $article_id
11   - * @property integer $category_id
  11 + * @property integer $article_category_id
12 12 *
13 13 * @property Article $article
14 14 * @property ArticleCategory $category
... ... @@ -29,7 +29,7 @@ class ArticleToCategory extends \yii\db\ActiveRecord
29 29 public function rules()
30 30 {
31 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 40 {
41 41 return [
42 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 49 */
50 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 57 */
58 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 3 use yii\bootstrap\ActiveField;
4 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="lang-<?=$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 33 </div>
31 34 <?php
32   -$form->end();
  35 + if($new_form) {
  36 + $form->end();
  37 + }
33 38 ?>
... ...
common/modules/blog/views/ajax/_article_media_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\bootstrap\ActiveField;
  4 +use mihaildev\ckeditor\CKEditor;
  5 +
  6 +$form = \yii\bootstrap\ActiveForm::begin();
  7 +?>
  8 +<div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>">
  9 +
  10 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?>
  11 +
  12 + <?= (new ActiveField(['model' => $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?>
  13 +
  14 +</div>
  15 +<?php
  16 +$form->end();
  17 +?>
... ...
common/modules/blog/views/ajax/_category_form.php
... ... @@ -5,9 +5,9 @@ use mihaildev\ckeditor\CKEditor;
5 5  
6 6 $form = \yii\bootstrap\ActiveForm::begin();
7 7 ?>
8   -<div role="" class="tab-pane active ajax-loaded" id="lang-<?=$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 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 21  
22 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 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 30 </div>
31 31 <?php
... ...
common/modules/blog/views/article/_form.php
1 1 <?php
2 2 use common\modules\blog\models\ArticleCategory;
3   -use yii\bootstrap\ActiveForm;
  3 +use common\modules\blog\models\ArticleMedia;
  4 +use common\widgets\Multilang;
  5 + use common\widgets\Multilanguage;
  6 + use yii\bootstrap\ActiveForm;
4 7 use common\modules\blog\models\Article;
5 8 use yii\bootstrap\Html;
6 9 use mihaildev\ckeditor\CKEditor;
... ... @@ -17,100 +20,117 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
17 20  
18 21 <?= $form->field($article, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?>
19 22  
20   - <?= $form->field($article, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
  23 + <?= $form->field($article, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
21 24  
22 25 <?= $form->field($article, 'sort')->input('number') ?>
23 26  
24   - <?= $form->field($article, 'parent_id')
25   - ->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')]) ?>
26 29  
27 30 <?= $form->field($article, 'articleCategoriesArray')
28 31 ->dropDownList(ArticleCategory::findArticleCategoryDropdown(NULL), ['multiple' => 'multiple'])->label(\Yii::t('app', 'Article Categories Array')); ?>
29 32  
30   - <?= $form->field($article, 'active')->checkbox() ?>
  33 + <?= $form->field($article, 'status')->checkbox() ?>
31 34  
32 35 <ul class="nav nav-tabs" id="image-tabs" role="tablist">
33   - <?php
34   - $first = 1;
35   - foreach($images as $index => $image) {
36   - ?>
37   - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li>
38   - <?php
39   - $first = 0;
40   - }
41   - ?>
  36 + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
  37 + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
  38 + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
42 39 </ul>
43 40 <div class="tab-content image-tab-content">
44   - <?php
45   - $first = 1;
46   - foreach($images as $index => $image) {
  41 + <div role="" class="tab-pane active main-tab" id="image-full">
  42 + <?php
  43 + $imagelang = Multilang::begin([
  44 + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=full']),
  45 + 'form' => $form,
  46 + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'full'])->indexBy('language_id')->all()
  47 + ]);
  48 + $first = 1;
  49 + foreach($images as $lang => $value) {
  50 + if(!array_key_exists('full', $value)) continue;
  51 + ?>
  52 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  53 + <?php
  54 + echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]);
  55 + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
  56 + if(!empty($images[$lang]['full']->article_media_id)) {
  57 + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
  58 + }
  59 + ?>
  60 + </div>
  61 + <?php
  62 + $first = 0;
  63 + }
  64 + $imagelang->end();
47 65 ?>
48   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>">
49   - <?php if($index == 'additional') {
50   - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
51   - if(is_array($image) && count($image) > 1) {
52   - foreach($image as $oneindex => $oneimage) {
53   - if($oneindex) {
54   - ?>
55   - <div class="additional_image_container">
56   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
57   - <a
58   - href="<?= Url::to(['ajax/remove-image']) ?>"
59   - class="remove_image glyphicon glyphicon-remove-circle"
60   - data-params='<?= Json::encode(['article_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
61   - ></a>
62   - </div>
63   - <?php
64   - }
65   - }
  66 + </div>
  67 + <div role="" class="tab-pane" id="image-preview">
  68 + <?php
  69 + $imagelang = Multilang::begin([
  70 + 'ajaxpath' => Url::to(['/blog/ajax/article-media-form?type=preview']),
  71 + 'form' => $form,
  72 + 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'preview'])->indexBy('language_id')->all()
  73 + ]);
  74 + $first = 1;
  75 + foreach($images as $lang => $value) {
  76 + if(!array_key_exists('preview', $value)) continue;
  77 + ?>
  78 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  79 + <?php
  80 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]);
  81 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
  82 + if(!empty($images[$lang]['preview']->article_media_id)) {
  83 + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
66 84 }
67   - } else {
68   - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']);
69   - if(!empty($image->id)) {
70   - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>";
  85 + ?>
  86 + </div>
  87 + <?php
  88 + $first = 0;
  89 + }
  90 + $imagelang->end();
  91 + ?>
  92 + </div>
  93 + <div role="" class="tab-pane" id="image-additional">
  94 + <?php
  95 + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
  96 + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
  97 + foreach($images[0]['additional'] as $onefield => $oneimage) {
  98 + if($onefield) {
  99 + ?>
  100 + <div class="additional_image_container">
  101 + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
  102 + <a
  103 + href="<?= Url::to(['ajax/remove-image']) ?>"
  104 + class="remove_image glyphicon glyphicon-remove-circle"
  105 + data-params='<?= Json::encode(['article_media_id' => $oneimage->article_media_id, 'remove_media' => true]) ?>',
  106 + ></a>
  107 + </div>
  108 + <?php
71 109 }
72 110 }
73   - ?>
74   - </div>
75   - <?php
76   - $first = 0;
77   - }
78   - ?>
  111 + }
  112 + ?>
  113 + </div>
79 114 </div>
80 115  
81 116 <hr>
82 117  
83   - <div class="dropdown pull-right">
84   - <button class="btn btn-default dropdown-toggle" type="button" id="dropdownLang" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
85   - <?= Yii::t('app', 'Add language') ?>
86   - <span class="caret"></span>
87   - </button>
88   - <ul class="dropdown-menu f32" id="lang-dropdown" aria-labelledby="dropdownMenu1">
89   - <?php foreach($langs as $index => $lang) {
90   - if(in_array($index, array_keys($article_langs))) continue;
91   - ?>
92   - <li><a href="#lang-tabs" data-lang="<?=$lang->language_id?>"><span class="flag <?=$lang->country_code?>"></span></a></li>
93   - <?php } ?>
94   - </ul>
95   - </div>
96   - <ul class="nav nav-tabs f32" id="lang-tabs" role="tablist">
97   - <?php
98   - $first = 1;
99   - foreach($article_langs as $index => $article_lang) {
100   - ?>
101   - <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#lang-<?=$index?>" aria-controls="lang-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li>
102   - <?php
103   - $first = 0;
104   - }
105   - ?>
106   - </ul>
107   - <div class="tab-content lang-tab-content">
  118 + <?php
  119 + echo Multilanguage::widget([
  120 + 'data' => $article_langs,
  121 + 'form' => $form,
  122 + 'ajaxView' => '@common/modules/blog/views/ajax/_article_form',
  123 + ]);
  124 + /*
  125 + $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/article-form']), 'form' => $form, 'data_langs' => $article_langs]);
  126 + ?>
108 127 <?php
109 128 $first = 1;
110 129 foreach($article_langs as $index => $article_lang) {
111 130 ?>
112   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="lang-<?=$index?>">
113   - <?= $form->field($article_langs[$index], "[$index]lang_id")->label(false)->hiddenInput(['value' => $index]) ?>
  131 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$multilang->id?>-<?=$index?>">
  132 +
  133 + <?= $form->field($article_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?>
114 134  
115 135 <?= $form->field($article_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
116 136  
... ... @@ -135,7 +155,10 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
135 155 $first = 0;
136 156 }
137 157 ?>
138   - </div>
  158 + <?php
  159 + $multilang->end();
  160 + */
  161 + ?>
139 162  
140 163 <div class="form-group">
141 164 <?= Html::submitButton($article->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $article->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
... ...
common/modules/blog/views/article/index.php
... ... @@ -8,12 +8,12 @@ use common\models\Language;
8 8 echo GridView::widget([
9 9 'dataProvider' => $dataProvider,
10 10 'columns' => [
11   - 'id',
  11 + 'article_id',
12 12 'code',
13   - 'create_at',
  13 + 'date_add',
14 14 [
15 15 'value' => function($data) {
16   - return $data->author0->firstname.' '.$data->author0->lastname;
  16 + return $data->user->firstname.' '.$data->user->lastname;
17 17 },
18 18 'header' => Yii::t('app', 'Author')
19 19 ],
... ... @@ -21,7 +21,7 @@ echo GridView::widget([
21 21 'class' => Column::className(),
22 22 'header' => Yii::t('app', 'Name'),
23 23 'content' => function($model, $key, $index, $column) {
24   - return $model->getArticleLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name;
  24 + return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name;
25 25 }
26 26 ],
27 27 [
... ...
common/modules/blog/views/category/_form.php
1 1 <?php
  2 +use common\modules\blog\models\ArticleCategoryMedia;
  3 +use common\widgets\Multilang;
2 4 use yii\bootstrap\ActiveForm;
3 5 use common\modules\blog\models\ArticleCategory;
4 6 use yii\bootstrap\Html;
... ... @@ -15,97 +17,107 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
15 17  
16 18 <?= $form->field($category, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?>
17 19  
18   - <?= $form->field($category, 'tags')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
  20 + <?= $form->field($category, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?>
19 21  
20 22 <?= $form->field($category, 'sort')->input('number') ?>
21 23  
22   - <?= $form->field($category, 'parent_id')
23   - ->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')]) ?>
24 26  
25   - <?= $form->field($category, 'active')->checkbox() ?>
  27 + <?= $form->field($category, 'status')->checkbox() ?>
26 28  
27 29 <ul class="nav nav-tabs" id="image-tabs" role="tablist">
28   - <?php
29   - $first = 1;
30   - foreach($images as $index => $image) {
31   - ?>
32   - <li role="image_inputs" class="<?php if($first) { echo 'active'; }?>" data-type="<?=$index?>"><a href="#image-<?=$index?>" aria-controls="image-<?=$index?>" role="tab" data-toggle="tab"><span><?= \Yii::t('app', $index)?></span></a></li>
33   - <?php
34   - $first = 0;
35   - }
36   - ?>
  30 + <li role="image_inputs" class="active" data-type="full"><a href="#image-full" aria-controls="image-full" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'full')?></span></a></li>
  31 + <li role="image_inputs" class="" data-type="preview"><a href="#image-preview" aria-controls="image-preview" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'preview')?></span></a></li>
  32 + <li role="image_inputs" class="" data-type="additional"><a href="#image-additional" aria-controls="image-additional" role="tab" data-toggle="tab"><span><?= \Yii::t('app', 'additional')?></span></a></li>
37 33 </ul>
38 34 <div class="tab-content image-tab-content">
39   - <?php
40   - $first = 1;
41   - foreach($images as $index => $image) {
  35 + <div role="" class="tab-pane active main-tab" id="image-full">
  36 + <?php
  37 + $imagelang = Multilang::begin([
  38 + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=full']),
  39 + 'form' => $form,
  40 + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'full'])->indexBy('language_id')->all()
  41 + ]);
  42 + $first = 1;
  43 + foreach($images as $lang => $value) {
  44 + if(!array_key_exists('full', $value)) continue;
  45 + ?>
  46 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  47 + <?php
  48 + echo $form->field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]);
  49 + echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']);
  50 + if(!empty($images[$lang]['full']->article_category_media_id)) {
  51 + echo "<img src='/images/upload/{$images[$lang]['full']->media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>";
  52 + }
  53 + ?>
  54 + </div>
  55 + <?php
  56 + $first = 0;
  57 + }
  58 + $imagelang->end();
42 59 ?>
43   - <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="image-<?=$index?>">
44   - <?php if($index == 'additional') {
45   - echo $form->field(is_array($image)?$images[$index][0]:$images[$index], "[{$index}]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
46   - if(is_array($image) && count($image) > 1) {
47   - foreach($image as $oneindex => $oneimage) {
48   - if($oneindex) {
49   - ?>
50   - <div class="additional_image_container">
51   - <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
52   - <a
53   - href="<?= Url::to(['ajax/remove-image-category']) ?>"
54   - class="remove_image glyphicon glyphicon-remove-circle"
55   - data-params='<?= Json::encode(['category_media_id' => $oneimage->id, 'remove_media' => true]) ?>',
56   - ></a>
57   - </div>
58   - <?php
59   - }
60   - }
  60 + </div>
  61 + <div role="" class="tab-pane" id="image-preview">
  62 + <?php
  63 + $imagelang = Multilang::begin([
  64 + 'ajaxpath' => Url::to(['/blog/ajax/article-category-media-form?type=preview']),
  65 + 'form' => $form,
  66 + 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'preview'])->indexBy('language_id')->all()
  67 + ]);
  68 + $first = 1;
  69 + foreach($images as $lang => $value) {
  70 + if(!array_key_exists('preview', $value)) continue;
  71 + ?>
  72 + <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="<?=$imagelang->id?>-<?=$lang?>">
  73 + <?php
  74 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]);
  75 + echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']);
  76 + if(!empty($images[$lang]['preview']->article_category_media_id)) {
  77 + echo "<img src='/images/upload/{$images[$lang]['preview']->media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>";
61 78 }
62   - } else {
63   - echo $form->field($images[$index], "[{$index}]imageFile")->fileInput(['class' => 'image_inputs_field']);
64   - if(!empty($image->id)) {
65   - echo "<img src='/images/upload/{$image->media->hash}/original.{$image->media->extension}' width='100' class='image_inputs_prev'>";
  79 + ?>
  80 + </div>
  81 + <?php
  82 + $first = 0;
  83 + }
  84 + $imagelang->end();
  85 + ?>
  86 + </div>
  87 + <div role="" class="tab-pane" id="image-additional">
  88 + <?php
  89 + echo $form->field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']);
  90 + if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) {
  91 + foreach($images[0]['additional'] as $onefield => $oneimage) {
  92 + if($onefield) {
  93 + ?>
  94 + <div class="additional_image_container">
  95 + <img src='/images/upload/<?= $oneimage->media->hash ?>/original.<?= $oneimage->media->extension ?>' width='100'>
  96 + <a
  97 + href="<?= Url::to(['ajax/remove-image']) ?>"
  98 + class="remove_image glyphicon glyphicon-remove-circle"
  99 + data-params='<?= Json::encode(['article_category_media_id' => $oneimage->article_category_media_id, 'remove_media' => true]) ?>',
  100 + ></a>
  101 + </div>
  102 + <?php
66 103 }
67 104 }
68   - ?>
69   - </div>
70   - <?php
71   - $first = 0;
72   - }
73   - ?>
  105 + }
  106 + ?>
  107 + </div>
74 108 </div>
75 109  
76 110 <hr>
77 111  
78   - <div class="dropdown pull-right">
79   - <button class="btn btn-default dropdown-toggle" type="button" id="dropdownLang" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
80   - <?= Yii::t('app', 'Add language') ?>
81   - <span class="caret"></span>
82   - </button>
83   - <ul class="dropdown-menu f32" id="lang-dropdown" aria-labelledby="dropdownMenu1">
84   - <?php foreach($langs as $index => $lang) {
85   - if(in_array($index, array_keys($category_langs))) continue;
86   - ?>
87   - <li><a href="#lang-tabs" data-lang="<?=$lang->language_id?>"><span class="flag <?=$lang->country_code?>"></span></a></li>
88   - <?php } ?>
89   - </ul>
90   - </div>
91   - <ul class="nav nav-tabs f32" id="lang-tabs" role="tablist">
92   - <?php
93   - $first = 1;
94   - foreach($category_langs as $index => $category_lang) {
95   - ?>
96   - <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#lang-<?=$index?>" aria-controls="lang-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li>
97   - <?php
98   - $first = 0;
99   - }
100   - ?>
101   - </ul>
102   - <div class="tab-content lang-tab-content">
  112 + <?php
  113 + $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/category-form']), 'form' => $form, 'data_langs' => $category_langs])
  114 + ?>
103 115 <?php
104 116 $first = 1;
105 117 foreach($category_langs as $index => $category_lang) {
106 118 ?>
107 119 <div role="" class="tab-pane <?php if($first) { echo 'active main-tab'; } ?>" id="lang-<?=$index?>">
108   - <?= $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]) ?>
109 121  
110 122 <?= $form->field($category_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
111 123  
... ... @@ -119,18 +131,20 @@ $uploaddir = \Yii::getAlias(&#39;@saveImageDir&#39;);
119 131  
120 132 <?= $form->field($category_langs[$index], "[$index]meta_descr")->textarea(); ?>
121 133  
122   - <?= $form->field($category_langs[$index], "[$index]meta_keywords")->textInput() ?>
  134 + <?= $form->field($category_langs[$index], "[$index]meta_keyword")->textInput() ?>
123 135  
124 136 <?= $form->field($category_langs[$index], "[$index]h1_tag")->textInput() ?>
125 137  
126   - <?= $form->field($category_langs[$index], "[$index]tags")->textInput() ?>
  138 + <?= $form->field($category_langs[$index], "[$index]tag")->textInput() ?>
127 139  
128 140 </div>
129 141 <?php
130 142 $first = 0;
131 143 }
132 144 ?>
133   - </div>
  145 + <?php
  146 + $multilang->end();
  147 + ?>
134 148  
135 149 <div class="form-group">
136 150 <?= Html::submitButton($category->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $category->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
... ...
common/modules/blog/views/category/index.php
... ... @@ -7,15 +7,15 @@ use common\models\Language;
7 7 echo GridView::widget([
8 8 'dataProvider' => $dataProvider,
9 9 'columns' => [
10   - 'id',
  10 + 'article_category_id',
11 11 'code',
12   - 'created_at',
13   - 'updated_at',
  12 + 'date_add',
  13 + 'date_update',
14 14 [
15 15 'class' => Column::className(),
16 16 'header' => Yii::t('app', 'Name'),
17 17 'content' => function($model, $key, $index, $column) {
18   - return $model->getArticleCategoryLangs()->where(['lang_id' => Language::getDefaultLang()->language_id])->one()->name;
  18 + return $model->getArticleCategoryLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name;
19 19 }
20 20 ],
21 21 [
... ...
common/modules/blog/views/default/index.php
1 1 <?php
  2 +
  3 +use yii\behaviors\BlameableBehavior;
  4 +use yii\web\Application;
  5 +
  6 +$behavior = new BlameableBehavior();
  7 +var_dump($behavior->value);
2 8 \ No newline at end of file
... ...
common/translation/ru/app.php
... ... @@ -58,9 +58,23 @@ return [
58 58 'Category update' => 'Редактирование категории',
59 59 'Article create' => 'Создание статьи',
60 60 'Update category' => 'Редактирование категории',
61   - 'Select parent' => 'Выберать родителя',
  61 + 'Select parent' => 'Выбрать родителя',
62 62 'Blog' => 'Блог',
63 63 'Static pages' => 'Статические страницы',
  64 + 'Create Admin Menu' => 'Создать элемент меню',
  65 + 'Admin Menus' => 'Административное меню',
  66 + 'Hide Min' => 'Спрятать в свернутом',
  67 + 'Path' => 'Путь',
  68 + 'Params' => 'Параметры',
  69 + 'Parent item' => 'Родительский элемент',
  70 + 'Active Menu' => 'Активный',
  71 + 'Not Active Menu' => 'Неактивный',
  72 + 'Show Menu Min' => 'Отобразить',
  73 + 'Hide Menu Min' => 'Спрятать',
  74 + 'Update' => 'Редактировать',
  75 + 'Delete' => 'Удалить',
  76 + 'Settings categories' => 'Разделы настроек',
  77 + 'Back' => 'Назад',
64 78  
65 79 // Вова
66 80 'page' => 'Страница',
... ... @@ -72,7 +86,7 @@ return [
72 86 'meta_description' => 'Meta Description',
73 87 'text' => 'Текст',
74 88 'page_alias' => 'alias',
75   - 'lang_id' => 'ID языка',
  89 + 'language_id' => 'ID языка',
76 90 'common' => 'Общее',
77 91 'lang' => 'Языковые переменные',
78 92 'termin' => 'Термин',
... ...
common/translation/uk/app.php
... ... @@ -14,7 +14,7 @@ return [
14 14 'meta_description' => 'Meta Description',
15 15 'text' => 'Текст',
16 16 'page_alias' => 'alias',
17   - 'lang_id' => 'ID мови',
  17 + 'language_id' => 'ID мови',
18 18 'common' => 'Загальне',
19 19 'lang' => 'Мовні змінні',
20 20 'termin' => 'Термін',
... ...
common/widgets/Multilang.php 0 → 100644
  1 +<?php
  2 +namespace common\widgets;
  3 +use common\models\Language;
  4 +use yii\base\InvalidParamException;
  5 +use yii\base\Widget;
  6 +use yii\bootstrap\ActiveForm;
  7 +
  8 +class Multilang extends Widget
  9 +{
  10 + public $id;
  11 +
  12 + public $langs;
  13 +
  14 + public $data_langs = [];
  15 +
  16 + public $ajaxpath;
  17 +
  18 + public $form;
  19 +
  20 + public function init()
  21 + {
  22 + parent::init();
  23 + if(empty($this->id)) {
  24 + $this->id = \Yii::$app->security->generateRandomString(8);
  25 + }
  26 + if(empty($this->langs)) {
  27 + $this->langs = Language::getActiveLanguages();
  28 + }
  29 + if(empty($this->ajaxpath)) {
  30 + throw new InvalidParamException('ajaxpath must be set');
  31 + }
  32 + if(empty($this->form)) {
  33 + throw new InvalidParamException('form must be set');
  34 + }
  35 + ob_start();
  36 + echo $this->render('multilang-begin', ['id' => $this->id, 'langs' => $this->langs, 'data_langs' => $this->data_langs, 'ajaxpath' => $this->ajaxpath, 'form' => $this->form]);
  37 + }
  38 +
  39 + public function run()
  40 + {
  41 + echo $this->render('multilang-end', ['id' => $this->id, 'langs' => $this->langs, 'data_langs' => $this->data_langs, 'ajaxpath' => $this->ajaxpath, 'form' => $this->form]);
  42 + $content = ob_get_clean();
  43 + return $content;
  44 + }
  45 +}
0 46 \ No newline at end of file
... ...
common/widgets/Multilanguage.php 0 → 100644
  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 88 \ No newline at end of file
... ...
common/widgets/views/multilang-begin.php 0 → 100644
  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 old" id="lang-<?=$id?>" aria-labelledby="<?=$id?>Menu">
  10 + <?php foreach($langs as $index => $lang) {
  11 + if(in_array($index, array_keys($data_langs))) 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 + $first = 1;
  20 + foreach($data_langs as $index => $data_lang) {
  21 + if(!$index) continue;
  22 + ?>
  23 + <li role="lang_inputs" class="<?php if($first) { echo 'active'; }?>" data-lang="<?=$index?>"><a href="#<?=$id?>-<?=$index?>" aria-controls="<?=$id?>-<?=$index?>" role="tab" data-toggle="tab"><span class="flag <?=$langs[$index]->country_code?>"></span></a></li>
  24 + <?php
  25 + $first = 0;
  26 + }
  27 + ?>
  28 +</ul>
  29 +<div class="tab-content lang-tab-content" id="tab-content-<?=$id?>">
  30 +
... ...
common/widgets/views/multilang-end.php 0 → 100644
  1 +<?php
  2 +use yii\helpers\Url;
  3 +?>
  4 +</div>
  5 +<script>
  6 + if(typeof form === 'undefined') {
  7 + var form = [];
  8 + }
  9 + form['<?=$id?>'] = '<?=$ajaxpath?>';
  10 +</script>
0 11 \ No newline at end of file
... ...
common/widgets/views/multilanguage-begin.php 0 → 100644
  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 +
... ...
common/widgets/views/multilanguage-end.php 0 → 100644
  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 11 \ No newline at end of file
... ...
composer.json
... ... @@ -12,7 +12,7 @@
12 12 "irc": "irc://irc.freenode.net/yii",
13 13 "source": "https://github.com/yiisoft/yii2"
14 14 },
15   - "minimum-stability": "stable",
  15 + "minimum-stability": "dev",
16 16 "require": {
17 17 "php": ">=5.4.0",
18 18 "yiisoft/yii2": ">=2.0.6",
... ...
db-migration/artbox_db.backup deleted
No preview for this file type
db-migration/artbox_db3.backup deleted
No preview for this file type
db-migration/catalog.backup deleted
No preview for this file type
db-migration/yarik.sql deleted
1   --- --------------------------------------------------------
2   --- Хост: 127.0.0.1
3   --- Версия сервера: PostgreSQL 9.4.4, compiled by Visual C++ build 1800, 32-bit
4   --- ОС Сервера:
5   --- HeidiSQL Версия: 9.3.0.4984
6   --- --------------------------------------------------------
7   -
8   -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
9   -/*!40101 SET NAMES */;
10   -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
11   -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
12   -
13   --- Дамп структуры для таблица public.article
14   -CREATE TABLE IF NOT EXISTS "article" (
15   - "id" INTEGER NOT NULL DEFAULT nextval('article_id_seq'::regclass) COMMENT E'',
16   - "sort" INTEGER NOT NULL DEFAULT 100 COMMENT E'',
17   - "create_at" TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
18   - "update_at" TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
19   - "code" CHARACTER VARYING NOT NULL COMMENT E'',
20   - "category_id" INTEGER NOT NULL DEFAULT 1 COMMENT E'',
21   - "author" INTEGER NOT NULL COMMENT E'',
22   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
23   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
24   - "active" SMALLINT NOT NULL DEFAULT 0 COMMENT E'',
25   - "comments" SMALLINT NOT NULL DEFAULT 0::smallint COMMENT E'',
26   - "voting" SMALLINT NOT NULL DEFAULT 0::smallint COMMENT E'',
27   - KEY ("author"),
28   - PRIMARY KEY ("id"),
29   - KEY ("parent_id"),
30   - KEY ("category_id"),
31   - KEY ("id")
32   -);
33   -
34   --- Дамп данных таблицы public.article: 3 rows
35   -/*!40000 ALTER TABLE "article" DISABLE KEYS */;
36   -INSERT INTO "article" ("id", "sort", "create_at", "update_at", "code", "category_id", "author", "tags", "parent_id", "active", "comments", "voting") VALUES
37   - (5, 100, E'2015-12-04 14:52:39.54', E'2015-12-04 14:52:39.54', E'test_article', 1, 1, E'test, tag', NULL, 1, 0, 0),
38   - (6, 100, E'2015-12-04 14:52:52.403', E'2015-12-04 14:52:52.403', E'test_article2', 1, 1, E'test, tag', NULL, 1, 0, 0),
39   - (12, 100, E'2015-12-04 14:52:52.403', E'2015-12-04 14:52:52.403', E'test_article3', 1, 1, E'test, tag', 5, 1, 0, 0);
40   -/*!40000 ALTER TABLE "article" ENABLE KEYS */;
41   -
42   -
43   --- Дамп структуры для таблица public.article_category
44   -CREATE TABLE IF NOT EXISTS "article_category" (
45   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_id_seq'::regclass) COMMENT E'',
46   - "sort" INTEGER NOT NULL DEFAULT 100 COMMENT E'',
47   - "code" CHARACTER VARYING NOT NULL COMMENT E'',
48   - "created_at" TIME WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
49   - "updated_at" TIME WITHOUT TIME ZONE NOT NULL DEFAULT now() COMMENT E'',
50   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
51   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
52   - "active" SMALLINT NOT NULL DEFAULT 0 COMMENT E'',
53   - PRIMARY KEY ("id"),
54   - KEY ("parent_id"),
55   - KEY ("id")
56   -);
57   -
58   --- Дамп данных таблицы public.article_category: 2 rows
59   -/*!40000 ALTER TABLE "article_category" DISABLE KEYS */;
60   -INSERT INTO "article_category" ("id", "sort", "code", "created_at", "updated_at", "tags", "parent_id", "active") VALUES
61   - (1, 100, E'static_pages', E'14:08:02.74', E'14:08:02.74', NULL, NULL, 1),
62   - (2, 100, E'qwerty', E'11:00:35.954', E'11:00:35.954', E'qwerty', NULL, 0);
63   -/*!40000 ALTER TABLE "article_category" ENABLE KEYS */;
64   -
65   -
66   --- Дамп структуры для таблица public.article_category_lang
67   -CREATE TABLE IF NOT EXISTS "article_category_lang" (
68   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_lang_id_seq'::regclass) COMMENT E'',
69   - "lang_id" INTEGER NOT NULL DEFAULT 0 COMMENT E'',
70   - "category_id" INTEGER NULL DEFAULT NULL COMMENT E'',
71   - "text" TEXT NOT NULL COMMENT E'',
72   - "preview" TEXT NULL DEFAULT NULL COMMENT E'',
73   - "seo_url" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
74   - "name" CHARACTER VARYING NOT NULL COMMENT E'',
75   - "meta_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
76   - "meta_descr" TEXT NULL DEFAULT NULL COMMENT E'',
77   - "meta_keywords" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
78   - "h1_tag" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
79   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
80   - PRIMARY KEY ("id"),
81   - KEY ("category_id"),
82   - KEY ("lang_id"),
83   - KEY ("id")
84   -);
85   -
86   --- Дамп данных таблицы public.article_category_lang: 3 rows
87   -/*!40000 ALTER TABLE "article_category_lang" DISABLE KEYS */;
88   -INSERT INTO "article_category_lang" ("id", "lang_id", "category_id", "text", "preview", "seo_url", "name", "meta_title", "meta_descr", "meta_keywords", "h1_tag", "tags") VALUES
89   - (1, 0, 1, E'Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem ', E'Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem Lorem ', E'lorem', E'Lorem ipsum', E'Lorem title', E'Lorem description', E'lorem, keyword', E'Lorem h1 tag', E'lorem tag'),
90   - (2, 2, 2, E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty', E'qwerty'),
91   - (3, 1, 2, E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен', E'йцукен');
92   -/*!40000 ALTER TABLE "article_category_lang" ENABLE KEYS */;
93   -
94   -
95   --- Дамп структуры для таблица public.article_category_media
96   -CREATE TABLE IF NOT EXISTS "article_category_media" (
97   - "id" INTEGER NOT NULL DEFAULT nextval('article_category_media_id_seq'::regclass) COMMENT E'',
98   - "category_id" INTEGER NOT NULL COMMENT E'',
99   - "media_id" INTEGER NOT NULL COMMENT E'',
100   - "media_alt" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
101   - "media_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
102   - "media_caption" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
103   - "type" CHARACTER VARYING(10) NOT NULL DEFAULT 'additional'::character varying COMMENT E'',
104   - PRIMARY KEY ("id"),
105   - KEY ("media_id"),
106   - KEY ("category_id"),
107   - KEY ("id")
108   -);
109   -
110   --- Дамп данных таблицы public.article_category_media: 0 rows
111   -/*!40000 ALTER TABLE "article_category_media" DISABLE KEYS */;
112   -/*!40000 ALTER TABLE "article_category_media" ENABLE KEYS */;
113   -
114   -
115   --- Дамп структуры для таблица public.article_lang
116   -CREATE TABLE IF NOT EXISTS "article_lang" (
117   - "id" INTEGER NOT NULL DEFAULT nextval('article_lang_id_seq'::regclass) COMMENT E'',
118   - "lang_id" INTEGER NOT NULL COMMENT E'',
119   - "article_id" INTEGER NOT NULL COMMENT E'',
120   - "text" TEXT NOT NULL COMMENT E'',
121   - "seo_url" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
122   - "name" CHARACTER VARYING NOT NULL COMMENT E'',
123   - "preview" TEXT NULL DEFAULT NULL COMMENT E'',
124   - "meta_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
125   - "meta_descr" TEXT NULL DEFAULT NULL COMMENT E'',
126   - "meta_keywords" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
127   - "h1_tag" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
128   - "tags" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
129   - PRIMARY KEY ("id"),
130   - KEY ("article_id"),
131   - KEY ("lang_id"),
132   - KEY ("id")
133   -);
134   -
135   --- Дамп данных таблицы public.article_lang: 2 rows
136   -/*!40000 ALTER TABLE "article_lang" DISABLE KEYS */;
137   -INSERT INTO "article_lang" ("id", "lang_id", "article_id", "text", "seo_url", "name", "preview", "meta_title", "meta_descr", "meta_keywords", "h1_tag", "tags") VALUES
138   - (1, 0, 5, E'Lorem Lorem Lorem', E'article1', E'artivle1', E'Lorem preview', E'Lorem title', E'Lorem description', E'lorem, keyword', E'lorem h1 tag', E'tag, lorem'),
139   - (2, 0, 12, E'Lorem Lorem Lorem', E'article3', E'artivle3\r\n', E'Lorem preview', E'Lorem title', E'Lorem description', E'lorem, keyword', E'lorem h1 tag', E'tag, lorem');
140   -/*!40000 ALTER TABLE "article_lang" ENABLE KEYS */;
141   -
142   -
143   --- Дамп структуры для таблица public.article_media
144   -CREATE TABLE IF NOT EXISTS "article_media" (
145   - "id" INTEGER NOT NULL DEFAULT nextval('article_media_id_seq'::regclass) COMMENT E'',
146   - "article_id" INTEGER NOT NULL COMMENT E'',
147   - "media_id" INTEGER NOT NULL COMMENT E'',
148   - "type" CHARACTER VARYING(10) NOT NULL DEFAULT 'additional'::character varying COMMENT E'',
149   - "media_alt" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
150   - "media_title" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
151   - "media_caption" CHARACTER VARYING NULL DEFAULT NULL COMMENT E'',
152   - PRIMARY KEY ("id"),
153   - KEY ("media_id"),
154   - KEY ("article_id"),
155   - KEY ("id")
156   -);
157   -
158   --- Дамп данных таблицы public.article_media: 0 rows
159   -/*!40000 ALTER TABLE "article_media" DISABLE KEYS */;
160   -/*!40000 ALTER TABLE "article_media" ENABLE KEYS */;
161   -
162   -
163   --- Дамп структуры для таблица public.media
164   -CREATE TABLE IF NOT EXISTS "media" (
165   - "id" INTEGER NOT NULL DEFAULT nextval('media_id_seq'::regclass) COMMENT E'',
166   - "hash" CHARACTER VARYING NOT NULL COMMENT E'',
167   - PRIMARY KEY ("id"),
168   - KEY ("id")
169   -);
170   -
171   --- Дамп данных таблицы public.media: 0 rows
172   -/*!40000 ALTER TABLE "media" DISABLE KEYS */;
173   -/*!40000 ALTER TABLE "media" ENABLE KEYS */;
174   -
175   -
176   --- Дамп структуры для таблица public.option
177   -CREATE TABLE IF NOT EXISTS "option" (
178   - "model" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
179   - "option_id" INTEGER NOT NULL DEFAULT nextval('option_option_id_seq'::regclass) COMMENT E'',
180   - "model_id" INTEGER NULL DEFAULT NULL COMMENT E'',
181   - "name" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
182   - "template" CHARACTER VARYING(200) NULL DEFAULT NULL COMMENT E'',
183   - "parent_id" INTEGER NULL DEFAULT NULL COMMENT E'',
184   - "translate" BIT(1) NULL DEFAULT NULL COMMENT E'',
185   - "created_at" TIMESTAMP WITHOUT TIME ZONE NULL DEFAULT now() COMMENT E'',
186   - KEY ("option_id"),
187   - KEY ("parent_id"),
188   - PRIMARY KEY ("option_id")
189   -);
190   -
191   --- Дамп данных таблицы public.option: 0 rows
192   -/*!40000 ALTER TABLE "option" DISABLE KEYS */;
193   -/*!40000 ALTER TABLE "option" ENABLE KEYS */;
194   -
195   -
196   --- Дамп структуры для таблица public.option_lang
197   -CREATE TABLE IF NOT EXISTS "option_lang" (
198   - "primary" INTEGER NOT NULL DEFAULT nextval('option_lang_primary_seq'::regclass) COMMENT E'',
199   - "id" INTEGER NULL DEFAULT NULL COMMENT E'',
200   - "lang_id" INTEGER NULL DEFAULT NULL COMMENT E'',
201   - "value" TEXT NULL DEFAULT NULL COMMENT E'',
202   - KEY ("id"),
203   - PRIMARY KEY ("primary")
204   -);
205   -
206   --- Дамп данных таблицы public.option_lang: 0 rows
207   -/*!40000 ALTER TABLE "option_lang" DISABLE KEYS */;
208   -/*!40000 ALTER TABLE "option_lang" ENABLE KEYS */;
209   -/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
210   -/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
211   -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
db-migration/yarik.zip deleted
No preview for this file type
db-migration/yarik/lang.backup 0 → 100644
No preview for this file type
db-migration/article_option_migration.backup renamed to db-migration/yarik/newnames.backup
No preview for this file type
db-migration/yarik/public.backup 0 → 100644
No preview for this file type
frontend/config/main.php
... ... @@ -16,9 +16,7 @@ return [
16 16 'bootstrap' => ['log'],
17 17 'controllerNamespace' => 'frontend\controllers',
18 18 'modules' => [
19   - 'blog' => [
20   - 'class' => 'common\modules\blog\Module',
21   - ],
  19 +
22 20 ],
23 21 'components' => [
24 22 //'PageController'=>[
... ...
frontend/controllers/OptionValuesController.php
... ... @@ -68,7 +68,7 @@ class OptionValuesController extends Controller
68 68 foreach($post['OptionValues']['option_value_text'] as $lang => $value) {
69 69 $models[$lang] = new OptionValues();
70 70 $models[$lang]->load(Yii::$app->request->post());
71   - $models[$lang]->option_lang_id = $lang;
  71 + $models[$lang]->option_language_id = $lang;
72 72 $models[$lang]->option_value_text = $value;
73 73 if($first && $id) {
74 74 $models[$lang]->option_value_parent = $id;
... ...
frontend/controllers/SiteController.php
... ... @@ -36,7 +36,7 @@ class SiteController extends Controller
36 36 return [
37 37 'access' => [
38 38 'class' => AccessControl::className(),
39   - 'only' => ['logout', 'signup'],
  39 + 'only' => ['logout', 'signup', 'index'],
40 40 'rules' => [
41 41 [
42 42 'actions' => ['signup'],
... ... @@ -48,6 +48,11 @@ class SiteController extends Controller
48 48 'allow' => true,
49 49 'roles' => ['@'],
50 50 ],
  51 + [
  52 + 'actions' => ['index'],
  53 + 'allow' => true,
  54 + 'roles' => ['@'],
  55 + ]
51 56 ],
52 57 ],
53 58 'verbs' => [
... ... @@ -298,10 +303,10 @@ class SiteController extends Controller
298 303 $option_values[$key] = new OptionValues();
299 304 $option_values[$key]['option_value_id'] = $options_to_values[$key]->getAttribute('option_value_id');
300 305 $option_values[$key]['option_value_text'] = $val['option_value'];
301   - if($options_to_values[$key]->option->getAttribute('option_translatable') == 0 || empty($val['option_lang_id'])) {
302   - $option_values[$key]['option_lang_id'] = 0;
  306 + if($options_to_values[$key]->option->getAttribute('option_translatable') == 0 || empty($val['option_language_id'])) {
  307 + $option_values[$key]['option_language_id'] = 0;
303 308 } else {
304   - $option_values[$key]['option_lang_id'] = $val['option_lang_id'];
  309 + $option_values[$key]['option_language_id'] = $val['option_language_id'];
305 310 }
306 311 if(!$option_values[$key]->save()) {
307 312 $options_to_values[$key]->delete();
... ...
frontend/models/Language.php
... ... @@ -61,6 +61,6 @@ class Language extends \yii\db\ActiveRecord
61 61 */
62 62 public function getOptionValues()
63 63 {
64   - return $this->hasMany(OptionValues::className(), ['option_lang_id' => 'language_id']);
  64 + return $this->hasMany(OptionValues::className(), ['option_language_id' => 'language_id']);
65 65 }
66 66 }
... ...
frontend/models/LanguageLang.php
... ... @@ -9,7 +9,7 @@ use Yii;
9 9 *
10 10 * @property integer $language_id
11 11 * @property string $lang_title
12   - * @property integer $lang_id
  12 + * @property integer $language_id
13 13 *
14 14 * @property Language $language
15 15 */
... ... @@ -43,7 +43,7 @@ class LanguageLang extends \yii\db\ActiveRecord
43 43 return [
44 44 'language_id' => Yii::t('app', 'Language ID'),
45 45 'lang_title' => Yii::t('app', 'Lang Title'),
46   - 'lang_id' => Yii::t('app', 'Lang ID'),
  46 + 'language_id' => Yii::t('app', 'Lang ID'),
47 47 ];
48 48 }
49 49  
... ...
frontend/models/Option.php
... ... @@ -31,7 +31,7 @@ class Option extends \yii\db\ActiveRecord
31 31 {
32 32 return [
33 33 [['model', 'model_id', 'name', 'template'], 'required'],
34   - [['model_id', 'parent_id'], 'integer'],
  34 + [['model_id', 'option_pid'], 'integer'],
35 35 [['model', 'name', 'template'], 'string', 'max' => 200]
36 36 ];
37 37 }
... ... @@ -47,29 +47,30 @@ class Option extends \yii\db\ActiveRecord
47 47 'model_id' => Yii::t('app', 'Model ID'),
48 48 'name' => Yii::t('app', 'Name'),
49 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 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 60 public static function change($id, $post, $modeldb, $model_id) {
60 61 $models[$id] = Option::findOne($id);
61 62 $modellang[$id] = array();
62   - $langs = OptionLang::findAll(['id' => $id]);
  63 + $langs = OptionLang::findAll(['option_language_id' => $id]);
63 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 68 foreach($children as $child) {
68 69 $models[$child->option_id] = $child;
69 70 $modellang[$child->option_id] = array();
70   - $langs = OptionLang::findAll(['id' =>$child->option_id]);
  71 + $langs = OptionLang::findAll(['option_id' =>$child->option_id]);
71 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 76 $ok = 1;
... ... @@ -77,7 +78,7 @@ class Option extends \yii\db\ActiveRecord
77 78 foreach($post['Option'] as $key => $option) {
78 79 if(in_array($key, array('model', 'model_id'))) { continue; }
79 80 if(empty($option['value'][$models[$key]->name]) && !empty($option['lang'])) {
80   - foreach($option['lang'] as $lang_id => $lang) {
  81 + foreach($option['lang'] as $language_id => $lang) {
81 82 if(!empty($lang)) {
82 83 $option['value'][$models[$key]->name] = $lang;
83 84 break;
... ... @@ -91,16 +92,16 @@ class Option extends \yii\db\ActiveRecord
91 92 $modellang[$key][0]->addError('value', 'Value must be set');
92 93 }
93 94 if(!empty($option['lang'])) {
94   - foreach($option['lang'] as $lang_id => $lang) {
95   - if(empty($modellang[$key][$lang_id])) {
96   - $modellang[$key][$lang_id] = new OptionLang();
97   - $modellang[$key][$lang_id]->id = $models[$key]->option_id;
98   - $modellang[$key][$lang_id]->lang_id = $lang_id;
99   - $modellang[$key][$lang_id]->value = $lang;
  95 + foreach($option['lang'] as $language_id => $lang) {
  96 + if(empty($modellang[$key][$language_id])) {
  97 + $modellang[$key][$language_id] = new OptionLang();
  98 + $modellang[$key][$language_id]->option_id = $models[$key]->option_id;
  99 + $modellang[$key][$language_id]->language_id = $language_id;
  100 + $modellang[$key][$language_id]->value = $lang;
100 101 } else {
101   - $modellang[$key][$lang_id]->value = $lang;
  102 + $modellang[$key][$language_id]->value = $lang;
102 103 }
103   - if(!$modellang[$key][$lang_id]->save()) {
  104 + if(!$modellang[$key][$language_id]->save()) {
104 105 $ok = 0;
105 106 }
106 107 }
... ... @@ -146,7 +147,7 @@ class Option extends \yii\db\ActiveRecord
146 147 $models[$index][$key]->translate = $option[$key]['translate']?1:0;
147 148 $models[$index][$key]->name = $key;
148 149 if(!$first) {
149   - $models[$index][$key]->parent_id = $parentid;
  150 + $models[$index][$key]->option_pid = $parentid;
150 151 }
151 152 $modelslang[$index][$key][0] = new OptionLang();
152 153 if(!empty($option['lang'][$key])) {
... ... @@ -161,16 +162,16 @@ class Option extends \yii\db\ActiveRecord
161 162 if($first) {
162 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 167 $modelslang[$index][$key][0]->value = $value;
167 168 if($modelslang[$index][$key][0]->save()) {
168 169 if(!empty($option['lang'][$key])) {
169 170 foreach($option['lang'][$key] as $code => $lang) {
170 171 if(!empty($lang)) {
171 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 175 $modelslang[$index][$key][$code]->value = $lang;
175 176 if(!$modelslang[$index][$key][$code]->save()) {
176 177 $ok = 0;
... ... @@ -187,8 +188,8 @@ class Option extends \yii\db\ActiveRecord
187 188 foreach($option['lang'][$key] as $code => $lang) {
188 189 if(!empty($lang)) {
189 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 193 $modelslang[$index][$key][$code]->value = $lang;
193 194 }
194 195 }
... ... @@ -205,12 +206,12 @@ class Option extends \yii\db\ActiveRecord
205 206 $newflag->model_id = $model_id;
206 207 $newflag->name = 'is_new';
207 208 $newflag->template = 'checkbox';
208   - $newflag->parent_id = $parentid;
  209 + $newflag->option_pid = $parentid;
209 210 $newflag->translate = 0;
210 211 if($newflag->save()) {
211 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 215 $newflaglang->value = '1';
215 216 if(!$newflaglang->save()) {
216 217 $newflag->delete();
... ... @@ -242,19 +243,19 @@ class Option extends \yii\db\ActiveRecord
242 243 }
243 244  
244 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 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 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 257 public function getOptionDefaultLang($array = false) {
257   - $query = $this->getOptionLangs()->where(['lang_id' => 0]);
  258 + $query = $this->getOptionLangs()->where(['language_id' => 0]);
258 259 if($array) {
259 260 $query->asArray();
260 261 }
... ...
frontend/models/OptionLang.php
... ... @@ -8,7 +8,7 @@ use Yii;
8 8 * This is the model class for table "option_lang".
9 9 *
10 10 * @property integer $id
11   - * @property integer $lang_id
  11 + * @property integer $language_id
12 12 * @property string $value
13 13 */
14 14 class OptionLang extends \yii\db\ActiveRecord
... ... @@ -27,8 +27,8 @@ class OptionLang extends \yii\db\ActiveRecord
27 27 public function rules()
28 28 {
29 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 32 [['value'], 'string']
33 33 ];
34 34 }
... ... @@ -39,8 +39,8 @@ class OptionLang extends \yii\db\ActiveRecord
39 39 public function attributeLabels()
40 40 {
41 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 44 'value' => Yii::t('app', 'Value'),
45 45 ];
46 46 }
... ...
frontend/models/OptionLangSearch.php
... ... @@ -18,7 +18,7 @@ class OptionLangSearch extends OptionLang
18 18 public function rules()
19 19 {
20 20 return [
21   - [['primary', 'id', 'lang_id'], 'integer'],
  21 + [['option_language_id', 'option_id', 'language_id'], 'integer'],
22 22 [['value'], 'safe'],
23 23 ];
24 24 }
... ... @@ -56,9 +56,9 @@ class OptionLangSearch extends OptionLang
56 56 }
57 57  
58 58 $query->andFilterWhere([
59   - 'primary' => $this->primary,
60   - 'id' => $this->id,
61   - 'lang_id' => $this->lang_id,
  59 + 'option_language_id' => $this->option_language_id,
  60 + 'option_id' => $this->option_id,
  61 + 'language_id' => $this->language_id,
62 62 ]);
63 63  
64 64 $query->andFilterWhere(['like', 'value', $this->value]);
... ...