]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/rssaction.php
Remove CSRF protection from username/password login and from OpenID login.
[quix0rs-gnu-social.git] / lib / rssaction.php
index 0e84a65e92406fd0b21314954c5808bdada59ac2..f366db97293241a849784956f37ff3063cc12390 100644 (file)
@@ -52,7 +52,7 @@ class Rss10Action extends Action
      * @see Action::__construct
      */
 
-    function __construct($output='php://output', $indent=true)
+    function __construct($output='php://output', $indent=null)
     {
         parent::__construct($output, $indent);
     }
@@ -176,8 +176,16 @@ class Rss10Action extends Action
         $this->showChannel();
         $this->showImage();
 
-        foreach ($this->notices as $n) {
-            $this->showItem($n);
+        if (count($this->notices)) {
+            foreach ($this->notices as $n) {
+                try {
+                    $this->showItem($n);
+                } catch (Exception $e) {
+                    // log exceptions and continue
+                    common_log(LOG_ERR, $e->getMessage());
+                    continue;
+                }
+            }
         }
 
         $this->showCreators();
@@ -203,8 +211,10 @@ class Rss10Action extends Action
         $this->elementStart('items');
         $this->elementStart('rdf:Seq');
 
-        foreach ($this->notices as $notice) {
-            $this->element('rdf:li', array('rdf:resource' => $notice->uri));
+        if (count($this->notices)) {
+            foreach ($this->notices as $notice) {
+                $this->element('rdf:li', array('rdf:resource' => $notice->uri));
+            }
         }
 
         $this->elementEnd('rdf:Seq');
@@ -228,7 +238,7 @@ class Rss10Action extends Action
 
     function showItem($notice)
     {
-        $profile = Profile::staticGet($notice->profile_id);
+        $profile = $notice->getProfile();
         $nurl = common_local_url('shownotice', array('notice' => $notice->id));
         $creator_uri = common_profile_uri($profile);
         $this->elementStart('item', array('rdf:about' => $notice->uri,
@@ -244,6 +254,16 @@ class Rss10Action extends Action
         $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;
+            }
+            $this->element('statusnet:origin', $attrs);
+        }
         $this->element('statusnet:postIcon', array('rdf:resource' => $profile->avatarUrl()));
         $this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
         if ($notice->reply_to) {
@@ -260,14 +280,7 @@ class Rss10Action extends Action
             foreach($attachments as $attachment){
                 $enclosure=$attachment->getEnclosure();
                 if ($enclosure) {
-                    // DO NOT move xmlns declaration to root element. Making it
-                    // the default namespace here improves compatibility with
-                    // real-world feed readers.
-                    $attribs = array(
-                        'rdf:resource' => $enclosure->url,
-                        'url' => $enclosure->url,
-                        'xmlns' => 'http://purl.oclc.org/net/rss_2.0/enc#'
-                        );
+                    $attribs = array('rdf:resource' => $enclosure->url);
                     if ($enclosure->title) {
                         $attribs['dc:title'] = $enclosure->title;
                     }
@@ -275,12 +288,12 @@ class Rss10Action extends Action
                         $attribs['dc:date'] = common_date_w3dtf($enclosure->modified);
                     }
                     if ($enclosure->size) {
-                        $attribs['length'] = $enclosure->size;
+                        $attribs['enc:length'] = $enclosure->size;
                     }
                     if ($enclosure->mimetype) {
-                        $attribs['type'] = $enclosure->mimetype;
+                        $attribs['enc:type'] = $enclosure->mimetype;
                     }
-                    $this->element('enclosure', $attribs);
+                    $this->element('enc:enclosure', $attribs);
                 }
                 $this->element('sioc:links_to', array('rdf:resource'=>$attachment->url));
             }
@@ -348,12 +361,16 @@ class Rss10Action extends Action
                                               'http://commontag.org/ns#',
                                               'xmlns:foaf' =>
                                               'http://xmlns.com/foaf/0.1/',
+                                              'xmlns:enc' =>
+                                              'http://purl.oclc.org/net/rss_2.0/enc#',
                                               'xmlns:sioc' =>
                                               'http://rdfs.org/sioc/ns#',
                                               'xmlns:sioct' =>
                                               'http://rdfs.org/sioc/types#',
                                               'xmlns:rdfs' =>
                                               'http://www.w3.org/2000/01/rdf-schema#',
+                                              'xmlns:geo' =>
+                                              'http://www.w3.org/2003/01/geo/wgs84_pos#',
                                               'xmlns:statusnet' =>
                                               'http://status.net/ont/',
                                               'xmlns' => 'http://purl.org/rss/1.0/'));
@@ -386,7 +403,7 @@ class Rss10Action extends Action
             return null;
         }
 
-        // FIXME: does not handle modified profiles, avatars, deleted notices
+        // FIXME: doesn't handle modified profiles, avatars, deleted notices
 
         return strtotime($this->notices[0]->created);
     }