2
0

EntryLink.php 4.2 KB

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