X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnoticesearch.php;h=ee7bb86f40a28f7fac5aba0dc8a848a4268c68d8;hb=01a4ab30dc1dfbf4d6ee6a42a7f8f45a1a42894d;hp=357e8ba192e15bcbfad67ea7eb59599a324ffe97;hpb=dcca04fd6fc08e3822d09f24117def6a7b872ae7;p=quix0rs-gnu-social.git diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 357e8ba192..ee7bb86f40 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -63,6 +63,21 @@ class NoticesearchAction extends SearchAction 303); } + if (!empty($this->q)) { + + $profile = Profile::current(); + $stream = new SearchNoticeStream($this->q, $profile); + $page = $this->trimmed('page'); + + if (empty($page)) { + $page = 1; + } else { + $page = (int)$page; + } + + $this->notice = $stream->getNotices((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); + } + common_set_returnto($this->selfUrl()); return true; @@ -117,18 +132,25 @@ class NoticesearchAction extends SearchAction */ 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 (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)); } - if ($cnt === 0) { + } + + function showEmptyResults($q, $page) + { // TRANS: Text for notice search results is the query had no results. $this->element('p', 'error', _('No results.')); @@ -148,15 +170,6 @@ class NoticesearchAction extends SearchAction $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); return; - } - if (Event::handle('StartNoticeSearchShowResults', array($this, $q, $notice))) { - $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)); - Event::handle('EndNoticeSearchShowResults', array($this, $q, $notice)); - } } function showScripts() @@ -189,7 +202,7 @@ class SearchNoticeListItem extends NoticeListItem { function showContent() { // FIXME: URL, image, video, audio - $this->out->elementStart('p', array('class' => 'entry-content')); + $this->out->elementStart('p', array('class' => 'e-content')); if ($this->notice->rendered) { $this->out->raw($this->highlight($this->notice->rendered, $this->terms)); } else {