123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class RsdAction extends Action
- {
-
- var $user = null;
-
- function prepare($args)
- {
- parent::prepare($args);
-
- $nickname_arg = $this->arg('nickname');
- if (empty($nickname_arg)) {
- $this->user = null;
- } else {
- $nickname = common_canonical_nickname($nickname_arg);
-
- if ($nickname_arg != $nickname) {
- common_redirect(common_local_url('rsd', array('nickname' => $nickname)), 301);
- }
- $this->user = User::getKV('nickname', $nickname);
- if (empty($this->user)) {
-
- $this->clientError(_('No such user.'), 404);
- }
- }
- return true;
- }
-
- function handle($args)
- {
- header('Content-Type: application/rsd+xml');
- $this->startXML();
- $rsdNS = 'http://archipelago.phrasewise.com/rsd';
- $this->elementStart('rsd', array('version' => '1.0',
- 'xmlns' => $rsdNS));
- $this->elementStart('service');
-
- $this->element('engineName', null, _('StatusNet'));
- $this->element('engineLink', null, 'http://status.net/');
- $this->elementStart('apis');
- if (Event::handle('StartRsdListApis', array($this, $this->user))) {
- $blogID = (empty($this->user)) ? '' : $this->user->nickname;
- $apiAttrs = array('name' => 'Twitter',
- 'preferred' => 'true',
- 'apiLink' => $this->_apiRoot(),
- 'blogID' => $blogID);
- $this->elementStart('api', $apiAttrs);
- $this->elementStart('settings');
- $this->element('docs', null,
- 'http://status.net/wiki/TwitterCompatibleAPI');
- $this->element('setting', array('name' => 'OAuth'),
- 'true');
- $this->elementEnd('settings');
- $this->elementEnd('api');
-
- if (empty($this->user)) {
- $service = common_local_url('ApiAtomService');
- } else {
- $service = common_local_url('ApiAtomService', array('id' => $this->user->nickname));
- }
- $this->element('api', array('name' => 'Atom',
- 'preferred' => 'false',
- 'apiLink' => $service,
- 'blogID' => $blogID));
- Event::handle('EndRsdListApis', array($this, $this->user));
- }
- $this->elementEnd('apis');
- $this->elementEnd('service');
- $this->elementEnd('rsd');
- $this->endXML();
- return true;
- }
-
- function lastModified()
- {
- if (!empty($this->user)) {
- return $this->user->modified;
- } else {
- return null;
- }
- }
-
- function isReadOnly($args)
- {
- return true;
- }
-
- private function _apiRoot()
- {
- if (common_config('site', 'fancy')) {
- return common_path('api/', true);
- } else {
- return common_path('index.php/api/', true);
- }
- }
- }
|