public function actionArticlemanger()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $query = Article::find();
     $pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('addTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$articleManger_view, ['countries' => $countries, 'pagination' => $pagination]);
 }
 public function actionIndex()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $query = Article::find()->where(['categoryId' => Variable::$articleCat_type_service]);
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('addTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$serviceIndex_view, ['countries' => $countries, 'pagination' => $pagination]);
 }
Exemple #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Article::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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, 'user_id' => $this->user_id, 'status' => $this->status, 'category_id' => $this->category_id, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
 public function actionLiftobject()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $countries = Article::find()->where(['in', 'categoryId', [Variable::$articleCat_type_good, Variable::$articleCat_type_nutrition, Variable::$articleCat_type_people]])->all();
     return $this->render(Variable::$liftObject_view, ['countries' => $countries]);
 }
Exemple #5
0
        $has_parent_id = Category::find()->where(['parent_id' => $V['id'], 'status' => 1])->asArray()->all();
        //var_dump($has_parent_id);exit;
        $left_second = array();
        if ($has_parent_id) {
            foreach ($has_parent_id as $K1 => $V1) {
                $left_second[] = Category::find()->where(['id' => $V1['id'], 'status' => 1])->asArray()->all();
            }
        }
        if (count($left_second) > 0) {
            $temp = Article::find()->where(['category_id' => $V['id'], 'status' => 1])->asArray()->all();
            foreach ($left_second as $K_slice => $V_slice) {
                $temp = array_merge($temp, $left_second[$K_slice]);
            }
            $left[] = $temp;
        } else {
            $left[] = Article::find()->where(['category_id' => $V['id'], 'status' => 1])->asArray()->all();
        }
    }
} catch (ErrorException $e) {
    $left = array();
}
?>
<style>
	body{
	 background:#fff;
	}
	 #header {
	  border-bottom: 1px solid #dcdcdc;
    }
</style>
Exemple #6
0
 /**
  * 根据分类查找文章列表
  * @param $title
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function get_category_article($title)
 {
     $category = Category::find()->where(['title' => $title, 'status' => Category::STATUS_ACTIVE])->one();
     if ($category !== null) {
         $cid = $category->id;
         $articles = Article::find()->select(['title', 'intro', 'content', 'logo', 'create_at'])->where(['category_id' => $cid, 'status' => 1])->asArray()->all();
         if ($articles !== null) {
             $data = array('list' => $articles);
             $return_array = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return_array;
         } else {
             $return_array = array('errorNum' => '1', 'errorMsg' => '暂无数据', 'data' => null);
             return $return_array;
         }
     } else {
         $return_array = array('errorNum' => '1', 'errorMsg' => '分类信息不存在', 'data' => null);
         return $return_array;
     }
 }
Exemple #7
0
 /**
  * 判定用户是否有未读消息
  * @param $uid
  * @return array
  */
 public static function is_exit_msg($uid)
 {
     $all_num = Article::find()->select(['id'])->where(['category_id' => '49', 'status' => Article::STATUS_ACTIVE])->asArray()->all();
     $msg_arr = array();
     if ($all_num) {
         foreach ($all_num as $key => $value) {
             $msg_arr[$key] = $value['id'];
         }
     }
     return self::is_msg($msg_arr, $uid);
 }