inject.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @var News $post
  4. * @var \yii\web\View $this
  5. */
  6. use app\models\base\Image;
  7. use app\models\News;
  8. use yii\helpers\ArrayHelper;
  9. use yii\helpers\Html;
  10. $preview = $post->image;
  11. $retina = $preview->getUrl(Image::SIZE_500x282,"webp");
  12. $normal = $preview->getUrl(Image::SIZE_320x180,"webp");
  13. $bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
  14. $bad = $bad?$bad:'/images/default.jpg';
  15. /*
  16. После этой даты не выводить фото до подтверждения юриста
  17. */
  18. if( isset( $post->dt_pub ) && !$post->isPhotosOnNews( $post->dt_pub ) ){
  19. $bad = '/images/default.jpg';
  20. $normal = $bad;
  21. $retina = $bad;
  22. };
  23. if( $retina === false || $normal === false ){
  24. $normal = $bad;
  25. $retina = $bad;
  26. }
  27. $preview = $post->preview;
  28. ?>
  29. <div class="inject" id="<?=$post->uid?>">
  30. <div class="illustration">
  31. <?php if($preview instanceof \app\models\base\Image):?>
  32. <div class="picture-cont-16x9">
  33. <a href="<?=$post->url?>">
  34. <picture class="w-100">
  35. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  36. <img src="<?=$bad?>" alt="<?=$post->photo_title?>" class="w-100" loading="lazy">
  37. </picture>
  38. </a>
  39. </div>
  40. <?php else:?>
  41. <div class="picture-cont-16x9">
  42. <a href="<?=$post->url?>">
  43. </a>
  44. </div>
  45. <?php endif;?>
  46. </div>
  47. <div class="meta">
  48. <div class="breadcrumbs">
  49. <?php
  50. echo Html::a("НОВОСТИ", ["/news"], ['class' => "breadcrumb"]);
  51. $topic = $post->getTopics()->andWhere(['show'=>"Y","active"=>1])->one();
  52. if($topic instanceof \app\models\base\NewsTopic) {
  53. echo Html::a($topic->title, ["/news/{$topic->url}"], ['class' => "breadcrumb"]);
  54. }
  55. ?>
  56. </div>
  57. <h2 class="title"><a href="<?=$post->url?>"><?=$post->title?></a></h2>
  58. </div>
  59. </div>