Merge file:///media/external_data/workspace/web/sport-group
[sport-group.git] / library / Zend / Service / Technorati / DailyCountsResultSet.php
blob10c6fa3b39840a9d0a9c9846c32a1accb9225441
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Service
17 * @subpackage Technorati
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: DailyCountsResultSet.php 16211 2009-06-21 19:23:55Z thomas $
24 /**
25 * @see Zend_Date
27 require_once 'Zend/Date.php';
29 /**
30 * @see Zend_Service_Technorati_ResultSet
32 require_once 'Zend/Service/Technorati/ResultSet.php';
34 /**
35 * @see Zend_Service_Technorati_Utils
37 require_once 'Zend/Service/Technorati/Utils.php';
40 /**
41 * Represents a Technorati Tag query result set.
43 * @category Zend
44 * @package Zend_Service
45 * @subpackage Technorati
46 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
47 * @license http://framework.zend.com/license/new-bsd New BSD License
49 class Zend_Service_Technorati_DailyCountsResultSet extends Zend_Service_Technorati_ResultSet
51 /**
52 * Technorati search URL for given query.
54 * @var Zend_Uri_Http
55 * @access protected
57 protected $_searchUrl;
59 /**
60 * Number of days for which counts provided.
62 * @var Zend_Service_Technorati_Weblog
63 * @access protected
65 protected $_days;
67 /**
68 * Parses the search response and retrieve the results for iteration.
70 * @param DomDocument $dom the ReST fragment for this object
71 * @param array $options query options as associative array
73 public function __construct(DomDocument $dom, $options = array())
75 parent::__construct($dom, $options);
77 // default locale prevent Zend_Date to fail
78 // when script is executed via shell
79 // Zend_Locale::setDefault('en');
81 $result = $this->_xpath->query('/tapi/document/result/days/text()');
82 if ($result->length == 1) $this->_days = (int) $result->item(0)->data;
84 $result = $this->_xpath->query('/tapi/document/result/searchurl/text()');
85 if ($result->length == 1) {
86 $this->_searchUrl = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data);
89 $this->_totalResultsReturned = (int) $this->_xpath->evaluate("count(/tapi/document/items/item)");
90 $this->_totalResultsAvailable = (int) $this->getDays();
94 /**
95 * Returns the search URL for given query.
97 * @return Zend_Uri_Http
99 public function getSearchUrl() {
100 return $this->_searchUrl;
104 * Returns the number of days for which counts provided.
106 * @return int
108 public function getDays() {
109 return $this->_days;
113 * Implements Zend_Service_Technorati_ResultSet::current().
115 * @return Zend_Service_Technorati_DailyCountsResult current result
117 public function current()
120 * @see Zend_Service_Technorati_DailyCountsResult
122 require_once 'Zend/Service/Technorati/DailyCountsResult.php';
123 return new Zend_Service_Technorati_DailyCountsResult($this->_results->item($this->_currentIndex));