WebResult.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 Yahoo
  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_Yahoo_Result
  24. */
  25. require_once 'Zend/Service/Yahoo/Result.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Service
  29. * @subpackage Yahoo
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Service_Yahoo_WebResult extends Zend_Service_Yahoo_Result
  34. {
  35. /**
  36. * A summary of the result
  37. *
  38. * @var string
  39. */
  40. public $Summary;
  41. /**
  42. * The file type of the result (text, html, pdf, etc.)
  43. *
  44. * @var string
  45. */
  46. public $MimeType;
  47. /**
  48. * The modification time of the result (as a unix timestamp)
  49. *
  50. * @var string
  51. */
  52. public $ModificationDate;
  53. /**
  54. * The URL for the Yahoo cache of this page, if it exists
  55. *
  56. * @var string
  57. */
  58. public $CacheUrl;
  59. /**
  60. * The size of the cache entry
  61. *
  62. * @var int
  63. */
  64. public $CacheSize;
  65. /**
  66. * Web result namespace
  67. *
  68. * @var string
  69. */
  70. protected $_namespace = 'urn:yahoo:srch';
  71. /**
  72. * Initializes the web result
  73. *
  74. * @param DOMElement $result
  75. * @return void
  76. */
  77. public function __construct(DOMElement $result)
  78. {
  79. $this->_fields = array('Summary', 'MimeType', 'ModificationDate');
  80. parent::__construct($result);
  81. $this->_xpath = new DOMXPath($result->ownerDocument);
  82. $this->_xpath->registerNamespace('yh', $this->_namespace);
  83. // check if the cache section exists
  84. $cacheUrl = $this->_xpath->query('./yh:Cache/yh:Url/text()', $result)->item(0);
  85. if ($cacheUrl instanceof DOMNode)
  86. {
  87. $this->CacheUrl = $cacheUrl->data;
  88. }
  89. $cacheSize = $this->_xpath->query('./yh:Cache/yh:Size/text()', $result)->item(0);
  90. if ($cacheSize instanceof DOMNode)
  91. {
  92. $this->CacheSize = (int) $cacheSize->data;
  93. }
  94. }
  95. }