]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/rss10action.php
Merge remote-tracking branch 'upstream/nightly' into nightly
[quix0rs-gnu-social.git] / lib / rss10action.php
index 8d73bec1d96a8508871c5c621880898cedf35a2e..6940ab4319590d34af19d63cea6edb7641e6b843 100644 (file)
@@ -50,7 +50,7 @@ class Rss10Action extends ManagedAction
     {
         $this->limit = $this->int('limit');
 
-        if ($this->limit == 0) {
+        if (empty($this->limit)) {
             $this->limit = DEFAULT_RSS_LIMIT;
         }
 
@@ -73,10 +73,19 @@ class Rss10Action extends ManagedAction
 
                     common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
                     $this->show_basic_auth_error();
-                    return;
+                    // the above calls 'exit'
                 }
             }
         }
+
+        $this->doStreamPreparation();
+
+        $this->notices = $this->getNotices($this->limit);
+    }
+
+    protected function doStreamPreparation()
+    {
+        // for example if we need to set $this->target or something
     }
 
     function show_basic_auth_error()
@@ -98,7 +107,7 @@ class Rss10Action extends ManagedAction
      * @return array an array of Notice objects sorted in reverse chron
      */
 
-    function getNotices()
+    protected function getNotices()
     {
         return array();
     }
@@ -200,22 +209,26 @@ class Rss10Action extends ManagedAction
         $this->element('title', null, $title);
         $this->element('link', null, $nurl);
         $this->element('description', null, $profile->nickname."'s status on ".common_exact_date($notice->created));
-        if ($notice->rendered) {
-            $this->element('content:encoded', null, common_xml_safe_str($notice->rendered));
+        if ($notice->getRendered()) {
+            $this->element('content:encoded', null, common_xml_safe_str($notice->getRendered()));
         }
         $this->element('dc:date', null, common_date_w3dtf($notice->created));
         $this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname);
         $this->element('foaf:maker', array('rdf:resource' => $creator_uri));
         $this->element('sioc:has_creator', array('rdf:resource' => $creator_uri.'#acct'));
-        $location = $notice->getLocation();
-        if ($location && isset($location->lat) && isset($location->lon)) {
-            $location_uri = $location->getRdfURL();
-            $attrs = array('geo:lat' => $location->lat,
-                'geo:long' => $location->lon);
-            if (strlen($location_uri)) {
-                $attrs['rdf:resource'] = $location_uri;
+        try {
+            $location = Notice_location::locFromStored($notice);
+            if (isset($location->lat) && isset($location->lon)) {
+                $location_uri = $location->getRdfURL();
+                $attrs = array('geo:lat' => $location->lat,
+                               'geo:long' => $location->lon);
+                if (strlen($location_uri)) {
+                    $attrs['rdf:resource'] = $location_uri;
+                }
+                $this->element('statusnet:origin', $attrs);
             }
-            $this->element('statusnet:origin', $attrs);
+        } catch (ServerException $e) {
+            // No result, so no location data
         }
         $this->element('statusnet:postIcon', array('rdf:resource' => $profile->avatarUrl()));
         $this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));