Commit 3d0e60939a73405b4f6f175e5aef287a8c214eef
1 parent
1a7bb1e7
15.02.16
Showing
6 changed files
with
99 additions
and
24 deletions
Show diff stats
common/models/Fields.php
... | ... | @@ -104,4 +104,52 @@ class Fields extends \yii\db\ActiveRecord |
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | + | |
108 | + | |
109 | + /** | |
110 | + * @param $post - array with field data | |
111 | + * @param $table_id - row id in model table | |
112 | + * @param $table_name - madel table name | |
113 | + * @param $language - language id | |
114 | + */ | |
115 | + | |
116 | + public static function saveFieldVideoData($post,$table_id,$table_name, $language){ | |
117 | + | |
118 | + self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]); | |
119 | + | |
120 | + if($post){ | |
121 | + | |
122 | + | |
123 | + foreach($post as $k => $field){ | |
124 | + | |
125 | + | |
126 | + | |
127 | + foreach($field as $parent_key => $row){ | |
128 | + | |
129 | + foreach($row as $key => $value){ | |
130 | + | |
131 | + preg_match('/src=\"(.[^"]*)\"/', $value[array_keys($value)[0]], $video_url); | |
132 | + | |
133 | + if(isset($video_url[1]) && !empty($video_url[1])){ | |
134 | + | |
135 | + $field_model = new Fields(); | |
136 | + $field_model->field_name = array_keys($value)[0]; | |
137 | + $field_model->value = $video_url[1].'?showinfo=0&autoplay=0'; | |
138 | + $field_model->table_name = $table_name; | |
139 | + $field_model->table_id = $table_id; | |
140 | + $field_model->field_type = $k; | |
141 | + $field_model->language = 'ru'; | |
142 | + $field_model->parent_key = $parent_key; | |
143 | + $field_model->key = $key; | |
144 | + $field_model->save(); | |
145 | + | |
146 | + } | |
147 | + | |
148 | + | |
149 | + } | |
150 | + | |
151 | + } | |
152 | + } | |
153 | + } | |
154 | + } | |
107 | 155 | } | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * @link http://www.yiiframework.com/ | |
4 | + * @copyright Copyright (c) 2008 Yii Software LLC | |
5 | + * @license http://www.yiiframework.com/license/ | |
6 | + */ | |
7 | + | |
8 | + | |
9 | +namespace frontend\assets; | |
10 | + | |
11 | +use yii\web\AssetBundle; | |
12 | + | |
13 | +/** | |
14 | + * Asset bundle for the Twitter bootstrap javascript files. | |
15 | + * | |
16 | + * @author Qiang Xue <qiang.xue@gmail.com> | |
17 | + * @since 2.0 | |
18 | + */ | |
19 | +class FancyboxAsset extends AssetBundle | |
20 | +{ | |
21 | + public $sourcePath = '@bower/fancybox/'; | |
22 | + | |
23 | + public $css = [ | |
24 | + 'source/jquery.fancybox.css', | |
25 | + 'source/helpers/jquery.fancybox-buttons.css', | |
26 | + 'source/helpers/jquery.fancybox-thumbs.css' | |
27 | + | |
28 | + ]; | |
29 | + | |
30 | + public $js = [ | |
31 | + 'lib/jquery.mousewheel-3.0.6.pack.js', | |
32 | + 'source/jquery.fancybox.pack.js', | |
33 | + 'source/helpers/jquery.fancybox-buttons.js', | |
34 | + 'source/helpers/jquery.fancybox-media.js', | |
35 | + 'source/helpers/jquery.fancybox-thumbs.js' | |
36 | + | |
37 | + | |
38 | + ]; | |
39 | +} | ... | ... |
frontend/controllers/AccountsController.php
... | ... | @@ -258,7 +258,7 @@ |
258 | 258 | |
259 | 259 | |
260 | 260 | if(!empty(Yii::$app->request->post('Fields'))) { |
261 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru'); | |
261 | + Fields::saveFieldVideoData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru'); | |
262 | 262 | } |
263 | 263 | |
264 | 264 | return $this->render('gallery-video', [ | ... | ... |
frontend/controllers/PerformerController.php
... | ... | @@ -193,12 +193,15 @@ class PerformerController extends Controller |
193 | 193 | 'allModels' => $gallery, |
194 | 194 | ]); |
195 | 195 | |
196 | + $videos = Fields::getData($user->id,Gallery::className(),'youtube'); | |
197 | + | |
196 | 198 | $this->layout = 'gallery'; |
197 | 199 | |
198 | 200 | return $this->render('gallery',[ |
199 | 201 | 'user' => $user, |
200 | 202 | 'gallery' =>$gallery, |
201 | - 'pagination' => $pagination | |
203 | + 'pagination' => $pagination, | |
204 | + 'videos' => $videos | |
202 | 205 | ]); |
203 | 206 | } |
204 | 207 | } | ... | ... |
frontend/views/accounts/gallery.php
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | <?= Html::a(Yii::t('app', 'Добавить'), [ 'gallery-create' ], [ 'class' => 'btn btn-success' ]) ?> |
17 | 17 | </p> |
18 | 18 | <?= GridView::widget([ |
19 | + 'options'=>['class'=>'test'], | |
19 | 20 | 'dataProvider' => $dataProvider, |
20 | 21 | 'filterModel' => $searchModel, |
21 | 22 | 'columns' => [ | ... | ... |
frontend/views/performer/gallery.php
... | ... | @@ -13,29 +13,14 @@ $this->title = 'My Yii Application'; |
13 | 13 | <div class="slider-video-wr"> |
14 | 14 | <div id="demo5" class="scroll-img video-slider"> |
15 | 15 | <ul> |
16 | - <li> | |
17 | - <div class="iframe-video"><iframe width="560" height="320" src="https://www.youtube.com/embed/0wAgwxcO1HY?showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div> | |
16 | + <?php foreach($videos as $video):?> | |
17 | + <li> | |
18 | + <div class="iframe-video"><iframe width="560" height="320" src="<?= $video['youtube'] ?>" frameborder="0" allowfullscreen></iframe></div> | |
18 | 19 | |
19 | - <a href="#"></a><span></span> | |
20 | - </li> | |
21 | - <li> | |
22 | - <div class="iframe-video"><iframe width="100%" height="100%" src="https://www.youtube.com/embed/0wAgwxcO1HY" frameborder="0" allowfullscreen></iframe></div> | |
23 | - <a href="#"></a><span></span> | |
24 | - </li> | |
20 | + <a href="#"></a><span></span> | |
21 | + </li> | |
22 | + <?php endforeach; ?> | |
25 | 23 | |
26 | - <li> | |
27 | - <div class="iframe-video"><iframe width="560" height="320" src="https://www.youtube.com/embed/0wAgwxcO1HY?showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div> | |
28 | - <a href="#"></a><span></span> | |
29 | - </li> | |
30 | - <li> | |
31 | - <div class="iframe-video"><iframe width="100%" height="100%" src="https://www.youtube.com/embed/0wAgwxcO1HY" frameborder="0" allowfullscreen></iframe></div> | |
32 | - <a href="#"></a><span></span> | |
33 | - </li> | |
34 | - | |
35 | - <li> | |
36 | - <div class="iframe-video"><iframe width="560" height="320" src="https://www.youtube.com/embed/0wAgwxcO1HY?showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div> | |
37 | - <a href="#"></a><span></span> | |
38 | - </li> | |
39 | 24 | </ul> |
40 | 25 | </div> |
41 | 26 | <div id="demo5-btn" class="text-center"> |
... | ... | @@ -47,7 +32,6 @@ $this->title = 'My Yii Application'; |
47 | 32 | |
48 | 33 | </div> |
49 | 34 | <div class="gallery-performer-wrapper style"> |
50 | - <div class="gallery-title">Фото: 130</div> | |
51 | 35 | <div class="gallery-performer-margin"> |
52 | 36 | <?= |
53 | 37 | ListView::widget( [ | ... | ... |