8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
17 * @package Zend_Service
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: Result.php 16211 2009-06-21 19:23:55Z thomas $
27 * @package Zend_Service
29 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
30 * @license http://framework.zend.com/license/new-bsd New BSD License
32 class Zend_Service_Yahoo_Result
35 * The title of the search entry
42 * The URL of the found object
49 * The URL for linking to the found object
63 * REST response fragment for the result
70 * Object for XPath queries
78 * Initializes the result
80 * @param DOMElement $result
83 public function __construct(DOMElement
$result)
85 // default fields for all search results:
86 $fields = array('Title', 'Url', 'ClickUrl');
88 // merge w/ child's fields
89 $this->_fields
= array_merge($this->_fields
, $fields);
91 $this->_xpath
= new DOMXPath($result->ownerDocument
);
92 $this->_xpath
->registerNamespace('yh', $this->_namespace
);
94 // add search results to appropriate fields
96 foreach ($this->_fields
as $f) {
97 $query = "./yh:$f/text()";
98 $node = $this->_xpath
->query($query, $result);
99 if ($node->length
== 1) {
100 $this->{$f} = $node->item(0)->data
;
104 $this->_result
= $result;
109 * Sets the Thumbnail property
113 protected function _setThumbnail()
115 $node = $this->_xpath
->query('./yh:Thumbnail', $this->_result
);
116 if ($node->length
== 1) {
118 * @see Zend_Service_Yahoo_Image
120 require_once 'Zend/Service/Yahoo/Image.php';
121 $this->Thumbnail
= new Zend_Service_Yahoo_Image($node->item(0), $this->_namespace
);
123 $this->Thumbnail
= null;