<?php
/**
 * @var $this SportController
 *
 * @var $show_silk_way string
 *
 * @var $study_title string
 * @var $study_image string
 * @var $study_content string
 * @var $study_button string
 *
 * @var $awards_content string
 * @var $awards_button string
 *
 * @var $champions_content string
 * @var $qualifications_content string
 *
 * @var $study_link
 * @var $awards_link
 * @var $team_link
 */
?>
<?php $this->renderPartial('//snippets/headerGallery'); ?>

<div class="wrapper content-wrapper">
    <div class="col-wrapper">
        <div class="col2 aside-no-title">
            <?php $this->renderPartial('//snippets/bajaBanner');?>
            <?php $this->renderPartial('_sidebar');?>
        </div>
        <div class="col7">
            <h1><?php echo CHtml::encode($this->pageName);?></h1>

            <?php if ($show_silk_way): ?>
            <?php
            /** @var $silk News */
            $silk = News::model()->with('i18n')->find(array(
                'condition' => 'is_silk_way=1',
                'order' => 'date desc',
            ));
            if (!empty($silk)):
                ?>
                <h2><?php
                    $timestamp = CDateTimeParser::parse($silk->date, 'yyyy-MM-dd');
                    echo CHtml::link($silk->i18n->name, array('news/view', 'link' => $silk->link, 'node_id'=>Node::idByDataId('newsRoot',$silk->newsCategory->news_root_id)));
                    echo ' - ';
                    echo Yii::app()->getDateFormatter()->format('d MMMM yyyy', $timestamp);
                    ?>
                </h2>

                <div class="tail-frame">
                    <div class="tail"></div>
                    <div class="diary">
                        <div class="diary-image">
                            <?php echo CHtml::image($silk->imageBehavior->getFileUrl(), '', array('width' => 304))?>
                        </div>
                        <div class="diary-text">
                            <?php echo $silk->i18n->short?>
                            <p><?php echo CHtml::link(Yii::t('site', 'Читать далее'), array('news/view', 'link' => $silk->link, 'node_id'=>Node::idByDataId('newsRoot',$silk->newsCategory->news_root_id)))?>
                                »</p>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
            <?php else: ?>
            <p class="section-title">
                <?php
                echo Yii::t('site', 'Актуальные новости автоспорта');
                echo CHtml::link('', array('site/feed'), array('class' => 'rss-icon'));
                ?></p>
            <?php foreach (SportController::getLatestNews(2) as $item): ?>
                <div class="news-item">
                    <div class="preview-img">
                        <!--                <a href="#"><img src="/images-test/news-1.png"/></a>-->
                        <?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; ?>


            <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>
            <?php endif?>

            <div class="col-wrapper in-col">
                <div class="col8 no-margin">
                    <div class="rally-box">
                        <div class="rally-box-inner">
                            <h1><?php echo CHtml::encode($study_title) ?> </h1>

                            <div class="rally-image">
                                <?php echo CHtml::image($study_image)?>
                            </div>
                            <div class="rally-text">
                                <?php echo $study_content ?>

                                <?php echo CHtml::link($study_button, $study_link, array('class' => 'button'));?>

                            </div>
                        </div>
                    </div>
                </div>
                <?php if ($show_silk_way): ?>
                <div class="col4 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 (SportController::getLatestNews(2) as $item): ?>
                    <div class="news-item">
                        <div class="preview-img">
                            <!--                <a href="#"><img src="/images-test/news-1.png"/></a>-->
                            <?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 class="date">
                                <?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;?>

                    <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>
                <?php else: ?>
                <div class="col4">
                    <?php echo $awards_content?>
                    <div class="text-content">
                        <p><?php echo CHtml::link($awards_button, $awards_link);?> »</p>
                    </div>
                </div>
                <?php endif?>
            </div>
            <div class="col10">
                <div class="col4">
                    <div class="text-content">
                        <?php echo $champions_content?>
                    </div>
                </div>
                <div class="col3 with-margin">
                    <div class="text-content">
                        <?php echo $qualifications_content ?>
                    </div>
                </div>
                <div class="col3 with-margin">
                    <?php $this->renderPartial('_nearestEvents');?>
                </div>
            </div>
        </div>
        <div class="col3 aside-no-title">
            <?php $this->renderPartial('_mediaFeed');?>
        </div>
    </div>
</div>
