*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Service / Yahoo / Result.php
blob99becd9336229a3f2a87fa3cb08e787c7b747440
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
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.
16 * @category Zend
17 * @package Zend_Service
18 * @subpackage Yahoo
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 $
25 /**
26 * @category Zend
27 * @package Zend_Service
28 * @subpackage Yahoo
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
34 /**
35 * The title of the search entry
37 * @var string
39 public $Title;
41 /**
42 * The URL of the found object
44 * @var string
46 public $Url;
48 /**
49 * The URL for linking to the found object
51 * @var string
53 public $ClickUrl;
55 /**
56 * Result fields
58 * @var array
60 protected $_fields;
62 /**
63 * REST response fragment for the result
65 * @var DOMElement
67 protected $_result;
69 /**
70 * Object for XPath queries
72 * @var DOMXPath
74 protected $_xpath;
77 /**
78 * Initializes the result
80 * @param DOMElement $result
81 * @return void
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
111 * @return void
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);
122 } else {
123 $this->Thumbnail = null;