WebContent.php 5.3 KB

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