Ejemplo n.º 1
0
 public function search($params)
 {
     $query = Post::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'tags', $this->tags])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'create_time', $this->create_time])->andFilterWhere(['like', 'update_time', $this->update_time])->andFilterWhere(['like', 'author_id', $this->author_id]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'tags', $this->tags]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['post_id' => $this->post_id, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'post_title', $this->post_title]);
     //            ->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $query->joinWith(['group', 'statusgroup']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['group'] = ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC]];
     $dataProvider->sort->attributes['statusgroup'] = ['asc' => ['status.name' => SORT_ASC], 'desc' => ['status.name' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id_post' => $this->id_post, 'group_post' => $this->group_post, 'create_day' => $this->create_day, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name_post', $this->name_post])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'group.name', $this->group])->andFilterWhere(['like', 'status.name', $this->statusgroup]);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 7
0
header('Content-Type: text/html; charset=UTF-8');
$this->title = Yii::$app->setting->get('siteTitle');
?>
<div class="post-index">
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Post'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
$form = ActiveForm::begin(['id' => 'all']);
?>
    <div class="post-all">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], 'id', ['attribute' => 'explore_status', 'value' => function ($model) {
    return Post::getExplore_status($model->explore_status);
}, 'headerOptions' => ['width' => '7%']], 'title:ntext', ['attribute' => 'content', 'value' => function ($model) {
    return mb_substr($model->content, 0, 200, 'utf-8');
}], 'tags:ntext', 'user_id', 'created_at:time', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
    </div>
    <input class=""  type="submit"  name="review" value="审核">
    <input class=""  type="submit"  name="soldout" value="下架">
    <?php 
ActiveForm::end();
?>
</div>
Ejemplo n.º 8
0
 public function actionDelete($id)
 {
     PageSelfRels::updateAll(['parent_page_id' => 0], 'parent_page_id = ' . $id);
     PageSelfRels::deleteAll(['page_id' => $id]);
     $images = PageImageRel::findAll(['page_id' => $id]);
     if (!empty($images)) {
         foreach ($images as $key => $value) {
             unlink(\Yii::getAlias('@webroot') . '/uploads/' . $value->image);
         }
     }
     PageImageRel::deleteAll(['page_id' => $id]);
     PageCategoryRel::deleteAll(['page_id' => $id]);
     Post::deleteAll(['page_id' => $id]);
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
Ejemplo n.º 9
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\Post;
/* @var $this yii\web\View */
/* @var $model backend\models\Post */
?>
<div class="post-view">

<ul class="post_sort">

    <?php 
$posts = Post::find()->where(['page_id' => $page_id])->orderBy('sort_order asc')->all();
if (!empty($posts)) {
    foreach ($posts as $value) {
        echo '<li data-id="' . $value->id . '" class="Post_' . $value->id . '">';
        echo '<div class="col-md-8">' . $value->post_title . '</div>';
        echo '<div class="col-md-4">';
        echo '<input type="button" class="btn btn-sm btn-primary view_post_btn" value="View" data_id="' . $value->id . '">';
        echo '<input type="button" class="btn btn-sm btn-default update_post_btn" value="Update" data_id="' . $value->id . '" style="margin-left:10px;">';
        echo '<input type="button" class="btn btn-sm btn-danger delete_post_btn" value="Delete" data_id="' . $value->id . '" style="margin-left:10px;">';
        echo '<span>' . $value->sort_order . '</span>';
        echo '</div>';
        echo '</li>';
    }
}
?>

</div>
Ejemplo n.º 10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosts()
 {
     return $this->hasMany(Post::className(), ['status' => 'id']);
 }
Ejemplo n.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPost()
 {
     return $this->hasOne(Post::className(), ['id' => 'post_id']);
 }
Ejemplo n.º 12
0
 public function actionPosts()
 {
     return $this->render('posts', ['dataProvider' => new ActiveDataProvider(['query' => Post::find(), 'pagination' => ['pageSize' => 25]])]);
 }