示例#1
0
 private function listPublicGroups($offset)
 {
     $sql = "SELECT * FROM groups WHERE active=1 AND type <> 'private' ";
     require_once FRAMEWORK_PATH . 'lib/pagination/pagination.class.php';
     $pagination = new Pagination($this->registry);
     $pagination->setQuery($sql);
     $pagination->setOffset($offset);
     $pagination->setLimit(20);
     $pagination->setMethod('cache');
     $pagination->generatePagination();
     if ($pagination->getNumRowsPage() == 0) {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'groups/no-public.tpl.php', 'footer.tpl.php');
     } else {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'groups/public.tpl.php', 'footer.tpl.php');
         $this->registry->getObject('template')->getPage()->addTag('groups', array('SQL', $pagination->getCache()));
         $this->registry->getObject('template')->getPage()->addTag('page_number', $pagination->getCurrentPage());
         $this->registry->getObject('template')->getPage()->addTag('num_pages', $pagination->getNumPages());
         if ($pagination->isFirst()) {
             $this->registry->getObject('template')->getPage()->addTag('first', '');
             $this->registry->getObject('template')->getPage()->addTag('previous', '');
         } else {
             $this->registry->getObject('template')->getPage()->addTag('first', "<a href='groups/'>First page</a>");
             $this->registry->getObject('template')->getPage()->addTag('previous', "<a href='groups/" . ($pagination->getCurrentPage() - 2) . "'>Previous page</a>");
         }
         if ($pagination->isLast()) {
             $this->registry->getObject('template')->getPage()->addTag('next', '');
             $this->registry->getObject('template')->getPage()->addTag('last', '');
         } else {
             $this->registry->getObject('template')->getPage()->addTag('first', "<a href='groups/" . $pagination->getCurrentPage() . "'>Next page</a>");
             $this->registry->getObject('template')->getPage()->addTag('previous', "<a href='groups/" . ($pagination->getNumPages() - 1) . "'>Last page</a>");
         }
     }
 }
示例#2
0
 /**
  * Search for members based on their name
  * @param String $filter name
  * @param int $offset the offset
  * @return Object pagination object
  */
 public function filterMembersByName($filter = '', $offset = 0)
 {
     $filter = $this->registry->getObject('db')->sanitizeData(urldecode($filter));
     require_once FRAMEWORK_PATH . 'lib/pagination/pagination.class.php';
     $paginatedMembers = new Pagination($this->registry);
     $paginatedMembers->setLimit(25);
     $paginatedMembers->setOffset($offset);
     $query = "SELECT u.ID, u.username, p.name, p.dino_name, p.dino_gender, p.dino_breed FROM users u, profile p WHERE p.user_id=u.ID AND u.active=1 AND u.banned=0 AND u.deleted=0 AND p.name LIKE'%" . $filter . "%' ORDER BY p.name ASC";
     $paginatedMembers->setQuery($query);
     $paginatedMembers->setMethod('cache');
     $paginatedMembers->generatePagination();
     return $paginatedMembers;
 }