_archive_item.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. $preview = $model->image;
  10. $retina = $preview->getUrl(Image::SIZE_680x383,"webp");
  11. $normal = $preview->getUrl(Image::SIZE_320x180,"webp");
  12. $bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
  13. $bad = $bad?$bad:'/images/default.jpg';
  14. if( $retina === false || $normal == false ){
  15. $normal = $bad;
  16. $retina = $bad;
  17. }
  18. /*
  19. После этой даты не выводить фото до подтверждения юриста
  20. */
  21. if( isset( $model->dt_pub ) && strtotime( $model->dt_pub ) < strtotime(Yii::$app->params['delPhoto']) ){
  22. $bad = '/images/default.jpg';
  23. $normal = $bad;
  24. $retina = $bad;
  25. };
  26. $normal .= "?v=".$model->rev;
  27. $retina .= "?v=".$model->rev;
  28. $bad .= "?v=".$model->rev;
  29. $count=$model->getCommentsAll()->count();
  30. /*
  31. После этой даты не выводить фото
  32. if( isset( $model->dt_pub ) && strtotime( $model->dt_pub ) < strtotime('2015-01-01 00:00:00') ){
  33. $bad = '/images/default.jpg';
  34. $normal = $bad;
  35. $retina = $bad;
  36. };
  37. */
  38. if( isset($index) ){
  39. $index = $index+1;
  40. }else{
  41. static $index = 0;
  42. }
  43. ?>
  44. <div class="">
  45. <div class="archive-news-item" data-key="<?=$key?>">
  46. <div class="illustration">
  47. <?php if($preview instanceof \app\models\base\Image):?>
  48. <div class="picture-cont-16x9">
  49. <a href="<?=$model->url?>">
  50. <picture class="w-100">
  51. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  52. <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
  53. </picture>
  54. </a>
  55. </div>
  56. <?php else:?>
  57. <div class="picture-cont-16x9">
  58. <a href="<?=$model->url?>">
  59. </a>
  60. </div>
  61. <?php endif;?>
  62. </div>
  63. <div class="meta">
  64. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  65. <div class="published_at">
  66. <?=$model->publishedAt?>
  67. <?php if($count>0):?>
  68. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  69. <?php endif;?>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <?php if($index == 4) echo $this->render("@app/views/_etc/banners/archiveAfterFive")?>