コード例 #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 {
         // TRANS: Text on page where groups can be searched if no results were found for a query.
         $this->element('p', 'error', _('No results.'));
         $this->searchSuggestions($q);
         if (common_logged_in()) {
             // TRANS: Additional text on page where groups can be searched if no results were found for a query for a logged in user.
             // TRANS: This message contains Markdown links in the form [link text](link).
             $message = _('If you cannot find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
         } else {
             // TRANS: Additional text on page where groups can be searched if no results were found for a query for a not logged in user.
             // TRANS: This message contains Markdown links in the form [link text](link).
             $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();
     }
 }
コード例 #2
0
ファイル: groupsearch.php プロジェクト: Br3nda/laconica
 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));
 }