<?php
/**
 * @var $this \yii\web\View
 * @var $model \app\models\front\News
 * @var $color string
 */
use app\models\base\Image;

$preview = $model->preview
?>
<div class="colorful-news-item <?=$color?>" onclick="location.href='<?=$model->getUrl()?>'">
    <div class="background">
        <picture class="">
            <source srcset="<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?>" media="(min-width: 600px)">
            <img
                    src="<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?>"
                    srcset="<?=$preview->getUrl(Image::SIZE_320x180)?>?v=<?=$model->rev?> 320w,<?=$preview->getUrl(Image::SIZE_500x282)?>?v=<?=$model->rev?> 500w,<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?> 680w"
                    alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>"
                    loading="lazy"
            >
        </picture>
    </div>
    <?php
    $topic = $model->getTopics()->andWhere(['show'=>"Y","active"=>1])->orderBy(["order"=>SORT_ASC])->limit(1)->one();
    if($topic instanceof \app\models\base\NewsTopic):
    ?>
        <div class="rubric">
            <a href="<?=$topic->getUrl()?>"><?=$topic->title?></a>
        </div>
    <?php endif;?>
    <div class="title">
        <a href="<?=$model->getUrl()?>"> <?=$model->title?></a>

        <?php
        $count=$model->getCommentsAll()->count();
        ?>
        <?php if($count>0):?>
            <span class="comments">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
        <?php endif;?>
    </div>

</div>
