text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Items.php 22804 2010-08-08 05:08:05Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Response_Histograms
 */
require_once 'Zend/Service/Ebay/Finding/Response/Histograms.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Response_Histograms
 */
class Zend_Service_Ebay_Finding_Response_Items extends Zend_Service_Ebay_Finding_Response_Histograms
{
    /**
     * @link http://developer.ebay.com/DevZone/finding/CallRef/types/PaginationInput.html
     */
    const PAGE_MAX_DEFAULT  = 100;
    const PAGE_MAX_INFINITY = 0;

    /**
     * Indicates the pagination of the result set.
     *
     * Child elements indicate the page number that is returned, the maximum
     * number of item listings to return per page, total number of pages that
     * can be returned, and the total number of listings that match the search
     * criteria.
     *
     * @var Zend_Service_Ebay_Finding_PaginationOutput
     */
    public $paginationOutput;

    /**
     * Container for the item listings that matched the search criteria.
     *
     * The data for each item is returned in individual containers, if any
     * matches were found.
     *
     * @var Zend_Service_Ebay_Finding_Search_Result
     */
    public $searchResult;

    /**
     * @var Zend_Service_Ebay_Finding_Response_Items[]
     */
    protected static $_pageCache = array();

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $this->_attributes['searchResult'] = array(
            'count' => $this->_query(".//$ns:searchResult[1]/@count[1]", 'string')
        );

        $node = $this->_xPath->query(".//$ns:searchResult[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Search_Result
             */
            require_once 'Zend/Service/Ebay/Finding/Search/Result.php';
            $this->searchResult = new Zend_Service_Ebay_Finding_Search_Result($node);
        }

        $node = $this->_xPath->query(".//$ns:paginationOutput[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_PaginationOutput
             */
            require_once 'Zend/Service/Ebay/Finding/PaginationOutput.php';
            $this->paginationOutput = new Zend_Service_Ebay_Finding_PaginationOutput($node);
        }
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @param  integer                   $number
     * @throws Zend_Service_Ebay_Finding_Exception When $number is invalid
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function page(Zend_Service_Ebay_Finding $proxy, $number)
    {
        // check page number
        if ($number < 1 || $number > $this->paginationOutput->totalPages) {
            /**
             * @see Zend_Service_Ebay_Finding_Exception
             */
            require_once 'Zend/Service/Ebay/Finding/Exception.php';
            throw new Zend_Service_Ebay_Finding_Exception(
                "Page number '{$number}' is out of range.");
        }

        // prepare arguments
        $arguments = array();
        switch ($this->_operation) {
            case 'findItemsAdvanced':
                $arguments[] = $this->getOption('keywords');
                $arguments[] = $this->getOption('descriptionSearch');
                $arguments[] = $this->getOption('categoryId');
                break;

            case 'findItemsByCategory':
                $arguments[] = $this->getOption('categoryId');
                break;

            case 'findItemsByKeywords':
                $arguments[] = $this->getOption('keywords');
                break;

            case 'findItemsByProduct':
                $productId = $this->getOption('productId');
                if (!is_array($productId)) {
                    $productId = array('' => $productId);
                }
                $arguments[] = array_key_exists('', $productId)
                             ? $productId['']
                             : null;
                $arguments[] = array_key_exists('type', $productId)
                             ? $productId['type']
                             : null;
                break;

            case 'findItemsIneBayStores':
                $arguments[] = $this->getOption('storeName');
                break;

            default:
                /**
                 * @see Zend_Service_Ebay_Finding_Exception
                 */
                require_once 'Zend/Service/Ebay/Finding/Exception.php';
                throw new Zend_Service_Ebay_Finding_Exception(
                    "Invalid operation '{$this->_operation}'.");
        }

        // prepare options
        // remove every pagination entry from current option list
        $options = $this->_options;
        foreach (array_keys($options) as $optionName) {
            if (substr($optionName, 0, 15) == 'paginationInput') {
                unset($options[$optionName]);
            }
        }

        // set new pagination values
        // see more at http://developer.ebay.com/DevZone/finding/CallRef/types/PaginationInput.html
        $entriesPerPage             = $this->paginationOutput->entriesPerPage;
        $options['paginationInput'] = array('entriesPerPage' => $entriesPerPage,
                                            'pageNumber'     => $number);

        // add current options as last argument
        ksort($options);
        $arguments[] = $options;

        // verify cache
        $id = serialize($arguments);
        if (!array_key_exists($id, self::$_pageCache)) {
            if ($number == $this->paginationOutput->pageNumber) {
                // add itself to cache
                $new = $this;
            } else {
                // request new page
                $callback = array($proxy, $this->_operation);
                $new      = call_user_func_array($callback, $arguments);
            }
            self::$_pageCache[$id] = $new;
        }

        return self::$_pageCache[$id];
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function pageFirst(Zend_Service_Ebay_Finding $proxy)
    {
        return $this->page($proxy, 1);
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @param  integer                   $max
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function pageLast(Zend_Service_Ebay_Finding $proxy, $max = self::PAGE_MAX_DEFAULT)
    {
        $last = $this->paginationOutput->totalPages;
        if ($max > 0 && $last > $max) {
            $last = $max;
        }
        return $this->page($proxy, $last);
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @param  integer                   $max
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function pageNext(Zend_Service_Ebay_Finding $proxy, $max = self::PAGE_MAX_DEFAULT)
    {
        $next = $this->paginationOutput->pageNumber + 1;
        $last = $this->paginationOutput->totalPages;
        if (($max > 0 && $next > $max) || $next > $last) {
            return null;
        }
        return $this->page($proxy, $next);
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function pagePrevious(Zend_Service_Ebay_Finding $proxy)
    {
        $previous = $this->paginationOutput->pageNumber - 1;
        if ($previous < 1) {
            return null;
        }
        return $this->page($proxy, $previous);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Histograms.php 22804 2010-08-08 05:08:05Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Response_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Response/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Response_Abstract
 */
class Zend_Service_Ebay_Finding_Response_Histograms extends Zend_Service_Ebay_Finding_Response_Abstract
{
    /**
     * Response container for aspect histograms.
     *
     * Aspect histograms are returned for categories that have been mapped to
     * domains only. In most cases, just leaf categories are mapped to domains,
     * but there are exceptions.
     *
     * @var Zend_Service_Ebay_Finding_Aspect_Histogram_Container
     */
    public $aspectHistogramContainer;

    /**
     * Response container for category histograms.
     *
     * This container is returned only when the specified category has children
     * categories.
     *
     * @var Zend_Service_Ebay_Finding_Category_Histogram_Container
     */
    public $categoryHistogramContainer;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $node = $this->_xPath->query(".//$ns:aspectHistogramContainer[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Aspect_Histogram_Container
             */
            require_once 'Zend/Service/Ebay/Finding/Aspect/Histogram/Container.php';
            $this->aspectHistogramContainer = new Zend_Service_Ebay_Finding_Aspect_Histogram_Container($node);
        }

        $node = $this->_xPath->query(".//$ns:categoryHistogramContainer[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Category_Histogram_Container
             */
            require_once 'Zend/Service/Ebay/Finding/Category/Histogram/Container.php';
            $this->categoryHistogramContainer = new Zend_Service_Ebay_Finding_Category_Histogram_Container($node);
        }
    }
}

repo_name: michael-romer/zf-boilerplate

repo_language: PHP

mime_type: text/html


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Abstract.php 22824 2010-08-09 18:59:54Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
abstract class Zend_Service_Ebay_Finding_Response_Abstract extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * Indicates whether or not errors or warnings were generated during the
     * processing of the request.
     *
     * Applicable values:
     *
     *     Failure
     *     eBay encountered a fatal error during the processing of the request,
     *     causing the request to fail. When a serious application-level error
     *     occurs, the error is returned instead of the business data.
     *
     *     PartialFailure
     *     eBay successfully processed the request, but one or more non-fatal
     *     errors occurred during the processing. For best results, requests
     *     should return without warning messages. Inspect the message details
     *     and resolve any problems before resubmitting the request.
     *
     *     Success
     *     eBay successfully processed the request and the business data is
     *     returned in the response. Note that it is possible for a response to
     *     return Success, but still not contain the expected data in the result.
     *
     *     Warning
     *     The request was successfully processed, but eBay encountered a
     *     non-fatal error during the processing. For best results, requests
     *     should return without warnings. Inspect the warning details and
     *     resolve the problem before resubmitting the request.
     *
     * @var string
     */
    public $ack;

    /**
     * Information regarding an error or warning that occurred when eBay
     * processed the request.
     *
     * Not returned when the ack value is Success. Run-time errors are not
     * reported here.
     *
     * @var Zend_Service_Ebay_Finding_Error_Message
     */
    public $errorMessage;

    /**
     * This value represents the date and time when eBay processed the request.
     *
     * This value is returned in GMT, the ISO 8601 date and time format
     * (YYYY-MM-DDTHH:MM:SS.SSSZ). See the "dateTime" type for information about
     * the time format, and for details on converting to and from the GMT time
     * zone.
     *
     * @var string
     */
    public $timestamp;

    /**
     * The release version that eBay used to process the request.
     *
     * Developer Technical Support may ask you for the version value if you work
     * with them to troubleshoot issues.
     *
     * @var string
     */
    public $version;

    /**
     * @var string
     */
    protected $_operation;

    /**
     * @var array
     */
    protected $_options = array();

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $this->ack       = $this->_query(".//$ns:ack[1]", 'string');
        $this->timestamp = $this->_query(".//$ns:timestamp[1]", 'string');
        $this->version   = $this->_query(".//$ns:version[1]", 'string');

        $node = $this->_xPath->query(".//$ns:errorMessage[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Error_Message
             */
            require_once 'Zend/Service/Ebay/Finding/Error/Message.php';
            $this->errorMessage = new Zend_Service_Ebay_Finding_Error_Message($node);
        }
    }

    /**
     * @param  string $operation
     * @return Zend_Service_Ebay_Finding_Response_Abstract Provides a fluent interface
     */
    public function setOperation($operation)
    {
        $this->_operation = (string) $operation;
        return $this;
    }

    /**
     * @return string
     */
    public function getOperation()
    {
        return $this->_operation;
    }

    /**
     * @param  string|Zend_Config|array $name
     * @param  mixed                    $value
     * @return Zend_Service_Ebay_Finding_Response_Abstract Provides a fluent interface
     */
    public function setOption($name, $value = null)
    {
        if ($name instanceof Zend_Config) {
            $name = $name->toArray();
        }
        if (is_array($name)) {
            $this->_options = $name;
        } else {
            $this->_options[$name] = $value;
        }
        return $this;
    }

    /**
     * @param  string $name
     * @return mixed
     */
    public function getOption($name = null)
    {
        if (null === $name) {
            return $this->_options;
        }
        if (array_key_exists($name, $this->_options)) {
            return $this->_options[$name];
        }
        return null;
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Histogram.php 22791 2010-08-04 16:11:47Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Category.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Category
 */
class Zend_Service_Ebay_Finding_Category_Histogram extends Zend_Service_Ebay_Finding_Category
{
    /**
     * Container for histogram information pertaining to a child of the category
     * specified in the request.
     *
     * Histograms return data on up to 10 children. Histograms are only a single
     * level deep. That is, a given category histogram contains only immediate
     * children.
     *
     * @var Zend_Service_Ebay_Finding_Category_Histogram_Set
     */
    public $childCategoryHistogram;

    /**
     * The total number of items in the associated category that match the
     * search criteria.
     *
     * @var integer
     */
    public $count;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $this->count = $this->_query(".//$ns:count[1]", 'integer');

        $nodes = $this->_xPath->query(".//$ns:childCategoryHistogram", $this->_dom);
        if ($nodes->length > 0) {
            /**
             * @see Zend_Service_Ebay_Finding_Category_Histogram_Set
             */
            require_once 'Zend/Service/Ebay/Finding/Category/Histogram/Set.php';
            $this->childCategoryHistogram = new Zend_Service_Ebay_Finding_Category_Histogram_Set($nodes);
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Set.php 20166 2010-01-09 19:00:17Z bkarwin $
 */

/**
 * @see Zend_Service_Ebay_Finding_Set_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Set/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Set_Abstract
 */
class Zend_Service_Ebay_Finding_Category_Histogram_Set extends Zend_Service_Ebay_Finding_Set_Abstract
{
    /**
     * Implement SeekableIterator::current()
     *
     * @return Zend_Service_Ebay_Finding_Category_Histogram
     */
    public function current()
    {
        // check node
        $node = $this->_nodes->item($this->_key);
        if (!$node) {
            return null;
        }

        /**
         * @see Zend_Service_Ebay_Finding_Category_Histogram
         */
        require_once 'Zend/Service/Ebay/Finding/Category/Histogram.php';
        return new Zend_Service_Ebay_Finding_Category_Histogram($node);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Container.php 22791 2010-08-04 16:11:47Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
class Zend_Service_Ebay_Finding_Category_Histogram_Container extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * Response container for category histograms.
     *
     * This container is returned only when the specified category has children
     * categories.
     *
     * @var Zend_Service_Ebay_Finding_Category_Histogram_Set
     */
    public $categoryHistogram;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $nodes = $this->_xPath->query(".//$ns:categoryHistogram", $this->_dom);
        if ($nodes->length > 0) {
            /**
             * @see Zend_Service_Ebay_Finding_Category_Histogram_Set
             */
            require_once 'Zend/Service/Ebay/Finding/Category/Histogram/Set.php';
            $this->categoryHistogram = new Zend_Service_Ebay_Finding_Category_Histogram_Set($nodes);
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Message.php 22802 2010-08-07 19:27:37Z ramon $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
class Zend_Service_Ebay_Finding_Error_Message extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * A container for error details.
     *
     * @var Zend_Service_Ebay_Finding_Error_Data_Set
     */
    public $error;

    /**
     * @return void
     */
    protected function _init()
    {
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;
        $nodes = $this->_xPath->query(".//$ns:error", $this->_dom);
        if ($nodes->length > 0) {
            /**
             * @see Zend_Service_Ebay_Finding_Error_Data_Set
             */
            require_once 'Zend/Service/Ebay/Finding/Error/Data/Set.php';
            $this->error = new Zend_Service_Ebay_Finding_Error_Data_Set($nodes);
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Data.php 22791 2010-08-04 16:11:47Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
class Zend_Service_Ebay_Finding_Error_Data extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * There are three categories of errors: request errors, application errors,
     * and system errors.
     *
     * @var string
     */
    public $category;

    /**
     * Name of the domain in which the error occurred.
     *
     * Domain values
     *
     * Marketplace: A business or validation error occurred in the service.
     *
     * SOA: An exception occurred in the Service Oriented Architecture (SOA)
     * framework.
     *
     * @var string
     */
    public $domain;

    /**
     * A unique code that identifies the particular error condition that
     * occurred. Your application can use error codes as identifiers in your
     * customized error-handling algorithms.
     *
     * @var integer
     */
    public $errorId;

    /**
     * Unique identifier for an exception associated with an error.
     *
     * @var string
     */
    public $exceptionId;

    /**
     * A detailed description of the condition that caused in the error.
     *
     * @var string
     */
    public $message;

    /**
     * Various warning and error messages return one or more variables that
     * contain contextual information about the error. This is often the field
     * or value that triggered the error.
     *
     * @var string[]
     */
    public $parameter;

    /**
     * Indicates whether the reported problem is fatal (an error) or is
     * less-severe (a warning). Review the error message details for information
     * on the cause.
     *
     * This API throws an exception when a fatal error occurs. Only warning
     * problems can fill this attribute. See more about error parsing at
     * {@Zend_Service_Ebay_Finding::_parseResponse()}.
     *
     * If the request fails and the application is the source of the error (for
     * example, a required element is missing), update the application before
     * you retry the request. If the problem is due to incorrect user data,
     * alert the end-user to the problem and provide the means for them to
     * correct the data. Once the problem in the application or data is
     * resolved, re-send the request to eBay.
     *
     * If the source of the problem is on eBay's side, you can retry the request
     * a reasonable number of times (eBay recommends you try the request twice).
     * If the error persists, contact Developer Technical Support. Once the
     * problem has been resolved, you can resend the request in its original
     * form.
     *
     * If a warning occurs, warning information is returned in addition to the
     * business data. Normally, you do not need to resend the request (as the
     * original request was successful). However, depending on the cause of the
     * warning, you might need to contact the end user, or eBay, to effect a
     * long term solution to the problem.
     *
     * @var string
     */
    public $severity;

    /**
     * Name of the subdomain in which the error occurred.
     *
     * Subdomain values
     *
     * Finding: The error is specific to the Finding service.
     *
     * MarketplaceCommon: The error is common to all Marketplace services.
     *
     * @var string
     */
    public $subdomain;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $this->category    = $this->_query(".//$ns:category[1]", 'string');
        $this->domain      = $this->_query(".//$ns:domain[1]", 'string');
        $this->errorId     = $this->_query(".//$ns:errorId[1]", 'integer');
        $this->exceptionId = $this->_query(".//$ns:exceptionId[1]", 'string');
        $this->message     = $this->_query(".//$ns:message[1]", 'string');
        $this->parameter   = $this->_query(".//$ns:parameter", 'string', true);
        $this->severity    = $this->_query(".//$ns:severity[1]", 'string');
        $this->subdomain   = $this->_query(".//$ns:subdomain[1]", 'string');

        $this->_attributes['parameter'] = array(
            'name' => $this->_query(".//$ns:parameter/@name", 'string', true)
        );
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Set.php 20166 2010-01-09 19:00:17Z bkarwin $
 */

/**
 * @see Zend_Service_Ebay_Finding_Set_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Set/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Set_Abstract
 */
class Zend_Service_Ebay_Finding_Error_Data_Set extends Zend_Service_Ebay_Finding_Set_Abstract
{
    /**
     * Implement SeekableIterator::current()
     *
     * @return Zend_Service_Ebay_Finding_Error_Data
     */
    public function current()
    {
        // check node
        $node = $this->_nodes->item($this->_key);
        if (!$node) {
            return null;
        }

        /**
         * @see Zend_Service_Ebay_Finding_Error_Data
         */
        require_once 'Zend/Service/Ebay/Finding/Error/Data.php';
        return new Zend_Service_Ebay_Finding_Error_Data($node);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Result.php 22804 2010-08-08 05:08:05Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
class Zend_Service_Ebay_Finding_Search_Result extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * Container for the data of a single item that matches the search criteria.
     *
     * @var Zend_Service_Ebay_Finding_Search_Item_Set
     */
    public $item;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $nodes = $this->_xPath->query(".//$ns:item", $this->_dom);
        if ($nodes) {
            /**
             * @see Zend_Service_Ebay_Finding_Search_Item_Set
             */
            require_once 'Zend/Service/Ebay/Finding/Search/Item/Set.php';
            $this->item = new Zend_Service_Ebay_Finding_Search_Item_Set($nodes);
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http:framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http:framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Item.php 22824 2010-08-09 18:59:54Z renanbr $
 */

/**
 * @see Zend_Service_Ebay_Finding_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http:framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Abstract
 */
class Zend_Service_Ebay_Finding_Search_Item extends Zend_Service_Ebay_Finding_Abstract
{
    /**
     * If true, the seller requires immediate payment for the item. If false (or
     * not specified), immediate payment is not requested. Buyers must have a
     * PayPal account to purchase items that require immediate payment.
     *
     * A seller can choose to require immediate payment for Fixed Price and Buy
     * It Now listings, including eBay Stores Inventory listings. If a Buy It
     * Now item ends as an auction (that is, if the Buy It Now option is removed
     * due to bids being placed on the listing), the immediate payment
     * requirement does not apply.
     *
     * @var boolean
     */
    public $autoPay;

    /**
     * A unique identification number assigned by eBay to registered nonprofit
     * charity organizations.
     *
     * @var integer
     */
    public $charityId;

    /**
     * Two-letter ISO 3166 country code to indicate the country where the item
     * is located.
     *
     * @link http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm
     * @var  string
     */
    public $country;

    /**
     * The distance that the item is from the buyer, calculated usin
     *  buyerPostalCode.
     *
     *  The unit for distance varies by site, and is either miles or kilometers.
     *  If the country whose site you are searching uses kilometers to measure
     *  distance (for example, India/EBAY-IN), the unit is kilometers. If the
     *  site is either the US or UK, the distance unit is miles.
     *
     *  This value is only returned for distance-based searches. You must
     *  specify a buyerPostalCode and either sort by Distance, or use a
     *  combination of the MaxDistance LocalSearch itemFilters.
     *
     * @var float
     */
    public $distance;

    /**
     * URL for the Gallery Plus image.
     *
     * The size of Gallery Plus images (up to 400 x 400 pixels) is bigger than
     * the size of standard gallery images. In site search results, you can view
     * the Gallery Plus image by hovering over or clicking the Enlarge link or
     * magifying glass icon. The image uses one of the following graphics
     * formats: JPEG, BMP, TIFF, or GIF. This field is only returned when the
     * seller has opted for the Gallery Plus option for the given item.
     *
     * @var string[]
     */
    public $galleryPlusPictureURL;

    /**
     * URL for the Gallery thumbnail image.
     *
     * The image must be provided in one of the following graphics formats:
     * JPEG, BMP, TIF, or GIF. Returned only if the seller chose to show a
     * gallery image.
     *
     * @var string
     */
    public $galleryURL;

    /**
     * The identifier for the site on which the item is listed.
     *
     * Returns a Global ID, which is a unique identifier that specifies the
     * combination of the site, language, and territory. In other eBay APIs
     * (such as the Shopping API), this value is know as the site ID.
     *
     * @link http://developer.ebay.com/DevZone/finding/CallRef/Enums/GlobalIdList.html
     * @var  string
     */
    public $globalId;

    /**
     * The ID that uniquely identifies the item listing.
     *
     * eBay generates this ID when an item is listed. ID values are unique
     * across all eBay sites.
     *
     * @var string
     */
    public $itemId;

    /**
     * The format type of the listing, such as online auction, fixed price, or
     * advertisement.
     *
     * @var Zend_Service_Ebay_Finding_ListingInfo
     */
    public $listingInfo;

    /**
     * Physical location of the item, as specified by the seller.
     *
     * This gives a general indication from where the item will be shipped (or
     * delivered).
     *
     * @var string
     */
    public $location;

    /**
     * Identifies the payment method (or methods) the seller will accept for the
     * item (such as PayPal).
     *
     *  Payment methods are not applicable to eBay Real Estate advertisement
     *  listings or other Classified Ad listing formats.
     *
     * @link http://developer.ebay.com/DevZone/shopping/docs/CallRef/types/BuyerPaymentMethodCodeType.html
     * @var  string[]
     */
    public $paymentMethod;

    /**
     * The postal code where the listed item is located.
     *
     * This field is returned only if a postal code has been specified by the
     * seller. eBay proximity and local search behavior can use the combination
     * of buyerPostalCode and postalCode values.
     *
     * @var string
     */
    public $postalCode;

    /**
     * Details about the first (or only) category in which the item is listed.
     *
     * Note that items can be listed in more than a single category.
     *
     * @var Zend_Service_Ebay_Finding_Category
     */
    public $primaryCategory;

    /**
     * Unique identifier for the eBay catalog product with which the item was
     * listed.
     *
     * An eBay catalog product consists of pre-filled Item Specifics, additional
     * descriptive information, plus a stock photo (if available). These product
     * details are used to pre-fill item information, which is used to describe
     * the item and can also help surface the item in searches.
     *
     * eBay supports the following types of product ID types: ISBN, UPC, EAN,
     * and ReferenceID (ePID, also known as an eBay Product Reference ID).
     * ReferenceID values are returned when available. A UPC, ISBN, or EAN
     * product identifier will be returned only when a ReferenceID is not
     * available.
     *
     * This productId value can be used as input with findItemsByProduct to
     * retrieve items that were listed with the specified eBay catalog product.
     *
     * This field is only returned when a product was used to list the item.
     *
     * @var string
     */
    public $productId;

    /**
     * Details about the second category in which the item is listed.
     *
     * This element is not returned if the seller did not specify a secondary
     * category.
     *
     * @var Zend_Service_Ebay_Finding_Category
     */
    public $secondaryCategory;

    /**
     * Information about the item's seller.
     *
     * Only returned if SellerInfo is specified in the outputSelector field in
     * the request.
     *
     * @var Zend_Service_Ebay_Finding_SellerInfo
     */
    public $sellerInfo;

    /**
     * Specifies the item's selling status with regards to eBay's processing
     * workflow.
     *
     * @var Zend_Service_Ebay_Finding_SellingStatus
     */
    public $sellingStatus;

    /**
     * Container for data about a listing's shipping details.
     *
     * @var Zend_Service_Ebay_Finding_ShippingInfo
     */
    public $shippingInfo;

    /**
     * Information about the eBay store in which the item is listed.
     *
     * Only returned if the item is listed in a store and StoreInfo is specified
     * in the outputSelector field in the request.
     *
     * @var Zend_Service_Ebay_Finding_Storefront
     */
    public $storeInfo;

    /**
     * Subtitle of the item.
     *
     * Only returned if the seller included a subtitle for the listing.
     *
     * @var string
     */
    public $subtitle;

    /**
     * Name of the item as it appears in the listing title, or in search and
     * browse results.
     *
     * @var string
     */
    public $title;

    /**
     * The URL to view this specific listing on eBay.
     *
     * The returned URL is optimized to support natural search. That is, the URL
     * is designed to make items on eBay easier to find via popular internet
     * search engines. The URL includes the item title along with other
     * optimizations. To note, "?" (question mark) optimizes to "_W0QQ", "&"
     * (ampersand) optimizes to "QQ", and "=" (equals sign) optimizes to "Z".
     *
     * Do not modify the returned URLs in your application queries (for example,
     * eBay won't recognize the URL if you change QQ to &). In the Sandbox
     * environment (and on the Hong Kong site), the data returned in this field
     * is a standard ViewItem URL rather than the ViewItemURL for natural
     * search.
     *
     * @var string
     */
    public $viewItemURL;

    /**
     * @return void
     */
    protected function _init()
    {
        parent::_init();
        $ns = Zend_Service_Ebay_Finding::XMLNS_FINDING;

        $this->autoPay               = $this->_query(".//$ns:autoPay[1]", 'boolean');
        $this->charityId             = $this->_query(".//$ns:charityId[1]", 'integer');
        $this->country               = $this->_query(".//$ns:country[1]", 'string');
        $this->distance              = $this->_query(".//$ns:distance[1]", 'float');
        $this->galleryPlusPictureURL = $this->_query(".//$ns:galleryPlusPictureURL", 'string', true);
        $this->galleryURL            = $this->_query(".//$ns:galleryURL[1]", 'string');
        $this->globalId              = $this->_query(".//$ns:globalId[1]", 'string');
        $this->itemId                = $this->_query(".//$ns:itemId[1]", 'string');
        $this->location              = $this->_query(".//$ns:location[1]", 'string');
        $this->paymentMethod         = $this->_query(".//$ns:paymentMethod", 'string', true);
        $this->postalCode            = $this->_query(".//$ns:postalCode[1]", 'string');
        $this->productId             = $this->_query(".//$ns:productId[1]", 'string');
        $this->subtitle              = $this->_query(".//$ns:subtitle[1]", 'string');
        $this->title                 = $this->_query(".//$ns:title[1]", 'string');
        $this->viewItemURL           = $this->_query(".//$ns:viewItemURL[1]", 'string');

        $this->_attributes['distance'] = array(
            'unit' => $this->_query(".//$ns:distance[1]/@unit[1]", 'string')
        );
        $this->_attributes['productId'] = array(
            'type' => $this->_query(".//$ns:productId[1]/@type[1]", 'string')
        );

        $node = $this->_xPath->query(".//$ns:listingInfo[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_ListingInfo
             */
            require_once 'Zend/Service/Ebay/Finding/ListingInfo.php';
            $this->listingInfo = new Zend_Service_Ebay_Finding_ListingInfo($node);
        }

        $node = $this->_xPath->query(".//$ns:primaryCategory[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Category
             */
            require_once 'Zend/Service/Ebay/Finding/Category.php';
            $this->primaryCategory = new Zend_Service_Ebay_Finding_Category($node);
        }

        $node = $this->_xPath->query(".//$ns:secondaryCategory[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Category
             */
            require_once 'Zend/Service/Ebay/Finding/Category.php';
            $this->secondaryCategory = new Zend_Service_Ebay_Finding_Category($node);
        }

        $node = $this->_xPath->query(".//$ns:sellerInfo[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_SellerInfo
             */
            require_once 'Zend/Service/Ebay/Finding/SellerInfo.php';
            $this->sellerInfo = new Zend_Service_Ebay_Finding_SellerInfo($node);
        }

        $node = $this->_xPath->query(".//$ns:sellingStatus[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_SellingStatus
             */
            require_once 'Zend/Service/Ebay/Finding/SellingStatus.php';
            $this->sellingStatus = new Zend_Service_Ebay_Finding_SellingStatus($node);
        }

        $node = $this->_xPath->query("./$ns:shippingInfo", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_ShippingInfo
             */
            require_once 'Zend/Service/Ebay/Finding/ShippingInfo.php';
            $this->shippingInfo = new Zend_Service_Ebay_Finding_ShippingInfo($node);
        }

        $node = $this->_xPath->query(".//$ns:storeInfo[1]", $this->_dom)->item(0);
        if ($node) {
            /**
             * @see Zend_Service_Ebay_Finding_Storefront
             */
            require_once 'Zend/Service/Ebay/Finding/Storefront.php';
            $this->storeInfo = new Zend_Service_Ebay_Finding_Storefront($node);
        }
    }

    /**
     * @param  Zend_Service_Ebay_Finding $proxy
     * @param  Zend_Config|array         $options
     * @return Zend_Service_Ebay_Finding_Response_Items
     */
    public function findItemsByProduct(Zend_Service_Ebay_Finding $proxy, $options = null)
    {
        $type = $this->attributes('productId', 'type');
        return $proxy->findItemsByProduct($this->productId, $type, $options);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Set.php 20166 2010-01-09 19:00:17Z bkarwin $
 */

/**
 * @see Zend_Service_Ebay_Finding_Set_Abstract
 */
require_once 'Zend/Service/Ebay/Finding/Set/Abstract.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Ebay
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @uses       Zend_Service_Ebay_Finding_Set_Abstract
 */
class Zend_Service_Ebay_Finding_Search_Item_Set extends Zend_Service_Ebay_Finding_Set_Abstract
{
    /**
     * Implement SeekableIterator::current()
     *
     * @return Zend_Service_Ebay_Finding_Search_Item
     */
    public function current()
    {
        // check node
        $node = $this->_nodes->item($this->_key);
        if (!$node) {
            return null;
        }

        /**
         * @see Zend_Service_Ebay_Finding_Search_Item
         */
        require_once 'Zend/Service/Ebay/Finding/Search/Item.php';
        return new Zend_Service_Ebay_Finding_Search_Item($node);
    }
}


text:
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: ResultSet.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see Zend_Service_Flickr_Result
 */
require_once 'Zend/Service/Flickr/Result.php';

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_Flickr_ResultSet implements SeekableIterator
{
    /**
     * Total number of available results
     *
     * @var int
     */
    public $totalResultsAvailable;

    /**
     * Number of results in this result set
     *
     * @var int
     */
    public $totalResultsReturned;

    /**
     * The offset of this result set in the total set of available results
     *
     * @var int
     */
    public $firstResultPosition;

    /**
     * Results storage
     *
     * @var DOMNodeList
     */
    protected $_results = null;

    /**
     * Reference to Zend_Service_Flickr object with which the request was made
     *
     * @var Zend_Service_Flickr
     */
    private $_flickr;

    /**
     * Current index for the Iterator
     *
     * @var int
     */
    private $_currentIndex = 0;

    /**
     * Parse the Flickr Result Set
     *
     * @param  DOMDocument         $dom
     * @param  Zend_Service_Flickr $flickr
     * @return void
     */
    public function __construct(DOMDocument $dom, Zend_Service_Flickr $flickr)
    {
        $this->_flickr = $flickr;

        $xpath = new DOMXPath($dom);

        $photos = $xpath->query('//photos')->item(0);

        $page    = $photos->getAttribute('page');
        $pages   = $photos->getAttribute('pages');
        $perPage = $photos->getAttribute('perpage');
        $total   = $photos->getAttribute('total');

        $this->totalResultsReturned  = ($page == $pages || $pages == 0) ? ($total - ($page - 1) * $perPage) : (int) $perPage;
        $this->firstResultPosition   = ($page - 1) * $perPage + 1;
        $this->totalResultsAvailable = (int) $total;

        if ($total > 0) {
            $this->_results = $xpath->query('//photo');
        }
    }

    /**
     * Total Number of results returned
     *
     * @return int Total number of results returned
     */
    public function totalResults()
    {
        return $this->totalResultsReturned;
    }

    /**
     * Implements SeekableIterator::current()
     *
     * @return Zend_Service_Flickr_Result
     */
    public function current()
    {
        return new Zend_Service_Flickr_Result($this->_results->item($this->_currentIndex), $this->_flickr);
    }

    /**
     * Implements SeekableIterator::key()
     *
     * @return int
     */
    public function key()
    {
        return $this->_currentIndex;
    }

    /**
     * Implements SeekableIterator::next()
     *
     * @return void
     */
    public function next()
    {
        $this->_currentIndex += 1;
    }

    /**
     * Implements SeekableIterator::rewind()
     *
     * @return void
     */
    public function rewind()
    {
        $this->_currentIndex = 0;
    }

    /**
     * Implements SeekableIterator::seek()
     *
     * @param  int $index
     * @throws OutOfBoundsException
     * @return void
     */
    public function seek($index)
    {
        $indexInt = (int) $index;
        if ($indexInt >= 0 && (null === $this->_results || $indexInt < $this->_results->length)) {
            $this->_currentIndex = $indexInt;
        } else {
            throw new OutOfBoundsException("Illegal index '$index'");
        }
    }

    /**
     * Implements SeekableIterator::valid()
     *
     * @return boolean
     */
    public function valid()
    {
        return null !== $this->_results && $this->_currentIndex < $this->_results->length;
    }
}


text:
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Image.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_Flickr_Image
{
    /**
     * The URI of the image
     *
     * @var string
     */
    public $uri;

    /**
     * The URI for linking to the photo on Flickr
     *
     * @var string
     */
    public $clickUri;

    /**
     * The height of the image in pixels
     *
     * @var string
     */
    public $height;

    /**
     * The width of the image in pixels
     *
     * @var string
     */
    public $width;

    /**
     * Parse given Flickr Image element
     *
     * @param  DOMElement $image
     * @return void
     */
    public function __construct(DOMElement $image)
    {
        $this->uri      = (string) $image->getAttribute('source');
        $this->clickUri = (string) $image->getAttribute('url');
        $this->height   = (int) $image->getAttribute('height');
        $this->width    = (int) $image->getAttribute('width');
    }
}


text:
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Result.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @category   Zend
 * @package    Zend_Service
 * @subpackage Flickr
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_Flickr_Result
{
    /**
     * The photo's Flickr ID.
     *
     * @var string
     */
    public $id;

    /**
     * The photo owner's NSID.
     *
     * @var string
     */
    public $owner;

    /**
     * A key used in URI construction.
     *
     * @var string
     */
    public $secret;

    /**
     * The servername to use for URI construction.
     *
     * @var string
     */
    public $server;

    /**
     * The photo's title.
     *
     * @var string
     */
    public $title;

    /**
     * Whether the photo is public.
     *
     * @var string
     */
    public $ispublic;

    /**
     * Whether the photo is visible to you because you are a friend of the owner.
     *
     * @var string
     */
    public $isfriend;

    /**
     * Whether the photo is visible to you because you are family of the owner.
     *
     * @var string
     */
    public $isfamily;

    /**
     * The license the photo is available under.
     *
     * @var string
     */
    public $license;

    /**
     * The date the photo was uploaded.
     *
     * @var string
     */
    public $dateupload;

    /**
     * The date the photo was taken.
     *
     * @var string
     */
    public $datetaken;

    /**
     * The screenname of the owner.
     *
     * @var string
     */
    public $ownername;

    /**
     * The server used in assembling icon URLs.
     *
     * @var string
     */
    public $iconserver;

    /**
     * A 75x75 pixel square thumbnail of the image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Square;

    /**
     * A 100 pixel thumbnail of the image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Thumbnail;

    /**
     * A 240 pixel version of the image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Small;

    /**
     * A 500 pixel version of the image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Medium;

    /**
     * A 640 pixel version of the image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Large;

    /**
     * The original image.
     *
     * @var Zend_Service_Flickr_Image
     */
    public $Original;

    /**
     * Original Zend_Service_Flickr object.
     *
     * @var Zend_Service_Flickr
     */
    protected $_flickr;

    /**
     * Parse the Flickr Result
     *
     * @param  DOMElement          $image
     * @param  Zend_Service_Flickr $flickr Original Zend_Service_Flickr object with which the request was made
     * @return void
     */
    public function __construct(DOMElement $image, Zend_Service_Flickr $flickr)
    {
        $xpath = new DOMXPath($image->ownerDocument);

        foreach ($xpath->query('./@*', $image) as $property) {
            $this->{$property->name} = (string) $property->value;
        }

        $this->_flickr = $flickr;

        foreach ($this->_flickr->getImageDetails($this->id) as $k => $v) {
            $this->$k = $v;
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Session
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: SessionHandler.php 23775 2011-03-01 17:25:24Z ralph $
 */

/** Zend_Service_WindowsAzure_Storage_Table */
require_once 'Zend/Service/WindowsAzure/Storage/Table.php';

/**
 * @see Zend_Service_WindowsAzure_Exception
 */
require_once 'Zend/Service/WindowsAzure/Exception.php';

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Session
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_WindowsAzure_SessionHandler
{
    /**
     * Table storage
     *
     * @var Zend_Service_WindowsAzure_Storage_Table
     */
    protected $_tableStorage;

    /**
     * Session table name
     *
     * @var string
     */
    protected $_sessionTable;

    /**
     * Session table partition
     *
     * @var string
     */
    protected $_sessionTablePartition;

    /**
     * Creates a new Zend_Service_WindowsAzure_SessionHandler instance
     *
     * @param Zend_Service_WindowsAzure_Storage_Table $tableStorage Table storage
     * @param string $sessionTable Session table name
     * @param string $sessionTablePartition Session table partition
     */
    public function __construct(Zend_Service_WindowsAzure_Storage_Table $tableStorage, $sessionTable = 'phpsessions', $sessionTablePartition = 'sessions')
	{
	    // Set properties
		$this->_tableStorage = $tableStorage;
		$this->_sessionTable = $sessionTable;
		$this->_sessionTablePartition = $sessionTablePartition;
	}

	/**
	 * Registers the current session handler as PHP's session handler
	 *
	 * @return boolean
	 */
	public function register()
	{
        return session_set_save_handler(array($this, 'open'),
                                        array($this, 'close'),
                                        array($this, 'read'),
                                        array($this, 'write'),
                                        array($this, 'destroy'),
                                        array($this, 'gc')
        );
    }

    /**
     * Open the session store
     *
     * @return bool
     */
    public function open()
    {
        // Make sure table exists
        $tableExists = $this->_tableStorage->tableExists($this->_sessionTable);
        if (!$tableExists) {
            $this->_tableStorage->createTable($this->_sessionTable);
        }

        // Ok!
        return true;
    }

    /**
     * Close the session store
     *
     * @return bool
     */
    public function close()
    {
        return true;
    }

    /**
     * Read a specific session
     *
     * @param int $id Session Id
     * @return string
     */
    public function read($id)
    {
        try
        {
            $sessionRecord = $this->_tableStorage->retrieveEntityById(
                $this->_sessionTable,
                $this->_sessionTablePartition,
                $id
            );
            return base64_decode($sessionRecord->serializedData);
        }
        catch (Zend_Service_WindowsAzure_Exception $ex)
        {
            return '';
        }
    }

    /**
     * Write a specific session
     *
     * @param int $id Session Id
     * @param string $serializedData Serialized PHP object
     */
    public function write($id, $serializedData)
    {
        $sessionRecord = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity($this->_sessionTablePartition, $id);
        $sessionRecord->sessionExpires = time();
        $sessionRecord->serializedData = base64_encode($serializedData);

        $sessionRecord->setAzurePropertyType('sessionExpires', 'Edm.Int32');

        try
        {
            $this->_tableStorage->updateEntity($this->_sessionTable, $sessionRecord);
        }
        catch (Zend_Service_WindowsAzure_Exception $unknownRecord)
        {
            $this->_tableStorage->insertEntity($this->_sessionTable, $sessionRecord);
        }
    }

    /**
     * Destroy a specific session
     *
     * @param int $id Session Id
     * @return boolean
     */
    public function destroy($id)
    {
        try
        {
            $sessionRecord = $this->_tableStorage->retrieveEntityById(
                $this->_sessionTable,
                $this->_sessionTablePartition,
                $id
            );
            $this->_tableStorage->deleteEntity($this->_sessionTable, $sessionRecord);

            return true;
        }
        catch (Zend_Service_WindowsAzure_Exception $ex)
        {
            return false;
        }
    }

    /**
     * Garbage collector
     *
     * @param int $lifeTime Session maximal lifetime
     * @see session.gc_divisor  100
     * @see session.gc_maxlifetime 1440
     * @see session.gc_probability 1
     * @usage Execution rate 1/100 (session.gc_probability/session.gc_divisor)
     * @return boolean
     */
    public function gc($lifeTime)
    {
        try
        {
            $result = $this->_tableStorage->retrieveEntities($this->_sessionTable, 'PartitionKey eq \'' . $this->_sessionTablePartition . '\' and sessionExpires lt ' . (time() - $lifeTime));
            foreach ($result as $sessionRecord)
            {
                $this->_tableStorage->deleteEntity($this->_sessionTable, $sessionRecord);
            }
            return true;
        }
        catch (Zend_Service_WindowsAzure_exception $ex)
        {
            return false;
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Exception
 * @version    $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * @see Zend_Service_Exception
 */
require_once 'Zend/Service/Exception.php';

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_WindowsAzure_Exception extends Zend_Service_Exception
{}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Storage.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
 */
require_once 'Zend/Service/WindowsAzure/Credentials/CredentialsAbstract.php';

/**
 * @see Zend_Service_WindowsAzure_Credentials_SharedKey
 */
require_once 'Zend/Service/WindowsAzure/Credentials/SharedKey.php';

/**
 * @see Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract
 */
require_once 'Zend/Service/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php';

/**
 * @see Zend_Service_WindowsAzure_Exception
 */
require_once 'Zend/Service/WindowsAzure/Exception.php';

/**
 * @see Zend_Http_Client
 */
require_once 'Zend/Http/Client.php';

/**
 * @see Zend_Http_Response
 */
require_once 'Zend/Http/Response.php';

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_WindowsAzure_Storage
{
	/**
	 * Development storage URLS
	 */
	const URL_DEV_BLOB      = "127.0.0.1:10000";
	const URL_DEV_QUEUE     = "127.0.0.1:10001";
	const URL_DEV_TABLE     = "127.0.0.1:10002";

	/**
	 * Live storage URLS
	 */
	const URL_CLOUD_BLOB    = "blob.core.windows.net";
	const URL_CLOUD_QUEUE   = "queue.core.windows.net";
	const URL_CLOUD_TABLE   = "table.core.windows.net";

	/**
	 * Resource types
	 */
	const RESOURCE_UNKNOWN     = "unknown";
	const RESOURCE_CONTAINER   = "c";
	const RESOURCE_BLOB        = "b";
	const RESOURCE_TABLE       = "t";
	const RESOURCE_ENTITY      = "e";
	const RESOURCE_QUEUE       = "q";

	/**
	 * HTTP header prefixes
	 */
	const PREFIX_PROPERTIES      = "x-ms-prop-";
	const PREFIX_METADATA        = "x-ms-meta-";
	const PREFIX_STORAGE_HEADER  = "x-ms-";

	/**
	 * Current API version
	 *
	 * @var string
	 */
	protected $_apiVersion = '2009-09-19';

	/**
	 * Storage host name
	 *
	 * @var string
	 */
	protected $_host = '';

	/**
	 * Account name for Windows Azure
	 *
	 * @var string
	 */
	protected $_accountName = '';

	/**
	 * Account key for Windows Azure
	 *
	 * @var string
	 */
	protected $_accountKey = '';

	/**
	 * Use path-style URI's
	 *
	 * @var boolean
	 */
	protected $_usePathStyleUri = false;

	/**
	 * Zend_Service_WindowsAzure_Credentials_CredentialsAbstract instance
	 *
	 * @var Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
	 */
	protected $_credentials = null;

	/**
	 * Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract instance
	 *
	 * @var Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract
	 */
	protected $_retryPolicy = null;

	/**
	 * Zend_Http_Client channel used for communication with REST services
	 *
	 * @var Zend_Http_Client
	 */
	protected $_httpClientChannel = null;

	/**
	 * Use proxy?
	 *
	 * @var boolean
	 */
	protected $_useProxy = false;

	/**
	 * Proxy url
	 *
	 * @var string
	 */
	protected $_proxyUrl = '';

	/**
	 * Proxy port
	 *
	 * @var int
	 */
	protected $_proxyPort = 80;

	/**
	 * Proxy credentials
	 *
	 * @var string
	 */
	protected $_proxyCredentials = '';

	/**
	 * Creates a new Zend_Service_WindowsAzure_Storage instance
	 *
	 * @param string $host Storage host name
	 * @param string $accountName Account name for Windows Azure
	 * @param string $accountKey Account key for Windows Azure
	 * @param boolean $usePathStyleUri Use path-style URI's
	 * @param Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
	 */
	public function __construct(
		$host = self::URL_DEV_BLOB,
		$accountName = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT,
		$accountKey = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY,
		$usePathStyleUri = false,
		Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null
	) {
		$this->_host = $host;
		$this->_accountName = $accountName;
		$this->_accountKey = $accountKey;
		$this->_usePathStyleUri = $usePathStyleUri;

		// Using local storage?
		if (!$this->_usePathStyleUri
			&& ($this->_host == self::URL_DEV_BLOB
				|| $this->_host == self::URL_DEV_QUEUE
				|| $this->_host == self::URL_DEV_TABLE)
		) {
			// Local storage
			$this->_usePathStyleUri = true;
		}

		if ($this->_credentials === null) {
		    $this->_credentials = new Zend_Service_WindowsAzure_Credentials_SharedKey(
		    	$this->_accountName, $this->_accountKey, $this->_usePathStyleUri);
		}

		$this->_retryPolicy = $retryPolicy;
		if ($this->_retryPolicy === null) {
		    $this->_retryPolicy = Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry();
		}

		// Setup default Zend_Http_Client channel
		$options = array(
			'adapter' => 'Zend_Http_Client_Adapter_Proxy'
		);
		if (function_exists('curl_init')) {
			// Set cURL options if cURL is used afterwards
			$options['curloptions'] = array(
					CURLOPT_FOLLOWLOCATION => true,
					CURLOPT_TIMEOUT => 120,
			);
		}
		$this->_httpClientChannel = new Zend_Http_Client(null, $options);
	}

	/**
	 * Set the HTTP client channel to use
	 *
	 * @param Zend_Http_Client_Adapter_Interface|string $adapterInstance Adapter instance or adapter class name.
	 */
	public function setHttpClientChannel($adapterInstance = 'Zend_Http_Client_Adapter_Proxy')
	{
		$this->_httpClientChannel->setAdapter($adapterInstance);
	}

    /**
     * Retrieve HTTP client channel
     *
     * @return Zend_Http_Client_Adapter_Interface
     */
    public function getHttpClientChannel()
    {
        return $this->_httpClientChannel;
    }

	/**
	 * Set retry policy to use when making requests
	 *
	 * @param Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
	 */
	public function setRetryPolicy(Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
	{
		$this->_retryPolicy = $retryPolicy;
		if ($this->_retryPolicy === null) {
		    $this->_retryPolicy = Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry();
		}
	}

	/**
	 * Set proxy
	 *
	 * @param boolean $useProxy         Use proxy?
	 * @param string  $proxyUrl         Proxy URL
	 * @param int     $proxyPort        Proxy port
	 * @param string  $proxyCredentials Proxy credentials
	 */
	public function setProxy($useProxy = false, $proxyUrl = '', $proxyPort = 80, $proxyCredentials = '')
	{
	    $this->_useProxy         = $useProxy;
	    $this->_proxyUrl         = $proxyUrl;
	    $this->_proxyPort        = $proxyPort;
	    $this->_proxyCredentials = $proxyCredentials;

	    if ($this->_useProxy) {
	    	$credentials = explode(':', $this->_proxyCredentials);

	    	$this->_httpClientChannel->setConfig(array(
				'proxy_host' => $this->_proxyUrl,
	    		'proxy_port' => $this->_proxyPort,
	    		'proxy_user' => $credentials[0],
	    		'proxy_pass' => $credentials[1],
	    	));
	    } else {
			$this->_httpClientChannel->setConfig(array(
				'proxy_host' => '',
	    		'proxy_port' => 8080,
	    		'proxy_user' => '',
	    		'proxy_pass' => '',
	    	));
	    }
	}

	/**
	 * Returns the Windows Azure account name
	 *
	 * @return string
	 */
	public function getAccountName()
	{
		return $this->_accountName;
	}

	/**
	 * Get base URL for creating requests
	 *
	 * @return string
	 */
	public function getBaseUrl()
	{
		if ($this->_usePathStyleUri) {
			return 'http://' . $this->_host . '/' . $this->_accountName;
		} else {
			return 'http://' . $this->_accountName . '.' . $this->_host;
		}
	}

	/**
	 * Set Zend_Service_WindowsAzure_Credentials_CredentialsAbstract instance
	 *
	 * @param Zend_Service_WindowsAzure_Credentials_CredentialsAbstract $credentials Zend_Service_WindowsAzure_Credentials_CredentialsAbstract instance to use for request signing.
	 */
	public function setCredentials(Zend_Service_WindowsAzure_Credentials_CredentialsAbstract $credentials)
	{
	    $this->_credentials = $credentials;
	    $this->_credentials->setAccountName($this->_accountName);
	    $this->_credentials->setAccountkey($this->_accountKey);
	    $this->_credentials->setUsePathStyleUri($this->_usePathStyleUri);
	}

	/**
	 * Get Zend_Service_WindowsAzure_Credentials_CredentialsAbstract instance
	 *
	 * @return Zend_Service_WindowsAzure_Credentials_CredentialsAbstract
	 */
	public function getCredentials()
	{
	    return $this->_credentials;
	}

	/**
	 * Perform request using Zend_Http_Client channel
	 *
	 * @param string $path Path
	 * @param string $queryString Query string
	 * @param string $httpVerb HTTP verb the request will use
	 * @param array $headers x-ms headers to add
	 * @param boolean $forTableStorage Is the request for table storage?
	 * @param mixed $rawData Optional RAW HTTP data to be sent over the wire
	 * @param string $resourceType Resource type
	 * @param string $requiredPermission Required permission
	 * @return Zend_Http_Response
	 */
	protected function _performRequest(
		$path = '/',
		$queryString = '',
		$httpVerb = Zend_Http_Client::GET,
		$headers = array(),
		$forTableStorage = false,
		$rawData = null,
		$resourceType = Zend_Service_WindowsAzure_Storage::RESOURCE_UNKNOWN,
		$requiredPermission = Zend_Service_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
	) {
	    // Clean path
		if (strpos($path, '/') !== 0) {
			$path = '/' . $path;
		}

		// Clean headers
		if ($headers === null) {
		    $headers = array();
		}

		// Ensure cUrl will also work correctly:
		//  - disable Content-Type if required
		//  - disable Expect: 100 Continue
		if (!isset($headers["Content-Type"])) {
			$headers["Content-Type"] = '';
		}
		$headers["Expect"]= '';

		// Add version header
		$headers['x-ms-version'] = $this->_apiVersion;

		// URL encoding
		$path           = self::urlencode($path);
		$queryString    = self::urlencode($queryString);

        // Generate URL and sign request
        $requestUrl     = $this->_credentials
                          ->signRequestUrl($this->getBaseUrl() . $path . $queryString, $resourceType, $requiredPermission);
        $requestHeaders = $this->_credentials
                          ->signRequestHeaders($httpVerb, $path, $queryString, $headers, $forTableStorage, $resourceType, $requiredPermission, $rawData);

		// Prepare request
		$this->_httpClientChannel->resetParameters(true);
		$this->_httpClientChannel->setUri($requestUrl);
		$this->_httpClientChannel->setHeaders($requestHeaders);
		$this->_httpClientChannel->setRawData($rawData);

		// Execute request
		$response = $this->_retryPolicy->execute(
		    array($this->_httpClientChannel, 'request'),
		    array($httpVerb)
		);

		return $response;
	}

	/**
	 * Parse result from Zend_Http_Response
	 *
	 * @param Zend_Http_Response $response Response from HTTP call
	 * @return object
	 * @throws Zend_Service_WindowsAzure_Exception
	 */
	protected function _parseResponse(Zend_Http_Response $response = null)
	{
		if ($response === null) {
			throw new Zend_Service_WindowsAzure_Exception('Response should not be null.');
		}

        $xml = @simplexml_load_string($response->getBody());

        if ($xml !== false) {
            // Fetch all namespaces
            $namespaces = array_merge($xml->getNamespaces(true), $xml->getDocNamespaces(true));

            // Register all namespace prefixes
            foreach ($namespaces as $prefix => $ns) {
                if ($prefix != '') {
                    $xml->registerXPathNamespace($prefix, $ns);
                }
            }
        }

        return $xml;
	}

	/**
	 * Generate metadata headers
	 *
	 * @param array $metadata
	 * @return HTTP headers containing metadata
	 */
	protected function _generateMetadataHeaders($metadata = array())
	{
		// Validate
		if (!is_array($metadata)) {
			return array();
		}

		// Return headers
		$headers = array();
		foreach ($metadata as $key => $value) {
			if (strpos($value, "\r") !== false || strpos($value, "\n") !== false) {
				throw new Zend_Service_WindowsAzure_Exception('Metadata cannot contain newline characters.');
			}

			if (!self::isValidMetadataName($key)) {
		    	throw new Zend_Service_WindowsAzure_Exception('Metadata name does not adhere to metadata naming conventions. See http://msdn.microsoft.com/en-us/library/aa664670(VS.71).aspx for more information.');
			}

		    $headers["x-ms-meta-" . strtolower($key)] = $value;
		}
		return $headers;
	}

	/**
	 * Parse metadata headers
	 *
	 * @param array $headers HTTP headers containing metadata
	 * @return array
	 */
	protected function _parseMetadataHeaders($headers = array())
	{
		// Validate
		if (!is_array($headers)) {
			return array();
		}

		// Return metadata
		$metadata = array();
		foreach ($headers as $key => $value) {
		    if (substr(strtolower($key), 0, 10) == "x-ms-meta-") {
		        $metadata[str_replace("x-ms-meta-", '', strtolower($key))] = $value;
		    }
		}
		return $metadata;
	}

	/**
	 * Parse metadata XML
	 *
	 * @param SimpleXMLElement $parentElement Element containing the Metadata element.
	 * @return array
	 */
	protected function _parseMetadataElement($element = null)
	{
		// Metadata present?
		if ($element !== null && isset($element->Metadata) && $element->Metadata !== null) {
			return get_object_vars($element->Metadata);
		}

		return array();
	}

	/**
	 * Generate ISO 8601 compliant date string in UTC time zone
	 *
	 * @param int $timestamp
	 * @return string
	 */
	public function isoDate($timestamp = null)
	{
	    $tz = @date_default_timezone_get();
	    @date_default_timezone_set('UTC');

	    if ($timestamp === null) {
	        $timestamp = time();
	    }

	    $returnValue = str_replace('+00:00', '.0000000Z', @date('c', $timestamp));
	    @date_default_timezone_set($tz);
	    return $returnValue;
	}

	/**
	 * URL encode function
	 *
	 * @param  string $value Value to encode
	 * @return string        Encoded value
	 */
	public static function urlencode($value)
	{
	    return str_replace(' ', '%20', $value);
	}

	/**
	 * Is valid metadata name?
	 *
	 * @param string $metadataName Metadata name
	 * @return boolean
	 */
    public static function isValidMetadataName($metadataName = '')
    {
        if (preg_match("/^[a-zA-Z0-9_@][a-zA-Z0-9_]*$/", $metadataName) === 0) {
            return false;
        }

        if ($metadataName == '') {
            return false;
        }

        return true;
    }

    /**
     * Builds a query string from an array of elements
     *
     * @param array     Array of elements
     * @return string   Assembled query string
     */
    public static function createQueryStringFromArray($queryString)
    {
        return count($queryString) > 0 ? '?' . implode('&', $queryString) : '';
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: QueueMessage.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see Zend_Service_WindowsAzure_Exception
 */
require_once 'Zend/Service/WindowsAzure/Exception.php';

/**
 * @see Zend_Service_WindowsAzure_Storage_StorageEntityAbstract
 */
require_once 'Zend/Service/WindowsAzure/Storage/StorageEntityAbstract.php';

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 *
 * @property string $MessageId         Message ID
 * @property string $InsertionTime     Insertion time
 * @property string $ExpirationTime    Expiration time
 * @property string $PopReceipt         Receipt verification for deleting the message from queue.
 * @property string $TimeNextVisible   Next time the message is visible in the queue
 * @property int    $DequeueCount      Number of times the message has been dequeued. This value is incremented each time the message is subsequently dequeued.
 * @property string $MessageText       Message text
 */
class Zend_Service_WindowsAzure_Storage_QueueMessage
    extends Zend_Service_WindowsAzure_Storage_StorageEntityAbstract
{
    /**
     * Constructor
     *
     * @param string $messageId         Message ID
     * @param string $insertionTime     Insertion time
     * @param string $expirationTime    Expiration time
     * @param string $popReceipt          Receipt verification for deleting the message from queue.
     * @param string $timeNextVisible   Next time the message is visible in the queue
     * @param int    $dequeueCount      Number of times the message has been dequeued. This value is incremented each time the message is subsequently dequeued.
     * @param string $messageText       Message text
     */
    public function __construct($messageId, $insertionTime, $expirationTime, $popReceipt, $timeNextVisible, $dequeueCount, $messageText)
    {
        $this->_data = array(
            'messageid'       => $messageId,
            'insertiontime'   => $insertionTime,
            'expirationtime'  => $expirationTime,
            'popreceipt'      => $popReceipt,
            'timenextvisible' => $timeNextVisible,
            'dequeuecount'    => $dequeueCount,
            'messagetext'     => $messageText
        );
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: TableEntityQuery.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Service_WindowsAzure_Storage_TableEntityQuery
{
    /**
     * From
     *
     * @var string
     */
	protected $_from  = '';

	/**
	 * Where
	 *
	 * @var array
	 */
	protected $_where = array();

	/**
	 * Order by
	 *
	 * @var array
	 */
	protected $_orderBy = array();

	/**
	 * Top
	 *
	 * @var int
	 */
	protected $_top = null;

	/**
	 * Partition key
	 *
	 * @var string
	 */
	protected $_partitionKey = null;

	/**
	 * Row key
	 *
	 * @var string
	 */
	protected $_rowKey = null;

	/**
	 * Select clause
	 *
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function select()
	{
		return $this;
	}

	/**
	 * From clause
	 *
	 * @param string $name Table name to select entities from
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function from($name)
	{
		$this->_from = $name;
		return $this;
	}

	/**
	 * Specify partition key
	 *
	 * @param string $value Partition key to query for
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function wherePartitionKey($value = null)
	{
	    $this->_partitionKey = $value;
	    return $this;
	}

	/**
	 * Specify row key
	 *
	 * @param string $value Row key to query for
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function whereRowKey($value = null)
	{
	    $this->_rowKey = $value;
	    return $this;
	}

	/**
	 * Add where clause
	 *
	 * @param string       $condition   Condition, can contain question mark(s) (?) for parameter insertion.
	 * @param string|array $value       Value(s) to insert in question mark (?) parameters.
	 * @param string       $cond        Condition for the clause (and/or/not)
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function where($condition, $value = null, $cond = '')
	{
	    $condition = $this->_replaceOperators($condition);

	    if ($value !== null) {
	        $condition = $this->_quoteInto($condition, $value);
	    }

		if (count($this->_where) == 0) {
			$cond = '';
		} else if ($cond !== '') {
			$cond = ' ' . strtolower(trim($cond)) . ' ';
		}

		$this->_where[] = $cond . $condition;
		return $this;
	}

	/**
	 * Add where clause with AND condition
	 *
	 * @param string       $condition   Condition, can contain question mark(s) (?) for parameter insertion.
	 * @param string|array $value       Value(s) to insert in question mark (?) parameters.
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function andWhere($condition, $value = null)
	{
		return $this->where($condition, $value, 'and');
	}

	/**
	 * Add where clause with OR condition
	 *
	 * @param string       $condition   Condition, can contain question mark(s) (?) for parameter insertion.
	 * @param string|array $value       Value(s) to insert in question mark (?) parameters.
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function orWhere($condition, $value = null)
	{
		return $this->where($condition, $value, 'or');
	}

	/**
	 * OrderBy clause
	 *
	 * @param string $column    Column to sort by
	 * @param string $direction Direction to sort (asc/desc)
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
	public function orderBy($column, $direction = 'asc')
	{
		$this->_orderBy[] = $column . ' ' . $direction;
		return $this;
	}

	/**
	 * Top clause
	 *
	 * @param int $top  Top to fetch
	 * @return Zend_Service_WindowsAzure_Storage_TableEntityQuery
	 */
    public function top($top = null)
    {
        $this->_top  = (int)$top;
        return $this;
    }

    /**
     * Assembles the query string
     *
     * @param boolean $urlEncode Apply URL encoding to the query string
     * @return string
     */
	public function assembleQueryString($urlEncode = false)
	{
		$query = array();
		if (count($this->_where) != 0) {
		    $filter = implode('', $this->_where);
			$query[] = '$filter=' . ($urlEncode ? self::encodeQuery($filter) : $filter);
		}

		if (count($this->_orderBy) != 0) {
		    $orderBy = implode(',', $this->_orderBy);
			$query[] = '$orderby=' . ($urlEncode ? self::encodeQuery($orderBy) : $orderBy);
		}

		if ($this->_top !== null) {
			$query[] = '$top=' . $this->_top;
		}

		if (count($query) != 0) {
			return '?' . implode('&', $query);
		}

		return '';
	}

	/**
	 * Assemble from
	 *
	 * @param boolean $includeParentheses Include parentheses? ()
	 * @return string
	 */
	public function assembleFrom($includeParentheses = true)
	{
	    $identifier = '';
	    if ($includeParentheses) {
	        $identifier .= '(';

	        if ($this->_partitionKey !== null) {
	            $identifier .= 'PartitionKey=\'' . $this->_partitionKey . '\'';
	        }

	        if ($this->_partitionKey !== null && $this->_rowKey !== null) {
	            $identifier .= ', ';
	        }

	        if ($this->_rowKey !== null) {
	            $identifier .= 'RowKey=\'' . $this->_rowKey . '\'';
	        }

	        $identifier .= ')';
	    }
		return $this->_from . $identifier;
	}

	/**
	 * Assemble full query
	 *
	 * @return string
	 */
	public function assembleQuery()
	{
		$assembledQuery = $this->assembleFrom();

		$queryString = $this->assembleQueryString();
		if ($queryString !== '') {
			$assembledQuery .= $queryString;
		}

		return $assembledQuery;
	}

	/**
	 * Quotes a variable into a condition
	 *
	 * @param string       $text   Condition, can contain question mark(s) (?) for parameter insertion.
	 * @param string|array $value  Value(s) to insert in question mark (?) parameters.
	 * @return string
	 */
	protected function _quoteInto($text, $value = null)
	{
		if (!is_array($value)) {
	        $text = str_replace('?', '\'' . addslashes($value) . '\'', $text);
	    } else {
	        $i = 0;
	        while(strpos($text, '?') !== false) {
	            if (is_numeric($value[$i])) {
	                $text = substr_replace($text, $value[$i++], strpos($text, '?'), 1);
	            } else {
	                $text = substr_replace($text, '\'' . addslashes($value[$i++]) . '\'', strpos($text, '?'), 1);
	            }
	        }
	    }
	    return $text;
	}

	/**
	 * Replace operators
	 *
	 * @param string $text
	 * @return string
	 */
	protected function _replaceOperators($text)
	{
	    $text = str_replace('==', 'eq',  $text);
	    $text = str_replace('>',  'gt',  $text);
	    $text = str_replace('<',  'lt',  $text);
	    $text = str_replace('>=', 'ge',  $text);
	    $text = str_replace('<=', 'le',  $text);
	    $text = str_replace('!=', 'ne',  $text);

	    $text = str_replace('&&', 'and', $text);
	    $text = str_replace('||', 'or',  $text);
	    $text = str_replace('!',  'not', $text);

	    return $text;
	}

	/**
	 * urlencode a query
	 *
	 * @param string $query Query to encode
	 * @return string Encoded query
	 */
	public static function encodeQuery($query)
	{
		$query = str_replace('/', '%2F', $query);
		$query = str_replace('?', '%3F', $query);
		$query = str_replace(':', '%3A', $query);
		$query = str_replace('@', '%40', $query);
		$query = str_replace('&', '%26', $query);
		$query = str_replace('=', '%3D', $query);
		$query = str_replace('+', '%2B', $query);
		$query = str_replace(',', '%2C', $query);
		$query = str_replace('$', '%24', $query);

		$query = str_replace(' ', '%20', $query);

		return $query;
	}

	/**
	 * __toString overload
	 *
	 * @return string
	 */
	public function __toString()
	{
		return $this->assembleQuery();
	}
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id$
 */

/**
 * @see Zend_Service_WindowsAzure_Exception
 */
require_once 'Zend/Service/WindowsAzure/Exception.php';

/**
 * @category   Zend
 * @package    Zend_Service_WindowsAzure
 * @subpackage Storage
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 *
 */
abstract class Zend_Service_WindowsAzure_Storage_StorageEntityAbstract
{
    /**
     * Data
     *
     * @var array
     */
    protected $_data = null;

    /**
     * Magic overload for setting properties
     *
     * @param string $name     Name of the property
     * @param string $value    Value to set
     */
    public function __set($name, $value) {
        if (array_key_exists(strtolower($name), $this->_data)) {
            $this->_data[strtolower($name)] = $value;
            return;
        }

        throw new Exception("Unknown property: " . $name);
    }

    /**
     * Magic overload for getting properties
     *
     * @param string $name     Name of the property
     */
    public function __get($name) {
        if (array_key_exists(strtolower($name), $this->_data)) {
            return $this->_data[strtolower($name)];
        }

        throw new Exception("Unknown property: " . $name);
    }
}