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_EntryLink
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Extension/EntryLink.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @see Zend_Gdata_Extension_OriginalEvent
|
---|
35 | */
|
---|
36 | require_once 'Zend/Gdata/Extension/OriginalEvent.php';
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Data model class to represent an entry's recurrenceException
|
---|
40 | *
|
---|
41 | * @category Zend
|
---|
42 | * @package Zend_Gdata
|
---|
43 | * @subpackage Gdata
|
---|
44 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
45 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
46 | */
|
---|
47 | class Zend_Gdata_Extension_RecurrenceException extends Zend_Gdata_Extension
|
---|
48 | {
|
---|
49 |
|
---|
50 | protected $_rootElement = 'recurrenceException';
|
---|
51 | protected $_specialized = null;
|
---|
52 | protected $_entryLink = null;
|
---|
53 | protected $_originalEvent = null;
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Constructs a new Zend_Gdata_Extension_RecurrenceException object.
|
---|
57 | * @param bool $specialized (optional) Whether this is a specialized exception or not.
|
---|
58 | * @param Zend_Gdata_EntryLink (optional) An Event entry with details about the exception.
|
---|
59 | * @param Zend_Gdata_OriginalEvent (optional) The origianl recurrent event this is an exeption to.
|
---|
60 | */
|
---|
61 | public function __construct($specialized = null, $entryLink = null,
|
---|
62 | $originalEvent = null)
|
---|
63 | {
|
---|
64 | parent::__construct();
|
---|
65 | $this->_specialized = $specialized;
|
---|
66 | $this->_entryLink = $entryLink;
|
---|
67 | $this->_originalEvent = $originalEvent;
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
72 | * child properties. This is used to build an entry back into a DOM
|
---|
73 | * and eventually XML text for sending to the server upon updates, or
|
---|
74 | * for application storage/persistence.
|
---|
75 | *
|
---|
76 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
77 | * @return DOMElement The DOMElement representing this element and all
|
---|
78 | * child properties.
|
---|
79 | */
|
---|
80 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
81 | {
|
---|
82 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
83 | if ($this->_specialized !== null) {
|
---|
84 | $element->setAttribute('specialized', ($this->_specialized ? "true" : "false"));
|
---|
85 | }
|
---|
86 | if ($this->_entryLink !== null) {
|
---|
87 | $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
|
---|
88 | }
|
---|
89 | if ($this->_originalEvent !== null) {
|
---|
90 | $element->appendChild($this->_originalEvent->getDOM($element->ownerDocument));
|
---|
91 | }
|
---|
92 | return $element;
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Given a DOMNode representing an attribute, tries to map the data into
|
---|
97 | * instance members. If no mapping is defined, the name and value are
|
---|
98 | * stored in an array.
|
---|
99 | *
|
---|
100 | * @param DOMNode $attribute The DOMNode attribute needed to be handled
|
---|
101 | */
|
---|
102 | protected function takeAttributeFromDOM($attribute)
|
---|
103 | {
|
---|
104 | switch ($attribute->localName) {
|
---|
105 | case 'specialized':
|
---|
106 | if ($attribute->nodeValue == "true") {
|
---|
107 | $this->_specialized = true;
|
---|
108 | }
|
---|
109 | else if ($attribute->nodeValue == "false") {
|
---|
110 | $this->_specialized = false;
|
---|
111 | }
|
---|
112 | else {
|
---|
113 | throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
|
---|
114 | }
|
---|
115 | break;
|
---|
116 | default:
|
---|
117 | parent::takeAttributeFromDOM($attribute);
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Creates individual Entry objects of the appropriate type and
|
---|
123 | * stores them as members of this entry based upon DOM data.
|
---|
124 | *
|
---|
125 | * @param DOMNode $child The DOMNode to process
|
---|
126 | */
|
---|
127 | protected function takeChildFromDOM($child)
|
---|
128 | {
|
---|
129 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
130 | switch ($absoluteNodeName) {
|
---|
131 | case $this->lookupNamespace('gd') . ':' . 'entryLink':
|
---|
132 | $entryLink = new Zend_Gdata_Extension_EntryLink();
|
---|
133 | $entryLink->transferFromDOM($child);
|
---|
134 | $this->_entryLink = $entryLink;
|
---|
135 | break;
|
---|
136 | case $this->lookupNamespace('gd') . ':' . 'originalEvent':
|
---|
137 | $originalEvent = new Zend_Gdata_Extension_OriginalEvent();
|
---|
138 | $originalEvent->transferFromDOM($child);
|
---|
139 | $this->_originalEvent = $originalEvent;
|
---|
140 | break;
|
---|
141 | default:
|
---|
142 | parent::takeChildFromDOM($child);
|
---|
143 | break;
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Get the value for this element's Specialized attribute.
|
---|
149 | *
|
---|
150 | * @return bool The requested attribute.
|
---|
151 | */
|
---|
152 | public function getSpecialized()
|
---|
153 | {
|
---|
154 | return $this->_specialized;
|
---|
155 | }
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Set the value for this element's Specialized attribute.
|
---|
159 | *
|
---|
160 | * @param bool $value The desired value for this attribute.
|
---|
161 | * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
|
---|
162 | */
|
---|
163 | public function setSpecialized($value)
|
---|
164 | {
|
---|
165 | $this->_specialized = $value;
|
---|
166 | return $this;
|
---|
167 | }
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Get the value for this element's EntryLink attribute.
|
---|
171 | *
|
---|
172 | * @return Zend_Gdata_Extension_EntryLink The requested attribute.
|
---|
173 | */
|
---|
174 | public function getEntryLink()
|
---|
175 | {
|
---|
176 | return $this->_entryLink;
|
---|
177 | }
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Set the value for this element's EntryLink attribute.
|
---|
181 | *
|
---|
182 | * @param Zend_Gdata_Extension_EntryLink $value The desired value for this attribute.
|
---|
183 | * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
|
---|
184 | */
|
---|
185 | public function setEntryLink($value)
|
---|
186 | {
|
---|
187 | $this->_entryLink = $value;
|
---|
188 | return $this;
|
---|
189 | }
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Get the value for this element's Specialized attribute.
|
---|
193 | *
|
---|
194 | * @return Zend_Gdata_Extension_OriginalEvent The requested attribute.
|
---|
195 | */
|
---|
196 | public function getOriginalEvent()
|
---|
197 | {
|
---|
198 | return $this->_originalEvent;
|
---|
199 | }
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Set the value for this element's Specialized attribute.
|
---|
203 | *
|
---|
204 | * @param Zend_Gdata_Extension_OriginalEvent $value The desired value for this attribute.
|
---|
205 | * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
|
---|
206 | */
|
---|
207 | public function setOriginalEvent($value)
|
---|
208 | {
|
---|
209 | $this->_originalEvent = $value;
|
---|
210 | return $this;
|
---|
211 | }
|
---|
212 |
|
---|
213 | }
|
---|
214 |
|
---|