inject2.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_1040x586,"webp");
  12. $normal = $preview->getUrl(Image::SIZE_680x383,"webp");
  13. $bad = $preview->getUrl(Image::SIZE_680x383,'jpg');
  14. $bad = $bad?$bad:'/images/default.jpg';
  15. /*
  16. После этой даты не выводить фото до подтверждения юриста
  17. */
  18. if( isset( $post->dt_pub ) && strtotime( $post->dt_pub ) < strtotime(Yii::$app->params['delPhoto']) ){
  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="inject2" 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. <h2 class="title"><a href="<?=$post->url?>"><?=$post->title?></a></h2>
  49. <div class="lead"><?=$post->lid?></div>
  50. <div class="breadcrumbs">
  51. <?php
  52. echo Html::a("НОВОСТИ", ["/news"], ['class' => "breadcrumb"]);
  53. $topic = $post->getTopics()->andWhere(['show'=>"Y","active"=>1])->one();
  54. if($topic instanceof \app\models\base\NewsTopic) {
  55. echo Html::a($topic->title, ["/news/{$topic->url}"], ['class' => "breadcrumb"]);
  56. }
  57. ?>
  58. </div>
  59. </div>
  60. </div>