Beispiel #1
0
 public function get()
 {
     if (($page = $this->input->query('page', 1)) < 1) {
         $page = 1;
     }
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $total = Model::factory('Article')->where('status', '1')->count();
     $this->data['articles'] = Model::factory('Article')->where('status', '1')->order_by_desc('point')->offset($offset)->limit($limit)->find_many();
     $this->data['latest_articles'] = array();
     /**
      * 第一页加载最新的几篇文章
      */
     if ($page == 1) {
         $this->data['latest_articles'] = Model::factory('Article')->where('status', '1')->order_by_desc('created_at')->limit(5)->find_many();
         if ($this->data['latest_articles'] && !$this->input->query('force_latest')) {
             $exists_articles_ids = array();
             foreach ($this->data['articles'] as $article) {
                 $exists_articles_ids[] = $article->id;
             }
             $this->data['latest_articles'] = array_filter($this->data['latest_articles'], function ($article) use($exists_articles_ids) {
                 if (in_array($article->id, $exists_articles_ids)) {
                     return false;
                 }
                 return true;
             });
         }
     }
     $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit);
 }
Beispiel #2
0
 public function get()
 {
     if (($page = $this->input->query('page', 1)) < 1) {
         $page = 1;
     }
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $total = $this->user->diggs()->where('status', '1')->count();
     $this->data['articles'] = $this->user->diggs()->where('status', '1')->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many();
     $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit);
 }
Beispiel #3
0
 public function get()
 {
     if (($page = $this->input->query('page', 1)) < 1) {
         $page = 1;
     }
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $kw = $this->input->query('kw');
     $total = Model::factory('Article')->where('status', '1')->where_like('title', '%' . $this->input->query('kw') . '%')->count();
     $this->data['kw'] = $kw;
     $this->data['articles'] = Model::factory('Article')->where('status', '1')->where_like('title', '%' . $kw . '%')->order_by_desc('point')->offset($offset)->limit($limit)->find_many();
     $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit);
 }
Beispiel #4
0
 public function get()
 {
     if (($page = $this->input->query('page', 1)) < 1) {
         $page = 1;
     }
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $is_read = is_null($this->input->query('read')) ? 0 : 1;
     $this->data['is_read'] = $is_read;
     $type = $is_read ? Notify::READ : Notify::UNREAD;
     $total = $this->user->notifies()->where('status', $type)->count();
     $this->data['notifies'] = $this->user->notifies()->where('status', $type)->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many();
     $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit);
 }
Beispiel #5
0
 public function get()
 {
     if (($page = $this->input->query('page', 1)) < 1) {
         $page = 1;
     }
     $limit = 20;
     $offset = ($page - 1) * $limit;
     $user = $this->user;
     if ($this->params && $this->params['id']) {
         $user = Model::factory('User')->find_one($this->params['id']);
         if (!$user) {
             $this->alert("User is not exists");
         }
         $this->title = $user->name . "'s comments";
     }
     $total = $user->comments()->count();
     $this->data['comments'] = $user->comments()->offset($offset)->limit($limit)->order_by_desc('created_at')->find_many();
     $this->data['page'] = Html::makePage($this->input->uri(), 'page=(:num)', $page, $total, $limit);
 }