Commit e75f2ac94fa0428a486d793e8a05217d6587ccdd

Authored by Alexey Boroda
1 parent b85b6bc8

-Doctor pages frontend ready

backend/views/persone/_form_language.php
... ... @@ -28,6 +28,9 @@
28 28 )
29 29 ->textInput([ 'maxlength' => true ]); ?>
30 30  
  31 +<?= $form->field($model_lang, '[' . $language->id . ']preview')
  32 + ->textarea() ?>
  33 +
31 34 <?php
32 35 echo $form->field($model_lang, '[' . $language->id . ']text')
33 36 ->widget(
... ...
common/models/PersoneLang.php
1 1 <?php
2   -
3   -namespace common\models;
4   -
5   -use artbox\core\behaviors\SlugBehavior;
6   -use artbox\core\models\Language;
7   -use Yii;
8   -use yii\db\ActiveRecord;
9   -
10   -/**
11   - * This is the model class for table "persone_lang".
12   - *
13   - * @property integer $persone_id
14   - * @property integer $language_id
15   - * @property integer $alias_id
16   - * @property string $title
17   - * @property string $text
18   - *
19   - * @property Language $language
20   - * @property Persone $persone
21   - */
22   -class PersoneLang extends ActiveRecord
23   -{
24   - /**
25   - * @inheritdoc
26   - */
27   - public static function tableName()
28   - {
29   - return 'persone_lang';
30   - }
31 2  
32   - /**
33   - * @inheritdoc
34   - */
35   - public static function primaryKey()
36   - {
37   - return [
38   - 'persone_id',
39   - 'language_id',
40   - ];
41   - }
  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;
42 10  
43 11 /**
44   - * @inheritdoc
  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
45 23 */
46   - public function behaviors()
  24 + class PersoneLang extends ActiveRecord
47 25 {
48   - return [
49   - 'slug' => [
50   - 'class' => SlugBehavior::className(),
51   - 'action' => 'persone/view',
52   - 'params' => [
53   - 'id' => 'persone_id',
  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' => [],
54 58 ],
55   - 'fields' => [
  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',
56 75 ],
57   - ],
58   - ];
59   - }
  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 + }
60 147  
61   - /**
62   - * @inheritdoc
63   - */
64   - public function rules()
65   - {
66   - return [
67   - [['persone_id', 'language_id', 'alias_id'], 'integer'],
68   - [['text'], 'string'],
69   - [['title'], 'string', 'max' => 255],
70   - [['persone_id', 'language_id'], 'unique', 'targetAttribute' => ['persone_id', 'language_id'], 'message' => 'The combination of Persone ID and Language ID has already been taken.'],
71   - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'id']],
72   - [['persone_id'], 'exist', 'skipOnError' => true, 'targetClass' => Persone::className(), 'targetAttribute' => ['persone_id' => 'id']],
73   - ];
74   - }
75   -
76   - /**
77   - * @inheritdoc
78   - */
79   - public function attributeLabels()
80   - {
81   - return [
82   - 'persone_id' => Yii::t('app', 'Persone ID'),
83   - 'language_id' => Yii::t('app', 'Language ID'),
84   - 'alias_id' => Yii::t('app', 'Alias ID'),
85   - 'title' => Yii::t('app', 'Title'),
86   - 'text' => Yii::t('app', 'Text'),
87   - ];
88   - }
89   -
90   - /**
91   - * @return \yii\db\ActiveQuery
92   - */
93   - public function getLanguage()
94   - {
95   - return $this->hasOne(Language::className(), ['id' => 'language_id']);
96   - }
97   -
98   - /**
99   - * @return \yii\db\ActiveQuery
100   - */
101   - public function getPersone()
102   - {
103   - return $this->hasOne(Persone::className(), ['id' => 'persone_id']);
  148 + /**
  149 + * @return \yii\db\ActiveQuery
  150 + */
  151 + public function getAlias()
  152 + {
  153 + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]);
  154 + }
104 155 }
105   -}
... ...
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
... ... @@ -57,6 +57,7 @@
57 57 'blog/category',
58 58 'blog/tag',
59 59 'blog/article',
  60 + 'persone/view',
60 61 ],
61 62 'rules' => [
62 63 '\/robots.txt' => 'site/robots',
... ...
frontend/controllers/PersoneController.php 0 → 100644
  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 @@ _________________________________________________________ --&gt;
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,
... ...
frontend/views/persone/_persone.php 0 → 100644
  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>
... ...
frontend/views/persone/index.php 0 → 100644
  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
... ...
frontend/views/persone/view.php 0 → 100644
  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
... ...