[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Service 17 * @subpackage Technorati 18 * @copyright Copyright (c) 2005-2010 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 24 /** 25 * @see Zend_Service_Technorati_ResultSet 26 */ 27 require_once 'Zend/Service/Technorati/ResultSet.php'; 28 29 30 /** 31 * Represents a Technorati Cosmos query result set. 32 * 33 * @category Zend 34 * @package Zend_Service 35 * @subpackage Technorati 36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 37 * @license http://framework.zend.com/license/new-bsd New BSD License 38 */ 39 class Zend_Service_Technorati_CosmosResultSet extends Zend_Service_Technorati_ResultSet 40 { 41 /** 42 * Technorati weblog url, if queried URL is a valid weblog. 43 * 44 * @var Zend_Uri_Http 45 * @access protected 46 */ 47 protected $_url; 48 49 /** 50 * Technorati weblog, if queried URL is a valid weblog. 51 * 52 * @var Zend_Service_Technorati_Weblog 53 * @access protected 54 */ 55 protected $_weblog; 56 57 /** 58 * Number of unique blogs linking this blog 59 * 60 * @var integer 61 * @access protected 62 */ 63 protected $_inboundBlogs; 64 65 /** 66 * Number of incoming links to this blog 67 * 68 * @var integer 69 * @access protected 70 */ 71 protected $_inboundLinks; 72 73 /** 74 * Parses the search response and retrieve the results for iteration. 75 * 76 * @param DomDocument $dom the ReST fragment for this object 77 * @param array $options query options as associative array 78 */ 79 public function __construct(DomDocument $dom, $options = array()) 80 { 81 parent::__construct($dom, $options); 82 83 $result = $this->_xpath->query('/tapi/document/result/inboundlinks/text()'); 84 if ($result->length == 1) $this->_inboundLinks = (int) $result->item(0)->data; 85 86 $result = $this->_xpath->query('/tapi/document/result/inboundblogs/text()'); 87 if ($result->length == 1) $this->_inboundBlogs = (int) $result->item(0)->data; 88 89 $result = $this->_xpath->query('/tapi/document/result/weblog'); 90 if ($result->length == 1) { 91 /** 92 * @see Zend_Service_Technorati_Weblog 93 */ 94 require_once 'Zend/Service/Technorati/Weblog.php'; 95 $this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0)); 96 } 97 98 $result = $this->_xpath->query('/tapi/document/result/url/text()'); 99 if ($result->length == 1) { 100 try { 101 // fetched URL often doens't include schema 102 // and this issue causes the following line to fail 103 $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data); 104 } catch(Zend_Service_Technorati_Exception $e) { 105 if ($this->getWeblog() instanceof Zend_Service_Technorati_Weblog) { 106 $this->_url = $this->getWeblog()->getUrl(); 107 } 108 } 109 } 110 111 $this->_totalResultsReturned = (int) $this->_xpath->evaluate("count(/tapi/document/item)"); 112 113 // total number of results depends on query type 114 // for now check only getInboundLinks() and getInboundBlogs() value 115 if ((int) $this->getInboundLinks() > 0) { 116 $this->_totalResultsAvailable = $this->getInboundLinks(); 117 } elseif ((int) $this->getInboundBlogs() > 0) { 118 $this->_totalResultsAvailable = $this->getInboundBlogs(); 119 } else { 120 $this->_totalResultsAvailable = 0; 121 } 122 } 123 124 125 /** 126 * Returns the weblog URL. 127 * 128 * @return Zend_Uri_Http 129 */ 130 public function getUrl() { 131 return $this->_url; 132 } 133 134 /** 135 * Returns the weblog. 136 * 137 * @return Zend_Service_Technorati_Weblog 138 */ 139 public function getWeblog() { 140 return $this->_weblog; 141 } 142 143 /** 144 * Returns number of unique blogs linking this blog. 145 * 146 * @return integer the number of inbound blogs 147 */ 148 public function getInboundBlogs() 149 { 150 return $this->_inboundBlogs; 151 } 152 153 /** 154 * Returns number of incoming links to this blog. 155 * 156 * @return integer the number of inbound links 157 */ 158 public function getInboundLinks() 159 { 160 return $this->_inboundLinks; 161 } 162 163 /** 164 * Implements Zend_Service_Technorati_ResultSet::current(). 165 * 166 * @return Zend_Service_Technorati_CosmosResult current result 167 */ 168 public function current() 169 { 170 /** 171 * @see Zend_Service_Technorati_CosmosResult 172 */ 173 require_once 'Zend/Service/Technorati/CosmosResult.php'; 174 return new Zend_Service_Technorati_CosmosResult($this->_results->item($this->_currentIndex)); 175 } 176 }
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 |