view.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\DetailView;
  4. use yii\web\View;
  5. /** @var yii\web\View $this */
  6. /** @var app\models\ReportTopic $model */
  7. $this->title = '';
  8. $this->params['breadcrumbs'][] = ['label' => 'Старые фоторепортажи', 'url' => ['index']];
  9. $this->params['breadcrumbs'][] = $this->title;
  10. $imgFileShort = "/images/report_photo/{$model->folder}/";
  11. $amic_image = $imgFileShort."0.size2.jpg";
  12. if( !file_exists(Yii::getAlias('@webroot').$amic_image) ){
  13. $amic_image = $imgFileShort."0.160.jpg";
  14. }
  15. \yii\web\YiiAsset::register($this);
  16. ?>
  17. <div class="report-topic-view">
  18. <h2><?= Html::encode( $model->title ) ?></h2>
  19. <p>
  20. <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  21. <?= Html::a('Delete', ['delete', 'id' => $model->id], [
  22. 'class' => 'btn btn-danger',
  23. 'data' => [
  24. 'confirm' => 'Are you sure you want to delete this item?',
  25. 'method' => 'post',
  26. ],
  27. ]) ?>
  28. </p>
  29. <div class="row">
  30. <div class ="col-md-4">
  31. <div class="card mb-2 bg-gradient-dark">
  32. <img class="card-img-top" src="<?=$amic_image?>" style="filter: brightness(0.5);">
  33. <div class="card-img-overlay d-flex flex-column justify-content-end">
  34. <h5 class="card-title text-primary text-white"><?= Html::decode( $model->title ) ?></h5>
  35. <p class="card-text text-white pb-2 pt-1"><?= Html::decode( substr( $model->body, 0, 250) ) ?></p>
  36. <a href="/photo/<?=$model->id?>" class="text-white">Переход >></a>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <?
  42. //var_dump($model->getReport());
  43. ?>
  44. <div class="row">
  45. <div class ="col-md-6">
  46. <div id="carousel" class="carousel slide" data-ride="carousel">
  47. <div class="carousel-inner">
  48. <?
  49. $f = true;
  50. foreach( $model->getReport() as $item ){
  51. ?>
  52. <div class="carousel-item<?=$f?' active':''?>">
  53. <img src="<?=$imgFileShort.$item->id?>.800.jpg" class="d-block w-100" alt="">
  54. <? if( trim($item->title) != ''){?>
  55. <div class="carousel-caption d-none d-md-block">
  56. <h5><?=Html::encode($item->title)?></h5>
  57. </div>
  58. <?}?>
  59. </div>
  60. <?
  61. $f = false;
  62. }
  63. ?>
  64. </div>
  65. <a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
  66. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  67. <span class="sr-only">Предыдущий</span>
  68. </a>
  69. <a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
  70. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  71. <span class="sr-only">Следующий</span>
  72. </a>
  73. </div>
  74. </div>
  75. </div>
  76. <?= DetailView::widget([
  77. 'model' => $model,
  78. 'attributes' => [
  79. 'id',
  80. 'parent_id',
  81. 'date',
  82. 'title:ntext',
  83. 'body:ntext',
  84. 'folder',
  85. 'sort',
  86. 'active',
  87. ],
  88. ]) ?>
  89. </div>
  90. <?
  91. $this->registerJs(
  92. <<<JS
  93. // $('#carousel').carousel()
  94. JS
  95. ,
  96. View::POS_END,
  97. 'carousel'
  98. );