album.php 6.66 KB
<?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
);
?>