/**
  * Display the list of paginated Posts (draft and published)
  */
 function home()
 {
     Doo::loadHelper('DooPager');
     Doo::loadModel('Post');
     $p = new Post();
     //if default, no sorting defined by user, show this as pager link
     if ($this->sortField == 'createtime' && $this->orderType == 'desc') {
         $pager = new DooPager(Doo::conf()->APP_URL . 'admin/post/page', $p->count(), 6, 10);
     } else {
         $pager = new DooPager(Doo::conf()->APP_URL . "admin/post/sort/{$this->sortField}/{$this->orderType}/page", $p->count(), 6, 10);
     }
     if (isset($this->params['pindex'])) {
         $pager->paginate(intval($this->params['pindex']));
     } else {
         $pager->paginate(1);
     }
     $data['rootUrl'] = Doo::conf()->APP_URL;
     $data['pager'] = $pager->output;
     //Order by ASC or DESC
     if ($this->orderType == 'desc') {
         $data['posts'] = $p->limit($pager->limit, null, $this->sortField, array('select' => 'id,createtime,status,title,totalcomment'));
         $data['order'] = 'asc';
     } else {
         $data['posts'] = $p->limit($pager->limit, $this->sortField, null, array('select' => 'id,createtime,status,title,totalcomment'));
         $data['order'] = 'desc';
     }
     $this->render('admin', $data);
 }
Esempio n. 2
0
 public function getMovies()
 {
     Doo::loadClass('Movie');
     $this->dbapi = new Movie();
     Doo::loadHelper('DooPager');
     $mtype = $this->ppv_cat_code;
     if ($_POST['mtype'] == 'svod') {
         $mtype = $this->svod_cat_code;
     }
     $pager = new DooPager(Doo::conf()->APP_URL . "ajax/movie", count($this->dbapi->get_movie_by_id($mtype)), 10, 10);
     if (isset($this->params['page'])) {
         $pager->paginate(intval($this->params['page']));
     } else {
         $pager->paginate(1);
     }
     $data['pager'] = $pager->output;
     list($start, $limit) = explode(',', $pager->limit);
     $movies = $this->dbapi->get_movie_by_id($mtype, (int) $start, (int) $limit, $orderby, $order);
     $this->setContentType('json');
     echo json_encode($movies);
 }
 /**
  * This shows the list of Posts filter by a Tag name
  * Show error if the tag name has no Posts
  */
 function getTag()
 {
     Doo::loadHelper('DooPager');
     Doo::loadModel('Post');
     Doo::loadModel('Tag');
     $p = new Post();
     $p->status = 1;
     //published post only
     $tag = new Tag();
     $tag->name = trim(urldecode($this->params['name']));
     $totalPosts = $tag->relatePost(array('select' => 'COUNT(tag.id) AS total', 'asArray' => true));
     $totalPosts = $totalPosts[0]['total'];
     if ($totalPosts < 1) {
         return 404;
     }
     $pager = new DooPager(Doo::conf()->APP_URL . "tag/{$tag->name}/page", $totalPosts, 4, 10);
     if (isset($this->params['pindex'])) {
         $pager->paginate(intval($this->params['pindex']));
     } else {
         $pager->paginate(1);
     }
     //limit post and filter by the related Tag name
     $this->data['posts'] = $p->relateTag(array('limit' => $pager->limit, 'desc' => 'post.createtime', 'where' => 'tag.name=?', 'param' => array($tag->name), 'match' => false));
     $this->data['pager'] = $pager->output;
     $this->data['rootUrl'] = Doo::conf()->APP_URL;
     //prepare sidebar data, tags and archive list
     $this->prepareSidebar();
     $this->render('index', $this->data);
 }