_main_view_item.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * @var $model \app\models\News
  4. * @var $key
  5. * @var $index
  6. * @var $widget
  7. */
  8. use app\models\base\Image;
  9. use app\models\PhotoFilter;
  10. if( $index == 0 ){
  11. $mfilter = new PhotoFilter();
  12. $filter = $mfilter->findOne($model->id);
  13. if( !$filter ){
  14. $filter = new stdClass();
  15. $filter->brightness = 100;
  16. $filter->saturate = 100;
  17. $filter->contrast = 100;
  18. $filter->opacity = 0.5;
  19. }
  20. $sstr = 'style="filter: saturate('.$filter->saturate.'%) brightness('.$filter->brightness.'%) contrast('.$filter->contrast.'%);"';
  21. ?>
  22. <style>
  23. #fimgb::after{
  24. background:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,<?=$filter->opacity?>)) !important;
  25. }
  26. #fimgb{
  27. filter:brightness(100%);
  28. }
  29. </style>
  30. <?
  31. }
  32. $preview = $model->preview;
  33. switch ($index){
  34. case 0:
  35. $className = "main";
  36. break;
  37. case 1:
  38. $className = "high";
  39. break;
  40. default:
  41. $className = "low";
  42. }
  43. if($index==2) echo \yii\helpers\Html::beginTag("div",["class"=>'group']);
  44. ?>
  45. <div class="news-item <?=$className?>" data-key="<?=$key?>">
  46. <?php if($preview instanceof Image && $index==0):?>
  47. <div class="picture-cont-16x9">
  48. <a href="<?=$model->url?>" title="<?=htmlentities($model->title,ENT_QUOTES)?>">
  49. <picture class="w-100" id="fimgb" >
  50. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?>" media="(min-width: 600px)">
  51. <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" id='mainphoto' <?=$sstr?>>
  52. </picture>
  53. </a>
  54. </div>
  55. <?php endif;?>
  56. <div class="meta">
  57. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  58. <?php if($className!="low"): ?><div class="lead"><?=$model->lid?></div><?php endif;?>
  59. <div class="published_at">
  60. <?=$model->publishedAt?> <?=date("H:i",strtotime($model->dt_pub))?>
  61. <?php if($model->comments=="Y"):?>
  62. <?php
  63. $count=$model->getCommentsAll()->count();
  64. ?>
  65. <?php if($count>0):?>
  66. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  67. <?php endif;?>
  68. <?php endif;?>
  69. </div>
  70. </div>
  71. </div>
  72. <?php
  73. if($index==3) echo \yii\helpers\Html::endTag("div");
  74. ?>