]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/noticesearch.php
generate an etag for shownotice
[quix0rs-gnu-social.git] / actions / noticesearch.php
index c257ecec56ebf23b4b9dda4c357824a2f192790a..96e4d777fa3aca01c86ea3a0d39285535e014ffd 100644 (file)
@@ -20,7 +20,6 @@
 if (!defined('LACONICA')) { exit(1); }
 
 require_once(INSTALLDIR.'/lib/searchaction.php');
-define('NOTICES_PER_PAGE', 20);
 
 # XXX common parent for people and content search?
 
@@ -40,14 +39,19 @@ class NoticesearchAction extends SearchAction {
 
                # lcase it for comparison
                $q = strtolower($q);
-               $notice->whereAdd('MATCH(content) against (\''.addslashes($q).'\')');
 
-               # Ask for an extra to see if there's more.
-
-               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
-               $cnt = $notice->find();
+        $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) {
                        $terms = preg_split('/[\s,]+/', $q);
                        common_element_start('ul', array('id' => 'notices'));
@@ -87,6 +91,7 @@ class NoticesearchAction extends SearchAction {
                $profile = $notice->getProfile();
                if (!$profile) {
                        common_log_db_error($notice, 'SELECT', __FILE__);
+                       $this->server_error(_('Notice without matching profile'));
                        return;
                }
                # XXX: RDFa
@@ -136,6 +141,8 @@ class NoticesearchAction extends SearchAction {
                                                                   'onclick' => 'doreply("'.$profile->nickname.'"); return false',
                                                                   'title' => _('reply'),
                                                                   'class' => 'replybutton'));
+               common_hidden('posttoken', common_session_token());
+               
                common_raw('→');
                common_element_end('a');
                common_element_end('p');