1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Zend Framework
|
---|
5 | *
|
---|
6 | * LICENSE
|
---|
7 | *
|
---|
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.
|
---|
15 | *
|
---|
16 | * @category Zend
|
---|
17 | * @package Zend_Gdata
|
---|
18 | * @subpackage Gdata
|
---|
19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata_Extension
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/Extension.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * @see Zend_Gdata_Extension_Reminder
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Extension/Reminder.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Represents the gd:when element
|
---|
35 | *
|
---|
36 | * @category Zend
|
---|
37 | * @package Zend_Gdata
|
---|
38 | * @subpackage Gdata
|
---|
39 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
40 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
41 | */
|
---|
42 | class Zend_Gdata_Extension_When extends Zend_Gdata_Extension
|
---|
43 | {
|
---|
44 |
|
---|
45 | protected $_rootElement = 'when';
|
---|
46 | protected $_reminders = array();
|
---|
47 | protected $_startTime = null;
|
---|
48 | protected $_valueString = null;
|
---|
49 | protected $_endTime = null;
|
---|
50 |
|
---|
51 | public function __construct($startTime = null, $endTime = null,
|
---|
52 | $valueString = null, $reminders = null)
|
---|
53 | {
|
---|
54 | parent::__construct();
|
---|
55 | $this->_startTime = $startTime;
|
---|
56 | $this->_endTime = $endTime;
|
---|
57 | $this->_valueString = $valueString;
|
---|
58 | $this->_reminders = $reminders;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
62 | {
|
---|
63 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
64 | if ($this->_startTime !== null) {
|
---|
65 | $element->setAttribute('startTime', $this->_startTime);
|
---|
66 | }
|
---|
67 | if ($this->_endTime !== null) {
|
---|
68 | $element->setAttribute('endTime', $this->_endTime);
|
---|
69 | }
|
---|
70 | if ($this->_valueString !== null) {
|
---|
71 | $element->setAttribute('valueString', $this->_valueString);
|
---|
72 | }
|
---|
73 | if ($this->_reminders !== null) {
|
---|
74 | foreach ($this->_reminders as $reminder) {
|
---|
75 | $element->appendChild(
|
---|
76 | $reminder->getDOM($element->ownerDocument));
|
---|
77 | }
|
---|
78 | }
|
---|
79 | return $element;
|
---|
80 | }
|
---|
81 |
|
---|
82 | protected function takeChildFromDOM($child)
|
---|
83 | {
|
---|
84 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
85 | switch ($absoluteNodeName) {
|
---|
86 | case $this->lookupNamespace('gd') . ':' . 'reminder';
|
---|
87 | $reminder = new Zend_Gdata_Extension_Reminder();
|
---|
88 | $reminder->transferFromDOM($child);
|
---|
89 | $this->_reminders[] = $reminder;
|
---|
90 | break;
|
---|
91 | default:
|
---|
92 | parent::takeChildFromDOM($child);
|
---|
93 | break;
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | protected function takeAttributeFromDOM($attribute)
|
---|
98 | {
|
---|
99 | switch ($attribute->localName) {
|
---|
100 | case 'startTime':
|
---|
101 | $this->_startTime = $attribute->nodeValue;
|
---|
102 | break;
|
---|
103 | case 'endTime':
|
---|
104 | $this->_endTime = $attribute->nodeValue;
|
---|
105 | break;
|
---|
106 | case 'valueString':
|
---|
107 | $this->_valueString = $attribute->nodeValue;
|
---|
108 | break;
|
---|
109 | default:
|
---|
110 | parent::takeAttributeFromDOM($attribute);
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | public function __toString()
|
---|
115 | {
|
---|
116 | if ($this->_valueString)
|
---|
117 | return $this->_valueString;
|
---|
118 | else {
|
---|
119 | return 'Starts: ' . $this->getStartTime() . ' ' .
|
---|
120 | 'Ends: ' . $this->getEndTime();
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | public function getStartTime()
|
---|
125 | {
|
---|
126 | return $this->_startTime;
|
---|
127 | }
|
---|
128 |
|
---|
129 | public function setStartTime($value)
|
---|
130 | {
|
---|
131 | $this->_startTime = $value;
|
---|
132 | return $this;
|
---|
133 | }
|
---|
134 |
|
---|
135 | public function getEndTime()
|
---|
136 | {
|
---|
137 | return $this->_endTime;
|
---|
138 | }
|
---|
139 |
|
---|
140 | public function setEndTime($value)
|
---|
141 | {
|
---|
142 | $this->_endTime = $value;
|
---|
143 | return $this;
|
---|
144 | }
|
---|
145 |
|
---|
146 | public function getValueString()
|
---|
147 | {
|
---|
148 | return $this->_valueString;
|
---|
149 | }
|
---|
150 |
|
---|
151 | public function setValueString($value)
|
---|
152 | {
|
---|
153 | $this->_valueString = $value;
|
---|
154 | return $this;
|
---|
155 | }
|
---|
156 |
|
---|
157 | public function getReminders()
|
---|
158 | {
|
---|
159 | return $this->_reminders;
|
---|
160 | }
|
---|
161 |
|
---|
162 | public function setReminders($value)
|
---|
163 | {
|
---|
164 | $this->_reminders = $value;
|
---|
165 | return $this;
|
---|
166 | }
|
---|
167 |
|
---|
168 | }
|
---|