]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapisearchatom.php
Regression fix for Recaptcha on SSL registration page; their API is served on a diffe...
[quix0rs-gnu-social.git] / actions / twitapisearchatom.php
index 7d618c471fe00dbc946a682b18383799176b73b4..51e8a8881bf2730646da314f0ebcb16729465c07 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/api.php';
-
 /**
  * Action for outputting search results in Twitter compatible Atom
  * format.
@@ -71,7 +69,7 @@ class TwitapisearchatomAction extends ApiAction
      * @see Action::__construct
      */
 
-    function __construct($output='php://output', $indent=true)
+    function __construct($output='php://output', $indent=null)
     {
         parent::__construct($output, $indent);
     }
@@ -161,7 +159,7 @@ class TwitapisearchatomAction extends ApiAction
         // lcase it for comparison
         $q = strtolower($this->query);
 
-        $search_engine = $notice->getSearchEngine('identica_notices');
+        $search_engine = $notice->getSearchEngine('notice');
         $search_engine->set_sort_mode('chron');
         $search_engine->limit(($this->page - 1) * $this->rpp,
             $this->rpp + 1, true);
@@ -208,7 +206,14 @@ class TwitapisearchatomAction extends ApiAction
         $this->showFeed();
 
         foreach ($notices as $n) {
-            $this->showEntry($n);
+
+            $profile = $n->getProfile();
+
+            // Don't show notices from deleted users
+
+            if (!empty($profile)) {
+                $this->showEntry($n);
+            }
         }
 
         $this->endAtom();
@@ -238,7 +243,7 @@ class TwitapisearchatomAction extends ApiAction
                              'xmlns:twitter' => 'http://api.twitter.com/',
                              'xml:lang' => 'en-US')); // XXX Other locales ?
 
-        $taguribase = common_config('integration', 'taguri');
+        $taguribase = TagURI::base();
         $this->element('id', null, "tag:$taguribase:search/$server");
 
         $site_uri = common_path(false);
@@ -322,7 +327,7 @@ class TwitapisearchatomAction extends ApiAction
 
         $this->elementStart('entry');
 
-        $taguribase = common_config('integration', 'taguri');
+        $taguribase = TagURI::base();
 
         $this->element('id', null, "tag:$taguribase:$notice->id");
         $this->element('published', null, common_date_w3dtf($notice->created));
@@ -337,10 +342,24 @@ class TwitapisearchatomAction extends ApiAction
                                      'rel' => 'related',
                                      'href' => $profile->avatarUrl()));
 
-        // TODO: Here is where we'd put in a link to an atom feed for threads
+        // @todo: Here is where we'd put in a link to an atom feed for threads
+
+        $source = null;
+
+        $ns = $notice->getSource();
+        if ($ns) {
+            if (!empty($ns->name) && !empty($ns->url)) {
+                $source = '<a href="'
+                  . htmlspecialchars($ns->url)
+                  . '" rel="nofollow">'
+                  . htmlspecialchars($ns->name)
+                  . '</a>';
+            } else {
+                $source = $ns->code;
+            }
+        }
 
-        $this->element("twitter:source", null,
-            htmlentities($this->sourceLink($notice->source)));
+        $this->element("twitter:source", null, $source);
 
         $this->elementStart('author');