FeedLink.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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_Feed
  28. */
  29. require_once 'Zend/Gdata/Feed.php';
  30. /**
  31. * Represents the gd:feedLink 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_FeedLink extends Zend_Gdata_Extension
  40. {
  41. protected $_rootElement = 'feedLink';
  42. protected $_countHint = null;
  43. protected $_href = null;
  44. protected $_readOnly = null;
  45. protected $_rel = null;
  46. protected $_feed = null;
  47. public function __construct($href = null, $rel = null,
  48. $countHint = null, $readOnly = null, $feed = null)
  49. {
  50. parent::__construct();
  51. $this->_countHint = $countHint;
  52. $this->_href = $href;
  53. $this->_readOnly = $readOnly;
  54. $this->_rel = $rel;
  55. $this->_feed = $feed;
  56. }
  57. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  58. {
  59. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  60. if ($this->_countHint !== null) {
  61. $element->setAttribute('countHint', $this->_countHint);
  62. }
  63. if ($this->_href !== null) {
  64. $element->setAttribute('href', $this->_href);
  65. }
  66. if ($this->_readOnly !== null) {
  67. $element->setAttribute('readOnly', ($this->_readOnly ? "true" : "false"));
  68. }
  69. if ($this->_rel !== null) {
  70. $element->setAttribute('rel', $this->_rel);
  71. }
  72. if ($this->_feed !== null) {
  73. $element->appendChild($this->_feed->getDOM($element->ownerDocument));
  74. }
  75. return $element;
  76. }
  77. protected function takeChildFromDOM($child)
  78. {
  79. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  80. switch ($absoluteNodeName) {
  81. case $this->lookupNamespace('atom') . ':' . 'feed';
  82. $feed = new Zend_Gdata_Feed();
  83. $feed->transferFromDOM($child);
  84. $this->_feed = $feed;
  85. break;
  86. default:
  87. parent::takeChildFromDOM($child);
  88. break;
  89. }
  90. }
  91. protected function takeAttributeFromDOM($attribute)
  92. {
  93. switch ($attribute->localName) {
  94. case 'countHint':
  95. $this->_countHint = $attribute->nodeValue;
  96. break;
  97. case 'href':
  98. $this->_href = $attribute->nodeValue;
  99. break;
  100. case 'readOnly':
  101. if ($attribute->nodeValue == "true") {
  102. $this->_readOnly = true;
  103. }
  104. else if ($attribute->nodeValue == "false") {
  105. $this->_readOnly = false;
  106. }
  107. else {
  108. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
  109. }
  110. break;
  111. case 'rel':
  112. $this->_rel = $attribute->nodeValue;
  113. break;
  114. default:
  115. parent::takeAttributeFromDOM($attribute);
  116. }
  117. }
  118. /**
  119. * @return string
  120. */
  121. public function getHref()
  122. {
  123. return $this->_href;
  124. }
  125. public function setHref($value)
  126. {
  127. $this->_href = $value;
  128. return $this;
  129. }
  130. public function getReadOnly()
  131. {
  132. return $this->_readOnly;
  133. }
  134. public function setReadOnly($value)
  135. {
  136. $this->_readOnly = $value;
  137. return $this;
  138. }
  139. public function getRel()
  140. {
  141. return $this->_rel;
  142. }
  143. public function setRel($value)
  144. {
  145. $this->_rel = $value;
  146. return $this;
  147. }
  148. public function getFeed()
  149. {
  150. return $this->_feed;
  151. }
  152. public function setFeed($value)
  153. {
  154. $this->_feed = $value;
  155. return $this;
  156. }
  157. }