X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fapiaction.php;h=9fc1a0779916d38722c65fee087998b5aff070d1;hb=040b4b74ef2a2c86da039a93612266a67bb260d8;hp=2af150ab994d6f5bc9c60a849fadf0c7c715be41;hpb=eabae96fb40a51002a90961b3092b38d29b1f5f9;p=quix0rs-gnu-social.git diff --git a/lib/apiaction.php b/lib/apiaction.php index 2af150ab99..9fc1a07799 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -63,7 +63,6 @@ class ApiAction extends Action var $count = null; var $max_id = null; var $since_id = null; - var $since = null; var $access = self::READ_ONLY; // read (default) or read-write @@ -85,7 +84,10 @@ class ApiAction extends Action $this->count = (int)$this->arg('count', 20); $this->max_id = (int)$this->arg('max_id', 0); $this->since_id = (int)$this->arg('since_id', 0); - $this->since = $this->arg('since'); + + if ($this->arg('since')) { + header('X-StatusNet-Warning: since parameter is disabled; use since_id'); + } return true; } @@ -289,11 +291,12 @@ class ApiAction extends Action $twitter_status['attachments'] = array(); foreach ($attachments as $attachment) { - if ($attachment->isEnclosure()) { + $enclosure_o=$attachment->getEnclosure(); + if ($enclosure_o) { $enclosure = array(); - $enclosure['url'] = $attachment->url; - $enclosure['mimetype'] = $attachment->mimetype; - $enclosure['size'] = $attachment->size; + $enclosure['url'] = $enclosure_o->url; + $enclosure['mimetype'] = $enclosure_o->mimetype; + $enclosure['size'] = $enclosure_o->size; $twitter_status['attachments'][] = $enclosure; } } @@ -488,7 +491,7 @@ class ApiAction extends Action $this->showXmlAttachments($twitter_status['attachments']); break; case 'geo': - $this->showGeoRSS($value); + $this->showGeoXML($value); break; case 'retweeted_status': $this->showTwitterXmlStatus($value, 'retweeted_status'); @@ -536,7 +539,7 @@ class ApiAction extends Action } } - function showGeoRSS($geo) + function showGeoXML($geo) { if (empty($geo)) { // empty geo element @@ -548,6 +551,17 @@ class ApiAction extends Action } } + function showGeoRSS($geo) + { + if (!empty($geo)) { + $this->element( + 'georss:point', + null, + $geo['coordinates'][0] . ' ' . $geo['coordinates'][1] + ); + } + } + function showTwitterRssItem($entry) { $this->elementStart('item'); @@ -616,13 +630,25 @@ class ApiAction extends Action $this->endDocument('xml'); } - function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null, $logo=null) + function showRssTimeline($notice, $title, $link, $subtitle, $suplink = null, $logo = null, $self = null) { $this->initDocument('rss'); $this->element('title', null, $title); $this->element('link', null, $link); + + if (!is_null($self)) { + $this->element( + 'atom:link', + array( + 'type' => 'application/rss+xml', + 'href' => $self, + 'rel' => 'self' + ) + ); + } + if (!is_null($suplink)) { // For FriendFeed's SUP protocol $this->element('link', array('xmlns' => 'http://www.w3.org/2005/Atom', @@ -729,8 +755,12 @@ class ApiAction extends Action function showTwitterAtomEntry($entry) { $this->elementStart('entry'); - $this->element('title', null, $entry['title']); - $this->element('content', array('type' => 'html'), $entry['content']); + $this->element('title', null, common_xml_safe_str($entry['title'])); + $this->element( + 'content', + array('type' => 'html'), + common_xml_safe_str($entry['content']) + ); $this->element('id', null, $entry['id']); $this->element('published', null, $entry['published']); $this->element('updated', null, $entry['updated']); @@ -845,7 +875,7 @@ class ApiAction extends Action $this->initDocument('atom'); - $this->element('title', null, $title); + $this->element('title', null, common_xml_safe_str($title)); $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); @@ -855,7 +885,7 @@ class ApiAction extends Action } $this->element('updated', null, common_date_iso8601('now')); - $this->element('subtitle', null, $subtitle); + $this->element('subtitle', null, common_xml_safe_str($subtitle)); if (is_array($group)) { foreach ($group as $g) { @@ -1135,7 +1165,14 @@ class ApiAction extends Action function initTwitterRss() { $this->startXML(); - $this->elementStart('rss', array('version' => '2.0', 'xmlns:atom'=>'http://www.w3.org/2005/Atom')); + $this->elementStart( + 'rss', + array( + 'version' => '2.0', + 'xmlns:atom' => 'http://www.w3.org/2005/Atom', + 'xmlns:georss' => 'http://www.georss.org/georss' + ) + ); $this->elementStart('channel'); Event::handle('StartApiRss', array($this)); } @@ -1236,7 +1273,7 @@ class ApiAction extends Action if (empty($local)) { return null; } else { - return User_group::staticGet('id', $local->id); + return User_group::staticGet('id', $local->group_id); } } @@ -1325,8 +1362,6 @@ class ApiAction extends Action case 'max_id': $max_id = (int)$this->args['max_id']; return ($max_id < 1) ? 0 : $max_id; - case 'since': - return strtotime($this->args['since']); default: return parent::arg($key, $def); } @@ -1335,8 +1370,27 @@ class ApiAction extends Action } } - function getSelfUri($action, $aargs) + /** + * Calculate the complete URI that called up this action. Used for + * Atom rel="self" links. Warning: this is funky. + * + * @return string URL a URL suitable for rel="self" Atom links + */ + function getSelfUri() { + $action = mb_substr(get_class($this), 0, -6); // remove 'Action' + + $id = $this->arg('id'); + $aargs = array('format' => $this->format); + if (!empty($id)) { + $aargs['id'] = $id; + } + + $tag = $this->arg('tag'); + if (!empty($tag)) { + $aargs['tag'] = $tag; + } + parse_str($_SERVER['QUERY_STRING'], $params); $pstring = ''; if (!empty($params)) {