diff options
author | Sarven Capadisli <csarven@status.net> | 2009-11-19 17:35:45 +0000 |
---|---|---|
committer | Sarven Capadisli <csarven@status.net> | 2009-11-19 17:35:45 +0000 |
commit | 318dd70de888513a5b0404c5eb1cdbb3c6e8e760 (patch) | |
tree | 9fbd3a33126978200ce5854ec87067935b592417 /lib | |
parent | 60391d0b96579aff2ee105ab64a89ffdb225bbdc (diff) | |
parent | ee22b2ccf9819cefba54ef38c6a57829c7d3fa73 (diff) |
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r-- | lib/location.php | 24 | ||||
-rw-r--r-- | lib/rssaction.php | 29 |
2 files changed, 42 insertions, 11 deletions
diff --git a/lib/location.php b/lib/location.php index bbfc15a36..191550d6d 100644 --- a/lib/location.php +++ b/lib/location.php @@ -52,6 +52,7 @@ class Location public $location_id; public $location_ns; private $_url; + private $_rdfurl; var $names = array(); @@ -185,4 +186,27 @@ class Location return $url; } + + /** + * Get an URL for this location, suitable for embedding in RDF + * + * @return string URL for this location or NULL + */ + + function getRdfURL() + { + // Keep one cached + + if (is_string($this->_rdfurl)) { + return $this->_rdfurl; + } + + $url = null; + + Event::handle('LocationRdfUrl', array($this, &$url)); + + $this->_rdfurl = $url; + + return $url; + } } diff --git a/lib/rssaction.php b/lib/rssaction.php index faf6bec7d..3b303f73e 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -244,6 +244,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 +270,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 +278,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 +351,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/')); |