pocoaddress.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * An activity
  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 Feed
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @author Zach Copley <zach@status.net>
  26. * @copyright 2010 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. exit(1);
  32. }
  33. class PoCoAddress
  34. {
  35. public $widgetOpts;
  36. public $scoped;
  37. const ADDRESS = 'address';
  38. const FORMATTED = 'formatted';
  39. public $formatted;
  40. // @todo Other address fields
  41. function asString()
  42. {
  43. $xs = new XMLStringer(true);
  44. $this->outputTo($xs);
  45. return $xs->getString();
  46. }
  47. function outputTo($xo)
  48. {
  49. if (!empty($this->formatted)) {
  50. $xo->elementStart('poco:address');
  51. $xo->element('poco:formatted', null, common_xml_safe_str($this->formatted));
  52. $xo->elementEnd('poco:address');
  53. }
  54. }
  55. /**
  56. * Return this PoCo address as an array suitable for serializing in JSON
  57. *
  58. * @return array the address
  59. */
  60. function asArray()
  61. {
  62. if (!empty($this->formatted)) {
  63. return array('formatted' => $this->formatted);
  64. }
  65. }
  66. }