WebContent.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 Calendar
  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. * Represents the gCal:webContent element used by the Calendar data API
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Calendar
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Gdata_Calendar_Extension_WebContent extends Zend_Gdata_App_Extension
  36. {
  37. protected $_rootNamespace = 'gCal';
  38. protected $_rootElement = 'webContent';
  39. protected $_url = null;
  40. protected $_height = null;
  41. protected $_width = null;
  42. /**
  43. * Constructs a new Zend_Gdata_Calendar_Extension_WebContent object.
  44. * @param string $url (optional) The value for this element's URL attribute.
  45. * @param string $height (optional) The value for this element's height attribute.
  46. * @param string $width (optional) The value for this element's width attribute.
  47. */
  48. public function __construct($url = null, $height = null, $width = null)
  49. {
  50. $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
  51. parent::__construct();
  52. $this->_url = $url;
  53. $this->_height = $height;
  54. $this->_width = $width;
  55. }
  56. /**
  57. * Retrieves a DOMElement which corresponds to this element and all
  58. * child properties. This is used to build an entry back into a DOM
  59. * and eventually XML text for sending to the server upon updates, or
  60. * for application storage/persistence.
  61. *
  62. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  63. * @return DOMElement The DOMElement representing this element and all
  64. * child properties.
  65. */
  66. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  67. {
  68. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  69. if ($this->url != null) {
  70. $element->setAttribute('url', $this->_url);
  71. }
  72. if ($this->height != null) {
  73. $element->setAttribute('height', $this->_height);
  74. }
  75. if ($this->width != null) {
  76. $element->setAttribute('width', $this->_width);
  77. }
  78. return $element;
  79. }
  80. /**
  81. * Given a DOMNode representing an attribute, tries to map the data into
  82. * instance members. If no mapping is defined, the name and value are
  83. * stored in an array.
  84. *
  85. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  86. */
  87. protected function takeAttributeFromDOM($attribute)
  88. {
  89. switch ($attribute->localName) {
  90. case 'url':
  91. $this->_url = $attribute->nodeValue;
  92. break;
  93. case 'height':
  94. $this->_height = $attribute->nodeValue;
  95. break;
  96. case 'width':
  97. $this->_width = $attribute->nodeValue;
  98. break;
  99. default:
  100. parent::takeAttributeFromDOM($attribute);
  101. }
  102. }
  103. /**
  104. * Get the value for this element's URL attribute.
  105. *
  106. * @return string The desired value for this attribute.
  107. */
  108. public function getURL()
  109. {
  110. return $this->_url;
  111. }
  112. /**
  113. * Set the value for this element's URL attribute.
  114. *
  115. * @param bool $value The desired value for this attribute.
  116. * @return Zend_Gdata_Calendar_Extension_WebContent The element being modified.
  117. */
  118. public function setURL($value)
  119. {
  120. $this->_url = $value;
  121. return $this;
  122. }
  123. /**
  124. * Get the value for this element's height attribute.
  125. *
  126. * @return int The desired value for this attribute.
  127. */
  128. public function getHeight()
  129. {
  130. return $this->_height;
  131. }
  132. /**
  133. * Set the value for this element's height attribute.
  134. *
  135. * @param int $value The desired value for this attribute.
  136. * @return Zend_Gdata_Calendar_Extension_WebContent The element being modified.
  137. */
  138. public function setHeight($value)
  139. {
  140. $this->_height = $value;
  141. return $this;
  142. }
  143. /**
  144. * Get the value for this element's height attribute.
  145. *
  146. * @return int The desired value for this attribute.
  147. */
  148. public function getWidth()
  149. {
  150. return $this->_width;
  151. }
  152. /**
  153. * Set the value for this element's height attribute.
  154. *
  155. * @param int $value The desired value for this attribute.
  156. * @return Zend_Gdata_Calendar_Extension_WebContent The element being modified.
  157. */
  158. public function setWidth($value)
  159. {
  160. $this->_width = $value;
  161. return $this;
  162. }
  163. }