Blame view

protected/views/sport/_mediaFeed.php 3.48 KB
a1684257   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  <?php
  /**
   * @var SportController $this
   */
  ?>
  <?php if ($this->sportRoot->video_stream): ?>
  <p class="section-title"><?php echo Yii::t('site', 'Видеолента');?></p>
  
  <div class="photofeed-box">
      <?php
      $photo = null;
      while (!$photo) {
          /** @var $album Album */
          $album = Album::model()->with('i18n')->find(array('order' => 'rand()'));
          /** @var $photo GalleryPhoto */
          $photo = GalleryPhoto::model()->with('i18n')->find(
              array(
                  'condition' => 'gallery_id = :gal_id',
                  'order' => 'rand()',
                  'params' => array(
                      ':gal_id' => $album->video_gallery_id
                  )
              ));
      }
      $url = $photo->i18n->link;
      $matches = array();
      preg_match('#(?<=(?:v|i)=)[a-zA-Z0-9-]+(?=&)|(?<=(?:v|i)\/)[^&\n]+|(?<=embed\/)[^"&\n]+|(?<=(?:v|i)=)[^&\n]+|(?<=youtu.be\/)[^&\n]+#', $url, $matches);
      if (count($matches) > 0) {
          $videoId = $matches[0];
          $url = 'http://www.youtube.com/embed/' . $videoId . '?feature=player_detailpage';
  
      }
      ?>
      <div class="photofeed-image">
          <?php echo CHtml::link(CHtml::image($photo->getUrl('small'), $photo->i18n->name), $url,array('rel'=>'video-feed','class'=>'iframe'))?>
          <div class="overlay"><a class="play-btn iframe" href="<?php echo CHtml::encode($url)?>" rel="video-feed"></a></div>
      </div>
      <?php echo CHtml::link($album->i18n->name, $url,array('rel'=>'video-feed','class'=>'iframe'));?>
  </div>
  <?php else: ?>
  <p class="section-title"><?php echo Yii::t('site', 'Фотолента');?></p>
  
  <div class="photofeed-box">
      <?php
      $photo = null;
      while (!$photo) {
          /** @var $album Album */
          $album = Album::model()->with('i18n')->find(array('order' => 'rand()'));
          /** @var $photo GalleryPhoto */
          $photo = GalleryPhoto::model()->with('i18n')->find(
              array(
                  'condition' => 'gallery_id = :gal_id',
                  'order' => 'rand()',
                  'params' => array(
                      ':gal_id' => $album->photo_gallery_id
                  )
              ));
      }
      $url = $this->createUrl('albumsSection/album', array('link' => $album->link,'node_id'=>Node::idByDataId('albumsSection',$album->albums_section_id)));
      ?>
      <div class="photofeed-image">
          <?php echo CHtml::link(CHtml::image($photo->getUrl('small'), $photo->i18n->name), $url)?>
      </div>
      <?php echo CHtml::link($album->i18n->name, $url);?>
  </div>
  
  <?php endif; ?>
  <?php
      $cs = Yii::app()->clientScript;
      $cs->registerCoreScript('jquery');
  //$cs->registerScriptFile(Yii::app()->baseUrl . '/js/fancybox/jquery.mousewheel-3.0.4.pack.js');
      $cs->registerScriptFile(Yii::app()->baseUrl . '/js/fancybox/jquery.fancybox-1.3.4.pack.js');
      $cs->registerCssFile(Yii::app()->baseUrl . '/js/fancybox/jquery.fancybox-1.3.4.css');
  $src = <<<JS
  $("a[rel=video-feed]").fancybox({
  	'transitionIn'	: 'none',
  	'type'			: 'iframe',
  	'transitionOut'	: 'none',
  	'titlePosition' : 'over',
  	'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
  
  	    var name = $(currentArray[currentIndex]).data('name'), r = '';
  	    var description = $(currentArray[currentIndex]).data('description');
  	    name = name?name:''; description = description?description:'';
  	    if(name.length) r+='<b>'+name+'</b> ';
  		if(description.length) r+=description;
  		if(r.length) return '<span id="fancybox-title-over">'+r+'</span>';
          else return '';
  	}
  });
  JS;
  $cs->registerScript('video-feed',$src);
  ?>