|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
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. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Service |
|
17 * @subpackage Technorati |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: SearchResultSet.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 * @see Zend_Service_Technorati_ResultSet |
|
26 */ |
|
27 require_once 'Zend/Service/Technorati/ResultSet.php'; |
|
28 |
|
29 |
|
30 /** |
|
31 * Represents a Technorati Search query result set. |
|
32 * |
|
33 * @category Zend |
|
34 * @package Zend_Service |
|
35 * @subpackage Technorati |
|
36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
38 */ |
|
39 class Zend_Service_Technorati_SearchResultSet extends Zend_Service_Technorati_ResultSet |
|
40 { |
|
41 /** |
|
42 * Number of query results. |
|
43 * |
|
44 * @var int |
|
45 * @access protected |
|
46 */ |
|
47 protected $_queryCount; |
|
48 |
|
49 /** |
|
50 * Parses the search response and retrieve the results for iteration. |
|
51 * |
|
52 * @param DomDocument $dom the ReST fragment for this object |
|
53 * @param array $options query options as associative array |
|
54 */ |
|
55 public function __construct(DomDocument $dom, $options = array()) |
|
56 { |
|
57 parent::__construct($dom, $options); |
|
58 |
|
59 $result = $this->_xpath->query('/tapi/document/result/querycount/text()'); |
|
60 if ($result->length == 1) $this->_queryCount = (int) $result->item(0)->data; |
|
61 |
|
62 $this->_totalResultsReturned = (int) $this->_xpath->evaluate("count(/tapi/document/item)"); |
|
63 $this->_totalResultsAvailable = (int) $this->_queryCount; |
|
64 } |
|
65 |
|
66 /** |
|
67 * Implements Zend_Service_Technorati_ResultSet::current(). |
|
68 * |
|
69 * @return Zend_Service_Technorati_SearchResult current result |
|
70 */ |
|
71 public function current() |
|
72 { |
|
73 /** |
|
74 * @see Zend_Service_Technorati_SearchResult |
|
75 */ |
|
76 require_once 'Zend/Service/Technorati/SearchResult.php'; |
|
77 return new Zend_Service_Technorati_SearchResult($this->_results->item($this->_currentIndex)); |
|
78 } |
|
79 } |