Esempio n. 1
0
 /**
  * Filter action
  *
  * This action is called through ajax on filter change like tags & order
  *
  * @access public
  * @return void
  *
  * @author Ole Aass <*****@*****.**>
  */
 public function filterAction()
 {
     if ($this->request->isPost() && $this->request->isAjax()) {
         $tags = $this->request->getPost('tags');
         $currentPage = $this->request->getPost('page', 'int');
         $counter = $this->request->getPost('counter', 'int');
         $projects = new Projects();
         if (empty($tags)) {
             $list = $projects->findAll();
         } else {
             $tags = array_keys($tags);
             $list = $projects->findByTags($tags);
         }
         $page = $projects->paginate($list, $currentPage, $counter);
         $page->counter = $counter;
         $this->view->setVar('page', $page);
         $this->view->partial('index/projects');
     }
 }
 /**
  * Paginate projects by group
  *
  * @param ProjectGroup $group
  * @param integer $page
  * @param integer $per_page
  * @return array
  */
 function paginateByGroup($group, $page = 1, $per_page = 10)
 {
     return Projects::paginate(array('conditions' => array('group_id = ? AND type = ?', $group->getId(), PROJECT_TYPE_NORMAL), 'order_by' => 'created_on DESC'), $page, $per_page);
 }