public static function getContents($where = null, $orderBy = null, $limit = 10, $options = []) { $query = Content::find(); if (!empty($where)) { $query->andWhere($where); } if (isset($options['is_pic'])) { $query->andWhere(['!=', 'thumb', '']); } if (isset($options['content_type'])) { $type = null; if (is_string($options['content_type'])) { $type = $options['content_type']; } else { $moduleId = LuLu::$app->controller->module->id; if ($moduleId !== 'app-frontend') { $type = $moduleId; } } if (!empty($type)) { $query->andWhere(['=', 'content_type', $type]); } } if (empty($orderBy)) { $orderBy = 'created_at desc'; } $query->orderBy($orderBy); if ($limit > 0) { $query->limit($limit); } return $query->all(); }
public function actionList() { $takonomy = LuLu::getGetValue('takonomy'); $takonomyModel = Takonomy::getOneOrDefault($takonomy); $query = Content::find(); $query->where(['content_type' => $this->content_type]); $query->andFilterWhere(['takonomy_id' => $takonomy]); $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]); $locals['takonomyModel'] = $takonomyModel; return $this->render('list_default', $locals); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Content::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([]); $query->andFilterWhere(['like', 'user_name', $this->user_name])->andFilterWhere(['like', 'last_user_name', $this->last_user_name])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'content_type', $this->content_type])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'summary', $this->summary])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'url_alias', $this->url_alias]); return $dataProvider; }
public function actionList($taxonomy = -1) { $query = Content::find(); $query->where(['content_type' => $this->content_type]); if ($taxonomy !== -1) { $query->andFilterWhere(['taxonomy_id' => $taxonomy]); } $taxonomyModel = $this->taxonomyService->getTaxonomyById($taxonomy); $vars = $this->getListVars($taxonomyModel); $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => $vars['pageSize']]); $locals['taxonomyModel'] = $taxonomyModel; LuLu::setViewParam(['taxonomyModel' => $taxonomyModel]); $this->layout = $vars['layout']; return $this->render($vars['view'], $locals); }
public function actionIndex() { $taxonomy = LuLu::getGetValue('taxonomy'); $query = Content::find(); $query->where(['content_type' => $this->content_type]); $query->andFilterWhere(['taxonomy_id' => $taxonomy]); if ($taxonomy === null) { $taxonomyModel = Taxonomy::findOne(['id' => $taxonomy]); } else { $taxonomyModel = ['id' => null, 'name' => '所有']; } $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]); $locals['taxonomyModel'] = $taxonomyModel; return $this->render('index', $locals); }