EntryLink.php 4.3 KB

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