Commit 147ec2fb7c1be60fa8d2988e328112471b0e44bb
1 parent
18b65d7d
add speakers part
Showing
12 changed files
with
253 additions
and
101 deletions
Show diff stats
backend/controllers/SpeakerController.php
... | ... | @@ -75,6 +75,10 @@ |
75 | 75 | 'name' => 'body', |
76 | 76 | 'type' => Form::WYSIWYG, |
77 | 77 | ], |
78 | + [ | |
79 | + 'name' => 'text1', | |
80 | + 'type' => Form::WYSIWYG, | |
81 | + ], | |
78 | 82 | ], |
79 | 83 | 'fields' => [ |
80 | 84 | [ |
... | ... | @@ -136,6 +140,10 @@ |
136 | 140 | 'name' => 'position', |
137 | 141 | 'type' => Form::TEXTAREA, |
138 | 142 | ], |
143 | + [ | |
144 | + 'name' => 'text1', | |
145 | + 'type' => Form::WYSIWYG, | |
146 | + ], | |
139 | 147 | [ |
140 | 148 | 'name' => 'organization', |
141 | 149 | 'type' => Form::TEXTAREA, | ... | ... |
common/models/speaker/Speaker.php
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | * @property integer $sort |
18 | 18 | * @property boolean $status |
19 | 19 | * @property Image $image |
20 | + * @property string $text1 | |
20 | 21 | * @method ActiveQuery hasDefaultVariationRelation(); |
21 | 22 | */ |
22 | 23 | class Speaker extends ActiveRecord |
... | ... | @@ -31,6 +32,7 @@ |
31 | 32 | ], |
32 | 33 | 'integer', |
33 | 34 | ], |
35 | + | |
34 | 36 | [ |
35 | 37 | [ |
36 | 38 | 'status', |
... | ... | @@ -107,9 +109,10 @@ |
107 | 109 | public function attributeLabels() |
108 | 110 | { |
109 | 111 | return [ |
110 | - 'sort' => \Yii::t('core', 'Sort'), | |
111 | - 'status' => \Yii::t('core', 'Status'), | |
112 | - 'image_id' => \Yii::t('core', 'Image'), | |
112 | + 'sort' => \Yii::t('core', 'Sort'), | |
113 | + 'status' => \Yii::t('core', 'Status'), | |
114 | + 'image_id' => \Yii::t('core', 'Image'), | |
115 | + | |
113 | 116 | ]; |
114 | 117 | } |
115 | 118 | } |
116 | 119 | \ No newline at end of file | ... | ... |
common/models/speaker/SpeakerLang.php
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | 'name', |
33 | 33 | 'organization', |
34 | 34 | 'position', |
35 | + 'text1' | |
35 | 36 | ], |
36 | 37 | 'string', |
37 | 38 | ], |
... | ... | @@ -56,6 +57,9 @@ |
56 | 57 | 'name' => \Yii::t('app', 'Speaker Name'), |
57 | 58 | 'organization' => \Yii::t('app', 'Organization'), |
58 | 59 | 'position' => \Yii::t('app', 'Position'), |
60 | + 'text1' => \Yii::t('app','text1'), | |
61 | + | |
62 | + | |
59 | 63 | ]; |
60 | 64 | } |
61 | 65 | } |
62 | 66 | \ No newline at end of file | ... | ... |
console/migrations/m181022_120253_speaker_lang_add_column_text1.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Class m181022_120253_speaker_lang_add_column_text1 | |
7 | + */ | |
8 | +class m181022_120253_speaker_lang_add_column_text1 extends Migration | |
9 | +{ | |
10 | + public function up() | |
11 | + { | |
12 | + $this->addColumn( | |
13 | + 'speaker_lang', | |
14 | + 'text1', | |
15 | + $this->text() | |
16 | + ); | |
17 | + | |
18 | + } | |
19 | + | |
20 | + public function down() | |
21 | + { | |
22 | + | |
23 | + $this->dropColumn('speaker_lang','text1'); | |
24 | + | |
25 | + | |
26 | + } | |
27 | + | |
28 | +} | ... | ... |
frontend/components/UrlManager.php
... | ... | @@ -79,7 +79,9 @@ |
79 | 79 | ] |
80 | 80 | ) |
81 | 81 | ->one(); |
82 | + | |
82 | 83 | $links[ $this->languages->getCurrent()->id ] = $request->url; |
84 | + | |
83 | 85 | if ($alias !== NULL) { |
84 | 86 | |
85 | 87 | $other = Alias::find() |
... | ... | @@ -97,10 +99,12 @@ |
97 | 99 | /** |
98 | 100 | * @var Alias $item |
99 | 101 | */ |
102 | + | |
100 | 103 | if ($item->language->default) { |
101 | 104 | if ($this->hideDefaultLanguagePrefix) { |
102 | 105 | $links[ $item->language->id ] = '/' . $item->value; |
103 | 106 | } else { |
107 | + | |
104 | 108 | $links[ $item->language->id ] = '/' . $item->language->url . '/' . $item->value; |
105 | 109 | } |
106 | 110 | } |
... | ... | @@ -126,15 +130,21 @@ |
126 | 130 | $params, |
127 | 131 | ]; |
128 | 132 | } |
133 | + $langs = ['/ru/','/ua/','/fr/','/en/']; | |
129 | 134 | foreach ($this->languages->getActive() as $key => $lang) { |
130 | - if ($this->hideDefaultLanguagePrefix and $lang->default) { | |
131 | - $links[ $lang->id ] = '/' . $request->pathInfo; | |
135 | + $url12 = str_replace($langs,'',$request->url); | |
136 | + if ($this->hideDefaultLanguagePrefix and $lang->default) { | |
137 | + | |
138 | + $links[ $lang->id ] = '/' . $url12; | |
132 | 139 | } else { |
133 | - $links[ $lang->id ] = '/' . $key . '/' . $request->pathInfo; | |
140 | + $links[ $lang->id ] = '/' . $key . '/' . $url12; | |
134 | 141 | } |
135 | 142 | |
136 | 143 | } |
137 | 144 | $langLink = \Yii::$app->get('langLinks'); |
145 | + $links = array_map(function ($links){ | |
146 | + return str_replace('//','/',$links); | |
147 | + },$links); | |
138 | 148 | $langLink->setLinks($links); |
139 | 149 | return parent::parseRequest($request); |
140 | 150 | } | ... | ... |
frontend/controllers/SiteController.php
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | use yii\swiftmailer\Mailer; |
13 | 13 | use yii\web\BadRequestHttpException; |
14 | 14 | use yii\web\Controller; |
15 | + use yii\web\NotFoundHttpException; | |
15 | 16 | use yii\web\Response; |
16 | 17 | use yii\web\UploadedFile; |
17 | 18 | |
... | ... | @@ -101,8 +102,33 @@ |
101 | 102 | |
102 | 103 | |
103 | 104 | |
104 | - public function actionSpeakers(){ | |
105 | - return $this->render('speakers'); | |
105 | + public function actionSpeakers($id){ | |
106 | + | |
107 | + | |
108 | + $currentSpeaker = Speaker::findOne($id); | |
109 | + if($currentSpeaker == null){ | |
110 | + throw new NotFoundHttpException(); | |
111 | + } | |
112 | + $speakers = Speaker::find() | |
113 | + ->with( | |
114 | + [ | |
115 | + 'language', | |
116 | + 'image', | |
117 | + ] | |
118 | + ) | |
119 | + ->where([ 'status' => true ]) | |
120 | + ->orderBy('sort') | |
121 | + ->all(); | |
122 | + $partners = Logo::find() | |
123 | + ->all(); | |
124 | + return $this->render( | |
125 | + 'speakers', | |
126 | + [ | |
127 | + 'speakers' => $speakers, | |
128 | + 'partners' => $partners, | |
129 | + 'currentSpeaker' => $currentSpeaker, | |
130 | + ] | |
131 | + ); | |
106 | 132 | } |
107 | 133 | |
108 | 134 | ... | ... |
frontend/views/site/index.php
... | ... | @@ -7,6 +7,23 @@ |
7 | 7 | use artbox\core\helpers\ImageHelper; |
8 | 8 | use artbox\core\helpers\Url; |
9 | 9 | use frontend\assets\SliderAsset; |
10 | + use frontend\widgets\SpeakersWidget; | |
11 | + | |
12 | + | |
13 | + | |
14 | + | |
15 | + | |
16 | + | |
17 | + | |
18 | + | |
19 | + | |
20 | + | |
21 | + | |
22 | + | |
23 | + | |
24 | + | |
25 | + | |
26 | + | |
10 | 27 | $currentLang=\artbox\core\models\Language::getCurrent()->url; |
11 | 28 | SliderAsset::register($this); |
12 | 29 | ?> |
... | ... | @@ -53,45 +70,11 @@ |
53 | 70 | </div> |
54 | 71 | </div> |
55 | 72 | </section> |
56 | -<?php if (!empty($speakers)){?> | |
57 | -<section class="section-speakers"> | |
58 | - <div class="container"> | |
59 | - <div class="row"> | |
60 | - <div class="col-xs-12"><div class="speakers-title"> | |
61 | - <?=\Yii::t('app', 'Speakers')?></div></div> | |
62 | - </div> | |
63 | - | |
64 | - <div class="row"> | |
65 | - <div class="col-xs-12 col-sm-12"> | |
66 | - <div class="slider-home sliders row owl-carousel"> | |
67 | - <?php foreach ($speakers as $speaker){?> | |
68 | - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col"> | |
69 | - <div class="items-home"> | |
70 | - <div class="items-home-img"> | |
71 | - <!--263x210--> | |
72 | - <span><img src="<?=ImageHelper::set($speaker->image->getPath()) | |
73 | - ->cropResize(263, 210) | |
74 | - ->render()?>" alt=""> | |
75 | - </span> | |
76 | - </div> | |
77 | - <div class="items-home-name"><?=$speaker->language->name?></div> | |
78 | - <div class="items-home-job"><?=$speaker->language->position?></div> | |
79 | - <div class="items-home-country-wr"> | |
80 | - <div class="items-home-country"> | |
81 | - <span> | |
82 | - <?=$speaker->language->organization?> | |
83 | - </span> | |
84 | - </div> | |
85 | - </div> | |
86 | - </div> | |
87 | - </div> | |
88 | - <?php } ?> | |
89 | - </div> | |
90 | - </div> | |
91 | - </div> | |
92 | - </div> | |
93 | -</section> | |
94 | -<?php } ?> | |
73 | +<?php if (!empty($speakers)){ | |
74 | + echo SpeakersWidget::widget([ | |
75 | + 'speakers' => $speakers, | |
76 | + ]); | |
77 | +} ?> | |
95 | 78 | |
96 | 79 | |
97 | 80 | |
... | ... | @@ -185,13 +168,13 @@ |
185 | 168 | </div> |
186 | 169 | </div> |
187 | 170 | |
188 | - <div class="partners-wr col-xs-3 col-sm-2"> | |
171 | + <!-- <div class="partners-wr col-xs-3 col-sm-2"> | |
189 | 172 | <div> |
190 | 173 | <span> |
191 | 174 | <img src="/images/partners/img-34.jpg" alt=""> |
192 | 175 | </span> |
193 | 176 | </div> |
194 | - </div> | |
177 | + </div>--> | |
195 | 178 | |
196 | 179 | <div class="partners-wr col-xs-3 col-sm-2"> |
197 | 180 | <div> | ... | ... |
frontend/views/site/speakers.php
1 | -<section class="section-breadcrumb"> | |
1 | +<?php | |
2 | +/** | |
3 | + * @var $this yii\web\View | |
4 | + * @var $speakers \common\models\speaker\Speaker[] | |
5 | + * @var $parthners \common\models\Logo[] | |
6 | + * @var $currentSpeaker \common\models\speaker\Speaker | |
7 | + */ | |
8 | + | |
9 | + | |
10 | + | |
11 | + | |
12 | +use artbox\core\helpers\ImageHelper; | |
13 | +use artbox\core\helpers\Url; | |
14 | +use frontend\assets\SliderAsset; | |
15 | +use frontend\widgets\SpeakersWidget; | |
16 | + | |
17 | + | |
18 | + | |
19 | +$this->params[ 'breadcrumbs' ][] = \Yii::t('app','Speakers'); | |
20 | +$this->params[ 'breadcrumbs' ][] = $currentSpeaker->language->name; | |
21 | + | |
22 | + | |
23 | + | |
24 | + | |
25 | +?> | |
26 | + | |
27 | + | |
28 | + | |
29 | +<!--<section class="section-breadcrumb"> | |
2 | 30 | <div class="container"> |
3 | 31 | <div class="row"> |
4 | 32 | <div class="col-xs-12 col-sm-12 breadcrumb-wrapp"> |
5 | 33 | <ul class="breadcrumb"> |
6 | 34 | <li><a href="/">Главная</a></li> |
7 | 35 | <li><a href="/">Спікери</a></li> |
8 | - <li class="active">Наталія Бойко</li> | |
36 | + <li class="active"><?/*=$currentSpeaker->language->name*/?></li> | |
9 | 37 | </ul> |
10 | 38 | </div> |
11 | 39 | </div> |
12 | 40 | </div> |
13 | -</section> | |
41 | +</section>--> | |
14 | 42 | |
15 | 43 | <section class="section-speakers-page"> |
16 | 44 | <div class="container"> |
17 | 45 | <div class="row"> |
18 | 46 | <div class="col-xs-12 col-sm-4 col-md-3 speakers-page-img"> |
19 | - <img src="/images/speakers/speakers-3-page.jpg" alt=""> | |
47 | + <img src="<?=ImageHelper::set($currentSpeaker->image->getPath()) | |
48 | + ->render()?>" alt=""> | |
20 | 49 | </div> |
21 | 50 | <div class="col-xs-12 col-sm-8 col-md-9"> |
22 | - <div class="speakers-page-name">Наталія Бойко</div> | |
23 | - <div class="speakers-page-specialty">Заступник міністра енергетики і вугільної промисловості</div> | |
24 | - <div class="speakers-page-country">Україна</div> | |
51 | + <div class="speakers-page-name"><?=$currentSpeaker->language->name?></div> | |
52 | + <div class="speakers-page-specialty"><?=$currentSpeaker->language->position?></div> | |
53 | + <div class="speakers-page-country"><?=$currentSpeaker->language->organization?></div> | |
25 | 54 | <div class="speakers-page-txt"> |
26 | - <p>Кабінет Міністрів України утворив Організаційний комітет з підготовки та проведення в Україні восени 2018 року 9-го Міжнародного форуму з енергетики для сталого розвитку. Його очолив Віце-прем’єр-міністр України Володимир Кістіон. Відповідне рішення прийнято 13 грудня на засіданні Уряду.</p> | |
27 | - <p>Форум проходитиме під егідою Європейської Економічної Комісії Організації Об’єднаних Націй.</p> | |
28 | - <p>Міжнародні форуми з енергетики в інтересах сталого розвитку є щорічними заходами, що організовуються п’ятьма Регіональними комісіями ООН з 2010 року. Такі заходи є важливим елементом для поліпшення розуміння сталої енергетики та дієвою платформою для широкого політичного діалогу з метою досягнення Цілей сталого розвитку ООН у майбутньому.</p> | |
29 | - <p>Кабінет Міністрів України утворив Організаційний комітет з підготовки та проведення в Україні восени 2018 року 9-го Міжнародного форуму з енергетики для сталого розвитку. Його очолив Віце-прем’єр-міністр України Володимир Кістіон. Відповідне рішення прийнято 13 грудня на засіданні Уряду.</p> | |
30 | - <p>Форум проходитиме під егідою Європейської Економічної Комісії Організації Об’єднаних Націй.</p> | |
31 | - <p>Міжнародні форуми з енергетики в інтересах сталого розвитку є щорічними заходами, що організовуються п’ятьма Регіональними комісіями ООН з 2010 року. Такі заходи є важливим елементом для поліпшення розуміння сталої енергетики та дієвою платформою для широкого політичного діалогу з метою досягнення Цілей сталого розвитку ООН у майбутньому.</p> | |
55 | + <?=$currentSpeaker->language->text1?> | |
32 | 56 | </div> |
33 | 57 | </div> |
34 | 58 | </div> |
... | ... | @@ -36,45 +60,15 @@ |
36 | 60 | </section> |
37 | 61 | |
38 | 62 | |
39 | -<?php if (!empty($speakers)){?> | |
40 | - <section class="section-speakers"> | |
41 | - <div class="container"> | |
42 | - <div class="row"> | |
43 | - <div class="col-xs-12"><div class="speakers-title"> | |
44 | - <?=\Yii::t('app', 'Speakers')?></div></div> | |
45 | - </div> | |
46 | 63 | |
47 | - <div class="row"> | |
48 | - <div class="col-xs-12 col-sm-12"> | |
49 | - <div class="slider-home sliders row owl-carousel"> | |
50 | - <?php foreach ($speakers as $speaker){?> | |
51 | - <div class="col-xs-12 col-sm-4 col-md-3 items-home-col"> | |
52 | - <div class="items-home"> | |
53 | - <div class="items-home-img"> | |
54 | - <!--263x210--> | |
55 | - <span><img src="<?=ImageHelper::set($speaker->image->getPath()) | |
56 | - ->cropResize(263, 210) | |
57 | - ->render()?>" alt=""> | |
58 | - </span> | |
59 | - </div> | |
60 | - <div class="items-home-name"><?=$speaker->language->name?></div> | |
61 | - <div class="items-home-job"><?=$speaker->language->position?></div> | |
62 | - <div class="items-home-country-wr"> | |
63 | - <div class="items-home-country"> | |
64 | - <span> | |
65 | - <?=$speaker->language->organization?> | |
66 | - </span> | |
67 | - </div> | |
68 | - </div> | |
69 | - </div> | |
70 | - </div> | |
71 | - <?php } ?> | |
72 | - </div> | |
73 | - </div> | |
74 | - </div> | |
75 | - </div> | |
76 | - </section> | |
77 | -<?php } ?> | |
64 | +<?php if (!empty($speakers)){ | |
65 | + echo SpeakersWidget::widget([ | |
66 | + 'speakers' => $speakers | |
67 | + ]); | |
68 | +} ?> | |
69 | + | |
70 | + | |
71 | + | |
78 | 72 | <section class="section-partners"> |
79 | 73 | <div class="container"> |
80 | 74 | <div class="row" style="margin-top: -20px;"> | ... | ... |
frontend/widgets/LangLinks.php
... | ... | @@ -31,15 +31,18 @@ |
31 | 31 | { |
32 | 32 | $items = []; |
33 | 33 | $langs = Language::getActive(); |
34 | - | |
34 | + | |
35 | 35 | foreach ($langs as $key => $item) { |
36 | + | |
36 | 37 | if ($item->id == Language::getCurrent()->id) { |
37 | 38 | $items[ $key ] = Html::tag('li', Html::a(($this->mobile ? $item->short : $item->name), '', ['class' => 'active'])); |
38 | 39 | } else { |
40 | + | |
39 | 41 | $items[ $key ] = Html::tag('li', Html::a(($this->mobile ? $item->short : $item->name), $this->links[ $key ])); |
40 | 42 | } |
41 | 43 | |
42 | 44 | } |
45 | + | |
43 | 46 | if ($this->mobile){ |
44 | 47 | return $this->render('links_mobile', [ 'links' => $items ]); |
45 | 48 | } | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * Виджет, который выводит grid карточки спикеров | |
4 | + */ | |
5 | +namespace frontend\widgets; | |
6 | + | |
7 | + | |
8 | +use yii\base\Widget; | |
9 | + | |
10 | + | |
11 | + | |
12 | + | |
13 | +class SpeakersWidget extends Widget{ | |
14 | + | |
15 | + public $speakers; | |
16 | + | |
17 | + | |
18 | + public function init() | |
19 | + { | |
20 | + parent::init(); | |
21 | + } | |
22 | + | |
23 | + | |
24 | + public function run() | |
25 | + { | |
26 | + | |
27 | + return $this->render('_speakers',[ | |
28 | + 'speakerList' =>$this->speakers | |
29 | + ]); | |
30 | + } | |
31 | + | |
32 | + | |
33 | +} | |
34 | + | |
35 | + | |
36 | + | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * @var $speakerList \common\models\speaker\Speaker[] | |
4 | + * | |
5 | + */ | |
6 | +use artbox\core\helpers\ImageHelper; | |
7 | +use artbox\core\helpers\Url; | |
8 | +?> | |
9 | + | |
10 | + | |
11 | + <section class="section-speakers"> | |
12 | + <div class="container"> | |
13 | + <div class="row"> | |
14 | + <div class="col-xs-12"><div class="speakers-title"> | |
15 | + <?=\Yii::t('app', 'Speakers')?></div></div> | |
16 | +</div> | |
17 | + | |
18 | +<div class="row"> | |
19 | + <div class="col-xs-12 col-sm-12"> | |
20 | + <div class="slider-home sliders row owl-carousel"> | |
21 | + | |
22 | + <?php foreach ($speakerList as $speaker){?> | |
23 | + <div class="col-xs-12 col-sm-4 col-md-3 items-home-col"> | |
24 | + <div class="items-home"> | |
25 | + <div class="items-home-img"> | |
26 | + <!--263x210--> | |
27 | + <span><img src="<?=ImageHelper::set($speaker->image->getPath()) | |
28 | + ->cropResize(263, 210) | |
29 | + ->render()?>" alt=""> | |
30 | + </span> | |
31 | + </div> | |
32 | + <div class="items-home-name"> | |
33 | + <?=\yii\helpers\Html::a($speaker->language->name, | |
34 | + Url::to(['site/speakers', | |
35 | + 'id'=>$speaker->id | |
36 | + ]) | |
37 | + )?> | |
38 | + </div> | |
39 | + <div class="items-home-job"><?=$speaker->language->position?></div> | |
40 | + <div class="items-home-country-wr"> | |
41 | + <div class="items-home-country"> | |
42 | + <span> | |
43 | + <?=$speaker->language->organization?> | |
44 | + </span> | |
45 | + </div> | |
46 | + </div> | |
47 | + </div> | |
48 | + </div> | |
49 | + <?php } ?> | |
50 | + </div> | |
51 | + </div> | |
52 | +</div> | |
53 | +</div> | |
54 | +</section> | |
0 | 55 | \ No newline at end of file | ... | ... |