source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/YouTube/InboxEntry.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 8.4 KB
Line 
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-2009 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_Media_Entry
25 */
26require_once 'Zend/Gdata/Media/Entry.php';
27
28/**
29 * @see Zend_Gdata_Extension_Rating
30 */
31require_once 'Zend/Gdata/Extension/Rating.php';
32
33/**
34 * @see Zend_Gdata_Extension_Comments
35 */
36require_once 'Zend/Gdata/Extension/Comments.php';
37
38/**
39 * @see Zend_Gdata_YouTube_Extension_Statistics
40 */
41require_once 'Zend/Gdata/YouTube/Extension/Statistics.php';
42
43/**
44 * @see Zend_Gdata_YouTube_Extension_Description
45 */
46require_once 'Zend/Gdata/YouTube/Extension/Description.php';
47
48
49/**
50 * Represents the YouTube message flavor of an Atom entry
51 *
52 * @category Zend
53 * @package Zend_Gdata
54 * @subpackage YouTube
55 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
56 * @license http://framework.zend.com/license/new-bsd New BSD License
57 */
58class Zend_Gdata_YouTube_InboxEntry extends Zend_Gdata_Media_Entry
59{
60
61 protected $_entryClassName = 'Zend_Gdata_YouTube_InboxEntry';
62
63 /**
64 * The gd:comments element of this entry.
65 *
66 * @var Zend_Gdata_Extension_Comments
67 */
68 protected $_comments = null;
69
70 /**
71 * The gd:rating element of this entry.
72 *
73 * @var Zend_Gdata_Extension_Rating
74 */
75 protected $_rating = null;
76
77 /**
78 * The yt:statistics element of this entry.
79 *
80 * @var Zend_Gdata_YouTube_Extension_Statistics
81 */
82 protected $_statistics = null;
83
84 /**
85 * The yt:description element of this entry.
86 *
87 * @var Zend_Gdata_YouTube_Extension_Description
88 */
89 protected $_description = null;
90
91 /**
92 * Creates a subscription entry, representing an individual subscription
93 * in a list of subscriptions, usually associated with an individual user.
94 *
95 * @param DOMElement $element (optional) DOMElement from which this
96 * object should be constructed.
97 */
98 public function __construct($element = null)
99 {
100 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
101 parent::__construct($element);
102 }
103
104 /**
105 * Retrieves a DOMElement which corresponds to this element and all
106 * child properties. This is used to build an entry back into a DOM
107 * and eventually XML text for sending to the server upon updates, or
108 * for application storage/persistence.
109 *
110 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
111 * @return DOMElement The DOMElement representing this element and all
112 * child properties.
113 */
114 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
115 {
116 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
117 if ($this->_description != null) {
118 $element->appendChild(
119 $this->_description->getDOM($element->ownerDocument));
120 }
121 if ($this->_rating != null) {
122 $element->appendChild(
123 $this->_rating->getDOM($element->ownerDocument));
124 }
125 if ($this->_statistics != null) {
126 $element->appendChild(
127 $this->_statistics->getDOM($element->ownerDocument));
128 }
129 if ($this->_comments != null) {
130 $element->appendChild(
131 $this->_comments->getDOM($element->ownerDocument));
132 }
133 return $element;
134 }
135
136 /**
137 * Creates individual Entry objects of the appropriate type and
138 * stores them in the $_entry array based upon DOM data.
139 *
140 * @param DOMNode $child The DOMNode to process
141 */
142 protected function takeChildFromDOM($child)
143 {
144 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
145 switch ($absoluteNodeName) {
146 case $this->lookupNamespace('gd') . ':' . 'comments':
147 $comments = new Zend_Gdata_Extension_Comments();
148 $comments->transferFromDOM($child);
149 $this->_comments = $comments;
150 break;
151 case $this->lookupNamespace('gd') . ':' . 'rating':
152 $rating = new Zend_Gdata_Extension_Rating();
153 $rating->transferFromDOM($child);
154 $this->_rating = $rating;
155 break;
156 case $this->lookupNamespace('yt') . ':' . 'description':
157 $description = new Zend_Gdata_YouTube_Extension_Description();
158 $description->transferFromDOM($child);
159 $this->_description = $description;
160 break;
161 case $this->lookupNamespace('yt') . ':' . 'statistics':
162 $statistics = new Zend_Gdata_YouTube_Extension_Statistics();
163 $statistics->transferFromDOM($child);
164 $this->_statistics = $statistics;
165 break;
166 default:
167 parent::takeChildFromDOM($child);
168 break;
169 }
170 }
171
172 /**
173 * Get the yt:description
174 *
175 * @throws Zend_Gdata_App_VersionException
176 * @return Zend_Gdata_YouTube_Extension_Description|null
177 */
178 public function getDescription()
179 {
180 if ($this->getMajorProtocolVersion() == 2) {
181 require_once 'Zend/Gdata/App/VersionException.php';
182 throw new Zend_Gdata_App_VersionException('The getDescription ' .
183 ' method is only supported in version 1 of the YouTube ' .
184 'API.');
185 } else {
186 return $this->_description;
187 }
188 }
189
190 /**
191 * Sets the yt:description element for a new inbox entry.
192 *
193 * @param Zend_Gdata_YouTube_Extension_Description $description The
194 * description.
195 * @throws Zend_Gdata_App_VersionException
196 * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
197 */
198 public function setDescription($description = null)
199 {
200 if ($this->getMajorProtocolVersion() == 2) {
201 require_once 'Zend/Gdata/App/VersionException.php';
202 throw new Zend_Gdata_App_VersionException('The setDescription ' .
203 ' method is only supported in version 1 of the YouTube ' .
204 'API.');
205 } else {
206 $this->_description = $description;
207 return $this;
208 }
209 }
210
211 /**
212 * Get the gd:rating element for the inbox entry
213 *
214 * @return Zend_Gdata_Extension_Rating|null
215 */
216 public function getRating()
217 {
218 return $this->_rating;
219 }
220
221 /**
222 * Sets the gd:rating element for the inbox entry
223 *
224 * @param Zend_Gdata_Extension_Rating $rating The rating for the video in
225 * the message
226 * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
227 */
228 public function setRating($rating = null)
229 {
230 $this->_rating = $rating;
231 return $this;
232 }
233
234 /**
235 * Get the gd:comments element of the inbox entry.
236 *
237 * @return Zend_Gdata_Extension_Comments|null
238 */
239 public function getComments()
240 {
241 return $this->_comments;
242 }
243
244 /**
245 * Sets the gd:comments element for the inbox entry
246 *
247 * @param Zend_Gdata_Extension_Comments $comments The comments feed link
248 * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
249 */
250 public function setComments($comments = null)
251 {
252 $this->_comments = $comments;
253 return $this;
254 }
255
256 /**
257 * Get the yt:statistics element for the inbox entry
258 *
259 * @return Zend_Gdata_YouTube_Extension_Statistics|null
260 */
261 public function getStatistics()
262 {
263 return $this->_statistics;
264 }
265
266 /**
267 * Sets the yt:statistics element for the inbox entry
268 *
269 * @param Zend_Gdata_YouTube_Extension_Statistics $statistics The
270 * statistics element for the video in the message
271 * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
272 */
273 public function setStatistics($statistics = null)
274 {
275 $this->_statistics = $statistics;
276 return $this;
277 }
278
279
280}
Note: See TracBrowser for help on using the repository browser.