topicAll.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. $this->title="Все рубрики";
  3. $newsDataProvider = new \yii\data\ActiveDataProvider(
  4. [
  5. "query"=>\app\models\base\NewsTopic::find()->orderBy(["order"=>SORT_ASC]),
  6. "pagination" => false
  7. ]
  8. );
  9. ?>
  10. <div class="table-responsive-sm custom-range-badge">
  11. <table class="table table-hover table-Light">
  12. <thead class="bg-gray table-sm">
  13. <tr>
  14. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">#</th>
  15. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">фото</th>
  16. <th scope="col">заголовок</th>
  17. <th scope="col">статусы</th>
  18. <th scope="col">управление</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <?
  23. foreach( $newsDataProvider->getModels() as $item ){
  24. // print_r($item);
  25. //return;
  26. $strbage = '<span class="badge badge-success">норма</span><br>';
  27. $mark = '';
  28. if( $item->show == 'N' ){
  29. $mark = ' class="table-dark"';
  30. $strbage .= '<span class="badge badge-dark">удалено</span><br>';
  31. }
  32. if( $item->active == 0 ){
  33. $mark = ' class="table-secondary"';
  34. $strbage .= '<span class="badge badge-secondary">Вне меню (спец.раздел)</span><br>';
  35. }
  36. ?>
  37. <tr<?=$mark?>>
  38. <th scope="row" class="text-nowrap"><?=$item->id?></th>
  39. <td><img src="/topic-images/<?=$item->id?>_size4.jpg" class="img-thumbnail" onerror="this.src='/images/topics/36_size2.jpg'"></td>
  40. <td><?=$item->title?><br><small><?=$item->description?></small></td>
  41. <td><?=$strbage?></td>
  42. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group">
  43. <a href="topicupdate?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a>
  44. <a href="topicshow?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>
  45. <a href="topicactive?id=<?=$item->id?>" title="не видно ни кому" role="button" class="btn btn-secondary btn-sm"><i class="fa <?=($item->active)?'fa-play':'fa fa-stop'?>"></i></a>
  46. <?
  47. if( Yii::$app->user->can('admin') ){
  48. ?>
  49. <a href="topicdel?id=<?=$item->id?>" role="button" class="btn btn-secondary btn-sm" onClick="return confirm('Удалить?')" title="удалить"><i class="fa fa-trash"></i></a>
  50. <?
  51. }
  52. ?>
  53. <a href="/topic/<?=$item->url?>" title="открыть на сайте" role="button" class="btn btn-secondary btn-sm"><i class="far fa-window-restore"></i></a>
  54. </div></td>
  55. </tr>
  56. <?
  57. // <pre>
  58. // print_r($item);
  59. // </pre>
  60. ?>
  61. <?
  62. }
  63. ?>
  64. </tbody>
  65. </table>
  66. </div>
  67. <?php
  68. //print_r($newsDataProvider->getModels());