2
0

FeedLink.php 4.5 KB

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