|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata/Entry.php'; 00028 00032 require_once 'Zend/Gdata/YouTube/Extension/VideoId.php'; 00033 00037 require_once 'Zend/Gdata/YouTube/Extension/Username.php'; 00038 00042 require_once 'Zend/Gdata/Extension/Rating.php'; 00043 00055 class Zend_Gdata_YouTube_ActivityEntry extends Zend_Gdata_Entry 00056 { 00057 const ACTIVITY_CATEGORY_SCHEME = 00058 'http://gdata.youtube.com/schemas/2007/userevents.cat'; 00059 00065 protected $_entryClassName = 'Zend_Gdata_YouTube_ActivityEntry'; 00066 00072 protected $_videoId = null; 00073 00079 protected $_username = null; 00080 00086 protected $_rating = null; 00087 00093 public function __construct($element = null) 00094 { 00095 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces); 00096 parent::__construct($element); 00097 } 00098 00108 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 00109 { 00110 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 00111 if ($this->_videoId !== null) { 00112 $element->appendChild($this->_videoId->getDOM( 00113 $element->ownerDocument)); 00114 } 00115 if ($this->_username !== null) { 00116 $element->appendChild($this->_username->getDOM( 00117 $element->ownerDocument)); 00118 } 00119 if ($this->_rating !== null) { 00120 $element->appendChild($this->_rating->getDOM( 00121 $element->ownerDocument)); 00122 } 00123 return $element; 00124 } 00125 00132 protected function takeChildFromDOM($child) 00133 { 00134 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; 00135 switch ($absoluteNodeName) { 00136 case $this->lookupNamespace('yt') . ':' . 'videoid': 00137 $videoId = new Zend_Gdata_YouTube_Extension_VideoId(); 00138 $videoId->transferFromDOM($child); 00139 $this->_videoId = $videoId; 00140 break; 00141 case $this->lookupNamespace('yt') . ':' . 'username': 00142 $username = new Zend_Gdata_YouTube_Extension_Username(); 00143 $username->transferFromDOM($child); 00144 $this->_username = $username; 00145 break; 00146 case $this->lookupNamespace('gd') . ':' . 'rating': 00147 $rating = new Zend_Gdata_Extension_Rating(); 00148 $rating->transferFromDOM($child); 00149 $this->_rating = $rating; 00150 break; 00151 default: 00152 parent::takeChildFromDOM($child); 00153 break; 00154 } 00155 } 00156 00162 public function getVideoId() 00163 { 00164 return $this->_videoId; 00165 } 00166 00172 public function getUsername() 00173 { 00174 return $this->_username; 00175 } 00176 00182 public function getRating() 00183 { 00184 return $this->_rating; 00185 } 00186 00194 public function getRatingValue() 00195 { 00196 $rating = $this->_rating; 00197 if ($rating) { 00198 return $rating->getValue(); 00199 } 00200 return null; 00201 } 00202 00211 public function getActivityType() 00212 { 00213 $categories = $this->getCategory(); 00214 foreach($categories as $category) { 00215 if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) { 00216 return $category->getTerm(); 00217 } 00218 } 00219 return null; 00220 } 00221 00227 public function getAuthorName() 00228 { 00229 $authors = $this->getAuthor(); 00230 return $authors[0]->getName()->getText(); 00231 } 00232 }