album.php
6.66 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/**
* @var $this SportController
* @var $album Album
*/
?>
<?php $this->renderPartial('//snippets/headerGallery'); ?>
<?php
$galleryItems = array();
$galleryItem = 0;
?>
<div class="wrapper content-wrapper">
<div class="col-wrapper">
<div class="col2 aside-no-title">
<?php $this->renderPartial('//snippets/bajaBanner');?>
<?php $this->renderPartial('//sport/_sidebar');?>
</div>
<div class="col7">
<h1><?php echo CHtml::encode($this->pageName)?></h1>
<?php if ($album->videoGalleryBehavior->getGalleryPhotoCount() > 0): ?>
<h2><?php echo Yii::t('site', 'Смотрите видео')?></h2>
<div class="sport-gallery-list">
<?php foreach ($album->videoGalleryBehavior->getGalleryPhotos() as $photo): ?>
<div class="video-box">
<?php echo CHtml::image($photo->getUrl('small'), $photo->i18n->name)?>
<div class="overlay">
<?php
preg_match('#(?<=(?:v|i)=)[a-zA-Z0-9-]+(?=&)|(?<=(?:v|i)\/)[^&\n]+|(?<=embed\/)[^"&\n]+|(?<=(?:v|i)=)[^&\n]+|(?<=youtu.be\/)[^&\n]+#', $photo->i18n->link, $matches);
if (count($matches) > 0) {
$videoId = $matches[0];
$url = 'http://www.youtube.com/embed/' . $videoId . '?feature=player_detailpage';
$galleryItems[] = array(
'id' => $videoId,
'type' => 'video',
'preview' => $photo->getUrl('small'),
);
} else {
$url = $photo->i18n->link;
}
echo CHtml::link('', $url, array('class' => 'play-btn iframe', 'rel' => 'video-gallery', 'onclick' => 'window.bigGallery.switchTo(' . $galleryItem . '); return false;'));
$galleryItem += 1;
?>
</div>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
<?php if ($album->photoGalleryBehavior->getGalleryPhotoCount() > 0): ?>
<h2><?php echo Yii::t('site', 'Смотрите фотографии')?></h2>
<div class="sport-gallery-list">
<?php foreach ($album->photoGalleryBehavior->getGalleryPhotos() as $photo): ?>
<?php
$galleryItems[] = array(
'image' => $photo->getUrl('medium'),
'type' => 'image',
'preview' => $photo->getUrl('small'),
);
echo CHtml::link(CHtml::image($photo->getUrl('small'), $photo->i18n->name),
$photo->getUrl('medium'), array('rel' => 'photo-gallery', 'onclick' => 'window.bigGallery.switchTo(' . $galleryItem . '); return false;'));
$galleryItem += 1;
?>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
<div class="col3">
<?php $this->renderPartial('//sport/_nearestEvents');?>
<?php $this->renderPartial('//sport/_mediaFeed');?>
<p class="section-title">
<?php
echo Yii::t('site', 'Актуальные новости автоспорта');
echo CHtml::link('', array('site/feed'), array('class' => 'rss-icon'));
?></p>
<?php foreach (SportController::getLatestNews() as $item): ?>
<div class="news-item">
<div class="preview-img">
<?php echo CHtml::link(CHtml::image($item->imageBehavior->getFileUrl('preview')), array('news/view', 'link' => $item->link, 'node_id' => Node::idByDataId('newsRoot', $item->newsCategory->news_root_id)))?>
</div>
<div class="news-content">
<p>
<?php
$timestamp = CDateTimeParser::parse($item->date, 'yyyy-MM-dd hh:mm:ss');
echo CHtml::link($item->i18n->name, array('news/view', 'link' => $item->link, 'node_id' => Node::idByDataId('newsRoot', $item->newsCategory->news_root_id)));
echo '<br/> — ';
echo Yii::app()->getDateFormatter()->format('d MMMM yyyy', $timestamp);
?>
</p>
</div>
</div>
<?php endforeach;?>
<span><?php
/** @var $cat NewsCategory */
$cat = NewsCategory::model()->findByPk(2);
echo CHtml::link(Yii::t('site', 'Архив новостей'), array('news/category', 'link' => $cat->link, 'node_id'=>Node::idByDataId('newsRoot', $cat->news_root_id)));
?>»</span>
</div>
</div>
</div>
<?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=photo-gallery]").fancybox({
'transitionIn' : 'none',
'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 '';
}
});
$("a[rel=video-gallery]").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('fancybox_gallery', $src);
$galleryItems = CJavaScript::encode($galleryItems);
$title = CJavaScript::encode($this->pageName);
$cs->registerScript('bigGallery', <<<JS
makeGallery($galleryItems,$title,true);
JS
);
?>