Ejemplo n.º 1
0
 function showResults($q, $page)
 {
     $user_group = new User_group();
     $user_group->limit(($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1);
     $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
     foreach ($wheres as $where) {
         $where_q = "{$where} like '%" . trim($user_group->escape($q), '\'') . '%\'';
         $user_group->whereAdd($where_q, 'OR');
     }
     $cnt = $user_group->find();
     if ($cnt > 0) {
         $terms = preg_split('/[\\s,]+/', $q);
         $results = new GroupSearchResults($user_group, $terms, $this);
         $results->show();
         $user_group->free();
         $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE, $page, 'groupsearch', array('q' => $q));
     } else {
         $this->element('p', 'error', _('No results.'));
         $this->searchSuggestions($q);
         if (common_logged_in()) {
             $message = _('If you can\'t find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
         } else {
             $message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
         }
         $this->elementStart('div', 'guide');
         $this->raw(common_markup_to_html($message));
         $this->elementEnd('div');
         $user_group->free();
     }
 }
Ejemplo n.º 2
0
 function showResults($q, $page)
 {
     $user_group = new User_group();
     $user_group->limit(($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1);
     $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
     foreach ($wheres as $where) {
         $where_q = "{$where} like '%" . trim($user_group->escape($q), '\'') . '%\'';
         $user_group->whereAdd($where_q, 'OR');
     }
     $cnt = $user_group->find();
     if ($cnt > 0) {
         $terms = preg_split('/[\\s,]+/', $q);
         $results = new GroupSearchResults($user_group, $terms, $this);
         $results->show();
     } else {
         $this->element('p', 'error', _('No results'));
     }
     $user_group->free();
     $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE, $page, 'groupsearch', array('q' => $q));
 }