Commit 0747f4557866afccf2212a0431cbe974e50f8785
Merge remote-tracking branch 'origin/master'
Showing
60 changed files
with
1247 additions
and
1 deletions
Show diff stats
1 | +<?php | |
2 | + | |
3 | + namespace backend\controllers; | |
4 | + | |
5 | + use Yii; | |
6 | + use common\models\Persone; | |
7 | + use common\models\PersoneSearch; | |
8 | + use yii\web\Controller; | |
9 | + use yii\web\NotFoundHttpException; | |
10 | + use yii\filters\VerbFilter; | |
11 | + | |
12 | + /** | |
13 | + * PersoneController implements the CRUD actions for Persone model. | |
14 | + */ | |
15 | + class PersoneController extends Controller | |
16 | + { | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function behaviors() | |
21 | + { | |
22 | + return [ | |
23 | + 'verbs' => [ | |
24 | + 'class' => VerbFilter::className(), | |
25 | + 'actions' => [ | |
26 | + 'delete' => [ 'POST' ], | |
27 | + ], | |
28 | + ], | |
29 | + ]; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * Lists all Persone models. | |
34 | + * | |
35 | + * @return mixed | |
36 | + */ | |
37 | + public function actionIndex() | |
38 | + { | |
39 | + $searchModel = new PersoneSearch(); | |
40 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
41 | + | |
42 | + return $this->render( | |
43 | + 'index', | |
44 | + [ | |
45 | + 'searchModel' => $searchModel, | |
46 | + 'dataProvider' => $dataProvider, | |
47 | + ] | |
48 | + ); | |
49 | + } | |
50 | + | |
51 | + /** | |
52 | + * Displays a single Persone model. | |
53 | + * | |
54 | + * @param integer $id | |
55 | + * | |
56 | + * @return mixed | |
57 | + */ | |
58 | + public function actionView($id) | |
59 | + { | |
60 | + return $this->render( | |
61 | + 'view', | |
62 | + [ | |
63 | + 'model' => $this->findModel($id), | |
64 | + ] | |
65 | + ); | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * Creates a new Persone model. | |
70 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
71 | + * | |
72 | + * @return mixed | |
73 | + */ | |
74 | + public function actionCreate() | |
75 | + { | |
76 | + $model = new Persone(); | |
77 | + $model->generateLangs(); | |
78 | + | |
79 | + if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
80 | + return $this->redirect( | |
81 | + [ | |
82 | + 'view', | |
83 | + 'id' => $model->id, | |
84 | + ] | |
85 | + ); | |
86 | + } | |
87 | + return $this->render( | |
88 | + 'create', | |
89 | + [ | |
90 | + 'model' => $model, | |
91 | + 'modelLangs' => $model->modelLangs, | |
92 | + ] | |
93 | + ); | |
94 | + } | |
95 | + | |
96 | + /** | |
97 | + * Updates an existing Persone model. | |
98 | + * If update is successful, the browser will be redirected to the 'view' page. | |
99 | + * | |
100 | + * @param integer $id | |
101 | + * | |
102 | + * @return mixed | |
103 | + */ | |
104 | + public function actionUpdate($id) | |
105 | + { | |
106 | + $model = $this->findModel($id); | |
107 | + $model->generateLangs(); | |
108 | + | |
109 | + if ($model->loadWithLangs(\Yii::$app->request) && $model->saveWithLangs()) { | |
110 | + return $this->redirect( | |
111 | + [ | |
112 | + 'view', | |
113 | + 'id' => $model->id, | |
114 | + ] | |
115 | + ); | |
116 | + } | |
117 | + return $this->render( | |
118 | + 'update', | |
119 | + [ | |
120 | + 'model' => $model, | |
121 | + 'modelLangs' => $model->modelLangs, | |
122 | + ] | |
123 | + ); | |
124 | + } | |
125 | + | |
126 | + /** | |
127 | + * Deletes an existing Persone model. | |
128 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
129 | + * | |
130 | + * @param integer $id | |
131 | + * | |
132 | + * @return mixed | |
133 | + */ | |
134 | + public function actionDelete($id) | |
135 | + { | |
136 | + $this->findModel($id) | |
137 | + ->delete(); | |
138 | + | |
139 | + return $this->redirect([ 'index' ]); | |
140 | + } | |
141 | + | |
142 | + /** | |
143 | + * Finds the Persone model based on its primary key value. | |
144 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
145 | + * | |
146 | + * @param integer $id | |
147 | + * | |
148 | + * @return Persone the loaded model | |
149 | + * @throws NotFoundHttpException if the model cannot be found | |
150 | + */ | |
151 | + protected function findModel($id) | |
152 | + { | |
153 | + if (( $model = Persone::findOne($id) ) !== null) { | |
154 | + return $model; | |
155 | + } else { | |
156 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
157 | + } | |
158 | + } | |
159 | + } | ... | ... |
backend/views/layouts/menu_items.php
1 | +<?php | |
2 | + | |
3 | + use artbox\core\components\imagemanager\components\ImageManagerInputWidget; | |
4 | + use artbox\core\widgets\LanguageForm; | |
5 | + use common\models\Persone; | |
6 | + use common\models\PersoneLang; | |
7 | + use yii\helpers\Html; | |
8 | + use yii\web\View; | |
9 | + use yii\widgets\ActiveForm; | |
10 | + | |
11 | + /** | |
12 | + * @var View $this | |
13 | + * @var Persone $model | |
14 | + * @var ActiveForm $form | |
15 | + * @var PersoneLang $modelLangs | |
16 | + */ | |
17 | + | |
18 | +?> | |
19 | + | |
20 | +<div class="persone-form"> | |
21 | + | |
22 | + <?php $form = ActiveForm::begin(); ?> | |
23 | + | |
24 | + <?= LanguageForm::widget( | |
25 | + [ | |
26 | + 'modelLangs' => $modelLangs, | |
27 | + 'formView' => '@backend/views/persone/_form_language', | |
28 | + 'form' => $form, | |
29 | + ] | |
30 | + ) ?> | |
31 | + | |
32 | + <?= $form->field($model, 'image_id') | |
33 | + ->widget( | |
34 | + ImageManagerInputWidget::className(), | |
35 | + [ | |
36 | + 'showPreview' => true, | |
37 | + 'showDeletePickedImageConfirm' => false, | |
38 | + ] | |
39 | + ); ?> | |
40 | + | |
41 | + <?= $form->field($model, 'facebook') ?> | |
42 | + | |
43 | + <?= $form->field($model, 'instagram') ?> | |
44 | + | |
45 | + <div class="form-group"> | |
46 | + <?= Html::submitButton( | |
47 | + $model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), | |
48 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | |
49 | + ) ?> | |
50 | + </div> | |
51 | + | |
52 | + <?php ActiveForm::end(); ?> | |
53 | + | |
54 | +</div> | ... | ... |
1 | +<?php | |
2 | + use artbox\core\helpers\SlugifyDecorator; | |
3 | + use artbox\core\models\Language; | |
4 | + use common\models\PersoneLang; | |
5 | + use dosamigos\tinymce\TinyMce; | |
6 | + use yii\web\View; | |
7 | + use yii\widgets\ActiveForm; | |
8 | + | |
9 | + /** | |
10 | + * @var PersoneLang $model_lang | |
11 | + * @var Language $language | |
12 | + * @var ActiveForm $form | |
13 | + * @var View $this | |
14 | + */ | |
15 | +?> | |
16 | +<?php | |
17 | + $attributeField = $form->field($model_lang, '[' . $language->id . ']title') | |
18 | + ->textInput([ 'maxlength' => true ]); | |
19 | + echo $attributeField; | |
20 | +?> | |
21 | + | |
22 | +<?= SlugifyDecorator::decorate( | |
23 | + $form->field($model_lang, '[' . $language->id . ']aliasValue'), | |
24 | + [ '/alias/slugify' ], | |
25 | + $attributeField, | |
26 | + false, | |
27 | + $language->id | |
28 | +) | |
29 | + ->textInput([ 'maxlength' => true ]); ?> | |
30 | + | |
31 | +<?= $form->field($model_lang, '[' . $language->id . ']preview') | |
32 | + ->textarea() ?> | |
33 | + | |
34 | +<?php | |
35 | + echo $form->field($model_lang, '[' . $language->id . ']text') | |
36 | + ->widget( | |
37 | + TinyMce::className(), | |
38 | + [ | |
39 | + 'options' => [ 'rows' => 30 ], | |
40 | + 'language' => 'ru', | |
41 | + 'clientOptions' => [ | |
42 | + 'file_browser_callback' => new yii\web\JsExpression( | |
43 | + "function(field_name, url, type, win) { | |
44 | +window.open('" . yii\helpers\Url::to( | |
45 | + [ | |
46 | + 'imagemanager/manager', | |
47 | + 'view-mode' => 'iframe', | |
48 | + 'select-type' => 'tinymce', | |
49 | + ] | |
50 | + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); | |
51 | +}" | |
52 | + ), | |
53 | + 'plugins' => [ | |
54 | + "advlist autolink lists link charmap print preview anchor", | |
55 | + "searchreplace visualblocks code fullscreen", | |
56 | + "insertdatetime media table contextmenu paste image", | |
57 | + ], | |
58 | + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", | |
59 | + ], | |
60 | + ] | |
61 | + ); | |
62 | +?> | |
0 | 63 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\PersoneSearch */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="persone-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, 'image_id') ?> | |
21 | + | |
22 | + <div class="form-group"> | |
23 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | |
24 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | |
25 | + </div> | |
26 | + | |
27 | + <?php ActiveForm::end(); ?> | |
28 | + | |
29 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use common\models\Persone; | |
4 | + use common\models\PersoneLang; | |
5 | + use yii\web\View; | |
6 | + use yiister\gentelella\widgets\Panel; | |
7 | + | |
8 | + /** | |
9 | + * @var View $this | |
10 | + * @var Persone $model | |
11 | + * @var PersoneLang[] $modelLangs | |
12 | + */ | |
13 | + | |
14 | + $this->title = Yii::t('app', 'Create Persone'); | |
15 | + $this->params[ 'breadcrumbs' ][] = [ | |
16 | + 'label' => Yii::t('app', 'Persones'), | |
17 | + 'url' => [ 'index' ], | |
18 | + ]; | |
19 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
20 | +?> | |
21 | +<div class="persone-create"> | |
22 | + | |
23 | + <?php Panel::begin([ | |
24 | + 'header' => $this->title | |
25 | + ])?> | |
26 | + | |
27 | + <?= $this->render( | |
28 | + '_form', | |
29 | + [ | |
30 | + 'model' => $model, | |
31 | + 'modelLangs' => $modelLangs, | |
32 | + ] | |
33 | + ) ?> | |
34 | + | |
35 | + <?php Panel::end()?> | |
36 | + | |
37 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use common\models\Persone; | |
4 | + use common\models\PersoneSearch; | |
5 | + use yii\data\ActiveDataProvider; | |
6 | + use yii\helpers\Html; | |
7 | + use yii\grid\GridView; | |
8 | + use yii\web\View; | |
9 | + use yiister\gentelella\widgets\Panel; | |
10 | + | |
11 | + /** | |
12 | + * @var View $this | |
13 | + * @var ActiveDataProvider $dataProvider | |
14 | + * @var PersoneSearch $searchModel | |
15 | + */ | |
16 | + | |
17 | + $this->title = Yii::t('app', 'Persones'); | |
18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
19 | +?> | |
20 | +<div class="persone-index"> | |
21 | + | |
22 | + <?php Panel::begin( | |
23 | + [ | |
24 | + 'header' => $this->title, | |
25 | + ] | |
26 | + ) ?> | |
27 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
28 | + | |
29 | + <p> | |
30 | + <?= Html::a(Yii::t('app', 'Create Persone'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | |
31 | + </p> | |
32 | + <?= GridView::widget( | |
33 | + [ | |
34 | + 'dataProvider' => $dataProvider, | |
35 | + 'filterModel' => $searchModel, | |
36 | + 'columns' => [ | |
37 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
38 | + | |
39 | + 'lang.title', | |
40 | + [ | |
41 | + 'attribute' => 'image_id', | |
42 | + 'value' => function (Persone $model) { | |
43 | + if (!empty($model->image)) { | |
44 | + return Html::img( | |
45 | + $model->image->getUrl(), | |
46 | + [ | |
47 | + 'width' => '500px', | |
48 | + ] | |
49 | + ); | |
50 | + } else { | |
51 | + return ''; | |
52 | + } | |
53 | + }, | |
54 | + 'format' => 'html', | |
55 | + ], | |
56 | + | |
57 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
58 | + ], | |
59 | + ] | |
60 | + ); ?> | |
61 | + <?php Panel::end() ?> | |
62 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use common\models\Persone; | |
4 | + use common\models\PersoneLang; | |
5 | + use yii\web\View; | |
6 | + use yiister\gentelella\widgets\Panel; | |
7 | + | |
8 | + /** | |
9 | + * @var View $this | |
10 | + * @var Persone $model | |
11 | + * @var PersoneLang[] $modelLangs | |
12 | + */ | |
13 | + | |
14 | + $this->title = Yii::t( | |
15 | + 'app', | |
16 | + 'Update {modelClass}: ', | |
17 | + [ | |
18 | + 'modelClass' => 'Persone', | |
19 | + ] | |
20 | + ) . $model->id; | |
21 | + $this->params[ 'breadcrumbs' ][] = [ | |
22 | + 'label' => Yii::t('app', 'Persones'), | |
23 | + 'url' => [ 'index' ], | |
24 | + ]; | |
25 | + $this->params[ 'breadcrumbs' ][] = [ | |
26 | + 'label' => $model->id, | |
27 | + 'url' => [ | |
28 | + 'view', | |
29 | + 'id' => $model->id, | |
30 | + ], | |
31 | + ]; | |
32 | + $this->params[ 'breadcrumbs' ][] = Yii::t('app', 'Update'); | |
33 | +?> | |
34 | +<div class="persone-update"> | |
35 | + | |
36 | + <?php Panel::begin( | |
37 | + [ | |
38 | + 'header' => $this->title, | |
39 | + ] | |
40 | + ) ?> | |
41 | + | |
42 | + <?= $this->render( | |
43 | + '_form', | |
44 | + [ | |
45 | + 'model' => $model, | |
46 | + 'modelLangs' => $modelLangs, | |
47 | + ] | |
48 | + ) ?> | |
49 | + | |
50 | + <?php Panel::end() ?> | |
51 | + | |
52 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use common\models\Persone; | |
4 | + use yii\helpers\Html; | |
5 | + use yii\web\View; | |
6 | + use yii\widgets\DetailView; | |
7 | + use yiister\gentelella\widgets\Panel; | |
8 | + | |
9 | + /** | |
10 | + * @var View $this | |
11 | + * @var Persone $model | |
12 | + */ | |
13 | + | |
14 | + $this->title = $model->id; | |
15 | + $this->params[ 'breadcrumbs' ][] = [ | |
16 | + 'label' => Yii::t('app', 'Persones'), | |
17 | + 'url' => [ 'index' ], | |
18 | + ]; | |
19 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
20 | +?> | |
21 | +<div class="persone-view"> | |
22 | + | |
23 | + <?php Panel::begin( | |
24 | + [ | |
25 | + 'header' => $this->title, | |
26 | + ] | |
27 | + ) ?> | |
28 | + | |
29 | + <p> | |
30 | + <?= Html::a( | |
31 | + Yii::t('app', 'Update'), | |
32 | + [ | |
33 | + 'update', | |
34 | + 'id' => $model->id, | |
35 | + ], | |
36 | + [ 'class' => 'btn btn-primary' ] | |
37 | + ) ?> | |
38 | + <?= Html::a( | |
39 | + Yii::t('app', 'Delete'), | |
40 | + [ | |
41 | + 'delete', | |
42 | + 'id' => $model->id, | |
43 | + ], | |
44 | + [ | |
45 | + 'class' => 'btn btn-danger', | |
46 | + 'data' => [ | |
47 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | |
48 | + 'method' => 'post', | |
49 | + ], | |
50 | + ] | |
51 | + ) ?> | |
52 | + </p> | |
53 | + | |
54 | + <?= DetailView::widget( | |
55 | + [ | |
56 | + 'model' => $model, | |
57 | + 'attributes' => [ | |
58 | + 'id', | |
59 | + 'image_id', | |
60 | + ], | |
61 | + ] | |
62 | + ) ?> | |
63 | + | |
64 | + <?php Panel::end() ?> | |
65 | + | |
66 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + namespace common\models; | |
4 | + | |
5 | + use artbox\core\behaviors\LanguageBehavior; | |
6 | + use artbox\core\models\Image; | |
7 | + use artbox\core\models\Language; | |
8 | + use yii\db\ActiveQuery; | |
9 | + use yii\db\ActiveRecord; | |
10 | + use yii\web\Request; | |
11 | + use Yii; | |
12 | + | |
13 | + /** | |
14 | + * This is the model class for table "persone". | |
15 | + * | |
16 | + * @property integer $id | |
17 | + * @property integer $image_id | |
18 | + * @property PersoneLang[] $personeLangs | |
19 | + * @property Language[] $languages | |
20 | + * @property Image $image | |
21 | + * @property string $instagram | |
22 | + * @property string $facebook | |
23 | + * * From language behavior * | |
24 | + * @property PersoneLang $lang | |
25 | + * @property PersoneLang[] $langs | |
26 | + * @property PersoneLang $objectLang | |
27 | + * @property string $ownerKey | |
28 | + * @property string $langKey | |
29 | + * @property PersoneLang[] $modelLangs | |
30 | + * @property bool $transactionStatus | |
31 | + * @method string getOwnerKey() | |
32 | + * @method void setOwnerKey( string $value ) | |
33 | + * @method string getLangKey() | |
34 | + * @method void setLangKey( string $value ) | |
35 | + * @method ActiveQuery getLangs() | |
36 | + * @method ActiveQuery getLang( integer $language_id ) | |
37 | + * @method PersoneLang[] generateLangs() | |
38 | + * @method void loadLangs( Request $request ) | |
39 | + * @method bool linkLangs() | |
40 | + * @method bool saveLangs() | |
41 | + * @method bool getTransactionStatus() | |
42 | + * @method bool loadWithLangs( Request $request ) | |
43 | + * @method bool saveWithLangs() | |
44 | + * * End language behavior * | |
45 | + * @see LanguageBehavior | |
46 | + */ | |
47 | + class Persone extends ActiveRecord | |
48 | + { | |
49 | + /** | |
50 | + * @inheritdoc | |
51 | + */ | |
52 | + public static function tableName() | |
53 | + { | |
54 | + return 'persone'; | |
55 | + } | |
56 | + | |
57 | + public function behaviors() | |
58 | + { | |
59 | + return [ | |
60 | + 'language' => [ | |
61 | + 'class' => LanguageBehavior::className(), | |
62 | + ], | |
63 | + ]; | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * @inheritdoc | |
68 | + */ | |
69 | + public function rules() | |
70 | + { | |
71 | + return [ | |
72 | + [ | |
73 | + [ 'image_id' ], | |
74 | + 'integer', | |
75 | + ], | |
76 | + [ | |
77 | + [ | |
78 | + 'facebook', | |
79 | + 'instagram', | |
80 | + ], | |
81 | + 'string', | |
82 | + ], | |
83 | + ]; | |
84 | + } | |
85 | + | |
86 | + /** | |
87 | + * @inheritdoc | |
88 | + */ | |
89 | + public function attributeLabels() | |
90 | + { | |
91 | + return [ | |
92 | + 'id' => Yii::t('app', 'ID'), | |
93 | + 'image_id' => Yii::t('app', 'Image ID'), | |
94 | + 'facebook' => Yii::t('app', 'Facebook'), | |
95 | + 'instagram' => Yii::t('app', 'Instagram'), | |
96 | + ]; | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * @return \yii\db\ActiveQuery | |
101 | + */ | |
102 | + public function getImage() | |
103 | + { | |
104 | + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]); | |
105 | + } | |
106 | + | |
107 | + /** | |
108 | + * @return \yii\db\ActiveQuery | |
109 | + */ | |
110 | + public function getPersoneLangs() | |
111 | + { | |
112 | + return $this->hasMany(PersoneLang::className(), [ 'persone_id' => 'id' ]); | |
113 | + } | |
114 | + | |
115 | + /** | |
116 | + * @return \yii\db\ActiveQuery | |
117 | + */ | |
118 | + public function getLanguages() | |
119 | + { | |
120 | + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) | |
121 | + ->viaTable('persone_lang', [ 'persone_id' => 'id' ]); | |
122 | + } | |
123 | + } | ... | ... |
1 | +<?php | |
2 | + | |
3 | + namespace common\models; | |
4 | + | |
5 | + use artbox\core\behaviors\SlugBehavior; | |
6 | + use artbox\core\models\Alias; | |
7 | + use artbox\core\models\Language; | |
8 | + use Yii; | |
9 | + use yii\db\ActiveRecord; | |
10 | + | |
11 | + /** | |
12 | + * This is the model class for table "persone_lang". | |
13 | + * | |
14 | + * @property integer $persone_id | |
15 | + * @property integer $language_id | |
16 | + * @property integer $alias_id | |
17 | + * @property string $title | |
18 | + * @property string $preview | |
19 | + * @property string $text | |
20 | + * @property Language $language | |
21 | + * @property Alias $alias | |
22 | + * @property Persone $persone | |
23 | + */ | |
24 | + class PersoneLang extends ActiveRecord | |
25 | + { | |
26 | + /** | |
27 | + * @inheritdoc | |
28 | + */ | |
29 | + public static function tableName() | |
30 | + { | |
31 | + return 'persone_lang'; | |
32 | + } | |
33 | + | |
34 | + /** | |
35 | + * @inheritdoc | |
36 | + */ | |
37 | + public static function primaryKey() | |
38 | + { | |
39 | + return [ | |
40 | + 'persone_id', | |
41 | + 'language_id', | |
42 | + ]; | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * @inheritdoc | |
47 | + */ | |
48 | + public function behaviors() | |
49 | + { | |
50 | + return [ | |
51 | + 'slug' => [ | |
52 | + 'class' => SlugBehavior::className(), | |
53 | + 'action' => 'persone/view', | |
54 | + 'params' => [ | |
55 | + 'id' => 'persone_id', | |
56 | + ], | |
57 | + 'fields' => [], | |
58 | + ], | |
59 | + ]; | |
60 | + } | |
61 | + | |
62 | + /** | |
63 | + * @inheritdoc | |
64 | + */ | |
65 | + public function rules() | |
66 | + { | |
67 | + return [ | |
68 | + [ | |
69 | + [ | |
70 | + 'persone_id', | |
71 | + 'language_id', | |
72 | + 'alias_id', | |
73 | + ], | |
74 | + 'integer', | |
75 | + ], | |
76 | + [ | |
77 | + [ | |
78 | + 'text', | |
79 | + 'preview', | |
80 | + ], | |
81 | + 'string', | |
82 | + ], | |
83 | + [ | |
84 | + [ 'title' ], | |
85 | + 'string', | |
86 | + 'max' => 255, | |
87 | + ], | |
88 | + [ | |
89 | + [ | |
90 | + 'persone_id', | |
91 | + 'language_id', | |
92 | + ], | |
93 | + 'unique', | |
94 | + 'targetAttribute' => [ | |
95 | + 'persone_id', | |
96 | + 'language_id', | |
97 | + ], | |
98 | + 'message' => 'The combination of Persone ID and Language ID has already been taken.', | |
99 | + ], | |
100 | + [ | |
101 | + [ 'language_id' ], | |
102 | + 'exist', | |
103 | + 'skipOnError' => true, | |
104 | + 'targetClass' => Language::className(), | |
105 | + 'targetAttribute' => [ 'language_id' => 'id' ], | |
106 | + ], | |
107 | + [ | |
108 | + [ 'persone_id' ], | |
109 | + 'exist', | |
110 | + 'skipOnError' => true, | |
111 | + 'targetClass' => Persone::className(), | |
112 | + 'targetAttribute' => [ 'persone_id' => 'id' ], | |
113 | + ], | |
114 | + ]; | |
115 | + } | |
116 | + | |
117 | + /** | |
118 | + * @inheritdoc | |
119 | + */ | |
120 | + public function attributeLabels() | |
121 | + { | |
122 | + return [ | |
123 | + 'persone_id' => Yii::t('app', 'Persone ID'), | |
124 | + 'language_id' => Yii::t('app', 'Language ID'), | |
125 | + 'alias_id' => Yii::t('app', 'Alias ID'), | |
126 | + 'title' => Yii::t('app', 'Title'), | |
127 | + 'text' => Yii::t('app', 'Text'), | |
128 | + 'preview' => Yii::t('app', 'Preview'), | |
129 | + ]; | |
130 | + } | |
131 | + | |
132 | + /** | |
133 | + * @return \yii\db\ActiveQuery | |
134 | + */ | |
135 | + public function getLanguage() | |
136 | + { | |
137 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | |
138 | + } | |
139 | + | |
140 | + /** | |
141 | + * @return \yii\db\ActiveQuery | |
142 | + */ | |
143 | + public function getPersone() | |
144 | + { | |
145 | + return $this->hasOne(Persone::className(), [ 'id' => 'persone_id' ]); | |
146 | + } | |
147 | + | |
148 | + /** | |
149 | + * @return \yii\db\ActiveQuery | |
150 | + */ | |
151 | + public function getAlias() | |
152 | + { | |
153 | + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); | |
154 | + } | |
155 | + } | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use yii\base\Model; | |
6 | +use yii\data\ActiveDataProvider; | |
7 | + | |
8 | +/** | |
9 | + * PersoneSearch represents the model behind the search form about `common\models\Persone`. | |
10 | + */ | |
11 | +class PersoneSearch extends Persone | |
12 | +{ | |
13 | + /** | |
14 | + * @inheritdoc | |
15 | + */ | |
16 | + public function rules() | |
17 | + { | |
18 | + return [ | |
19 | + [['id', 'image_id'], 'integer'], | |
20 | + ]; | |
21 | + } | |
22 | + | |
23 | + /** | |
24 | + * @inheritdoc | |
25 | + */ | |
26 | + public function scenarios() | |
27 | + { | |
28 | + // bypass scenarios() implementation in the parent class | |
29 | + return Model::scenarios(); | |
30 | + } | |
31 | + | |
32 | + public function behaviors() | |
33 | + { | |
34 | + return []; | |
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 = Persone::find(); | |
47 | + | |
48 | + // add conditions that should always apply here | |
49 | + | |
50 | + $dataProvider = new ActiveDataProvider([ | |
51 | + 'query' => $query, | |
52 | + ]); | |
53 | + | |
54 | + $this->load($params); | |
55 | + | |
56 | + if (!$this->validate()) { | |
57 | + // uncomment the following line if you do not want to return any records when validation fails | |
58 | + // $query->where('0=1'); | |
59 | + return $dataProvider; | |
60 | + } | |
61 | + | |
62 | + // grid filtering conditions | |
63 | + $query->andFilterWhere([ | |
64 | + 'id' => $this->id, | |
65 | + 'image_id' => $this->image_id, | |
66 | + ]); | |
67 | + | |
68 | + return $dataProvider; | |
69 | + } | |
70 | +} | ... | ... |
console/migrations/m170928_095137_add_column_to_image_table.php
100644 → 100755
console/migrations/m170928_141247_create_persone_table.php
0 → 100755
1 | +<?php | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
5 | + /** | |
6 | + * Handles the creation of table `persone`. | |
7 | + */ | |
8 | + class m170928_141247_create_persone_table extends Migration | |
9 | + { | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable( | |
16 | + 'persone', | |
17 | + [ | |
18 | + 'id' => $this->primaryKey(), | |
19 | + 'image_id' => $this->integer(), | |
20 | + ] | |
21 | + ); | |
22 | + } | |
23 | + | |
24 | + /** | |
25 | + * @inheritdoc | |
26 | + */ | |
27 | + public function down() | |
28 | + { | |
29 | + $this->dropTable('persone'); | |
30 | + } | |
31 | + } | ... | ... |
console/migrations/m170928_141633_create_persone_lang_table.php
0 → 100755
1 | +<?php | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
5 | + /** | |
6 | + * Handles the creation of table `persone_lang`. | |
7 | + */ | |
8 | + class m170928_141633_create_persone_lang_table extends Migration | |
9 | + { | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable( | |
16 | + 'persone_lang', | |
17 | + [ | |
18 | + 'persone_id' => $this->integer(), | |
19 | + 'language_id' => $this->integer(), | |
20 | + 'alias_id' => $this->integer(), | |
21 | + 'title' => $this->string(), | |
22 | + 'text' => $this->text(), | |
23 | + ] | |
24 | + ); | |
25 | + | |
26 | + $this->createIndex( | |
27 | + 'persone_ix', | |
28 | + 'persone_lang', | |
29 | + [ | |
30 | + 'persone_id', | |
31 | + 'language_id', | |
32 | + ], | |
33 | + true | |
34 | + ); | |
35 | + | |
36 | + $this->addForeignKey('persone_fk', 'persone_lang', 'persone_id', 'persone', 'id', 'CASCADE', 'CASCADE'); | |
37 | + | |
38 | + $this->addForeignKey('lang_fk', 'persone_lang', 'language_id', 'language', 'id', 'CASCADE', 'CASCADE'); | |
39 | + | |
40 | + } | |
41 | + | |
42 | + /** | |
43 | + * @inheritdoc | |
44 | + */ | |
45 | + public function down() | |
46 | + { | |
47 | + $this->dropForeignKey('lang_fk', 'persone_lang'); | |
48 | + | |
49 | + $this->dropForeignKey('persone_fk', 'persone_lang'); | |
50 | + | |
51 | + $this->dropTable('persone_lang'); | |
52 | + } | |
53 | + } | ... | ... |
console/migrations/m170929_080835_add_columns_to_doctor.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
5 | + class m170929_080835_add_columns_to_doctor extends Migration | |
6 | + { | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->addColumn('persone', 'instagram', $this->string()); | |
10 | + $this->addColumn('persone', 'facebook', $this->string()); | |
11 | + } | |
12 | + | |
13 | + public function safeDown() | |
14 | + { | |
15 | + $this->dropColumn('persone', 'instagram'); | |
16 | + $this->dropColumn('persone', 'facebook'); | |
17 | + } | |
18 | + } | |
19 | + | ... | ... |
console/migrations/m170929_083119_add_preview_column_to_persone_lang.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | + use yii\db\Migration; | |
4 | + | |
5 | + class m170929_083119_add_preview_column_to_persone_lang extends Migration | |
6 | + { | |
7 | + public function safeUp() | |
8 | + { | |
9 | + $this->addColumn('persone_lang', 'preview', $this->string()); | |
10 | + } | |
11 | + | |
12 | + public function safeDown() | |
13 | + { | |
14 | + $this->dropColumn('persone_lang', 'preview'); | |
15 | + } | |
16 | + } | ... | ... |
frontend/config/main.php
1 | +<?php | |
2 | + | |
3 | + namespace frontend\controllers; | |
4 | + | |
5 | + use common\models\Persone; | |
6 | + use yii\web\Controller; | |
7 | + use yii\web\NotFoundHttpException; | |
8 | + | |
9 | + /** | |
10 | + * Class PersoneController | |
11 | + * | |
12 | + * @package frontend\controllers | |
13 | + */ | |
14 | + class PersoneController extends Controller | |
15 | + { | |
16 | + /** | |
17 | + * @return string | |
18 | + */ | |
19 | + public function actionIndex() | |
20 | + { | |
21 | + $persones = Persone::find() | |
22 | + ->with('lang.alias') | |
23 | + ->all(); | |
24 | + | |
25 | + return $this->render( | |
26 | + 'index', | |
27 | + [ | |
28 | + 'persones' => $persones, | |
29 | + ] | |
30 | + ); | |
31 | + } | |
32 | + | |
33 | + /** | |
34 | + * @param int $id | |
35 | + * | |
36 | + * @return string | |
37 | + */ | |
38 | + public function actionView(int $id) | |
39 | + { | |
40 | + $model = $this->findModel($id); | |
41 | + | |
42 | + return $this->render( | |
43 | + 'view', | |
44 | + [ | |
45 | + 'model' => $model, | |
46 | + ] | |
47 | + ); | |
48 | + } | |
49 | + | |
50 | + /** | |
51 | + * @param $id | |
52 | + * | |
53 | + * @return array|null|\yii\db\ActiveRecord | |
54 | + * @throws \yii\web\NotFoundHttpException | |
55 | + */ | |
56 | + protected function findModel($id) | |
57 | + { | |
58 | + $model = Persone::find() | |
59 | + ->with('lang.alias') | |
60 | + ->where([ 'id' => $id ]) | |
61 | + ->one(); | |
62 | + | |
63 | + if (empty($model)) { | |
64 | + throw new NotFoundHttpException(); | |
65 | + } else { | |
66 | + return $model; | |
67 | + } | |
68 | + } | |
69 | + } | |
0 | 70 | \ No newline at end of file | ... | ... |
frontend/views/layouts/main.php
... | ... | @@ -323,6 +323,10 @@ _________________________________________________________ --> |
323 | 323 | 'label' => \Yii::t('app', 'Галерея'), |
324 | 324 | 'url' => [ 'site/gallery' ], |
325 | 325 | ]; |
326 | + $items[] = [ | |
327 | + 'label' => \Yii::t('app', 'Персонал'), | |
328 | + 'url' => [ 'persone/index' ], | |
329 | + ]; | |
326 | 330 | echo Nav::widget( |
327 | 331 | [ |
328 | 332 | 'items' => $items, | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use artbox\core\helpers\ImageHelper; | |
4 | + use common\models\Persone; | |
5 | + use yii\helpers\Url; | |
6 | + use yii\web\View; | |
7 | + | |
8 | + /** | |
9 | + * @var View $this | |
10 | + * @var Persone $model | |
11 | + */ | |
12 | + | |
13 | +?> | |
14 | + | |
15 | +<div class="col-md-3 col-sm-3"> | |
16 | + <div class="team-member" data-animate="fadeInUp"> | |
17 | + <div class="image"> | |
18 | + <a href="<?= Url::to( | |
19 | + [ | |
20 | + 'persone/view', | |
21 | + 'alias' => $model->lang->alias, | |
22 | + ] | |
23 | + ) ?>"> | |
24 | + <?= ImageHelper::set($model->image->getPath()) | |
25 | + ->cropResize(263, 263) | |
26 | + ->renderImage( | |
27 | + [ | |
28 | + 'class' => 'img-responsive img-circle', | |
29 | + 'alt' => $model->lang->title, | |
30 | + ] | |
31 | + ) ?> | |
32 | + </a> | |
33 | + </div> | |
34 | + <h3><a href="<?= Url::to( | |
35 | + [ | |
36 | + 'persone/view', | |
37 | + 'alias' => $model->lang->alias, | |
38 | + ] | |
39 | + ) ?>"><?= $model->lang->title ?></a></h3> | |
40 | + <!-- <p class="role">Founder</p>--> | |
41 | + <div class="social"> | |
42 | + <?php if (!empty($model->facebook)) { ?> | |
43 | + <a href="<?= $model->facebook ?>" class="external facebook" data-animate-hover="pulse" target="_blank"><i class="fa fa-facebook"></i></a> | |
44 | + <?php | |
45 | + } | |
46 | + if (!empty($model->instagram)) { | |
47 | + ?> | |
48 | + <a href="<?= $model->instagram ?>" class="external gplus" data-animate-hover="pulse" target="_blank"><i class="fa fa-instagram"></i></a> | |
49 | + <?php } ?> | |
50 | + </div> | |
51 | + <div class="text"> | |
52 | + <p><?= $model->lang->preview ?></p> | |
53 | + </div> | |
54 | + </div> | |
55 | + <!-- /.team-member --> | |
56 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use common\models\Persone; | |
4 | + use yii\web\View; | |
5 | + | |
6 | + /** | |
7 | + * @var View $this | |
8 | + * @var Persone[] $persones | |
9 | + */ | |
10 | + | |
11 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Персонал'); | |
12 | + | |
13 | +?> | |
14 | + | |
15 | +<div id="content"> | |
16 | + <div class="container"> | |
17 | + | |
18 | + <section> | |
19 | + | |
20 | + <div class="row"> | |
21 | + <div class="col-md-12"> | |
22 | + <div class="heading"> | |
23 | + <h2>Who is responsible for Universal?</h2> | |
24 | + </div> | |
25 | + | |
26 | + <p class="lead">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean | |
27 | + ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
28 | + </div> | |
29 | + </div> | |
30 | + | |
31 | + <div class="row"> | |
32 | + <?php | |
33 | + foreach ($persones as $persone) { | |
34 | + echo $this->render( | |
35 | + '_persone', | |
36 | + [ | |
37 | + 'model' => $persone, | |
38 | + ] | |
39 | + ); | |
40 | + } ?> | |
41 | + </div> | |
42 | + <!-- /.row --> | |
43 | + | |
44 | + </section> | |
45 | + | |
46 | + </div> | |
47 | + <!-- /.container --> | |
48 | +</div> | |
49 | +<!-- /#content --> | |
50 | + | |
0 | 51 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | + use artbox\core\helpers\ImageHelper; | |
4 | + use common\models\Persone; | |
5 | + use yii\web\View; | |
6 | + | |
7 | + /** | |
8 | + * @var View $this | |
9 | + * @var Persone $model | |
10 | + */ | |
11 | + | |
12 | + $this->params[ 'breadcrumbs' ][] = [ | |
13 | + 'url' => [ 'persone/index' ], | |
14 | + 'label' => \Yii::t('app', 'песонал'), | |
15 | + ]; | |
16 | + | |
17 | + $this->params[ 'breadcrumbs' ][] = $model->lang->title; | |
18 | + | |
19 | +?> | |
20 | + | |
21 | +<div id="content" class="team-member-detail"> | |
22 | + <div class="container"> | |
23 | + <section> | |
24 | + <div class="row"> | |
25 | + <div class="col-md-12"> | |
26 | + <div class="heading"> | |
27 | + <h2><?= $model->lang->title ?></h2> | |
28 | + </div> | |
29 | + <p class="lead">Do greatest at in learning steepest. Breakfast extremity suffering one who all otherwise suspected. He at no nothing forbade up moments. Wholly uneasy at missed be of pretty whence. John way sir high than law who week. Surrounded | |
30 | + prosperous introduced it if is up dispatched. Improved so strictly produced answered elegance is.</p> | |
31 | + </div> | |
32 | + </div> | |
33 | + | |
34 | + <div class="row"> | |
35 | + <div class="col-md-8"> | |
36 | + | |
37 | + <?= $model->lang->text ?> | |
38 | + | |
39 | + <div class="heading"> | |
40 | + <h3>Get in touch with Han</h3> | |
41 | + </div> | |
42 | + | |
43 | + <div class="social"> | |
44 | + <?php if (!empty($model->facebook)) { ?> | |
45 | + <a href="<?= $model->facebook ?>" class="external facebook" data-animate-hover="pulse" target="_blank"><i class="fa fa-facebook"></i></a> | |
46 | + <?php | |
47 | + } | |
48 | + if (!empty($model->instagram)) { | |
49 | + ?> | |
50 | + <a href="<?= $model->instagram ?>" class="external gplus" data-animate-hover="pulse" target="_blank"><i class="fa fa-instagram"></i></a> | |
51 | + <?php } ?> | |
52 | + </div> | |
53 | + </div> | |
54 | + | |
55 | + <div class="col-md-4"> | |
56 | + <?= ImageHelper::set($model->image->getPath()) | |
57 | + ->cropResize(360, 360) | |
58 | + ->renderImage( | |
59 | + [ | |
60 | + 'class' => 'img-responsive img-circle', | |
61 | + 'alt' => $model->lang->title, | |
62 | + ] | |
63 | + ) ?> | |
64 | + </div> | |
65 | + </div> | |
66 | + </section> | |
67 | + | |
68 | + </div> | |
69 | + <!-- /.container --> | |
70 | + | |
71 | + | |
72 | +</div> | |
73 | +<!-- /#content --> | |
74 | + | |
0 | 75 | \ No newline at end of file | ... | ... |