xrdsoutputter.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Low-level generator for HTML
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Output
  23. * @package StatusNet
  24. * @author Craig Andrews <candrews@integralblue.com>
  25. * @copyright 2008 StatusNet, Inc.
  26. * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('GNUSOCIAL')) { exit(1); }
  31. /**
  32. * Low-level generator for XRDS XML
  33. *
  34. * @category Output
  35. * @package StatusNet
  36. * @author Craig Andrews <candrews@integralblue.com>
  37. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  38. * @link http://status.net/
  39. *
  40. * @see Action
  41. * @see XMLOutputter
  42. */
  43. class XRDSOutputter extends XMLOutputter
  44. {
  45. public function startXRDS()
  46. {
  47. header('Content-Type: application/xrds+xml');
  48. $this->startXML();
  49. $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
  50. }
  51. public function endXRDS()
  52. {
  53. $this->elementEnd('XRDS');
  54. $this->endXML();
  55. }
  56. /**
  57. * Show service.
  58. *
  59. * @param string $type XRDS type
  60. * @param string $uri URI
  61. * @param array $params type parameters, null by default
  62. * @param array $sigs type signatures, null by default
  63. * @param string $localId local ID, null by default
  64. *
  65. * @return void
  66. */
  67. function showXrdsService($type, $uri, $params=null, $sigs=null, $localId=null)
  68. {
  69. $this->elementStart('Service');
  70. if ($uri) {
  71. $this->element('URI', null, $uri);
  72. }
  73. $this->element('Type', null, $type);
  74. if ($params) {
  75. foreach ($params as $param) {
  76. $this->element('Type', null, $param);
  77. }
  78. }
  79. if ($sigs) {
  80. foreach ($sigs as $sig) {
  81. $this->element('Type', null, $sig);
  82. }
  83. }
  84. if ($localId) {
  85. $this->element('LocalID', null, $localId);
  86. }
  87. $this->elementEnd('Service');
  88. }
  89. }