예제 #1
0
파일: LetArticle.php 프로젝트: letyii/cms
 public function search($params, $with = [])
 {
     $query = LetArticle::find();
     foreach ($with as $row) {
         $query->with($row);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) and $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'from_time' => $this->from_time, 'to_time' => $this->to_time, 'creator' => $this->creator, 'create_time' => $this->create_time, 'editor' => $this->editor, 'update_time' => $this->update_time, 'promotion' => $this->promotion, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'source', $this->source])->andFilterWhere(['like', 'tags', $this->tags])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_url', $this->seo_url])->andFilterWhere(['like', 'seo_desc', $this->seo_desc]);
     //        $this->category_id
     return $dataProvider;
 }
예제 #2
0
파일: index.php 프로젝트: letyii/cms
use app\components\GridView;
use yii\helpers\ArrayHelper;
use app\modules\member\models\LetUser;
use app\modules\article\models\LetArticle;
$this->title = Yii::t(Yii::$app->controller->module->id, ucfirst(Yii::$app->controller->module->id));
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="margin-bottom">
    <div class="btn-group pull-left">
        <?php 
if (Yii::$app->user->can(Yii::$app->controller->module->id . ':create')) {
    echo Html::a(Yii::t('yii', 'Create'), ['backend/default/create'], ['class' => 'btn btn-success', 'onclick' => '$("#formDefault").submit();']);
}
if (Yii::$app->user->can(Yii::$app->controller->module->id . ':delete')) {
    echo Html::button(Yii::t('yii', 'Delete'), ['class' => 'btn btn-danger', 'onclick' => "deleteSelectedRows('" . Url::to(['/cms/backend/crud/deleteselectedrows']) . "', '" . LetArticle::tableName() . "')"]);
}
?>
    </div>
    <div class="clearfix"></div>
</div>

<div>
    <?php 
echo GridView::widget(['panel' => ['heading' => Yii::t(Yii::$app->controller->module->id, 'Article'), 'tableOptions' => ['id' => 'listDefault']], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kartik\\grid\\CheckboxColumn'], ['attribute' => 'id', 'mergeHeader' => TRUE, 'hAlign' => 'center'], 'title', ['attribute' => 'category_id', 'vAlign' => 'middle', 'hAlign' => 'center', 'value' => function ($model, $index, $widget) {
    if (!empty($model->category_id) and is_array($model->category_id)) {
        $result = '';
        foreach ($model->category as $key => $value) {
            $result .= Html::tag('div', Html::a($value->title, '#'));
        }
        return $result;
예제 #3
0
 /**
  * Finds the model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = LetArticle::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }