|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00028 require_once 'Zend/Service/Amazon.php'; 00029 00030 00038 class Zend_Service_Amazon_Query extends Zend_Service_Amazon 00039 { 00045 protected $_search = array(); 00046 00052 protected $_searchIndex = null; 00053 00062 public function __call($method, $args) 00063 { 00064 if (strtolower($method) === 'asin') { 00065 $this->_searchIndex = 'asin'; 00066 $this->_search['ItemId'] = $args[0]; 00067 return $this; 00068 } 00069 00070 if (strtolower($method) === 'category') { 00071 $this->_searchIndex = $args[0]; 00072 $this->_search['SearchIndex'] = $args[0]; 00073 } else if (isset($this->_search['SearchIndex']) || $this->_searchIndex !== null || $this->_searchIndex === 'asin') { 00074 $this->_search[$method] = $args[0]; 00075 } else { 00079 require_once 'Zend/Service/Exception.php'; 00080 throw new Zend_Service_Exception('You must set a category before setting the search parameters'); 00081 } 00082 00083 return $this; 00084 } 00085 00091 public function search() 00092 { 00093 if ($this->_searchIndex === 'asin') { 00094 return $this->itemLookup($this->_search['ItemId'], $this->_search); 00095 } 00096 return $this->itemSearch($this->_search); 00097 } 00098 }