Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/Amazon/ResultSet.php
Go to the documentation of this file.
00001 <?php
00002 
00028 require_once 'Zend/Service/Amazon/Item.php';
00029 
00030 
00038 class Zend_Service_Amazon_ResultSet implements SeekableIterator
00039 {
00045     protected $_results = null;
00046 
00052     protected $_dom;
00053 
00059     protected $_xpath;
00060 
00066     protected $_currentIndex = 0;
00067 
00074     public function __construct(DOMDocument $dom)
00075     {
00076         $this->_dom = $dom;
00077         $this->_xpath = new DOMXPath($dom);
00078         $this->_xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
00079         $this->_results = $this->_xpath->query('//az:Item');
00080     }
00081 
00087     public function totalResults()
00088     {
00089         $result = $this->_xpath->query('//az:TotalResults/text()');
00090         return (int) $result->item(0)->data;
00091     }
00092 
00098     public function totalPages()
00099     {
00100         $result = $this->_xpath->query('//az:TotalPages/text()');
00101         return (int) $result->item(0)->data;
00102     }
00103 
00109     public function current()
00110     {
00111         return new Zend_Service_Amazon_Item($this->_results->item($this->_currentIndex));
00112     }
00113 
00119     public function key()
00120     {
00121         return $this->_currentIndex;
00122     }
00123 
00129     public function next()
00130     {
00131         $this->_currentIndex += 1;
00132     }
00133 
00139     public function rewind()
00140     {
00141         $this->_currentIndex = 0;
00142     }
00143 
00151     public function seek($index)
00152     {
00153         $indexInt = (int) $index;
00154         if ($indexInt >= 0 && (null === $this->_results || $indexInt < $this->_results->length)) {
00155             $this->_currentIndex = $indexInt;
00156         } else {
00157             throw new OutOfBoundsException("Illegal index '$index'");
00158         }
00159     }
00160 
00166     public function valid()
00167     {
00168         return null !== $this->_results && $this->_currentIndex < $this->_results->length;
00169     }
00170 }
 All Data Structures Namespaces Files Functions Variables Enumerations