[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Zend Framework 5 * 6 * LICENSE 7 * 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 [email protected] so we can send you a copy immediately. 15 * 16 * @category Zend 17 * @package Zend_Service 18 * @subpackage Yahoo 19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 20 * @license http://framework.zend.com/license/new-bsd New BSD License 21 * @version $Id$ 22 */ 23 24 25 /** 26 * @category Zend 27 * @package Zend_Service 28 * @subpackage Yahoo 29 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 30 * @license http://framework.zend.com/license/new-bsd New BSD License 31 */ 32 class Zend_Service_Yahoo_Result 33 { 34 /** 35 * The title of the search entry 36 * 37 * @var string 38 */ 39 public $Title; 40 41 /** 42 * The URL of the found object 43 * 44 * @var string 45 */ 46 public $Url; 47 48 /** 49 * The URL for linking to the found object 50 * 51 * @var string 52 */ 53 public $ClickUrl; 54 55 /** 56 * Result fields 57 * 58 * @var array 59 */ 60 protected $_fields; 61 62 /** 63 * REST response fragment for the result 64 * 65 * @var DOMElement 66 */ 67 protected $_result; 68 69 /** 70 * Object for XPath queries 71 * 72 * @var DOMXPath 73 */ 74 protected $_xpath; 75 76 77 /** 78 * Initializes the result 79 * 80 * @param DOMElement $result 81 * @return void 82 */ 83 public function __construct(DOMElement $result) 84 { 85 // default fields for all search results: 86 $fields = array('Title', 'Url', 'ClickUrl'); 87 88 // merge w/ child's fields 89 $this->_fields = array_merge($this->_fields, $fields); 90 91 $this->_xpath = new DOMXPath($result->ownerDocument); 92 $this->_xpath->registerNamespace('yh', $this->_namespace); 93 94 // add search results to appropriate fields 95 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; 101 } 102 } 103 104 $this->_result = $result; 105 } 106 107 108 /** 109 * Sets the Thumbnail property 110 * 111 * @return void 112 */ 113 protected function _setThumbnail() 114 { 115 $node = $this->_xpath->query('./yh:Thumbnail', $this->_result); 116 if ($node->length == 1) { 117 /** 118 * @see Zend_Service_Yahoo_Image 119 */ 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; 124 } 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |