Esempio n. 1
0
 public function actionSave_post_sort_order()
 {
     if (Yii::$app->request->isAjax) {
         $data = $_POST['data'];
         $page = $_POST['page'];
         if (!empty($data)) {
             $i = 1;
             foreach ($data as $key) {
                 $Post = Post::find()->where(['page_id' => $page, 'id' => $key])->one();
                 if (!empty($Post)) {
                     $Post->sort_order = $i;
                     $Post->save();
                 }
                 $i++;
             }
             $response['result'] = 'success';
             $response['msg'] = 'Sort Order successfully saved.';
             $response['post_list'] = $this->renderAjax('list_of_post', ['page_id' => $page]);
         } else {
             $response['result'] = 'error';
             $response['msg'] = 'Error saving sort order.';
         }
         return json_encode($response);
     }
 }
Esempio n. 2
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;
 }
Esempio 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]);
     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;
 }
Esempio 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(['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;
 }
Esempio n. 5
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;
 }
 /**
  * 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;
 }
Esempio n. 7
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $PageSelfRels_model_q = PageSelfRels::find()->where(['page_id' => $id])->all();
     $Page_cat_rel = PageCategoryRel::find()->where(['page_id' => $id])->one();
     $model->category = $Page_cat_rel->category_id;
     $PageImageRel_model = new PageImageRel();
     $PageCategoryRel_model = new PageCategoryRel();
     $posts = Post::find()->where(['page_id' => $id])->all();
     $_SESSION['KCFINDER']['disabled'] = false;
     // enables the file browser in the admin
     $_SESSION['KCFINDER']['uploadURL'] = Url::base() . "/kcupload/";
     // URL for the uploads folder
     $_SESSION['KCFINDER']['uploadDir'] = Yii::getAlias('@app') . "/web/kcupload/";
     // path to the uploads folder
     if (empty($PageSelfRels_model_q)) {
         $PageSelfRels_model = new PageSelfRels();
     } else {
         $PageSelfRels_model = new PageSelfRels();
         $PageSelfRels_model->parent_page_id = ArrayHelper::getColumn($PageSelfRels_model_q, 'parent_page_id');
     }
     $image_rel_model = PageImageRel::find()->where(['page_id' => $id])->orderBy('sort_order asc')->all();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $PageCategoryRel_model->deleteAll(['page_id' => $id]);
             $PageCategoryRel_model->page_id = $model->id;
             $PageCategoryRel_model->category_id = $model->category;
             $PageCategoryRel_model->save();
             $PageSelfRels_model->page_id = $model->id;
             if (empty($PageSelfRels_model->parent_page_id)) {
                 PageSelfRels::deleteAll(['page_id' => $PageSelfRels_model->page_id]);
                 $PageSelfRels_model->parent_page_id = 0;
                 $PageSelfRels_model->save();
             } else {
                 Page::update_page_self_rel($PageSelfRels_model);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             echo '<pre>';
             var_dump($_POST['Page']);
             var_dump($model->getErrors());
         }
     }
     $breadcumb = array_reverse(Page::get_breadcumb($id));
     return $this->render('update', ['model' => $model, 'PageSelfRels_model' => $PageSelfRels_model, 'image_rel_model' => $image_rel_model, 'breadcumb' => $breadcumb, 'PageImageRel_model' => $PageImageRel_model, 'posts' => $posts]);
 }
Esempio n. 8
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Esempio 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>
Esempio n. 10
0
 public function actionPosts()
 {
     return $this->render('posts', ['dataProvider' => new ActiveDataProvider(['query' => Post::find(), 'pagination' => ['pageSize' => 25]])]);
 }