예제 #1
0
 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();
 }
예제 #2
0
 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);
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }