From: Mikael Nordfeldth Date: Wed, 3 Jun 2015 23:08:03 +0000 (+0200) Subject: Move some last OpenID stuff into the OpenID plugin (XRDS) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a4739b010795fc9a7f32cf1e85366453aa379206;p=quix0rs-gnu-social.git Move some last OpenID stuff into the OpenID plugin (XRDS) --- diff --git a/actions/networkpublic.php b/actions/networkpublic.php index 6f1124a9d8..41c4e37e3c 100644 --- a/actions/networkpublic.php +++ b/actions/networkpublic.php @@ -28,11 +28,6 @@ class NetworkpublicAction extends SitestreamAction } } - function extraHead() - { - parent::extraHead(); - } - function showSections() { // Show invite button, as long as site isn't closed, and diff --git a/actions/public.php b/actions/public.php index 175e0f1e70..000f82cb93 100644 --- a/actions/public.php +++ b/actions/public.php @@ -39,7 +39,6 @@ if (!defined('GNUSOCIAL')) { exit(1); } * @link http://status.net/ * * @see PublicrssAction - * @see PublicxrdsAction */ class PublicAction extends SitestreamAction { @@ -69,13 +68,6 @@ class PublicAction extends SitestreamAction } } - function extraHead() - { - parent::extraHead(); - $this->element('meta', array('http-equiv' => 'X-XRDS-Location', - 'content' => common_local_url('publicxrds'))); - } - function showSections() { // Show invite button, as long as site isn't closed, and diff --git a/actions/publicxrds.php b/actions/publicxrds.php deleted file mode 100644 index aac6f423cf..0000000000 --- a/actions/publicxrds.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @author Craig Andrews - * @author Robin Millette - * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ - * - * StatusNet - the distributed open-source microblogging tool - * Copyright (C) 2008, 2009, StatusNet, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/plugins/OpenID/openid.php'; -require_once INSTALLDIR.'/lib/xrdsoutputter.php'; - -/** - * Public XRDS - * - * @category Action - * @package StatusNet - * @author Evan Prodromou - * @author Robin Millette - * @author Craig Andrews - * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ - * - * @todo factor out similarities with XrdsAction - */ -class PublicxrdsAction extends Action -{ - /** - * Is read only? - * - * @return boolean true - */ - function isReadOnly($args) - { - return true; - } - - /** - * Class handler. - * - * @param array $args array of arguments - * - * @return nothing - */ - function handle($args) - { - parent::handle($args); - $xrdsOutputter = new XRDSOutputter(); - $xrdsOutputter->startXRDS(); - Event::handle('StartPublicXRDS', array($this,&$xrdsOutputter)); - Event::handle('EndPublicXRDS', array($this,&$xrdsOutputter)); - $xrdsOutputter->endXRDS(); - } -} - diff --git a/lib/xrdsoutputter.php b/lib/xrdsoutputter.php deleted file mode 100644 index 95dc73300a..0000000000 --- a/lib/xrdsoutputter.php +++ /dev/null @@ -1,97 +0,0 @@ -. - * - * @category Output - * @package StatusNet - * @author Craig Andrews - * @copyright 2008 StatusNet, Inc. - * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/xmloutputter.php'; - -/** - * Low-level generator for XRDS XML - * - * @category Output - * @package StatusNet - * @author Craig Andrews - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - * - * @see Action - * @see XMLOutputter - */ -class XRDSOutputter extends XMLOutputter -{ - public function startXRDS() - { - header('Content-Type: application/xrds+xml'); - $this->startXML(); - $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds')); - } - - public function endXRDS() - { - $this->elementEnd('XRDS'); - $this->endXML(); - } - - /** - * 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 showXrdsService($type, $uri, $params=null, $sigs=null, $localId=null) - { - $this->elementStart('Service'); - if ($uri) { - $this->element('URI', null, $uri); - } - $this->element('Type', null, $type); - if ($params) { - foreach ($params as $param) { - $this->element('Type', null, $param); - } - } - if ($sigs) { - foreach ($sigs as $sig) { - $this->element('Type', null, $sig); - } - } - if ($localId) { - $this->element('LocalID', null, $localId); - } - $this->elementEnd('Service'); - } -} diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index 0d093f2868..cf820c3ab6 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -154,7 +154,7 @@ class OpenIDPlugin extends Plugin * * @return boolean hook return */ - function onEndPublicXRDS($action, &$xrdsOutputter) + function onEndPublicXRDS(Action $action, &$xrdsOutputter) { $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', @@ -184,7 +184,7 @@ class OpenIDPlugin extends Plugin * * @return boolean hook return */ - function onEndUserXRDS($action, &$xrdsOutputter) + function onEndUserXRDS(Action $action, &$xrdsOutputter) { $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'openid', @@ -415,7 +415,7 @@ class OpenIDPlugin extends Plugin * * @return void */ - function onEndShowHeadElements($action) + function onEndShowHeadElements(Action $action) { if ($action instanceof ShowstreamAction) { $action->element('link', array('rel' => 'openid2.provider', @@ -427,6 +427,11 @@ class OpenIDPlugin extends Plugin $action->element('link', array('rel' => 'openid.delegate', 'href' => $action->profile->profileurl)); } + + if ($action instanceof SitestreamAction) { + $action->element('meta', array('http-equiv' => 'X-XRDS-Location', + 'content' => common_local_url('publicxrds'))); + } return true; } diff --git a/plugins/OpenID/actions/publicxrds.php b/plugins/OpenID/actions/publicxrds.php new file mode 100644 index 0000000000..5b099872f4 --- /dev/null +++ b/plugins/OpenID/actions/publicxrds.php @@ -0,0 +1,79 @@ + + * @author Craig Andrews + * @author Robin Millette + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +if (!defined('GNUSOCIAL')) { exit(1); } + +require_once __DIR__.'/../openid.php'; + +/** + * Public XRDS + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette + * @author Craig Andrews + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * @todo factor out similarities with XrdsAction + */ +class PublicxrdsAction extends Action +{ + /** + * Is read only? + * + * @return boolean true + */ + function isReadOnly($args) + { + return true; + } + + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ + protected function handle() + { + parent::handle(); + $xrdsOutputter = new XRDSOutputter(); + $xrdsOutputter->startXRDS(); + Event::handle('StartPublicXRDS', array($this,&$xrdsOutputter)); + Event::handle('EndPublicXRDS', array($this,&$xrdsOutputter)); + $xrdsOutputter->endXRDS(); + } +} diff --git a/plugins/OpenID/lib/xrdsoutputter.php b/plugins/OpenID/lib/xrdsoutputter.php new file mode 100644 index 0000000000..9841d9e871 --- /dev/null +++ b/plugins/OpenID/lib/xrdsoutputter.php @@ -0,0 +1,93 @@ +. + * + * @category Output + * @package StatusNet + * @author Craig Andrews + * @copyright 2008 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('GNUSOCIAL')) { exit(1); } + +/** + * Low-level generator for XRDS XML + * + * @category Output + * @package StatusNet + * @author Craig Andrews + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see Action + * @see XMLOutputter + */ +class XRDSOutputter extends XMLOutputter +{ + public function startXRDS() + { + header('Content-Type: application/xrds+xml'); + $this->startXML(); + $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds')); + } + + public function endXRDS() + { + $this->elementEnd('XRDS'); + $this->endXML(); + } + + /** + * 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 showXrdsService($type, $uri, $params=null, $sigs=null, $localId=null) + { + $this->elementStart('Service'); + if ($uri) { + $this->element('URI', null, $uri); + } + $this->element('Type', null, $type); + if ($params) { + foreach ($params as $param) { + $this->element('Type', null, $param); + } + } + if ($sigs) { + foreach ($sigs as $sig) { + $this->element('Type', null, $sig); + } + } + if ($localId) { + $this->element('LocalID', null, $localId); + } + $this->elementEnd('Service'); + } +}