Where.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 Gdata
  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_Extension_EntryLink
  27. */
  28. require_once 'Zend/Gdata/Extension/EntryLink.php';
  29. /**
  30. * Data model class to represent a location (gd:where element)
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage Gdata
  35. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Gdata_Extension_Where extends Zend_Gdata_Extension
  39. {
  40. protected $_rootElement = 'where';
  41. protected $_label = null;
  42. protected $_rel = null;
  43. protected $_valueString = null;
  44. protected $_entryLink = null;
  45. public function __construct($valueString = null, $label = null, $rel = null, $entryLink = null)
  46. {
  47. parent::__construct();
  48. $this->_valueString = $valueString;
  49. $this->_label = $label;
  50. $this->_rel = $rel;
  51. $this->_entryLink = $entryLink;
  52. }
  53. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  54. {
  55. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  56. if ($this->_label !== null) {
  57. $element->setAttribute('label', $this->_label);
  58. }
  59. if ($this->_rel !== null) {
  60. $element->setAttribute('rel', $this->_rel);
  61. }
  62. if ($this->_valueString !== null) {
  63. $element->setAttribute('valueString', $this->_valueString);
  64. }
  65. if ($this->entryLink !== null) {
  66. $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
  67. }
  68. return $element;
  69. }
  70. protected function takeAttributeFromDOM($attribute)
  71. {
  72. switch ($attribute->localName) {
  73. case 'label':
  74. $this->_label = $attribute->nodeValue;
  75. break;
  76. case 'rel':
  77. $this->_rel = $attribute->nodeValue;
  78. break;
  79. case 'valueString':
  80. $this->_valueString = $attribute->nodeValue;
  81. break;
  82. default:
  83. parent::takeAttributeFromDOM($attribute);
  84. }
  85. }
  86. /**
  87. * Creates individual Entry objects of the appropriate type and
  88. * stores them in the $_entry array based upon DOM data.
  89. *
  90. * @param DOMNode $child The DOMNode to process
  91. */
  92. protected function takeChildFromDOM($child)
  93. {
  94. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  95. switch ($absoluteNodeName) {
  96. case $this->lookupNamespace('gd') . ':' . 'entryLink':
  97. $entryLink = new Zend_Gdata_Extension_EntryLink();
  98. $entryLink->transferFromDOM($child);
  99. $this->_entryLink = $entryLink;
  100. break;
  101. default:
  102. parent::takeChildFromDOM($child);
  103. break;
  104. }
  105. }
  106. public function __toString()
  107. {
  108. if ($this->_valueString != null) {
  109. return $this->_valueString;
  110. }
  111. else {
  112. return parent::__toString();
  113. }
  114. }
  115. public function getLabel()
  116. {
  117. return $this->_label;
  118. }
  119. public function setLabel($value)
  120. {
  121. $this->_label = $value;
  122. return $this;
  123. }
  124. public function getRel()
  125. {
  126. return $this->_rel;
  127. }
  128. public function setRel($value)
  129. {
  130. $this->_rel = $value;
  131. return $this;
  132. }
  133. public function getValueString()
  134. {
  135. return $this->_valueString;
  136. }
  137. public function setValueString($value)
  138. {
  139. $this->_valueString = $value;
  140. return $this;
  141. }
  142. public function getEntryLink()
  143. {
  144. return $this->_entryLink;
  145. }
  146. public function setEntryLink($value)
  147. {
  148. $this->_entryLink = $value;
  149. return $this;
  150. }
  151. }