]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twitapisearchatom.php
add bookmarklet to main help
[quix0rs-gnu-social.git] / actions / twitapisearchatom.php
index 3ab82bfb646949d71142eb8e2f24bb186ebfcffd..eb9ab5d8e9425add9688045321eb62aaa3ba7b05 100644 (file)
@@ -52,7 +52,6 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
 class TwitapisearchatomAction extends TwitterapiAction
 {
 
-    var $notices;
     var $cnt;
     var $query;
     var $lang;
@@ -156,6 +155,7 @@ class TwitapisearchatomAction extends TwitterapiAction
     {
         // TODO: Support search operators like from: and to:, boolean, etc.
 
+        $notices = array();
         $notice = new Notice();
 
         // lcase it for comparison
@@ -218,7 +218,6 @@ class TwitapisearchatomAction extends TwitterapiAction
     {
         // TODO: A9 OpenSearch stuff like search.twitter.com?
 
-        $lang     = common_config('site', 'language');
         $server   = common_config('site', 'server');
         $sitename = common_config('site', 'name');
 
@@ -226,11 +225,15 @@ class TwitapisearchatomAction extends TwitterapiAction
 
         $this->elementStart('feed',
             array('xmlns' => 'http://www.w3.org/2005/Atom',
+
+                             // XXX: xmlns:twitter causes Atom validation to fail
+                             // It's used for the source attr on notices
+
                              'xmlns:twitter' => 'http://api.twitter.com/',
-                             'xml:lang' => $lang));
+                             'xml:lang' => 'en-US')); // XXX Other locales ?
 
-        $year = date('Y');
-        $this->element('id', null, "tag:$server,$year:search/$server");
+        $taguribase = common_config('integration', 'taguri');
+        $this->element('id', null, "tag:$taguribase:search/$server");
 
         $site_uri = common_path(false);
 
@@ -251,13 +254,18 @@ class TwitapisearchatomAction extends TwitterapiAction
 
         // self link
 
-        $self_uri = $search_uri . '&page=' . $this->page;
+        $self_uri = $search_uri;
+        $self_uri .= ($this->page > 1) ? '&page=' . $this->page : '';
 
         $this->element('link', array('type' => 'application/atom+xml',
                                      'rel'  => 'self',
                                      'href' => $self_uri));
 
         $this->element('title', null, "$this->query - $sitename Search");
+        $this->element('updated', null, common_date_iso8601('now'));
+
+        // XXX: The below "rel" links are not valid Atom, but it's what
+        // Twitter does...
 
         // refresh link
 
@@ -308,18 +316,19 @@ class TwitapisearchatomAction extends TwitterapiAction
 
         $this->elementStart('entry');
 
-        $year = date('Y', strtotime($notice->created));
+        $taguribase = common_config('integration', 'taguri');
 
-        $this->element('id', null, "tag:$server,$year:$notice->id");
+        $this->element('id', null, "tag:$taguribase:$notice->id");
         $this->element('published', null, common_date_w3dtf($notice->created));
         $this->element('link', array('type' => 'text/html',
                                      'rel'  => 'alternate',
                                      'href' => $nurl));
         $this->element('title', null, common_xml_safe_str(trim($notice->content)));
-        $this->element('content', array('type' => 'text/html'), $notice->rendered);
+        $this->element('content', array('type' => 'html'), $notice->rendered);
         $this->element('updated', null, common_date_w3dtf($notice->created));
         $this->element('link', array('type' => 'image/png',
-                                     'rel' => 'image',
+                                     // XXX: Twitter uses rel="image" (not valid)
+                                     'rel' => 'related',
                                      'href' => $profile->avatarUrl()));
 
         // TODO: Here is where we'd put in a link to an atom feed for threads