topicList.php 3.4 KB

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