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 YouTube
|
---|
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_Entry
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/Entry.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * @see Zend_Gdata_Extension_FeedLink
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Extension/FeedLink.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @see Zend_Gdata_YouTube_Extension_Description
|
---|
35 | */
|
---|
36 | require_once 'Zend/Gdata/YouTube/Extension/Description.php';
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * @see Zend_Gdata_YouTube_Extension_PlaylistTitle
|
---|
40 | */
|
---|
41 | require_once 'Zend/Gdata/YouTube/Extension/PlaylistTitle.php';
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @see Zend_Gdata_YouTube_Extension_PlaylistId
|
---|
45 | */
|
---|
46 | require_once 'Zend/Gdata/YouTube/Extension/PlaylistId.php';
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * @see Zend_Gdata_Media_Extension_MediaThumbnail
|
---|
50 | */
|
---|
51 | require_once 'Zend/Gdata/Media/Extension/MediaThumbnail.php';
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * @see Zend_Gdata_YouTube_Extension_Username
|
---|
55 | */
|
---|
56 | require_once 'Zend/Gdata/YouTube/Extension/Username.php';
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * @see Zend_Gdata_YouTube_Extension_CountHint
|
---|
60 | */
|
---|
61 | require_once 'Zend/Gdata/YouTube/Extension/CountHint.php';
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * @see Zend_Gdata_YouTube_Extension_QueryString
|
---|
65 | */
|
---|
66 | require_once 'Zend/Gdata/YouTube/Extension/QueryString.php';
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Represents the YouTube video subscription flavor of an Atom entry
|
---|
70 | *
|
---|
71 | * @category Zend
|
---|
72 | * @package Zend_Gdata
|
---|
73 | * @subpackage YouTube
|
---|
74 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
75 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
76 | */
|
---|
77 | class Zend_Gdata_YouTube_SubscriptionEntry extends Zend_Gdata_Entry
|
---|
78 | {
|
---|
79 |
|
---|
80 | protected $_entryClassName = 'Zend_Gdata_YouTube_SubscriptionEntry';
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Nested feed links
|
---|
84 | *
|
---|
85 | * @var array
|
---|
86 | */
|
---|
87 | protected $_feedLink = array();
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * The username of this entry.
|
---|
91 | *
|
---|
92 | * @var Zend_Gdata_YouTube_Extension_Username
|
---|
93 | */
|
---|
94 | protected $_username = null;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * The playlist title for this entry.
|
---|
98 | *
|
---|
99 | * This element is only used on subscriptions to playlists.
|
---|
100 | *
|
---|
101 | * @var Zend_Gdata_YouTube_Extension_PlaylistTitle
|
---|
102 | */
|
---|
103 | protected $_playlistTitle = null;
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * The playlist id for this entry.
|
---|
107 | *
|
---|
108 | * This element is only used on subscriptions to playlists.
|
---|
109 | *
|
---|
110 | * @var Zend_Gdata_YouTube_Extension_PlaylistId
|
---|
111 | */
|
---|
112 | protected $_playlistId = null;
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * The media:thumbnail element for this entry.
|
---|
116 | *
|
---|
117 | * This element is only used on subscriptions to playlists.
|
---|
118 | *
|
---|
119 | * @var Zend_Gdata_Media_Extension_MediaThumbnail
|
---|
120 | */
|
---|
121 | protected $_mediaThumbnail = null;
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * The countHint for this entry.
|
---|
125 | *
|
---|
126 | * @var Zend_Gdata_YouTube_Extension_CountHint
|
---|
127 | */
|
---|
128 | protected $_countHint = null;
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * The queryString for this entry.
|
---|
132 | *
|
---|
133 | * @var Zend_Gdata_YouTube_Extension_QueryString
|
---|
134 | */
|
---|
135 | protected $_queryString = null;
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Creates a subscription entry, representing an individual subscription
|
---|
139 | * in a list of subscriptions, usually associated with an individual user.
|
---|
140 | *
|
---|
141 | * @param DOMElement $element (optional) DOMElement from which this
|
---|
142 | * object should be constructed.
|
---|
143 | */
|
---|
144 | public function __construct($element = null)
|
---|
145 | {
|
---|
146 | $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
|
---|
147 | parent::__construct($element);
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
152 | * child properties. This is used to build an entry back into a DOM
|
---|
153 | * and eventually XML text for sending to the server upon updates, or
|
---|
154 | * for application storage/persistence.
|
---|
155 | *
|
---|
156 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
157 | * @return DOMElement The DOMElement representing this element and all
|
---|
158 | * child properties.
|
---|
159 | */
|
---|
160 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
161 | {
|
---|
162 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
163 | if ($this->_countHint != null) {
|
---|
164 | $element->appendChild($this->_countHint->getDOM($element->ownerDocument));
|
---|
165 | }
|
---|
166 | if ($this->_playlistTitle != null) {
|
---|
167 | $element->appendChild($this->_playlistTitle->getDOM($element->ownerDocument));
|
---|
168 | }
|
---|
169 | if ($this->_playlistId != null) {
|
---|
170 | $element->appendChild($this->_playlistId->getDOM($element->ownerDocument));
|
---|
171 | }
|
---|
172 | if ($this->_mediaThumbnail != null) {
|
---|
173 | $element->appendChild($this->_mediaThumbnail->getDOM($element->ownerDocument));
|
---|
174 | }
|
---|
175 | if ($this->_username != null) {
|
---|
176 | $element->appendChild($this->_username->getDOM($element->ownerDocument));
|
---|
177 | }
|
---|
178 | if ($this->_queryString != null) {
|
---|
179 | $element->appendChild($this->_queryString->getDOM($element->ownerDocument));
|
---|
180 | }
|
---|
181 | if ($this->_feedLink != null) {
|
---|
182 | foreach ($this->_feedLink as $feedLink) {
|
---|
183 | $element->appendChild($feedLink->getDOM($element->ownerDocument));
|
---|
184 | }
|
---|
185 | }
|
---|
186 | return $element;
|
---|
187 | }
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * Creates individual Entry objects of the appropriate type and
|
---|
191 | * stores them in the $_entry array based upon DOM data.
|
---|
192 | *
|
---|
193 | * @param DOMNode $child The DOMNode to process
|
---|
194 | */
|
---|
195 | protected function takeChildFromDOM($child)
|
---|
196 | {
|
---|
197 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
198 | switch ($absoluteNodeName) {
|
---|
199 | case $this->lookupNamespace('gd') . ':' . 'feedLink':
|
---|
200 | $feedLink = new Zend_Gdata_Extension_FeedLink();
|
---|
201 | $feedLink->transferFromDOM($child);
|
---|
202 | $this->_feedLink[] = $feedLink;
|
---|
203 | break;
|
---|
204 | case $this->lookupNamespace('media') . ':' . 'thumbnail':
|
---|
205 | $mediaThumbnail = new Zend_Gdata_Media_Extension_MediaThumbnail();
|
---|
206 | $mediaThumbnail->transferFromDOM($child);
|
---|
207 | $this->_mediaThumbnail = $mediaThumbnail;
|
---|
208 | break;
|
---|
209 | case $this->lookupNamespace('yt') . ':' . 'countHint':
|
---|
210 | $countHint = new Zend_Gdata_YouTube_Extension_CountHint();
|
---|
211 | $countHint->transferFromDOM($child);
|
---|
212 | $this->_countHint = $countHint;
|
---|
213 | break;
|
---|
214 | case $this->lookupNamespace('yt') . ':' . 'playlistTitle':
|
---|
215 | $playlistTitle = new Zend_Gdata_YouTube_Extension_PlaylistTitle();
|
---|
216 | $playlistTitle->transferFromDOM($child);
|
---|
217 | $this->_playlistTitle = $playlistTitle;
|
---|
218 | break;
|
---|
219 | case $this->lookupNamespace('yt') . ':' . 'playlistId':
|
---|
220 | $playlistId = new Zend_Gdata_YouTube_Extension_PlaylistId();
|
---|
221 | $playlistId->transferFromDOM($child);
|
---|
222 | $this->_playlistId = $playlistId;
|
---|
223 | break;
|
---|
224 | case $this->lookupNamespace('yt') . ':' . 'queryString':
|
---|
225 | $queryString = new Zend_Gdata_YouTube_Extension_QueryString();
|
---|
226 | $queryString->transferFromDOM($child);
|
---|
227 | $this->_queryString = $queryString;
|
---|
228 | break;
|
---|
229 | case $this->lookupNamespace('yt') . ':' . 'username':
|
---|
230 | $username = new Zend_Gdata_YouTube_Extension_Username();
|
---|
231 | $username->transferFromDOM($child);
|
---|
232 | $this->_username = $username;
|
---|
233 | break;
|
---|
234 | default:
|
---|
235 | parent::takeChildFromDOM($child);
|
---|
236 | break;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * Sets the array of embedded feeds related to the video
|
---|
242 | *
|
---|
243 | * @param array $feedLink The array of embedded feeds relating to the video
|
---|
244 | * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
|
---|
245 | */
|
---|
246 | public function setFeedLink($feedLink = null)
|
---|
247 | {
|
---|
248 | $this->_feedLink = $feedLink;
|
---|
249 | return $this;
|
---|
250 | }
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * Get the feed link property for this entry.
|
---|
254 | *
|
---|
255 | * @see setFeedLink
|
---|
256 | * @param string $rel (optional) The rel value of the link to be found.
|
---|
257 | * If null, the array of links is returned.
|
---|
258 | * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink
|
---|
259 | * object corresponding to the requested rel value is returned
|
---|
260 | * if found, or null if the requested value is not found. If
|
---|
261 | * $rel is null or not specified, an array of all available
|
---|
262 | * feed links for this entry is returned, or null if no feed
|
---|
263 | * links are set.
|
---|
264 | */
|
---|
265 | public function getFeedLink($rel = null)
|
---|
266 | {
|
---|
267 | if ($rel == null) {
|
---|
268 | return $this->_feedLink;
|
---|
269 | } else {
|
---|
270 | foreach ($this->_feedLink as $feedLink) {
|
---|
271 | if ($feedLink->rel == $rel) {
|
---|
272 | return $feedLink;
|
---|
273 | }
|
---|
274 | }
|
---|
275 | return null;
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Get the playlist title for a 'playlist' subscription.
|
---|
281 | *
|
---|
282 | * @throws Zend_Gdata_App_VersionException
|
---|
283 | * @return Zend_Gdata_YouTube_Extension_PlaylistId
|
---|
284 | */
|
---|
285 | public function getPlaylistId()
|
---|
286 | {
|
---|
287 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
288 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
289 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
290 | throw new Zend_Gdata_App_VersionException('The getPlaylistId ' .
|
---|
291 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
292 | 'API.');
|
---|
293 | } else {
|
---|
294 | return $this->_playlistId;
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | /**
|
---|
299 | * Sets the yt:playlistId element for a new playlist subscription.
|
---|
300 | *
|
---|
301 | * @param Zend_Gdata_YouTube_Extension_PlaylistId $id The id of
|
---|
302 | * the playlist to which to subscribe to.
|
---|
303 | * @throws Zend_Gdata_App_VersionException
|
---|
304 | * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
|
---|
305 | */
|
---|
306 | public function setPlaylistId($id = null)
|
---|
307 | {
|
---|
308 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
309 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
310 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
311 | throw new Zend_Gdata_App_VersionException('The setPlaylistTitle ' .
|
---|
312 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
313 | 'API.');
|
---|
314 | } else {
|
---|
315 | $this->_playlistId = $id;
|
---|
316 | return $this;
|
---|
317 | }
|
---|
318 | }
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Get the queryString of the subscription
|
---|
322 | *
|
---|
323 | * @return Zend_Gdata_YouTube_Extension_QueryString
|
---|
324 | */
|
---|
325 | public function getQueryString()
|
---|
326 | {
|
---|
327 | return $this->_queryString;
|
---|
328 | }
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Sets the yt:queryString element for a new keyword subscription.
|
---|
332 | *
|
---|
333 | * @param Zend_Gdata_YouTube_Extension_QueryString $queryString The query
|
---|
334 | * string to subscribe to
|
---|
335 | * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
|
---|
336 | */
|
---|
337 | public function setQueryString($queryString = null)
|
---|
338 | {
|
---|
339 | $this->_queryString = $queryString;
|
---|
340 | return $this;
|
---|
341 | }
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * Get the playlist title for a 'playlist' subscription.
|
---|
345 | *
|
---|
346 | * @throws Zend_Gdata_App_VersionException
|
---|
347 | * @return Zend_Gdata_YouTube_Extension_PlaylistTitle
|
---|
348 | */
|
---|
349 | public function getPlaylistTitle()
|
---|
350 | {
|
---|
351 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
352 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
353 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
354 | throw new Zend_Gdata_App_VersionException('The getPlaylistTitle ' .
|
---|
355 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
356 | 'API.');
|
---|
357 | } else {
|
---|
358 | return $this->_playlistTitle;
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Sets the yt:playlistTitle element for a new playlist subscription.
|
---|
364 | *
|
---|
365 | * @param Zend_Gdata_YouTube_Extension_PlaylistTitle $title The title of
|
---|
366 | * the playlist to which to subscribe to.
|
---|
367 | * @throws Zend_Gdata_App_VersionException
|
---|
368 | * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
|
---|
369 | */
|
---|
370 | public function setPlaylistTitle($title = null)
|
---|
371 | {
|
---|
372 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
373 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
374 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
375 | throw new Zend_Gdata_App_VersionException('The setPlaylistTitle ' .
|
---|
376 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
377 | 'API.');
|
---|
378 | } else {
|
---|
379 | $this->_playlistTitle = $title;
|
---|
380 | return $this;
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | /**
|
---|
385 | * Get the counthint for a subscription.
|
---|
386 | *
|
---|
387 | * @throws Zend_Gdata_App_VersionException
|
---|
388 | * @return Zend_Gdata_YouTube_Extension_CountHint
|
---|
389 | */
|
---|
390 | public function getCountHint()
|
---|
391 | {
|
---|
392 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
393 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
394 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
395 | throw new Zend_Gdata_App_VersionException('The getCountHint ' .
|
---|
396 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
397 | 'API.');
|
---|
398 | } else {
|
---|
399 | return $this->_countHint;
|
---|
400 | }
|
---|
401 | }
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Get the thumbnail for a subscription.
|
---|
405 | *
|
---|
406 | * @throws Zend_Gdata_App_VersionException
|
---|
407 | * @return Zend_Gdata_Media_Extension_MediaThumbnail
|
---|
408 | */
|
---|
409 | public function getMediaThumbnail()
|
---|
410 | {
|
---|
411 | if (($this->getMajorProtocolVersion() == null) ||
|
---|
412 | ($this->getMajorProtocolVersion() == 1)) {
|
---|
413 | require_once 'Zend/Gdata/App/VersionException.php';
|
---|
414 | throw new Zend_Gdata_App_VersionException('The getMediaThumbnail ' .
|
---|
415 | ' method is only supported as of version 2 of the YouTube ' .
|
---|
416 | 'API.');
|
---|
417 | } else {
|
---|
418 | return $this->_mediaThumbnail;
|
---|
419 | }
|
---|
420 | }
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Get the username for a channel subscription.
|
---|
424 | *
|
---|
425 | * @return Zend_Gdata_YouTube_Extension_Username
|
---|
426 | */
|
---|
427 | public function getUsername()
|
---|
428 | {
|
---|
429 | return $this->_username;
|
---|
430 | }
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * Sets the username for a new channel subscription.
|
---|
434 | *
|
---|
435 | * @param Zend_Gdata_YouTube_Extension_Username $username The username of
|
---|
436 | * the channel to which to subscribe to.
|
---|
437 | * @return Zend_Gdata_YouTube_SubscriptionEntry Provides a fluent interface
|
---|
438 | */
|
---|
439 | public function setUsername($username = null)
|
---|
440 | {
|
---|
441 | $this->_username = $username;
|
---|
442 | return $this;
|
---|
443 | }
|
---|
444 |
|
---|
445 | }
|
---|