SearchResultSet.php 2.4 KB

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