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 Gapps |
---|
19 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
21 | * @version $Id: EmailListEntry.php 24594 2012-01-05 21:27:01Z matthew $ |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * @see Zend_Gdata_Entry |
---|
26 | */ |
---|
27 | require_once 'Zend/Gdata/Entry.php'; |
---|
28 | |
---|
29 | /** |
---|
30 | * @see Zend_Gdata_Extension_FeedLink |
---|
31 | */ |
---|
32 | require_once 'Zend/Gdata/Extension/FeedLink.php'; |
---|
33 | |
---|
34 | /** |
---|
35 | * @see Zend_Gdata_Gapps_Extension_EmailList |
---|
36 | */ |
---|
37 | require_once 'Zend/Gdata/Gapps/Extension/EmailList.php'; |
---|
38 | |
---|
39 | /** |
---|
40 | * Data model class for a Google Apps Email List Entry. |
---|
41 | * |
---|
42 | * Each email list entry describes a single email list within a Google Apps |
---|
43 | * hosted domain. Email lists may contain multiple recipients, as |
---|
44 | * described by instances of Zend_Gdata_Gapps_EmailListRecipient. Multiple |
---|
45 | * entries are contained within instances of Zend_Gdata_Gapps_EmailListFeed. |
---|
46 | * |
---|
47 | * To transfer email list entries to and from the Google Apps servers, |
---|
48 | * including creating new entries, refer to the Google Apps service class, |
---|
49 | * Zend_Gdata_Gapps. |
---|
50 | * |
---|
51 | * This class represents <atom:entry> in the Google Data protocol. |
---|
52 | * |
---|
53 | * @category Zend |
---|
54 | * @package Zend_Gdata |
---|
55 | * @subpackage Gapps |
---|
56 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
57 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
58 | */ |
---|
59 | class Zend_Gdata_Gapps_EmailListEntry extends Zend_Gdata_Entry |
---|
60 | { |
---|
61 | |
---|
62 | protected $_entryClassName = 'Zend_Gdata_Gapps_EmailListEntry'; |
---|
63 | |
---|
64 | /** |
---|
65 | * <apps:emailList> child element containing general information about |
---|
66 | * this email list. |
---|
67 | * |
---|
68 | * @var Zend_Gdata_Gapps_Extension_EmailList |
---|
69 | */ |
---|
70 | protected $_emailList = null; |
---|
71 | |
---|
72 | /** |
---|
73 | * <gd:feedLink> element containing information about other feeds |
---|
74 | * relevant to this entry. |
---|
75 | * |
---|
76 | * @var Zend_Gdata_Extension_FeedLink |
---|
77 | */ |
---|
78 | protected $_feedLink = array(); |
---|
79 | |
---|
80 | /** |
---|
81 | * Create a new instance. |
---|
82 | * |
---|
83 | * @param DOMElement $element (optional) DOMElement from which this |
---|
84 | * object should be constructed. |
---|
85 | */ |
---|
86 | public function __construct($element = null) |
---|
87 | { |
---|
88 | $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); |
---|
89 | parent::__construct($element); |
---|
90 | } |
---|
91 | |
---|
92 | /** |
---|
93 | * Retrieves a DOMElement which corresponds to this element and all |
---|
94 | * child properties. This is used to build an entry back into a DOM |
---|
95 | * and eventually XML text for application storage/persistence. |
---|
96 | * |
---|
97 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
---|
98 | * @return DOMElement The DOMElement representing this element and all |
---|
99 | * child properties. |
---|
100 | */ |
---|
101 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
---|
102 | { |
---|
103 | $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
---|
104 | if ($this->_emailList !== null) { |
---|
105 | $element->appendChild($this->_emailList->getDOM($element->ownerDocument)); |
---|
106 | } |
---|
107 | foreach ($this->_feedLink as $feedLink) { |
---|
108 | $element->appendChild($feedLink->getDOM($element->ownerDocument)); |
---|
109 | } |
---|
110 | return $element; |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * Creates individual Entry objects of the appropriate type and |
---|
115 | * stores them as members of this entry based upon DOM data. |
---|
116 | * |
---|
117 | * @param DOMNode $child The DOMNode to process |
---|
118 | */ |
---|
119 | protected function takeChildFromDOM($child) |
---|
120 | { |
---|
121 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; |
---|
122 | |
---|
123 | switch ($absoluteNodeName) { |
---|
124 | case $this->lookupNamespace('apps') . ':' . 'emailList'; |
---|
125 | $emailList = new Zend_Gdata_Gapps_Extension_EmailList(); |
---|
126 | $emailList->transferFromDOM($child); |
---|
127 | $this->_emailList = $emailList; |
---|
128 | break; |
---|
129 | case $this->lookupNamespace('gd') . ':' . 'feedLink'; |
---|
130 | $feedLink = new Zend_Gdata_Extension_FeedLink(); |
---|
131 | $feedLink->transferFromDOM($child); |
---|
132 | $this->_feedLink[] = $feedLink; |
---|
133 | break; |
---|
134 | default: |
---|
135 | parent::takeChildFromDOM($child); |
---|
136 | break; |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | /** |
---|
141 | * Retrieve the email list property for this entry. |
---|
142 | * |
---|
143 | * @see setEmailList |
---|
144 | * @return Zend_Gdata_Gapps_Extension_EmailList The requested object |
---|
145 | * or null if not set. |
---|
146 | */ |
---|
147 | public function getEmailList() |
---|
148 | { |
---|
149 | return $this->_emailList; |
---|
150 | } |
---|
151 | |
---|
152 | /** |
---|
153 | * Set the email list property for this entry. This property contains |
---|
154 | * information such as the name of this email list. |
---|
155 | * |
---|
156 | * This corresponds to the <apps:emailList> property in the Google Data |
---|
157 | * protocol. |
---|
158 | * |
---|
159 | * @param Zend_Gdata_Gapps_Extension_EmailList $value The desired value |
---|
160 | * this element, or null to unset. |
---|
161 | * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface |
---|
162 | */ |
---|
163 | public function setEmailList($value) |
---|
164 | { |
---|
165 | $this->_emailList = $value; |
---|
166 | return $this; |
---|
167 | } |
---|
168 | |
---|
169 | /** |
---|
170 | * Get the feed link property for this entry. |
---|
171 | * |
---|
172 | * @see setFeedLink |
---|
173 | * @param string $rel (optional) The rel value of the link to be found. |
---|
174 | * If null, the array of links is returned. |
---|
175 | * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink |
---|
176 | * object corresponding to the requested rel value is returned |
---|
177 | * if found, or null if the requested value is not found. If |
---|
178 | * $rel is null or not specified, an array of all available |
---|
179 | * feed links for this entry is returned, or null if no feed |
---|
180 | * links are set. |
---|
181 | */ |
---|
182 | public function getFeedLink($rel = null) |
---|
183 | { |
---|
184 | if ($rel == null) { |
---|
185 | return $this->_feedLink; |
---|
186 | } else { |
---|
187 | foreach ($this->_feedLink as $feedLink) { |
---|
188 | if ($feedLink->rel == $rel) { |
---|
189 | return $feedLink; |
---|
190 | } |
---|
191 | } |
---|
192 | return null; |
---|
193 | } |
---|
194 | } |
---|
195 | |
---|
196 | /** |
---|
197 | * Set the feed link property for this entry. Feed links provide |
---|
198 | * information about other feeds associated with this entry. |
---|
199 | * |
---|
200 | * This corresponds to the <gd:feedLink> property in the Google Data |
---|
201 | * protocol. |
---|
202 | * |
---|
203 | * @param array $value A collection of Zend_Gdata_Gapps_Extension_FeedLink |
---|
204 | * instances representing all feed links for this entry, or |
---|
205 | * null to unset. |
---|
206 | * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface |
---|
207 | */ |
---|
208 | public function setFeedLink($value) |
---|
209 | { |
---|
210 | $this->_feedLink = $value; |
---|
211 | return $this; |
---|
212 | } |
---|
213 | |
---|
214 | } |
---|