2
0

GeoRssWhere.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Geo
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Gdata_Extension
  23. */
  24. require_once 'Zend/Gdata/Extension.php';
  25. /**
  26. * @see Zend_Gdata_Geo
  27. */
  28. require_once 'Zend/Gdata/Geo.php';
  29. /**
  30. * @see Zend_Gdata_Geo_Extension_GmlPoint
  31. */
  32. require_once 'Zend/Gdata/Geo/Extension/GmlPoint.php';
  33. /**
  34. * Represents the georss:where element used by the Gdata Geo extensions.
  35. *
  36. * @category Zend
  37. * @package Zend_Gdata
  38. * @subpackage Geo
  39. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. */
  42. class Zend_Gdata_Geo_Extension_GeoRssWhere extends Zend_Gdata_Extension
  43. {
  44. protected $_rootNamespace = 'georss';
  45. protected $_rootElement = 'where';
  46. /**
  47. * The point location for this geo element
  48. *
  49. * @var Zend_Gdata_Geo_Extension_GmlPoint
  50. */
  51. protected $_point = null;
  52. /**
  53. * Create a new instance.
  54. *
  55. * @param Zend_Gdata_Geo_Extension_GmlPoint $point (optional) Point to which
  56. * object should be initialized.
  57. */
  58. public function __construct($point = null)
  59. {
  60. $this->registerAllNamespaces(Zend_Gdata_Geo::$namespaces);
  61. parent::__construct();
  62. $this->setPoint($point);
  63. }
  64. /**
  65. * Retrieves a DOMElement which corresponds to this element and all
  66. * child properties. This is used to build an entry back into a DOM
  67. * and eventually XML text for application storage/persistence.
  68. *
  69. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  70. * @return DOMElement The DOMElement representing this element and all
  71. * child properties.
  72. */
  73. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  74. {
  75. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  76. if ($this->_point !== null) {
  77. $element->appendChild($this->_point->getDOM($element->ownerDocument));
  78. }
  79. return $element;
  80. }
  81. /**
  82. * Creates individual Entry objects of the appropriate type and
  83. * stores them as members of this entry based upon DOM data.
  84. *
  85. * @param DOMNode $child The DOMNode to process
  86. */
  87. protected function takeChildFromDOM($child)
  88. {
  89. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  90. switch ($absoluteNodeName) {
  91. case $this->lookupNamespace('gml') . ':' . 'Point';
  92. $point = new Zend_Gdata_Geo_Extension_GmlPoint();
  93. $point->transferFromDOM($child);
  94. $this->_point = $point;
  95. break;
  96. }
  97. }
  98. /**
  99. * Get the value for this element's point attribute.
  100. *
  101. * @see setPoint
  102. * @return Zend_Gdata_Geo_Extension_GmlPoint The requested attribute.
  103. */
  104. public function getPoint()
  105. {
  106. return $this->_point;
  107. }
  108. /**
  109. * Set the value for this element's point attribute.
  110. *
  111. * @param Zend_Gdata_Geo_Extension_GmlPoint $value The desired value for this attribute.
  112. * @return Zend_Gdata_Geo_Extension_GeoRssWhere Provides a fluent interface
  113. */
  114. public function setPoint($value)
  115. {
  116. $this->_point = $value;
  117. return $this;
  118. }
  119. }