|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata/YouTube.php'; 00028 00032 require_once 'Zend/Gdata/Entry.php'; 00033 00037 require_once 'Zend/Gdata/Extension/FeedLink.php'; 00038 00042 require_once 'Zend/Gdata/YouTube/Extension/Description.php'; 00043 00047 require_once 'Zend/Gdata/YouTube/Extension/PlaylistId.php'; 00048 00052 require_once 'Zend/Gdata/YouTube/Extension/CountHint.php'; 00053 00063 class Zend_Gdata_YouTube_PlaylistListEntry extends Zend_Gdata_Entry 00064 { 00065 00066 protected $_entryClassName = 'Zend_Gdata_YouTube_PlaylistListEntry'; 00067 00073 protected $_feedLink = array(); 00074 00081 protected $_description = null; 00082 00088 protected $_playlistId = null; 00089 00095 protected $_countHint = null; 00096 00104 public function __construct($element = null) 00105 { 00106 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces); 00107 parent::__construct($element); 00108 } 00109 00120 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 00121 { 00122 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 00123 if ($this->_description != null) { 00124 $element->appendChild($this->_description->getDOM($element->ownerDocument)); 00125 } 00126 if ($this->_countHint != null) { 00127 $element->appendChild($this->_countHint->getDOM($element->ownerDocument)); 00128 } 00129 if ($this->_playlistId != null) { 00130 $element->appendChild($this->_playlistId->getDOM($element->ownerDocument)); 00131 } 00132 if ($this->_feedLink != null) { 00133 foreach ($this->_feedLink as $feedLink) { 00134 $element->appendChild($feedLink->getDOM($element->ownerDocument)); 00135 } 00136 } 00137 return $element; 00138 } 00139 00146 protected function takeChildFromDOM($child) 00147 { 00148 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; 00149 switch ($absoluteNodeName) { 00150 case $this->lookupNamespace('yt') . ':' . 'description': 00151 $description = new Zend_Gdata_YouTube_Extension_Description(); 00152 $description->transferFromDOM($child); 00153 $this->_description = $description; 00154 break; 00155 case $this->lookupNamespace('yt') . ':' . 'countHint': 00156 $countHint = new Zend_Gdata_YouTube_Extension_CountHint(); 00157 $countHint->transferFromDOM($child); 00158 $this->_countHint = $countHint; 00159 break; 00160 case $this->lookupNamespace('yt') . ':' . 'playlistId': 00161 $playlistId = new Zend_Gdata_YouTube_Extension_PlaylistId(); 00162 $playlistId->transferFromDOM($child); 00163 $this->_playlistId = $playlistId; 00164 break; 00165 case $this->lookupNamespace('gd') . ':' . 'feedLink': 00166 $feedLink = new Zend_Gdata_Extension_FeedLink(); 00167 $feedLink->transferFromDOM($child); 00168 $this->_feedLink[] = $feedLink; 00169 break; 00170 default: 00171 parent::takeChildFromDOM($child); 00172 break; 00173 } 00174 } 00175 00183 public function setDescription($description = null) 00184 { 00185 if ($this->getMajorProtocolVersion() >= 2) { 00186 $this->setSummary($description); 00187 } else { 00188 $this->_description = $description; 00189 } 00190 return $this; 00191 } 00192 00199 public function getDescription() 00200 { 00201 if ($this->getMajorProtocolVersion() >= 2) { 00202 return $this->getSummary(); 00203 } else { 00204 return $this->_description; 00205 } 00206 } 00207 00217 public function getCountHint() 00218 { 00219 if (($this->getMajorProtocolVersion() == null) || 00220 ($this->getMajorProtocolVersion() == 1)) { 00221 require_once 'Zend/Gdata/App/VersionException.php'; 00222 throw new Zend_Gdata_App_VersionException('The yt:countHint ' . 00223 'element is not supported in versions earlier than 2.'); 00224 } else { 00225 return $this->_countHint; 00226 } 00227 } 00228 00235 public function getPlaylistId() 00236 { 00237 if (($this->getMajorProtocolVersion() == null) || 00238 ($this->getMajorProtocolVersion() == 1)) { 00239 require_once 'Zend/Gdata/App/VersionException.php'; 00240 throw new Zend_Gdata_App_VersionException('The yt:playlistId ' . 00241 'element is not supported in versions earlier than 2.'); 00242 } else { 00243 return $this->_playlistId; 00244 } 00245 } 00246 00253 public function setFeedLink($feedLink = null) 00254 { 00255 $this->_feedLink = $feedLink; 00256 return $this; 00257 } 00258 00272 public function getFeedLink($rel = null) 00273 { 00274 if ($rel == null) { 00275 return $this->_feedLink; 00276 } else { 00277 foreach ($this->_feedLink as $feedLink) { 00278 if ($feedLink->rel == $rel) { 00279 return $feedLink; 00280 } 00281 } 00282 return null; 00283 } 00284 } 00285 00291 public function getPlaylistVideoFeedUrl() 00292 { 00293 if ($this->getMajorProtocolVersion() >= 2) { 00294 return $this->getContent()->getSrc(); 00295 } else { 00296 return $this->getFeedLink(Zend_Gdata_YouTube::PLAYLIST_REL)->href; 00297 } 00298 } 00299 00300 }