2
0

Where.php 4.4 KB

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