storyList.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. use yii\widgets\LinkPager;
  3. use yii\data\Pagination;
  4. $this->title="Сюжеты";
  5. $newsDataProvider = new \yii\data\ActiveDataProvider(
  6. [
  7. "query"=>\app\models\base\Story::find()->orderBy(["order"=>SORT_ASC])->limit(50),
  8. "pagination" =>[
  9. "pageSize"=>50
  10. ],
  11. ]
  12. );
  13. $query = \app\models\base\Story::find();
  14. $count = $query->count();
  15. ?>
  16. <div class="table-responsive-sm custom-range-badge">
  17. <table class="table table-hover table-Light">
  18. <thead class="bg-gray table-sm">
  19. <tr>
  20. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
  21. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">фото</th>
  22. <th scope="col">заголовок</th>
  23. <th scope="col">статусы</th>
  24. <th scope="col">управление</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. <?
  29. foreach( $newsDataProvider->getModels() as $item ){
  30. // print_r($item);
  31. //return;
  32. $strbage = '<span class="badge badge-success">норма</span><br>';
  33. $mark = '';
  34. if( $item->show == 'N' ){
  35. $mark = ' class="table-dark"';
  36. $strbage .= '<span class="badge badge-dark">Не показывать на сайте</span><br>';
  37. }
  38. if( $item->active == 0 ){
  39. $mark = ' class="table-secondary"';
  40. $strbage .= '<span class="badge badge-secondary">Не видно ни кому(del)</span><br>';
  41. }
  42. ?>
  43. <tr<?=$mark?>>
  44. <th scope="row" class="text-nowrap"><?=$item->id?></th>
  45. <td><img src="/story-images/<?=$item->id?>_size2.jpg" class="img-thumbnail" onerror="this.src='/images/topics/36_size2.jpg'"></td>
  46. <td><?=$item->title?><br><small><?=$item->description?></small></td>
  47. <td><?=$strbage?></td>
  48. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
  49. <a href="storyupdate?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
  50. <a href="storyshow?id=<?=$item->id?>" title="спрятать в меню" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->show == 'N')?'fa-eye-slash':'fa fa-eye'?>"></i></a>
  51. <a href="storyactive?id=<?=$item->id?>" title="не видно ни кому" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->active)?'fa-play':'fa fa-stop'?>"></i></a>
  52. <?
  53. if( Yii::$app->user->can('admin') ){
  54. ?>
  55. <a href="storydel?id=<?=$item->id?>" role="button" class="btn btn-secondary btn-sm" onClick="return confirm('Удалить?')" title="удалить"><i class="fa fa-trash"></i></a>
  56. <?
  57. }
  58. ?>
  59. <a href="/story/<?=$item->url?>" title="открыть на сайте" role="button" class="btn btn-secondary btn-sm"><i class="far fa-window-restore"></i></a>
  60. </div></td>
  61. </tr>
  62. <?
  63. // <pre>
  64. // print_r($item);
  65. // </pre>
  66. ?>
  67. <?
  68. }
  69. ?>
  70. </tbody>
  71. </table>
  72. </div>
  73. <?php
  74. $pagination = new Pagination(['totalCount' => $count, 'defaultPageSize' => 50]);
  75. echo "<nav>";
  76. echo LinkPager::widget([
  77. 'pagination' => $pagination,
  78. // 'class' => 'yii\bootstrap4\LinkPager',
  79. 'pageCssClass' => 'page-item',
  80. 'linkOptions' => [ 'class'=>'page-link'],
  81. 'prevPageCssClass' => 'page-item',
  82. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  83. ]);
  84. //print_r($newsDataProvider->getModels());
  85. echo "</nav>";