X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Frssaction.php;h=dac7fa4606e8d4fa5563f4229b10fc8a22b5a275;hb=8a0f67b773c0c3fe7c3642730fdb184f288ba45d;hp=cd4c8b51c4810894ffaa3f675c3a94ca66b20fef;hpb=4463768baed036b487d473a60b30f0c314ee1673;p=quix0rs-gnu-social.git diff --git a/lib/rssaction.php b/lib/rssaction.php index cd4c8b51c4..dac7fa4606 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -34,7 +34,7 @@ define('DEFAULT_RSS_LIMIT', 48); class Rss10Action extends Action { - # This will contain the details of each feed item's author and be used to generate SIOC data. + // This will contain the details of each feed item's author and be used to generate SIOC data. var $creators = array(); var $limit = DEFAULT_RSS_LIMIT; @@ -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); } @@ -88,10 +88,10 @@ class Rss10Action extends Action if (common_config('site', 'private')) { if (!isset($_SERVER['PHP_AUTH_USER'])) { - # This header makes basic auth go + // This header makes basic auth go header('WWW-Authenticate: Basic realm="StatusNet RSS"'); - # If the user hits cancel -- bam! + // If the user hits cancel -- bam! $this->show_basic_auth_error(); return; } else { @@ -99,7 +99,7 @@ class Rss10Action extends Action $password = $_SERVER['PHP_AUTH_PW']; if (!common_check_user($nickname, $password)) { - # basic authentication failed + // basic authentication failed list($proxy, $ip) = common_client_ip(); common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip."); @@ -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, @@ -270,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; } @@ -285,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)); } @@ -358,6 +361,8 @@ 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' =>