<?php
/**
 * @var $model \app\models\News
 * @var $key
 * @var $index
 * @var $widget
 */

use app\models\base\Image;

$preview = $model->preview;
switch ($index){
    case 0:
        $className = "main";
        break;
    case 1:
        $className = "high";
        break;
    default:
        $className = "low";
}
if($index==2) echo \yii\helpers\Html::beginTag("div",["class"=>'group']);
?>
<div class="news-item <?=$className?>" data-key="<?=$key?>">

        <?php if($preview instanceof Image && $index==0):?>
        <div class="picture-cont-16x9">
            <a href="<?=$model->url?>" title="<?=htmlentities($model->title,ENT_QUOTES)?>">
                <picture class="w-100">
                    <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)?>" class="w-100" loading="lazy">
                </picture>
            </a>
        </div>
        <?php endif;?>
        <div class="meta">
            <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
            <?php if($className!="low"): ?><div class="lead"><?=$model->lid?></div><?php endif;?>
            <div class="published_at">
                <?=$model->publishedAt?> <?=date("H:i",strtotime($model->dt_pub))?>
                <?php if($model->comments=="Y"):?>
                    <?php
                    $count=$model->getCommentsAll()->count();
                    ?>
                    <?php if($count>0):?>
                        <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
                    <?php endif;?>
                <?php endif;?>
            </div>
        </div>


</div>
<?php
    if($index==3) echo \yii\helpers\Html::endTag("div");
?>
