]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - extlib/libomb/base_url_xrds_mapper.php
Update to last upstream version of libomb: coding style updates, static call fix...
[quix0rs-gnu-social.git] / extlib / libomb / base_url_xrds_mapper.php
1 <?php
2 /**
3  * This file is part of libomb
4  *
5  * PHP version 5
6  *
7  * LICENSE: This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * @package OMB
21  * @author  Adrian Lang <mail@adrianlang.de>
22  * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
23  * @version 0.1a-20090828
24  * @link    http://adrianlang.de/libomb
25  */
26
27 require_once 'xrds_mapper.php';
28 require_once 'constants.php';
29
30 /**
31  * Map XRDS actions to URLs using base URLs
32  *
33  * This class realizes a simple mapping of action URIs to handler URLs. The
34  * target URLs are constructed using a base URL.
35  */
36 class OMB_Base_URL_XRDS_Mapper implements OMB_XRDS_Mapper
37 {
38     protected $urls;
39
40     /**
41      * Constructor
42      *
43      * Initialize the XRDS mapper with base URLs for OAuth and OMB endpoints.
44      *
45      * @param string $oauth_base The base URL for OAuth endpoints
46      * @param string $omb_base   The base URL for OMB endpoints
47      */
48     public function __construct($oauth_base, $omb_base)
49     {
50         $this->urls = array(
51                 OAUTH_ENDPOINT_REQUEST => $oauth_base . 'requesttoken',
52                 OAUTH_ENDPOINT_AUTHORIZE => $oauth_base . 'userauthorization',
53                 OAUTH_ENDPOINT_ACCESS => $oauth_base . 'accesstoken',
54                 OMB_ENDPOINT_POSTNOTICE => $omb_base . 'postnotice',
55                 OMB_ENDPOINT_UPDATEPROFILE => $omb_base . 'updateprofile');
56     }
57
58     /**
59      * Fetch an URL for a specified action
60      *
61      * Returns the action URL for an action specified by the endpoint URI.
62      *
63      * @param string $action The endpoint URI
64      *
65      * @return string The action URL
66      */
67     public function getURL($action)
68     {
69         return $this->urls[$action];
70     }
71 }
72 ?>