<?php
/**
 * @var $this SiteController
 * @var $about string
 * @var $slides GalleryPhoto[]
 */
?>
<div class="hide-back-top" style="display: none;"></div>
<div class="slider-wrapper home-page-slider" id="main-page-slider">
    <div class="slides-container" style="height: 401px; overflow: hidden;">
        <?php foreach ($slides as $slide): ?>
        <div class="slide">
            <?php
            $link = $slide->i18n->link;
            if (empty($link))
                echo CHtml::image($slide->getUrl('gallery'));
            else
                echo CHtml::link(CHtml::image($slide->getUrl('gallery')), $link);
            ?>
            <div class="caption">
                <?php if (!empty($slide->i18n->name)) echo '<span>', $slide->i18n->name, '</span>'?><br/>
                <?php if (!empty($slide->i18n->description)) echo '<span>', $slide->i18n->description, '</span>'?>
            </div>
        </div>
        <?php endforeach;?>
    </div>
    <a class="prev"></a>
    <a class="next"></a>
    <ul class="slide-pagination">
        <?php foreach ($slides as $slide): ?>
        <li><a href="#"></a></li>
        <?php endforeach;?>
    </ul>
</div>
<?php
/** @var $cs CClientScript */
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile('/js/slides.min.jquery.js');
$src = <<<JS
$('#main-page-slider').slides({
    'container':'slides-container',
    'next':'next',
    'prev':'prev',
    'paginationClass':'slide-pagination',
    'currentClass':'active',
    'generatePagination':false,
    'play': 5000,
    'pause': 2500,
    'hoverPause': false
});
JS;

$cs->registerScript('main-page-gallery', $src);
?>

<div class="col-wrapper home-page-banners">
    <div class="col4">
        <?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/img/auto-tuning.png'), array('tuning/index', 'node_id'=>Node::idByDataId('tuningRoot'))); ?>
    </div>
    <div class="col4">
        <?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/img/auto-service.png'), array('service/index')); ?>
    </div>
    <div class="col4">
        <?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/img/sport-team.png'), array('sport/index', 'node_id'=>Node::idByDataId('sportRoot'))); ?>
    </div>
</div>
<div class="col-wrapper">
    <div class="col4">
        <p class="section-title"><?php echo Yii::t('site', 'О нашей компании');?></p>

        <div class="text-content">
            <?php echo $about ?>
        </div>
    </div>
    <div class="col6 home-page-news">
        <p class="section-title">
            <?php
            echo Yii::t('site', 'Новости');
            echo CHtml::link('', array('site/feed'), array('class' => 'rss-icon'));
            ?></p>
        <?php foreach ($this->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 ' - ';
                echo Yii::app()->getDateFormatter()->format('d MMMM yyyy', $timestamp);
                ?>
                </p>

                <p><?php echo $item->i18n->short?></p>
            </div>
        </div>
        <?php endforeach;?>
        <div class="news-item">
            <span class="read-more">
                <?php echo CHtml::link(Yii::t('site', 'Архив новостей'), array('news/index', 'node_id'=>Node::model()->find('data_type = \'newsRoot\'')->id));?>»
            </span>
        </div>
    </div>
    <div class="col2">
        <p class="section-title"><?php echo Yii::t('site','Мы в сети');?></p>

        <div class="text-content"><p><?php echo Yii::t('site','Следите за новостями автотюнинга и автоспорта в социальной сети');?></p></div>
        <div class="header-soc">
            <?php echo $this->socialLinksSport;?>
            <p><?php echo Yii::t('site','Автоспорт:');?></p><br/>
            <br/>
            <?php echo $this->socialLinks ?>
            <p><?php echo Yii::t('site','Тюнинг:');?></p><br/>
        </div>
    </div>
</div>