xrdsoutputter.php 2.89 KB
Newer Older
Evan Prodromou's avatar
Evan Prodromou committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2
/**
3
 * StatusNet, the distributed open-source microblogging tool
Robin Millette's avatar
Robin Millette committed
4
 *
5
 * Low-level generator for HTML
Robin Millette's avatar
Robin Millette committed
6
 *
7
 * PHP version 5
Evan Prodromou's avatar
Evan Prodromou committed
8
 *
9
 * LICENCE: This program is free software: you can redistribute it and/or modify
Evan Prodromou's avatar
Evan Prodromou committed
10 11 12 13 14 15 16 17 18 19 20
 * 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 <http://www.gnu.org/licenses/>.
21 22 23 24 25
 *
 * @category  Output
 * @package   StatusNet
 * @author    Craig Andrews <candrews@integralblue.com>
 * @copyright 2008 StatusNet, Inc.
26
 * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
27 28
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link      http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
29 30
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Robin Millette's avatar
Robin Millette committed
32 33
    exit(1);
}
Evan Prodromou's avatar
Evan Prodromou committed
34

35
require_once INSTALLDIR.'/lib/xmloutputter.php';
Evan Prodromou's avatar
Evan Prodromou committed
36

Robin Millette's avatar
Robin Millette committed
37
/**
38
 * Low-level generator for XRDS XML
Robin Millette's avatar
Robin Millette committed
39
 *
40
 * @category Output
41
 * @package  StatusNet
42 43
 * @author   Craig Andrews <candrews@integralblue.com>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
45
 *
46 47
 * @see      Action
 * @see      XMLOutputter
Robin Millette's avatar
Robin Millette committed
48
 */
49 50 51
class XRDSOutputter extends XMLOutputter
{
    public function startXRDS()
52
    {
53
        header('Content-Type: application/xrds+xml');
54
        $this->startXML();
55
        $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
56 57 58 59
    }
    
    public function endXRDS()
    {
60
        $this->elementEnd('XRDS');
61
        $this->endXML();
62
    }
63

Robin Millette's avatar
Robin Millette committed
64 65
    /**
     * Show service.
66
     *
Robin Millette's avatar
Robin Millette committed
67 68 69 70 71 72 73 74
     * @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
     */
75
    function showXrdsService($type, $uri, $params=null, $sigs=null, $localId=null)
76
    {
77
        $this->elementStart('Service');
78
        if ($uri) {
79
            $this->element('URI', null, $uri);
80
        }
81
        $this->element('Type', null, $type);
82 83
        if ($params) {
            foreach ($params as $param) {
84
                $this->element('Type', null, $param);
85 86 87 88
            }
        }
        if ($sigs) {
            foreach ($sigs as $sig) {
89
                $this->element('Type', null, $sig);
90 91 92
            }
        }
        if ($localId) {
93
            $this->element('LocalID', null, $localId);
94
        }
95
        $this->elementEnd('Service');
96
    }
Robin Millette's avatar
Robin Millette committed
97
}