]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/noticesearch.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / actions / noticesearch.php
index 4f4c7a05ba35fdd510cf4c9d69f465595b101926..357e8ba192e15bcbfad67ea7eb59599a324ffe97 100644 (file)
@@ -48,10 +48,21 @@ require_once INSTALLDIR.'/lib/searchaction.php';
  */
 class NoticesearchAction extends SearchAction
 {
+    protected $q = null;
+
     function prepare($args)
     {
         parent::prepare($args);
 
+        $this->q = $this->trimmed('q');
+
+        // FIXME: very dependent on tag format
+        if (preg_match('/^#([\pL\pN_\-\.]{1,64})/ue', $this->q)) {
+            common_redirect(common_local_url('tag',
+                                             array('tag' => common_canonical_tag(substr($this->q, 1)))),
+                            303);
+        }
+
         common_set_returnto($this->selfUrl());
 
         return true;
@@ -138,11 +149,14 @@ class NoticesearchAction extends SearchAction
             $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));
+        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()