diff options
author | Robin Millette <millette@controlyourself.ca> | 2009-01-22 15:37:35 +0000 |
---|---|---|
committer | Robin Millette <millette@plantard.controlezvous.ca> | 2009-01-22 15:37:35 +0000 |
commit | b39d4788b9c5b6c1166b10135d3a38355c62ba53 (patch) | |
tree | 0826e9490afd05d50d591e93f98f8ee20bc56720 /actions/xrds.php | |
parent | dfb21679e22e982bcbd26c48230f269735d601e0 (diff) |
uiredesign + phpdocs
Diffstat (limited to 'actions/xrds.php')
-rw-r--r-- | actions/xrds.php | 108 |
1 files changed, 72 insertions, 36 deletions
diff --git a/actions/xrds.php b/actions/xrds.php index 14cb9d503..629de3a86 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -1,5 +1,17 @@ <?php -/* + +/** + * XRDS for OpenID + * + * PHP version 5 + * + * @category Action + * @package Laconica + * @author Evan Prodromou <evan@controlyourself.ca> + * @author Robin Millette <millette@controlyourself.ca> + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,35 +29,63 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/omb.php'); +require_once INSTALLDIR.'/lib/omb.php'; +/** + * XRDS for OpenID + * + * @category Action + * @package Laconica + * @author Evan Prodromou <evan@controlyourself.ca> + * @author Robin Millette <millette@controlyourself.ca> + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class XrdsAction extends Action { - + /** + * Is read only? + * + * @return boolean true + */ function isReadOnly() { return true; } + /** + * Class handler. + * + * @param array $args query arguments + * + * @return void + */ function handle($args) { parent::handle($args); $nickname = $this->trimmed('nickname'); - $user = User::staticGet('nickname', $nickname); + $user = User::staticGet('nickname', $nickname); if (!$user) { $this->clientError(_('No such user.')); return; } - $this->show_xrds($user); + $this->showXrds($user); } - function show_xrds($user) + /** + * Show XRDS for a user. + * + * @param class $user XRDS for this user. + * + * @return void + */ + function showXrds($user) { - header('Content-Type: application/xrds+xml'); - common_start_xml(); $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds')); @@ -53,66 +93,61 @@ class XrdsAction extends Action 'xml:id' => 'oauth', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); - $this->element('Type', null, 'xri://$xrds*simple'); - - $this->show_service(OAUTH_ENDPOINT_REQUEST, + $this->showService(OAUTH_ENDPOINT_REQUEST, common_local_url('requesttoken'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY), array(OAUTH_HMAC_SHA1), $user->uri); - - $this->show_service(OAUTH_ENDPOINT_AUTHORIZE, + $this->showService(OAUTH_ENDPOINT_AUTHORIZE, common_local_url('userauthorization'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY), array(OAUTH_HMAC_SHA1)); - - $this->show_service(OAUTH_ENDPOINT_ACCESS, + $this->showService(OAUTH_ENDPOINT_ACCESS, common_local_url('accesstoken'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY), array(OAUTH_HMAC_SHA1)); - - $this->show_service(OAUTH_ENDPOINT_RESOURCE, + $this->showService(OAUTH_ENDPOINT_RESOURCE, null, array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY), array(OAUTH_HMAC_SHA1)); - $this->elementEnd('XRD'); - # XXX: decide whether to include user's ID/nickname in postNotice URL - + // XXX: decide whether to include user's ID/nickname in postNotice URL $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'omb', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); - $this->element('Type', null, 'xri://$xrds*simple'); - - $this->show_service(OMB_ENDPOINT_POSTNOTICE, + $this->showService(OMB_ENDPOINT_POSTNOTICE, common_local_url('postnotice')); - - $this->show_service(OMB_ENDPOINT_UPDATEPROFILE, + $this->showService(OMB_ENDPOINT_UPDATEPROFILE, common_local_url('updateprofile')); - $this->elementEnd('XRD'); - $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'version' => '2.0')); - $this->element('Type', null, 'xri://$xrds*simple'); - - $this->show_service(OAUTH_DISCOVERY, + $this->showService(OAUTH_DISCOVERY, '#oauth'); - $this->show_service(OMB_NAMESPACE, + $this->showService(OMB_NAMESPACE, '#omb'); - $this->elementEnd('XRD'); - $this->elementEnd('XRDS'); common_end_xml(); } - function show_service($type, $uri, $params=null, $sigs=null, $localId=null) + /** + * Show service. + * + * @param string $type XRDS type + * @param string $uri URI + * @param array $params type parameters, null by default + * @param array $sigs type signatures, null by default + * @param string $localId local ID, null by default + * + * @return void + */ + function showService($type, $uri, $params=null, $sigs=null, $localId=null) { $this->elementStart('Service'); if ($uri) { @@ -134,4 +169,5 @@ class XrdsAction extends Action } $this->elementEnd('Service'); } -}
\ No newline at end of file +} + |