*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Gdata / YouTube / InboxEntry.php
blobfcf0d66f389c0f0e57c3750517a276b677245ba7
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
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.
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 * @version $Id: InboxEntry.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 /**
25 * @see Zend_Gdata_Media_Entry
27 require_once 'Zend/Gdata/Media/Entry.php';
29 /**
30 * @see Zend_Gdata_Extension_Rating
32 require_once 'Zend/Gdata/Extension/Rating.php';
34 /**
35 * @see Zend_Gdata_Extension_Comments
37 require_once 'Zend/Gdata/Extension/Comments.php';
39 /**
40 * @see Zend_Gdata_YouTube_Extension_Statistics
42 require_once 'Zend/Gdata/YouTube/Extension/Statistics.php';
44 /**
45 * @see Zend_Gdata_YouTube_Extension_Description
47 require_once 'Zend/Gdata/YouTube/Extension/Description.php';
50 /**
51 * Represents the YouTube message flavor of an Atom entry
53 * @category Zend
54 * @package Zend_Gdata
55 * @subpackage YouTube
56 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
57 * @license http://framework.zend.com/license/new-bsd New BSD License
59 class Zend_Gdata_YouTube_InboxEntry extends Zend_Gdata_Media_Entry
62 protected $_entryClassName = 'Zend_Gdata_YouTube_InboxEntry';
64 /**
65 * The gd:comments element of this entry.
67 * @var Zend_Gdata_Extension_Comments
69 protected $_comments = null;
71 /**
72 * The gd:rating element of this entry.
74 * @var Zend_Gdata_Extension_Rating
76 protected $_rating = null;
78 /**
79 * The yt:statistics element of this entry.
81 * @var Zend_Gdata_YouTube_Extension_Statistics
83 protected $_statistics = null;
85 /**
86 * The yt:description element of this entry.
88 * @var Zend_Gdata_YouTube_Extension_Description
90 protected $_description = null;
92 /**
93 * Creates a subscription entry, representing an individual subscription
94 * in a list of subscriptions, usually associated with an individual user.
96 * @param DOMElement $element (optional) DOMElement from which this
97 * object should be constructed.
99 public function __construct($element = null)
101 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
102 parent::__construct($element);
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.
111 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
112 * @return DOMElement The DOMElement representing this element and all
113 * child properties.
115 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
117 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
118 if ($this->_description != null) {
119 $element->appendChild(
120 $this->_description->getDOM($element->ownerDocument));
122 if ($this->_rating != null) {
123 $element->appendChild(
124 $this->_rating->getDOM($element->ownerDocument));
126 if ($this->_statistics != null) {
127 $element->appendChild(
128 $this->_statistics->getDOM($element->ownerDocument));
130 if ($this->_comments != null) {
131 $element->appendChild(
132 $this->_comments->getDOM($element->ownerDocument));
134 return $element;
138 * Creates individual Entry objects of the appropriate type and
139 * stores them in the $_entry array based upon DOM data.
141 * @param DOMNode $child The DOMNode to process
143 protected function takeChildFromDOM($child)
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;
174 * Get the yt:description
176 * @throws Zend_Gdata_App_VersionException
177 * @return Zend_Gdata_YouTube_Extension_Description|null
179 public function getDescription()
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;
192 * Sets the yt:description element for a new inbox entry.
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
199 public function setDescription($description = null)
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;
213 * Get the gd:rating element for the inbox entry
215 * @return Zend_Gdata_Extension_Rating|null
217 public function getRating()
219 return $this->_rating;
223 * Sets the gd:rating element for the inbox entry
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
229 public function setRating($rating = null)
231 $this->_rating = $rating;
232 return $this;
236 * Get the gd:comments element of the inbox entry.
238 * @return Zend_Gdata_Extension_Comments|null
240 public function getComments()
242 return $this->_comments;
246 * Sets the gd:comments element for the inbox entry
248 * @param Zend_Gdata_Extension_Comments $comments The comments feed link
249 * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
251 public function setComments($comments = null)
253 $this->_comments = $comments;
254 return $this;
258 * Get the yt:statistics element for the inbox entry
260 * @return Zend_Gdata_YouTube_Extension_Statistics|null
262 public function getStatistics()
264 return $this->_statistics;
268 * Sets the yt:statistics element for the inbox entry
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
274 public function setStatistics($statistics = null)
276 $this->_statistics = $statistics;
277 return $this;