8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * @see Zend_Gdata_Extension_Reminder
32 require_once 'Zend/Gdata/Extension/Reminder.php';
35 * Represents the gd:when element
40 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
41 * @license http://framework.zend.com/license/new-bsd New BSD License
43 class Zend_Gdata_Extension_When extends Zend_Gdata_Extension
46 protected $_rootElement = 'when';
47 protected $_reminders = array();
48 protected $_startTime = null;
49 protected $_valueString = null;
50 protected $_endTime = null;
52 public function __construct($startTime = null, $endTime = null,
53 $valueString = null, $reminders = null)
55 parent::__construct();
56 $this->_startTime = $startTime;
57 $this->_endTime = $endTime;
58 $this->_valueString = $valueString;
59 $this->_reminders = $reminders;
62 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
64 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
65 if ($this->_startTime !== null) {
66 $element->setAttribute('startTime', $this->_startTime);
68 if ($this->_endTime !== null) {
69 $element->setAttribute('endTime', $this->_endTime);
71 if ($this->_valueString !== null) {
72 $element->setAttribute('valueString', $this->_valueString);
74 if ($this->_reminders !== null) {
75 foreach ($this->_reminders as $reminder) {
76 $element->appendChild(
77 $reminder->getDOM($element->ownerDocument));
83 protected function takeChildFromDOM($child)
85 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
86 switch ($absoluteNodeName) {
87 case $this->lookupNamespace('gd') . ':' . 'reminder';
88 $reminder = new Zend_Gdata_Extension_Reminder();
89 $reminder->transferFromDOM($child);
90 $this->_reminders[] = $reminder;
93 parent::takeChildFromDOM($child);
98 protected function takeAttributeFromDOM($attribute)
100 switch ($attribute->localName) {
102 $this->_startTime = $attribute->nodeValue;
105 $this->_endTime = $attribute->nodeValue;
108 $this->_valueString = $attribute->nodeValue;
111 parent::takeAttributeFromDOM($attribute);
115 public function __toString()
117 if ($this->_valueString)
118 return $this->_valueString;
120 return 'Starts: ' . $this->getStartTime() . ' ' .
121 'Ends: ' . $this->getEndTime();
125 public function getStartTime()
127 return $this->_startTime;
130 public function setStartTime($value)
132 $this->_startTime = $value;
136 public function getEndTime()
138 return $this->_endTime;
141 public function setEndTime($value)
143 $this->_endTime = $value;
147 public function getValueString()
149 return $this->_valueString;
152 public function setValueString($value)
154 $this->_valueString = $value;
158 public function getReminders()
160 return $this->_reminders;
163 public function setReminders($value)
165 $this->_reminders = $value;