[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Service/Amazon/ -> Query.php (source)

   1  <?php
   2  
   3  /**
   4   * Zend Framework
   5   *
   6   * LICENSE
   7   *
   8   * This source file is subject to the new BSD license that is bundled
   9   * with this package in the file LICENSE.txt.
  10   * It is also available through the world-wide-web at this URL:
  11   * http://framework.zend.com/license/new-bsd
  12   * If you did not receive a copy of the license and are unable to
  13   * obtain it through the world-wide-web, please send an email
  14   * to [email protected] so we can send you a copy immediately.
  15   *
  16   * @category   Zend
  17   * @package    Zend_Service
  18   * @subpackage Amazon
  19   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  20   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  21   * @version    $Id$
  22   */
  23  
  24  
  25  /**
  26   * @see Zend_Service_Amazon
  27   */
  28  require_once 'Zend/Service/Amazon.php';
  29  
  30  
  31  /**
  32   * @category   Zend
  33   * @package    Zend_Service
  34   * @subpackage Amazon
  35   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  36   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  37   */
  38  class Zend_Service_Amazon_Query extends Zend_Service_Amazon
  39  {
  40      /**
  41       * Search parameters
  42       *
  43       * @var array
  44       */
  45      protected $_search = array();
  46  
  47      /**
  48       * Search index
  49       *
  50       * @var string
  51       */
  52      protected $_searchIndex = null;
  53  
  54      /**
  55       * Prepares query parameters
  56       *
  57       * @param  string $method
  58       * @param  array  $args
  59       * @throws Zend_Service_Exception
  60       * @return Zend_Service_Amazon_Query Provides a fluent interface
  61       */
  62      public function __call($method, $args)
  63      {
  64          if (strtolower($method) === 'asin') {
  65              $this->_searchIndex = 'asin';
  66              $this->_search['ItemId'] = $args[0];
  67              return $this;
  68          }
  69  
  70          if (strtolower($method) === 'category') {
  71              $this->_searchIndex = $args[0];
  72              $this->_search['SearchIndex'] = $args[0];
  73          } else if (isset($this->_search['SearchIndex']) || $this->_searchIndex !== null || $this->_searchIndex === 'asin') {
  74              $this->_search[$method] = $args[0];
  75          } else {
  76              /**
  77               * @see Zend_Service_Exception
  78               */
  79              require_once 'Zend/Service/Exception.php';
  80              throw new Zend_Service_Exception('You must set a category before setting the search parameters');
  81          }
  82  
  83          return $this;
  84      }
  85  
  86      /**
  87       * Search using the prepared query
  88       *
  89       * @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet
  90       */
  91      public function search()
  92      {
  93          if ($this->_searchIndex === 'asin') {
  94              return $this->itemLookup($this->_search['ItemId'], $this->_search);
  95          }
  96          return $this->itemSearch($this->_search);
  97      }
  98  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1