Пример #1
0
 /**
  * Show results
  *
  * @param string  $q    search query
  * @param integer $page page number
  *
  * @return void
  */
 function showResults($q, $page)
 {
     $notice = new Notice();
     $search_engine = $notice->getSearchEngine('notice');
     $search_engine->set_sort_mode('chron');
     // Ask for an extra to see if there's more.
     $search_engine->limit(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     if (false === $search_engine->query($q)) {
         $cnt = 0;
     } else {
         $cnt = $notice->find();
     }
     if ($cnt === 0) {
         $this->element('p', 'error', _('No results.'));
         $this->searchSuggestions($q);
         if (common_logged_in()) {
             $message = sprintf(_('Be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
         } else {
             $message = sprintf(_('Why not [register an account](%%%%action.register%%%%) and be the first to [post on this topic](%%%%action.newnotice%%%%?status_textarea=%s)!'), urlencode($q));
         }
         $this->elementStart('div', 'guide');
         $this->raw(common_markup_to_html($message));
         $this->elementEnd('div');
         return;
     }
     $terms = preg_split('/[\\s,]+/', $q);
     $nl = new SearchNoticeList($notice, $this, $terms);
     $cnt = $nl->show();
     $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'noticesearch', array('q' => $q));
 }
Пример #2
0
 /**
  * Show results
  *
  * @param string  $q    search query
  * @param integer $page page number
  *
  * @return void
  */
 function showResults($q, $page)
 {
     if (Event::handle('StartNoticeSearchShowResults', array($this, $q, $this->notice))) {
         if ($this->notice->N === 0) {
             $this->showEmptyResults($q, $page);
         } else {
             $terms = preg_split('/[\\s,]+/', $q);
             $nl = new SearchNoticeList($this->notice, $this, $terms);
             $cnt = $nl->show();
             $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'noticesearch', array('q' => $q));
         }
         Event::handle('EndNoticeSearchShowResults', array($this, $q, $this->notice));
     }
 }
Пример #3
0
 /**
  * Show results
  *
  * @param string  $q    search query
  * @param integer $page page number
  *
  * @return void
  */
 function showResults($q, $page)
 {
     $notice = new Notice();
     $search_engine = $notice->getSearchEngine('identica_notices');
     $search_engine->set_sort_mode('chron');
     // Ask for an extra to see if there's more.
     $search_engine->limit(($page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     if (false === $search_engine->query($q)) {
         $cnt = 0;
     } else {
         $cnt = $notice->find();
     }
     if ($cnt === 0) {
         $this->element('p', 'error', _('No results'));
         return;
     }
     $terms = preg_split('/[\\s,]+/', $q);
     $nl = new SearchNoticeList($notice, $this, $terms);
     $cnt = $nl->show();
     $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'noticesearch', array('q' => $q));
 }