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.
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
25 * @see Zend_Gdata_YouTube
27 require_once 'Zend/Gdata/YouTube.php';
30 * @see Zend_Gdata_Entry
32 require_once 'Zend/Gdata/Entry.php';
35 * @see Zend_Gdata_Extension_FeedLink
37 require_once 'Zend/Gdata/Extension/FeedLink.php';
40 * @see Zend_Gdata_YouTube_Extension_Description
42 require_once 'Zend/Gdata/YouTube/Extension/Description.php';
45 * @see Zend_Gdata_YouTube_Extension_PlaylistId
47 require_once 'Zend/Gdata/YouTube/Extension/PlaylistId.php';
50 * @see Zend_Gdata_YouTube_Extension_CountHint
52 require_once 'Zend/Gdata/YouTube/Extension/CountHint.php';
55 * Represents the YouTube video playlist flavor of an Atom entry
60 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
61 * @license http://framework.zend.com/license/new-bsd New BSD License
63 class Zend_Gdata_YouTube_PlaylistListEntry extends Zend_Gdata_Entry
66 protected $_entryClassName = 'Zend_Gdata_YouTube_PlaylistListEntry';
73 protected $_feedLink = array();
76 * Description of this playlist
78 * @deprecated Deprecated as of version 2 of the YouTube API.
79 * @var Zend_Gdata_YouTube_Extension_Description
81 protected $_description = null;
86 * @var Zend_Gdata_YouTube_Extension_PlaylistId
88 protected $_playlistId = null;
91 * CountHint for this playlist.
93 * @var Zend_Gdata_YouTube_Extension_CountHint
95 protected $_countHint = null;
98 * Creates a Playlist list entry, representing an individual playlist
99 * in a list of playlists, usually associated with an individual user.
101 * @param DOMElement $element (optional) DOMElement from which this
102 * object should be constructed.
104 public function __construct($element = null)
106 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
107 parent::__construct($element);
111 * Retrieves a DOMElement which corresponds to this element and all
112 * child properties. This is used to build an entry back into a DOM
113 * and eventually XML text for sending to the server upon updates, or
114 * for application storage/persistence.
116 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
117 * @return DOMElement The DOMElement representing this element and all
120 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
122 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
123 if ($this->_description != null) {
124 $element->appendChild($this->_description->getDOM($element->ownerDocument));
126 if ($this->_countHint != null) {
127 $element->appendChild($this->_countHint->getDOM($element->ownerDocument));
129 if ($this->_playlistId != null) {
130 $element->appendChild($this->_playlistId->getDOM($element->ownerDocument));
132 if ($this->_feedLink != null) {
133 foreach ($this->_feedLink as $feedLink) {
134 $element->appendChild($feedLink->getDOM($element->ownerDocument));
141 * Creates individual Entry objects of the appropriate type and
142 * stores them in the $_entry array based upon DOM data.
144 * @param DOMNode $child The DOMNode to process
146 protected function takeChildFromDOM($child)
148 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
149 switch ($absoluteNodeName) {
150 case $this->lookupNamespace('yt') . ':' . 'description':
151 $description = new Zend_Gdata_YouTube_Extension_Description();
152 $description->transferFromDOM($child);
153 $this->_description = $description;
155 case $this->lookupNamespace('yt') . ':' . 'countHint':
156 $countHint = new Zend_Gdata_YouTube_Extension_CountHint();
157 $countHint->transferFromDOM($child);
158 $this->_countHint = $countHint;
160 case $this->lookupNamespace('yt') . ':' . 'playlistId':
161 $playlistId = new Zend_Gdata_YouTube_Extension_PlaylistId();
162 $playlistId->transferFromDOM($child);
163 $this->_playlistId = $playlistId;
165 case $this->lookupNamespace('gd') . ':' . 'feedLink':
166 $feedLink = new Zend_Gdata_Extension_FeedLink();
167 $feedLink->transferFromDOM($child);
168 $this->_feedLink[] = $feedLink;
171 parent::takeChildFromDOM($child);
177 * Sets the description relating to the playlist.
179 * @deprecated Deprecated as of version 2 of the YouTube API.
180 * @param Zend_Gdata_YouTube_Extension_Description $description The description relating to the video
181 * @return Zend_Gdata_YouTube_PlaylistListEntry Provides a fluent interface
183 public function setDescription($description = null)
185 if ($this->getMajorProtocolVersion() >= 2) {
186 $this->setSummary($description);
188 $this->_description = $description;
194 * Returns the description relating to the video.
196 * @return Zend_Gdata_YouTube_Extension_Description The description
197 * relating to the video
199 public function getDescription()
201 if ($this->getMajorProtocolVersion() >= 2) {
202 return $this->getSummary();
204 return $this->_description;
209 * Returns the countHint relating to the playlist.
211 * The countHint is the number of videos on a playlist.
213 * @throws Zend_Gdata_App_VersionException
214 * @return Zend_Gdata_YouTube_Extension_CountHint The count of videos on
217 public function getCountHint()
219 if (($this->getMajorProtocolVersion() == null) ||
220 ($this->getMajorProtocolVersion() == 1)) {
221 require_once 'Zend/Gdata/App/VersionException.php';
222 throw new Zend_Gdata_App_VersionException('The yt:countHint ' .
223 'element is not supported in versions earlier than 2.');
225 return $this->_countHint;
230 * Returns the Id relating to the playlist.
232 * @throws Zend_Gdata_App_VersionException
233 * @return Zend_Gdata_YouTube_Extension_PlaylistId The id of this playlist.
235 public function getPlaylistId()
237 if (($this->getMajorProtocolVersion() == null) ||
238 ($this->getMajorProtocolVersion() == 1)) {
239 require_once 'Zend/Gdata/App/VersionException.php';
240 throw new Zend_Gdata_App_VersionException('The yt:playlistId ' .
241 'element is not supported in versions earlier than 2.');
243 return $this->_playlistId;
248 * Sets the array of embedded feeds related to the playlist
250 * @param array $feedLink The array of embedded feeds relating to the video
251 * @return Zend_Gdata_YouTube_PlaylistListEntry Provides a fluent interface
253 public function setFeedLink($feedLink = null)
255 $this->_feedLink = $feedLink;
260 * Get the feed link property for this entry.
263 * @param string $rel (optional) The rel value of the link to be found.
264 * If null, the array of links is returned.
265 * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink
266 * object corresponding to the requested rel value is returned
267 * if found, or null if the requested value is not found. If
268 * $rel is null or not specified, an array of all available
269 * feed links for this entry is returned, or null if no feed
272 public function getFeedLink($rel = null)
275 return $this->_feedLink;
277 foreach ($this->_feedLink as $feedLink) {
278 if ($feedLink->rel == $rel) {
287 * Returns the URL of the playlist video feed
289 * @return string The URL of the playlist video feed
291 public function getPlaylistVideoFeedUrl()
293 if ($this->getMajorProtocolVersion() >= 2) {
294 return $this->getContent()->getSrc();
296 return $this->getFeedLink(Zend_Gdata_YouTube::PLAYLIST_REL)->href;