index.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. use app\models\ReportTopic;
  3. use yii\helpers\Html;
  4. use yii\helpers\Url;
  5. use yii\grid\ActionColumn;
  6. use yii\grid\GridView;
  7. /** @var yii\web\View $this */
  8. /** @var yii\data\ActiveDataProvider $dataProvider */
  9. $this->title = 'Старые фоторепортажи';
  10. $this->params['breadcrumbs'][] = $this->title;
  11. $dataProvider->getPagination()->pageSize = 50;
  12. ?>
  13. <div class="report-topic-index">
  14. <p>
  15. <?= Html::a('Create Report Topic', ['create'], ['class' => 'btn btn-success']) ?>
  16. </p>
  17. <?= GridView::widget([
  18. 'dataProvider' => $dataProvider,
  19. 'columns' => [
  20. 'id',
  21. [
  22. 'class' => 'yii\grid\DataColumn',
  23. 'format' => 'raw',
  24. 'value' => function ($data) {
  25. return Html::a(Html::encode(strip_tags($data->title)),["/photo/".$data->id]);
  26. },
  27. 'attribute' => 'Заголовок',
  28. ],
  29. [
  30. 'class' => 'yii\grid\DataColumn',
  31. 'format' => 'raw',
  32. 'value' => function ($data) {
  33. $imgFileShort = "/images/report_photo/";
  34. return '<div class="attachment-block clearfix" style="max-width: 92px;"><img src="'.$imgFileShort.$data->folder.'/0.160.jpg'.'" width="80px" class="attachment-img"></div>';
  35. },
  36. 'attribute' => 'img',
  37. ],
  38. [
  39. 'class' => 'yii\grid\DataColumn',
  40. 'value' => function ($data) {
  41. return $data->parent_id?'Вложенная папка в: '.$data->parent_id:'';
  42. },
  43. 'attribute' => 'Вложенные',
  44. ],
  45. [
  46. 'class' => 'yii\grid\DataColumn',
  47. 'format' => 'raw',
  48. 'value' => function ($data, $key, $index, $column) {
  49. return $data->active?'<small class="badge badge-success"><i class="fas fa-exclamation-triangle"></i> Вкл.</small>':'<small class="badge badge-secondary"><i class="fas fa-exclamation-triangle"></i> Выкл.</small>';
  50. },
  51. 'attribute' => 'Статус',
  52. ],
  53. [
  54. 'class' => ActionColumn::className(),
  55. 'header' => 'Управление',
  56. 'template' => '{view} {update}',
  57. 'buttonOptions' => ['class' => 'btn btn-default'],
  58. 'urlCreator' => function ($action, $model, $key, $index, $column) {
  59. return Url::toRoute([$action, 'id' => $model->id]);
  60. },
  61. ],
  62. ],
  63. 'layout' => "{errors}\n{pager}\n{items}\n{pager}\n{summary}",
  64. 'pager' => [
  65. 'prevPageCssClass' => 'page-item',
  66. 'firstPageLabel' => 'Начало',
  67. 'lastPageLabel' => 'Конец',
  68. 'linkOptions' => [ 'class'=>'page-link'],
  69. 'pageCssClass' => 'page-item',
  70. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  71. ],
  72. ]); ?>
  73. </div>