<?php
/**
 * @var $post \app\models\News
 * @var \yii\data\ActiveDataProvider $newsDataProvider
 * @var \app\models\base\NewsTopic | \app\models\base\Story $topic
 * @var \app\models\Design $design
 */

if( $topic instanceof \app\models\base\NewsTopic ) $url = '/news/';
if( $topic instanceof \app\models\base\Story ) $url = '/story/';
if( $topic instanceof \app\models\base\Tags ) $url = '/tags/';


$post = Yii::$app->cache->getOrSet("main-page-wide-widget-".$design->id,function () use($newsDataProvider){
   return $newsDataProvider->models[0];
},600);

?>
<div class="wide-widget row">
    <div class="col-md-8">
        <div class="cont">
            <?php if($post->image instanceof \app\models\base\Image):?>
                <div class="picture-cont-16x9">
                    <picture class="w-100">
                        <source srcset="<?=$post->image->url?>" media="(min-width: 600px)">
                        <img src="<?=$post->image->url?>" alt="<?=htmlentities($post->photo_title,ENT_QUOTES)?>" class="w-100" loading="lazy">
                    </picture>
                </div>
            <?php endif;?>
            <div class="meta">
                <h2 class="title">
                    <a href="<?=$post->url?>"><?=$post->title?></a>

                </h2>
                <div class="topic">
                    <a href="<?=$design->url!=""?$design->url:$url.$topic->url?>" class="wwt"><?=$topic->title?></a>
                </div>
                <?php
                $comments = $post->commentsAll;
                if(!is_null($comments)){
                    $count=count($comments);
                } else{
                    $count = 0;
                }

                ?>
                <?php if($count>0 || 1):?>
                    <div class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></div>
                <?php endif;?>
            </div>
        </div>
    </div>
    <div class="adv col-md-4">
        <div class="cont">
            <?=$this->render('@app/views/_etc/banners/peregovorkaBanner')?>
        </div>
    </div>
</div>
