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