|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata/App/Entry.php'; 00028 00032 require_once 'Zend/Gdata/App/FeedSourceParent.php'; 00033 00043 class Zend_Gdata_App_Feed extends Zend_Gdata_App_FeedSourceParent 00044 implements Iterator, ArrayAccess 00045 { 00046 00052 protected $_rootElement = 'feed'; 00053 00059 protected $_entry = array(); 00060 00066 protected $_entryIndex = 0; 00067 00079 public function __get($var) 00080 { 00081 switch ($var) { 00082 case 'entries': 00083 return $this; 00084 default: 00085 return parent::__get($var); 00086 } 00087 } 00088 00095 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 00096 { 00097 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 00098 foreach ($this->_entry as $entry) { 00099 $element->appendChild($entry->getDOM($element->ownerDocument)); 00100 } 00101 return $element; 00102 } 00103 00110 protected function takeChildFromDOM($child) 00111 { 00112 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; 00113 switch ($absoluteNodeName) { 00114 case $this->lookupNamespace('atom') . ':' . 'entry': 00115 $newEntry = new $this->_entryClassName($child); 00116 $newEntry->setHttpClient($this->getHttpClient()); 00117 $newEntry->setMajorProtocolVersion($this->getMajorProtocolVersion()); 00118 $newEntry->setMinorProtocolVersion($this->getMinorProtocolVersion()); 00119 $this->_entry[] = $newEntry; 00120 break; 00121 default: 00122 parent::takeChildFromDOM($child); 00123 break; 00124 } 00125 } 00126 00132 public function count() 00133 { 00134 return count($this->_entry); 00135 } 00136 00142 public function rewind() 00143 { 00144 $this->_entryIndex = 0; 00145 } 00146 00152 public function current() 00153 { 00154 return $this->_entry[$this->_entryIndex]; 00155 } 00156 00162 public function key() 00163 { 00164 return $this->_entryIndex; 00165 } 00166 00172 public function next() 00173 { 00174 ++$this->_entryIndex; 00175 } 00176 00182 public function valid() 00183 { 00184 return 0 <= $this->_entryIndex && $this->_entryIndex < $this->count(); 00185 } 00186 00193 public function getEntry() 00194 { 00195 return $this->_entry; 00196 } 00197 00205 public function setEntry($value) 00206 { 00207 $this->_entry = $value; 00208 return $this; 00209 } 00210 00218 public function addEntry($value) 00219 { 00220 $this->_entry[] = $value; 00221 return $this; 00222 } 00223 00231 public function offsetSet($key, $value) 00232 { 00233 $this->_entry[$key] = $value; 00234 } 00235 00242 public function offsetGet($key) 00243 { 00244 if (array_key_exists($key, $this->_entry)) { 00245 return $this->_entry[$key]; 00246 } 00247 } 00248 00255 public function offsetUnset($key) 00256 { 00257 if (array_key_exists($key, $this->_entry)) { 00258 unset($this->_entry[$key]); 00259 } 00260 } 00261 00268 public function offsetExists($key) 00269 { 00270 return (array_key_exists($key, $this->_entry)); 00271 } 00272 00280 public function getNextFeed() 00281 { 00282 $nextLink = $this->getNextLink(); 00283 if (!$nextLink) { 00284 require_once 'Zend/Gdata/App/HttpException.php'; 00285 throw new Zend_Gdata_App_Exception('No link to next set ' . 00286 'of results found.'); 00287 } 00288 $nextLinkHref = $nextLink->getHref(); 00289 $service = new Zend_Gdata_App($this->getHttpClient()); 00290 00291 return $service->getFeed($nextLinkHref, get_class($this)); 00292 } 00293 00301 public function getPreviousFeed() 00302 { 00303 $previousLink = $this->getPreviousLink(); 00304 if (!$previousLink) { 00305 require_once 'Zend/Gdata/App/HttpException.php'; 00306 throw new Zend_Gdata_App_Exception('No link to previous set ' . 00307 'of results found.'); 00308 } 00309 $previousLinkHref = $previousLink->getHref(); 00310 $service = new Zend_Gdata_App($this->getHttpClient()); 00311 00312 return $service->getFeed($previousLinkHref, get_class($this)); 00313 } 00314 00325 public function setMajorProtocolVersion($value) 00326 { 00327 parent::setMajorProtocolVersion($value); 00328 foreach ($this->entries as $entry) { 00329 $entry->setMajorProtocolVersion($value); 00330 } 00331 } 00332 00344 public function setMinorProtocolVersion($value) 00345 { 00346 parent::setMinorProtocolVersion($value); 00347 foreach ($this->entries as $entry) { 00348 $entry->setMinorProtocolVersion($value); 00349 } 00350 } 00351 00352 }