Commit 0ca0742e0aed2d750bdfcfe484bd988f2c9efcfb

Authored by Виталий
2 parents 19aeb07c 3d0e6093

Merge remote-tracking branch 'origin/master'

common/behaviors/ShowImage.php
@@ -8,6 +8,10 @@ use yii\base\Behavior; @@ -8,6 +8,10 @@ use yii\base\Behavior;
8 class ShowImage extends Behavior 8 class ShowImage extends Behavior
9 { 9 {
10 function minImg($dir, $width, $height=null){ 10 function minImg($dir, $width, $height=null){
  11 + if(empty($dir)){
  12 + return $dir;
  13 + }
  14 +
11 if($width=='original'){ 15 if($width=='original'){
12 $preg = '/\/(.[^\/]*)$/'; 16 $preg = '/\/(.[^\/]*)$/';
13 preg_match('/\.(.[^.]*)$/', $dir, $type); 17 preg_match('/\.(.[^.]*)$/', $dir, $type);
@@ -23,4 +27,5 @@ class ShowImage extends Behavior @@ -23,4 +27,5 @@ class ShowImage extends Behavior
23 27
24 } 28 }
25 29
  30 +
26 } 31 }
27 \ No newline at end of file 32 \ No newline at end of file
common/models/Fields.php
@@ -104,4 +104,52 @@ class Fields extends \yii\db\ActiveRecord @@ -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 }
frontend/assets/FancyboxAsset.php 0 → 100644
  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
@@ -63,7 +63,6 @@ @@ -63,7 +63,6 @@
63 'portfolio-delete' => [ 'POST' ], 63 'portfolio-delete' => [ 'POST' ],
64 'projects-delete' => [ 'POST' ], 64 'projects-delete' => [ 'POST' ],
65 'blog-delete' => [ 'POST' ], 65 'blog-delete' => [ 'POST' ],
66 - 'gallery' => [ 'POST' ],  
67 ], 66 ],
68 ], 67 ],
69 ]; 68 ];
@@ -259,7 +258,7 @@ @@ -259,7 +258,7 @@
259 258
260 259
261 if(!empty(Yii::$app->request->post('Fields'))) { 260 if(!empty(Yii::$app->request->post('Fields'))) {
262 - 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');
263 } 262 }
264 263
265 return $this->render('gallery-video', [ 264 return $this->render('gallery-video', [
frontend/controllers/PerformerController.php
@@ -193,12 +193,15 @@ class PerformerController extends Controller @@ -193,12 +193,15 @@ class PerformerController extends Controller
193 'allModels' => $gallery, 193 'allModels' => $gallery,
194 ]); 194 ]);
195 195
  196 + $videos = Fields::getData($user->id,Gallery::className(),'youtube');
  197 +
196 $this->layout = 'gallery'; 198 $this->layout = 'gallery';
197 199
198 return $this->render('gallery',[ 200 return $this->render('gallery',[
199 'user' => $user, 201 'user' => $user,
200 'gallery' =>$gallery, 202 'gallery' =>$gallery,
201 - 'pagination' => $pagination 203 + 'pagination' => $pagination,
  204 + 'videos' => $videos
202 ]); 205 ]);
203 } 206 }
204 } 207 }
frontend/views/accounts/_gallery_form.php
@@ -36,8 +36,8 @@ @@ -36,8 +36,8 @@
36 <?= ImageUploader::widget([ 36 <?= ImageUploader::widget([
37 'model' => $gallery, 37 'model' => $gallery,
38 'field' => 'photo', 38 'field' => 'photo',
39 - 'width' => 148,  
40 - 'height' => 104, 39 + 'width' => 152,
  40 + 'height' => 108,
41 'multi' => true, 41 'multi' => true,
42 'gallery' => $gallery->photo, 42 'gallery' => $gallery->photo,
43 'name' => 'Загрузить фото галереи', 43 'name' => 'Загрузить фото галереи',
frontend/views/accounts/gallery.php
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 <?= Html::a(Yii::t('app', 'Добавить'), [ 'gallery-create' ], [ 'class' => 'btn btn-success' ]) ?> 16 <?= Html::a(Yii::t('app', 'Добавить'), [ 'gallery-create' ], [ 'class' => 'btn btn-success' ]) ?>
17 </p> 17 </p>
18 <?= GridView::widget([ 18 <?= GridView::widget([
  19 + 'options'=>['class'=>'test'],
19 'dataProvider' => $dataProvider, 20 'dataProvider' => $dataProvider,
20 'filterModel' => $searchModel, 21 'filterModel' => $searchModel,
21 'columns' => [ 22 'columns' => [
frontend/views/performer/_gallery_list_view.php
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 11
12 </div> 12 </div>
13 <div class="gallery-box-big"> 13 <div class="gallery-box-big">
14 - <?php foreach(explode(',', $model->photo ) as $image):?> 14 + <?php foreach(explode(',', $model->photo ) as $image): ?>
15 <span data-link="<?= $model->minImg($image, 'original'); ?>"></span> 15 <span data-link="<?= $model->minImg($image, 'original'); ?>"></span>
16 <?php endforeach; ?> 16 <?php endforeach; ?>
17 </div> 17 </div>
frontend/views/performer/gallery.php
@@ -13,29 +13,14 @@ $this-&gt;title = &#39;My Yii Application&#39;; @@ -13,29 +13,14 @@ $this-&gt;title = &#39;My Yii Application&#39;;
13 <div class="slider-video-wr"> 13 <div class="slider-video-wr">
14 <div id="demo5" class="scroll-img video-slider"> 14 <div id="demo5" class="scroll-img video-slider">
15 <ul> 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 </ul> 24 </ul>
40 </div> 25 </div>
41 <div id="demo5-btn" class="text-center"> 26 <div id="demo5-btn" class="text-center">
@@ -47,7 +32,6 @@ $this-&gt;title = &#39;My Yii Application&#39;; @@ -47,7 +32,6 @@ $this-&gt;title = &#39;My Yii Application&#39;;
47 32
48 </div> 33 </div>
49 <div class="gallery-performer-wrapper style"> 34 <div class="gallery-performer-wrapper style">
50 - <div class="gallery-title">Фото: 130</div>  
51 <div class="gallery-performer-margin"> 35 <div class="gallery-performer-margin">
52 <?= 36 <?=
53 ListView::widget( [ 37 ListView::widget( [