index.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2016-03-23 17:51
  7. */
  8. /**
  9. * @var $this yii\web\View
  10. * @var $dataProvider yii\data\ActiveDataProvider
  11. * @var $searchModel backend\models\search\ArticleSearch
  12. * @var $frontendURLManager yii\web\UrlManager
  13. */
  14. use backend\grid\DateColumn;
  15. use backend\grid\GridView;
  16. use backend\grid\SortColumn;
  17. use yii\helpers\Url;
  18. use common\libs\Constants;
  19. use yii\helpers\Html;
  20. use backend\widgets\Bar;
  21. use backend\grid\CheckboxColumn;
  22. use backend\grid\ActionColumn;
  23. $this->title = 'Pages';
  24. $this->params['breadcrumbs'][] = Yii::t('app', 'Pages');
  25. ?>
  26. <div class="row">
  27. <div class="col-sm-12">
  28. <div class="ibox">
  29. <?= $this->render('/widgets/_ibox-title') ?>
  30. <div class="ibox-content">
  31. <?= Bar::widget() ?>
  32. <?= GridView::widget([
  33. 'dataProvider' => $dataProvider,
  34. 'filterModel' => $searchModel,
  35. 'columns' => [
  36. [
  37. 'class' => CheckboxColumn::className(),
  38. ],
  39. [
  40. 'attribute' => 'id',
  41. ],
  42. [
  43. 'class' => SortColumn::className()
  44. ],
  45. [
  46. 'attribute' => 'title',
  47. ],
  48. [
  49. 'attribute' => 'sub_title',
  50. 'label' => Yii::t("app", "Page Sign"),
  51. 'format' => 'raw',
  52. 'value' => function($model)use($frontendURLManager){
  53. /** @var common\models\Article $model */
  54. $scriptName = "";
  55. if( $frontendURLManager->showScriptName ){
  56. $scriptName = "index.php/";
  57. }
  58. $url = $frontendURLManager->enablePrettyUrl ? Yii::$app->params['site']['url'] . $scriptName . 'page/' . $model->sub_title . $frontendURLManager->suffix : Yii::$app->params['site']['url'] . 'index.php?r=page/' . $model->sub_title . $frontendURLManager->suffix;
  59. return Html::a($model->sub_title, $url, ["target" => "_blank"]);
  60. },
  61. ],
  62. [
  63. 'attribute' => 'author_name',
  64. ],
  65. [
  66. 'attribute' => 'status',
  67. 'format' => 'raw',
  68. 'value' => function ($model, $key, $index, $column) {
  69. /** @var $model common\models\Article */
  70. return Html::a(Constants::getArticleStatus($model['status']), ['update', 'id' => $model['id']], [
  71. 'class' => 'btn btn-xs btn-rounded ' . ( $model['status'] == Constants::YesNo_Yes ? 'btn-info' : 'btn-default' ),
  72. 'data-confirm' => $model['status'] == Constants::YesNo_Yes ? Yii::t('app', 'Are you sure you want to cancel release?') : Yii::t('app', 'Are you sure you want to publish?'),
  73. 'data-method' => 'post',
  74. 'data-pjax' => '0',
  75. 'data-params' => [
  76. $model->formName() . '[status]' => $model['status'] == Constants::YesNo_Yes ? Constants::YesNo_No : Constants::YesNo_Yes
  77. ]
  78. ]);
  79. },
  80. 'filter' => Constants::getArticleStatus(),
  81. ],
  82. [
  83. 'class' => DateColumn::className(),
  84. 'attribute' => 'created_at',
  85. ],
  86. [
  87. 'class' => DateColumn::className(),
  88. 'attribute' => 'updated_at',
  89. ],
  90. [
  91. 'class' => ActionColumn::className(),
  92. 'buttons' => [
  93. 'comment' => function ($url, $model, $key) {
  94. return Html::a('<i class="fa fa-commenting-o" aria-hidden="true"></i> ', Url::to([
  95. 'comment/index',
  96. 'CommentSearch[aid]' => $model->id
  97. ]), [
  98. 'title' => Yii::t('app', 'Comments'),
  99. 'data-pjax' => '0',
  100. 'class' => 'btn-sm openContab',
  101. ]);
  102. }
  103. ],
  104. 'width' => '135',
  105. 'template' => '{view-layer} {update} {delete} {comment}',
  106. ],
  107. ]
  108. ]); ?>
  109. </div>
  110. </div>
  111. </div>
  112. </div>