Commit 5dfa349e16b8a477b395aeaa43b4ed90add9c5ac

Authored by Yarik
1 parent 14adae3b

Коммит последний день 2015

backend/controllers/AdminMenuController.php
@@ -14,6 +14,8 @@ use yii\filters\VerbFilter; @@ -14,6 +14,8 @@ use yii\filters\VerbFilter;
14 */ 14 */
15 class AdminMenuController extends Controller 15 class AdminMenuController extends Controller
16 { 16 {
  17 + public $layout = 'settings';
  18 +
17 public function behaviors() 19 public function behaviors()
18 { 20 {
19 return [ 21 return [
@@ -117,4 +119,5 @@ class AdminMenuController extends Controller @@ -117,4 +119,5 @@ class AdminMenuController extends Controller
117 throw new NotFoundHttpException('The requested page does not exist.'); 119 throw new NotFoundHttpException('The requested page does not exist.');
118 } 120 }
119 } 121 }
  122 +
120 } 123 }
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/models/AdminMenu.php
@@ -23,6 +23,8 @@ use Yii; @@ -23,6 +23,8 @@ use Yii;
23 */ 23 */
24 class AdminMenu extends \yii\db\ActiveRecord 24 class AdminMenu extends \yii\db\ActiveRecord
25 { 25 {
  26 +
  27 + public $parentt;
26 /** 28 /**
27 * @inheritdoc 29 * @inheritdoc
28 */ 30 */
@@ -39,7 +41,7 @@ class AdminMenu extends \yii\db\ActiveRecord @@ -39,7 +41,7 @@ class AdminMenu extends \yii\db\ActiveRecord
39 return [ 41 return [
40 [['parent_id', 'active', 'hide_min', 'sort'], 'integer'], 42 [['parent_id', 'active', 'hide_min', 'sort'], 'integer'],
41 [['name'], 'required'], 43 [['name'], 'required'],
42 - [['name', 'path', 'params'], 'string'] 44 + [['name', 'path', 'params','parentt'], 'string']
43 ]; 45 ];
44 } 46 }
45 47
@@ -57,6 +59,7 @@ class AdminMenu extends \yii\db\ActiveRecord @@ -57,6 +59,7 @@ class AdminMenu extends \yii\db\ActiveRecord
57 'name' => Yii::t('app', 'Name'), 59 'name' => Yii::t('app', 'Name'),
58 'path' => Yii::t('app', 'Path'), 60 'path' => Yii::t('app', 'Path'),
59 'params' => Yii::t('app', 'Params'), 61 'params' => Yii::t('app', 'Params'),
  62 + 'parentt' => Yii::t('app', 'Parent item')
60 ]; 63 ];
61 } 64 }
62 65
@@ -98,17 +101,17 @@ class AdminMenu extends \yii\db\ActiveRecord @@ -98,17 +101,17 @@ class AdminMenu extends \yii\db\ActiveRecord
98 $roots = self::find()->where(['parent_id' => NULL])->with(['adminMenus'])->all(); 101 $roots = self::find()->where(['parent_id' => NULL])->with(['adminMenus'])->all();
99 foreach($roots as $root) { 102 foreach($roots as $root) {
100 if($root->adminMenus) { 103 if($root->adminMenus) {
101 - $result[] = ['label' => $root->name, 'id' => $root->id, 'options' => ['class' => 'header']]; 104 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id, 'options' => ['class' => 'header']];
102 foreach($root->adminMenus as $submenu) { 105 foreach($root->adminMenus as $submenu) {
103 if($submenu->adminMenus) { 106 if($submenu->adminMenus) {
104 $items = []; 107 $items = [];
105 foreach($submenu->adminMenus as $item) { 108 foreach($submenu->adminMenus as $item) {
106 - $items[] = ['label' => $item->name, 'id' => $item->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$item->path], \common\models\Tools::parseUrlParams($item->params))]; 109 + $items[] = ['label' => Yii::t('app', $item->name), 'id' => $item->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$item->path], \common\models\Tools::parseUrlParams($item->params))];
107 } 110 }
108 - $result[] = ['label' => $submenu->name, 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items]; 111 + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => $items];
109 unset($items); 112 unset($items);
110 } else { 113 } else {
111 - $result[] = ['label' => $submenu->name, 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->params))]; 114 + $result[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id, 'icon' => 'fa fa-circle-o', 'url' => array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->params))];
112 } 115 }
113 } 116 }
114 } 117 }
@@ -124,14 +127,26 @@ class AdminMenu extends \yii\db\ActiveRecord @@ -124,14 +127,26 @@ class AdminMenu extends \yii\db\ActiveRecord
124 if($root->adminMenus) { 127 if($root->adminMenus) {
125 $items = []; 128 $items = [];
126 foreach($root->adminMenus as $submenu) { 129 foreach($root->adminMenus as $submenu) {
127 - $items[] = ['label' => $submenu->name, 'id' => $submenu->id]; 130 + $items[] = ['label' => Yii::t('app', $submenu->name), 'id' => $submenu->id];
128 } 131 }
129 - $result[] = ['label' => $root->name, 'id' => $root->id, 'items' => $items]; 132 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id, 'items' => $items];
130 unset($items); 133 unset($items);
131 } else { 134 } else {
132 - $result[] = ['label' => $root->name, 'id' => $root->id]; 135 + $result[] = ['label' => Yii::t('app', $root->name), 'id' => $root->id];
133 } 136 }
134 } 137 }
135 return $result; 138 return $result;
136 } 139 }
  140 +
  141 + public function beforeSave($insert)
  142 + {
  143 + if (parent::beforeSave($insert)) {
  144 + if(!$this->parent_id) {
  145 + $this->parent_id = NULL;
  146 + }
  147 + return true;
  148 + } else {
  149 + return false;
  150 + }
  151 + }
137 } 152 }
backend/models/AdminMenuSearch.php
@@ -12,6 +12,8 @@ use backend\models\AdminMenu; @@ -12,6 +12,8 @@ use backend\models\AdminMenu;
12 */ 12 */
13 class AdminMenuSearch extends AdminMenu 13 class AdminMenuSearch extends AdminMenu
14 { 14 {
  15 +
  16 +
15 /** 17 /**
16 * @inheritdoc 18 * @inheritdoc
17 */ 19 */
@@ -19,7 +21,7 @@ class AdminMenuSearch extends AdminMenu @@ -19,7 +21,7 @@ class AdminMenuSearch extends AdminMenu
19 { 21 {
20 return [ 22 return [
21 [['id', 'parent_id', 'active', 'hide_min', 'sort'], 'integer'], 23 [['id', 'parent_id', 'active', 'hide_min', 'sort'], 'integer'],
22 - [['name', 'path', 'params'], 'safe'], 24 + [['name', 'path', 'params','parentt'], 'safe'],
23 ]; 25 ];
24 } 26 }
25 27
@@ -45,6 +47,24 @@ class AdminMenuSearch extends AdminMenu @@ -45,6 +47,24 @@ class AdminMenuSearch extends AdminMenu
45 47
46 $dataProvider = new ActiveDataProvider([ 48 $dataProvider = new ActiveDataProvider([
47 'query' => $query, 49 'query' => $query,
  50 + 'pagination' => [
  51 + 'pageSize' => 5
  52 + ],
  53 + 'sort' => [
  54 + 'attributes' => [
  55 + 'id',
  56 + 'name',
  57 + 'path',
  58 + 'params',
  59 + 'active',
  60 + 'hide_min',
  61 + 'parentt' => [
  62 + 'asc' => ['name' => SORT_ASC],
  63 + 'desc' => ['name' => SORT_DESC],
  64 + 'default' => SORT_DESC
  65 + ]
  66 + ]
  67 + ]
48 ]); 68 ]);
49 69
50 $this->load($params); 70 $this->load($params);
@@ -60,12 +80,14 @@ class AdminMenuSearch extends AdminMenu @@ -60,12 +80,14 @@ class AdminMenuSearch extends AdminMenu
60 'parent_id' => $this->parent_id, 80 'parent_id' => $this->parent_id,
61 'active' => $this->active, 81 'active' => $this->active,
62 'hide_min' => $this->hide_min, 82 'hide_min' => $this->hide_min,
63 - 'sort' => $this->sort, 83 + 'sort' => $this->sort
64 ]); 84 ]);
65 85
  86 +
66 $query->andFilterWhere(['like', 'name', $this->name]) 87 $query->andFilterWhere(['like', 'name', $this->name])
67 ->andFilterWhere(['like', 'path', $this->path]) 88 ->andFilterWhere(['like', 'path', $this->path])
68 - ->andFilterWhere(['like', 'params', $this->params]); 89 + ->andFilterWhere(['like', 'params', $this->params])
  90 + ->andFilterWhere(['in', 'parent_id', $this->find()->select(['id'])->andFilterWhere(['like', 'name', $this->parentt])->column()]);
69 91
70 return $dataProvider; 92 return $dataProvider;
71 } 93 }
backend/views/admin-menu/_form.php
@@ -16,22 +16,6 @@ use yii\widgets\ActiveForm; @@ -16,22 +16,6 @@ use yii\widgets\ActiveForm;
16 16
17 <?= $form->field($model, 'name')->textInput() ?> 17 <?= $form->field($model, 'name')->textInput() ?>
18 18
19 - <p><strong><?= Yii::t('app', 'parent_id') ?></strong></p>  
20 - <ul class="list-group checkboxer">  
21 - <?php  
22 - $roots = AdminMenu::buildMenuSelect();  
23 - echo $form->field($model, 'parent_id', ['options' => ['class' => 'form-group list-group-item level0 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => 0, 'uncheck' => null, 'label' => Yii::t('app', 'root'), 'labelOptions' => ['class' => 'checkboxer_label']]);  
24 - foreach($roots as $root) {  
25 - echo $form->field($model, 'parent_id', ['options' => ['class' => 'form-group list-group-item level1 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $root['id'], 'uncheck' => null, 'label' => Yii::t('app', $root['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);  
26 - if($root['items']) {  
27 - foreach($root['items'] as $submenu) {  
28 - echo $form->field($model, 'parent_id', ['options' => ['class' => 'form-group list-group-item level2 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $submenu['id'], 'uncheck' => null, 'label' => Yii::t('app', $submenu['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);  
29 - }  
30 - }  
31 - }  
32 - ?>  
33 - </ul>  
34 -  
35 <?= $form->field($model, 'active')->checkbox() ?> 19 <?= $form->field($model, 'active')->checkbox() ?>
36 20
37 <?= $form->field($model, 'hide_min')->checkbox() ?> 21 <?= $form->field($model, 'hide_min')->checkbox() ?>
@@ -40,8 +24,36 @@ use yii\widgets\ActiveForm; @@ -40,8 +24,36 @@ use yii\widgets\ActiveForm;
40 24
41 <?= $form->field($model, 'params')->textInput() ?> 25 <?= $form->field($model, 'params')->textInput() ?>
42 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, 'parent_id', ['options' => ['class' => 'form-group list-group-item level0 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => 0, 'uncheck' => null, 'label' => Yii::t('app', 'root'), 'labelOptions' => ['class' => 'checkboxer_label']]);
  41 + foreach($roots as $root) {
  42 + echo $form->field($model, 'parent_id', ['options' => ['class' => 'form-group list-group-item level1 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $root['id'], 'uncheck' => null, 'label' => Yii::t('app', $root['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);
  43 + if($root['items']) {
  44 + foreach($root['items'] as $submenu) {
  45 + echo $form->field($model, 'parent_id', ['options' => ['class' => 'form-group list-group-item level2 checkboxer_container', 'tag' => 'li']])->error(false)->radio(['value' => $submenu['id'], 'uncheck' => null, 'label' => Yii::t('app', $submenu['label']), 'labelOptions' => ['class' => 'checkboxer_label']]);
  46 + }
  47 + }
  48 + }
  49 + ?>
  50 + </ul>
  51 + </div>
  52 + </div>
  53 + </div>
  54 +
43 <div class="form-group"> 55 <div class="form-group">
44 - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 56 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => ($model->isNewRecord ? 'btn btn-success' : 'btn btn-primary') . ' btn-flat']) ?>
45 </div> 57 </div>
46 58
47 <?php ActiveForm::end(); ?> 59 <?php ActiveForm::end(); ?>
backend/views/admin-menu/create.php
@@ -11,11 +11,12 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = [&#39;label&#39; =&gt; Yii::t(&#39;app&#39;, &#39;Admin Menus&#39;), &#39;url&#39; @@ -11,11 +11,12 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = [&#39;label&#39; =&gt; Yii::t(&#39;app&#39;, &#39;Admin Menus&#39;), &#39;url&#39;
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 <div class="admin-menu-create"> 13 <div class="admin-menu-create">
14 -  
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 -  
17 - <?= $this->render('_form', [  
18 - 'model' => $model,  
19 - ]) ?> 14 + <div class="box box-primary">
  15 + <div class="box-body">
  16 + <?= $this->render('_form', [
  17 + 'model' => $model,
  18 + ]) ?>
  19 + </div>
  20 + </div>
20 21
21 </div> 22 </div>
backend/views/admin-menu/index.php
@@ -10,31 +10,82 @@ use yii\grid\GridView; @@ -10,31 +10,82 @@ use yii\grid\GridView;
10 $this->title = Yii::t('app', 'Admin Menus'); 10 $this->title = Yii::t('app', 'Admin Menus');
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="admin-menu-index"> 13 +<div class="admin-menu-index box box-primary">
14 14
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 15 <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17 16
18 - <p>  
19 - <?= Html::a(Yii::t('app', 'Create Admin Menu'), ['create'], ['class' => 'btn btn-success']) ?>  
20 - </p>  
21 -  
22 <?= GridView::widget([ 17 <?= GridView::widget([
23 'dataProvider' => $dataProvider, 18 'dataProvider' => $dataProvider,
24 'filterModel' => $searchModel, 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>",
25 'columns' => [ 40 'columns' => [
26 - ['class' => 'yii\grid\SerialColumn'],  
27 -  
28 - 'id',  
29 - 'parent_id',  
30 - 'active',  
31 - 'hide_min',  
32 - 'sort',  
33 - // 'name',  
34 - // 'path',  
35 - // 'params',  
36 -  
37 ['class' => 'yii\grid\ActionColumn'], 41 ['class' => 'yii\grid\ActionColumn'],
  42 + 'id',
  43 + 'name',
  44 + 'path',
  45 + 'params',
  46 + [
  47 + 'format' => 'raw',
  48 + 'filter' => [
  49 + '1'=>'Отображаются',
  50 + '0'=>'Скрытые',
  51 + ],
  52 + 'value' => function($data){
  53 + if($data->active){
  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'=>'active',
  61 + ],
  62 + [
  63 + 'attribute' => 'parentt',
  64 + 'content' =>
  65 + function($model, $key, $index, $column) {
  66 + if($model->parent->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 + ],
38 ], 89 ],
39 ]); ?> 90 ]); ?>
40 91
backend/views/admin-menu/update.php
@@ -5,17 +5,13 @@ use yii\helpers\Html; @@ -5,17 +5,13 @@ use yii\helpers\Html;
5 /* @var $this yii\web\View */ 5 /* @var $this yii\web\View */
6 /* @var $model backend\models\AdminMenu */ 6 /* @var $model backend\models\AdminMenu */
7 7
8 -$this->title = Yii::t('app', 'Update {modelClass}: ', [  
9 - 'modelClass' => 'Admin Menu',  
10 -]) . ' ' . $model->name; 8 +$this->title = Yii::t('app', 'Update') . ': ' . $model->name;
11 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; 9 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']];
12 $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; 10 $this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
13 $this->params['breadcrumbs'][] = Yii::t('app', 'Update'); 11 $this->params['breadcrumbs'][] = Yii::t('app', 'Update');
14 ?> 12 ?>
15 <div class="admin-menu-update"> 13 <div class="admin-menu-update">
16 14
17 - <h1><?= Html::encode($this->title) ?></h1>  
18 -  
19 <?= $this->render('_form', [ 15 <?= $this->render('_form', [
20 'model' => $model, 16 'model' => $model,
21 ]) ?> 17 ]) ?>
backend/views/admin-menu/view.php
@@ -6,24 +6,11 @@ use yii\widgets\DetailView; @@ -6,24 +6,11 @@ use yii\widgets\DetailView;
6 /* @var $this yii\web\View */ 6 /* @var $this yii\web\View */
7 /* @var $model backend\models\AdminMenu */ 7 /* @var $model backend\models\AdminMenu */
8 8
9 -$this->title = $model->name; 9 +$this->title = Yii::t('app', 'Admin Menus').': '.$model->name;
10 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']]; 10 $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Admin Menus'), 'url' => ['index']];
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 -<div class="admin-menu-view">  
14 -  
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 -  
17 - <p>  
18 - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [  
20 - 'class' => 'btn btn-danger',  
21 - 'data' => [  
22 - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),  
23 - 'method' => 'post',  
24 - ],  
25 - ]) ?>  
26 - </p> 13 +<div class="admin-menu-view box box-primary">
27 14
28 <?= DetailView::widget([ 15 <?= DetailView::widget([
29 'model' => $model, 16 'model' => $model,
@@ -39,4 +26,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -39,4 +26,18 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
39 ], 26 ],
40 ]) ?> 27 ]) ?>
41 28
  29 + <div class="box-footer with-border">
  30 + <p>
  31 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary btn-flat']) ?>
  32 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->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 +
42 </div> 43 </div>
backend/views/layouts/left.php
@@ -13,103 +13,16 @@ @@ -13,103 +13,16 @@
13 <a href="#"><i class="fa fa-circle text-success"></i> Online</a> 13 <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
14 </div> 14 </div>
15 </div> 15 </div>
16 - <?php  
17 - /*  
18 - <ul class="sidebar-menu">  
19 - <?php  
20 - $roots = \backend\models\AdminMenu::find()->where(['parent_id' => NULL])->all();  
21 - foreach($roots as $root) {  
22 - if($root->adminMenus) {  
23 - echo "<li class='header'>{$root->name}</li>";  
24 - echo "<li class='treeview'>";  
25 - foreach($root->adminMenus as $submenu) {  
26 - if($submenu->adminMenus) {  
27 - echo \yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($submenu->name)."</span><i class='fa fa-angle-left pull-right'></i>");  
28 - echo "<ul class='treeview-menu' style='display:none'>";  
29 - foreach($submenu->adminMenus as $item) {  
30 - echo "<li>".\yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($item->name)."</span>", array_merge([$item->path], \common\models\Tools::parseUrlParams($item->params)))."</li>";  
31 - }  
32 - echo "</ul>";  
33 - } else {  
34 - echo \yii\helpers\Html::a("<i class='fa fa-circle-o'></i><span>".\yii\helpers\Html::encode($submenu->name)."</span>", array_merge([$submenu->path], \common\models\Tools::parseUrlParams($submenu->params)));  
35 - }  
36 - }  
37 - echo "</li>";  
38 - }  
39 - }  
40 - ?>  
41 - </ul>  
42 - */ ?>  
43 16
44 <?= dmstr\widgets\Menu::widget([ 17 <?= dmstr\widgets\Menu::widget([
45 'options' => ['class' => 'sidebar-menu'], 18 'options' => ['class' => 'sidebar-menu'],
46 - 'items' => \backend\models\AdminMenu::buildMenu(), 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 + ),
47 ]) ?> 25 ]) ?>
48 - <?php  
49 - /*  
50 - <?= dmstr\widgets\Menu::widget(  
51 - [  
52 - 'options' => ['class' => 'sidebar-menu'],  
53 - 'items' => [  
54 - ['label' => 'Термины', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']],  
55 - //['label' => Yii::t('app', 'Pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']],  
56 - //['label' => 'Каталог', 'icon' => 'fa fa-file-code-o', 'url' => ['/catalog/']],  
57 - ['label' => 'Меню', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']],  
58 - ['label' => 'Заявки', 'icon' => 'fa fa-file-code-o', 'url' => ['/site/requests/']],  
59 - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']],  
60 - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']],  
61 - ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],  
62 - ['label' => 'Пользователи', 'icon' => 'fa fa-file-code-o', 'url' => ['/user/']],  
63 - [  
64 - 'label' => Yii::t('app', 'Blog'),  
65 - 'icon' => 'fa fa-share',  
66 - 'url' => '#',  
67 - 'items' => [  
68 - ['label' => Yii::t('app', 'Static pages'), 'icon' => 'fa fa-file-code-o', 'url' => ['blog/articles', 'category_id' => '63'],],  
69 - ['label' => Yii::t('app', 'Categories'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/categories'],],  
70 - ['label' => Yii::t('app', 'Articles'), 'icon' => 'fa fa-dashboard', 'url' => ['blog/articles'],],  
71 - ],  
72 - ],  
73 - [  
74 - 'label' => 'Роли',  
75 - 'icon' => 'fa fa-share',  
76 - 'url' => '#',  
77 - 'items' => [  
78 - ['label' => 'Управление ролями', 'icon' => 'fa fa-file-code-o', 'url' => ['/permit/access/role'],],  
79 - ['label' => 'Управление правами доступа', 'icon' => 'fa fa-dashboard', 'url' => ['/permit/access/permission'],],  
80 - ],  
81 - ],  
82 - [  
83 - 'label' => 'Same tools',  
84 - 'icon' => 'fa fa-share',  
85 - 'url' => '#',  
86 - 'items' => [  
87 - ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii'],],  
88 - ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug'],],  
89 - [  
90 - 'label' => 'Level One',  
91 - 'icon' => 'fa fa-circle-o',  
92 - 'url' => '#',  
93 - 'items' => [  
94 - ['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#',],  
95 - [  
96 - 'label' => 'Level Two',  
97 - 'icon' => 'fa fa-circle-o',  
98 - 'url' => '#',  
99 - 'items' => [  
100 - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',],  
101 - ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#',],  
102 - ],  
103 - ],  
104 - ],  
105 - ],  
106 - ],  
107 - ],  
108 - ],  
109 - ]  
110 - ) ?>  
111 - */  
112 - ?>  
113 26
114 </section> 27 </section>
115 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 \ No newline at end of file 41 \ No newline at end of file
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/web/css/site.css
@@ -123,4 +123,13 @@ a.desc:after { @@ -123,4 +123,13 @@ a.desc:after {
123 .checkboxer .checkboxer_label input[type=radio] { 123 .checkboxer .checkboxer_label input[type=radio] {
124 position: absolute; 124 position: absolute;
125 clip: rect(0,0,0,0); 125 clip: rect(0,0,0,0);
126 -}  
127 \ No newline at end of file 126 \ No newline at end of file
  127 +}
  128 +.action_link {
  129 + float: left;
  130 +}
  131 +.admin_grid_action {
  132 + padding: 0 20px;
  133 +}
  134 +.admin_grid_action .pagination {
  135 + margin: 0;
  136 +}
backend/web/js/option.js
@@ -12,6 +12,12 @@ function readURL(input) { @@ -12,6 +12,12 @@ function readURL(input) {
12 } 12 }
13 return urls; 13 return urls;
14 } 14 }
  15 +function checkboxerInit() {
  16 + $.each($('.checkboxer input[type=radio]:checked'), function(index, value) {
  17 + console.log(value);
  18 + $(value).trigger('change');
  19 + });
  20 +}
15 $(function() { 21 $(function() {
16 var counter = 0; 22 var counter = 0;
17 $(document).on('click', '.add_row', function() { 23 $(document).on('click', '.add_row', function() {
@@ -36,42 +42,6 @@ $(function() { @@ -36,42 +42,6 @@ $(function() {
36 $(document).on('click', '.remove_lang', function() { 42 $(document).on('click', '.remove_lang', function() {
37 $(this).parents('.form-wrapper').remove(); 43 $(this).parents('.form-wrapper').remove();
38 }); 44 });
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() {  
43 - var lang = $(this).data('lang');  
44 - var flag = $(this).find('span').first().clone();  
45 - 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());  
51 - $('body').append($(data).filter('script'));  
52 - $(el).parent().remove();  
53 - if(!$('#lang-dropdown li').length) {  
54 - $('#dropdownLang').addClass('disabled');  
55 - }  
56 - if($('#lang-tabs li').length > 1) {  
57 - $('#lang-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')  
58 - }  
59 - });  
60 - });  
61 - $(document).on('click', '.remove-lang', function() {  
62 - var lang = $(this).parent().data('lang');  
63 - 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');  
67 - $(this).parent().remove();  
68 - if($('#lang-tabs li').length <= 1) {  
69 - $('#lang-tabs li').find('.remove-lang').remove();  
70 - }  
71 - if(!$('#lang-tabs>li.active').length) {  
72 - $('#lang-tabs>li').first().find('a').tab('show');  
73 - }  
74 - });  
75 $(document).on('change', '.image_inputs_field', function() { 45 $(document).on('change', '.image_inputs_field', function() {
76 readURL(this); 46 readURL(this);
77 }); 47 });
@@ -89,9 +59,50 @@ $(function() { @@ -89,9 +59,50 @@ $(function() {
89 } 59 }
90 return false; 60 return false;
91 }); 61 });
  62 + $.each($('.nav-tabs.f32'), function(key, value) {
  63 + if($(value).find('li').length > 1) {
  64 + $(value).find('li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>');
  65 + }
  66 + });
  67 + $(document).on('click', '.dropdown-menu.f32 li a[data-lang]', function() {
  68 + var lang = $(this).data('lang');
  69 + var flag = $(this).find('span').first().clone();
  70 + var el = $(this);
  71 + var id = $(this).attr('href').substr(1);
  72 + $.get(form[id], { lang_id: lang, widget_id: id }, function(data) {
  73 + $('#'+id+'-tabs li').removeClass('active');
  74 + $('#'+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>');
  75 + $('#tab-content-'+id+' .tab-pane.active').removeClass('active');
  76 + $('#tab-content-'+id).append($(data).find('.ajax-loaded').first());
  77 + $('body').append($(data).filter('script'));
  78 + $(el).parent().remove();
  79 + if(!$('#lang-'+id+' li').length) {
  80 + $('#'+id+'Lang').addClass('disabled');
  81 + }
  82 + if($('#'+id+'-tabs li').length > 1) {
  83 + $('#'+id+'-tabs li').append('<span class="glyphicon glyphicon-remove-circle remove-lang"></span>')
  84 + }
  85 + });
  86 + });
  87 + $(document).on('click', '.remove-lang', function() {
  88 + var lang = $(this).parent().data('lang');
  89 + var flag = $(this).parent().find('span.flag').first().clone();
  90 + var id = $(this).parent().find('a[aria-controls]').first().attr('aria-controls').substr(0,8);
  91 + $('#'+id+'-'+lang).remove();
  92 + $('#lang-'+id).append('<li><a href="#'+id+'" data-lang="'+lang+'">'+$('<p>').append($(flag)).html()+'</a></li>');
  93 + $('#'+id+'Lang').removeClass('disabled');
  94 + $(this).parent().remove();
  95 + if($('#'+id+'-tabs li').length <= 1) {
  96 + $('#'+id+'-tabs li').find('.remove-lang').remove();
  97 + }
  98 + if(!$('#'+id+'-tabs>li.active').length) {
  99 + $('#'+id+'-tabs>li').first().find('a').tab('show');
  100 + }
  101 + });
92 $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() { 102 $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() {
93 console.log($(this).val()); 103 console.log($(this).val());
94 $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); 104 $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active');
95 $(this).parents('.checkboxer_container').addClass('active'); 105 $(this).parents('.checkboxer_container').addClass('active');
96 }); 106 });
  107 + checkboxerInit();
97 }); 108 });
98 \ No newline at end of file 109 \ No newline at end of file
common/config/main.php
@@ -8,6 +8,9 @@ return [ @@ -8,6 +8,9 @@ return [
8 'userClass' => 'common\models\User' 8 'userClass' => 'common\models\User'
9 ] 9 ]
10 ], 10 ],
  11 + 'blog' => [
  12 + 'class' => 'common\modules\blog\Module',
  13 + ],
11 ], 14 ],
12 'components' => [ 15 'components' => [
13 'cache' => [ 16 'cache' => [
common/translation/ru/app.php
@@ -58,9 +58,23 @@ return [ @@ -58,9 +58,23 @@ return [
58 'Category update' => 'Редактирование категории', 58 'Category update' => 'Редактирование категории',
59 'Article create' => 'Создание статьи', 59 'Article create' => 'Создание статьи',
60 'Update category' => 'Редактирование категории', 60 'Update category' => 'Редактирование категории',
61 - 'Select parent' => 'Выберать родителя', 61 + 'Select parent' => 'Выбрать родителя',
62 'Blog' => 'Блог', 62 'Blog' => 'Блог',
63 'Static pages' => 'Статические страницы', 63 'Static pages' => 'Статические страницы',
  64 + 'Create Admin Menu' => 'Создать элемент меню',
  65 + 'Admin Menus' => 'Административное меню',
  66 + 'Hide Min' => 'Спрятать в свернутом',
  67 + 'Path' => 'Путь',
  68 + 'Params' => 'Параметры',
  69 + 'Parent item' => 'Родительский элемент',
  70 + 'Active Menu' => 'Активный',
  71 + 'Not Active Menu' => 'Неактивный',
  72 + 'Show Menu Min' => 'Отобразить',
  73 + 'Hide Menu Min' => 'Спрятать',
  74 + 'Update' => 'Редактировать',
  75 + 'Delete' => 'Удалить',
  76 + 'Settings categories' => 'Разделы настроек',
  77 + 'Back' => 'Назад',
64 78
65 // Вова 79 // Вова
66 'page' => 'Страница', 80 'page' => 'Страница',
db-migration/yarik/public.backup
No preview for this file type
frontend/config/main.php
@@ -16,9 +16,7 @@ return [ @@ -16,9 +16,7 @@ return [
16 'bootstrap' => ['log'], 16 'bootstrap' => ['log'],
17 'controllerNamespace' => 'frontend\controllers', 17 'controllerNamespace' => 'frontend\controllers',
18 'modules' => [ 18 'modules' => [
19 - 'blog' => [  
20 - 'class' => 'common\modules\blog\Module',  
21 - ], 19 +
22 ], 20 ],
23 'components' => [ 21 'components' => [
24 //'PageController'=>[ 22 //'PageController'=>[
frontend/web/js/option.js
@@ -93,4 +93,9 @@ $(function() { @@ -93,4 +93,9 @@ $(function() {
93 $('#'+id+'-tabs>li').first().find('a').tab('show'); 93 $('#'+id+'-tabs>li').first().find('a').tab('show');
94 } 94 }
95 }); 95 });
  96 + $(document).on('change', '.checkboxer .checkboxer_label input[type=radio]', function() {
  97 + console.log($(this).val());
  98 + $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active');
  99 + $(this).parents('.checkboxer_container').addClass('active');
  100 + });
96 }); 101 });
97 \ No newline at end of file 102 \ No newline at end of file