_main_view_item_slider.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. $brightness = Yii::$app->deviceDetect->isMobile()?85:100;
  11. $mfilter = new PhotoFilter();
  12. $filter = $mfilter->findOne($model->id);
  13. if( !$filter ){
  14. $filter = new stdClass();
  15. $filter->brightness = $brightness;
  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. $preview = $model->preview;
  22. $className = 'main';
  23. ?>
  24. <div class="news-sitem <?=$className?> col-md-12" data-key="<?=$key?>">
  25. <?php if($preview instanceof Image ):?>
  26. <div class="picture-cont-16x9" >
  27. <a href="<?=$model->url?>" title="<?=htmlentities($model->title,ENT_QUOTES)?>">
  28. <picture class="w-100" id="fimgb<?=$index?>" >
  29. <source srcset="<?=$preview->getUrl(Image::SIZE_841x473)?>?v=<?=$model->rev?>" media="(min-width: 600px)">
  30. <img src="<?=$preview->getUrl(Image::SIZE_841x473)?>?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?>>
  31. </picture>
  32. </a>
  33. </div>
  34. <div class="meta">
  35. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  36. <?php if($className!="low"): ?><div class="lead"><?=$model->lid?></div><?php endif;?>
  37. <div class="published_at">
  38. <?=$model->publishedAt?> <?=date("H:i",strtotime($model->dt_pub))?>
  39. <?php if($model->comments=="Y"):?>
  40. <?php
  41. $count=$model->getCommentsAll()->count();
  42. ?>
  43. <?php if($count>0):?>
  44. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  45. <?php endif;?>
  46. <?php endif;?>
  47. </div>
  48. </div>
  49. <?php endif;?>
  50. <span class="slpager slinner">
  51. <?
  52. for( $i = 0; $i < $elcount; $i++ ){
  53. ?>
  54. <span class="slider-indicator<?=$index == $i?' active':' '?>"></span>
  55. <?
  56. }
  57. ?>
  58. </span>
  59. <style>
  60. #fimgb<?=$index?>::after{
  61. background:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,<?=$filter->opacity?>)) !important;
  62. }
  63. #fimgb<?=$index?>{
  64. filter:brightness(100%);
  65. }
  66. </style>
  67. </div>