diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Service/Technorati/CosmosResultSet.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Service/Technorati/CosmosResultSet.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,176 @@ +_xpath->query('/tapi/document/result/inboundlinks/text()'); + if ($result->length == 1) $this->_inboundLinks = (int) $result->item(0)->data; + + $result = $this->_xpath->query('/tapi/document/result/inboundblogs/text()'); + if ($result->length == 1) $this->_inboundBlogs = (int) $result->item(0)->data; + + $result = $this->_xpath->query('/tapi/document/result/weblog'); + if ($result->length == 1) { + /** + * @see Zend_Service_Technorati_Weblog + */ + require_once 'Zend/Service/Technorati/Weblog.php'; + $this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0)); + } + + $result = $this->_xpath->query('/tapi/document/result/url/text()'); + if ($result->length == 1) { + try { + // fetched URL often doens't include schema + // and this issue causes the following line to fail + $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data); + } catch(Zend_Service_Technorati_Exception $e) { + if ($this->getWeblog() instanceof Zend_Service_Technorati_Weblog) { + $this->_url = $this->getWeblog()->getUrl(); + } + } + } + + $this->_totalResultsReturned = (int) $this->_xpath->evaluate("count(/tapi/document/item)"); + + // total number of results depends on query type + // for now check only getInboundLinks() and getInboundBlogs() value + if ((int) $this->getInboundLinks() > 0) { + $this->_totalResultsAvailable = $this->getInboundLinks(); + } elseif ((int) $this->getInboundBlogs() > 0) { + $this->_totalResultsAvailable = $this->getInboundBlogs(); + } else { + $this->_totalResultsAvailable = 0; + } + } + + + /** + * Returns the weblog URL. + * + * @return Zend_Uri_Http + */ + public function getUrl() { + return $this->_url; + } + + /** + * Returns the weblog. + * + * @return Zend_Service_Technorati_Weblog + */ + public function getWeblog() { + return $this->_weblog; + } + + /** + * Returns number of unique blogs linking this blog. + * + * @return integer the number of inbound blogs + */ + public function getInboundBlogs() + { + return $this->_inboundBlogs; + } + + /** + * Returns number of incoming links to this blog. + * + * @return integer the number of inbound links + */ + public function getInboundLinks() + { + return $this->_inboundLinks; + } + + /** + * Implements Zend_Service_Technorati_ResultSet::current(). + * + * @return Zend_Service_Technorati_CosmosResult current result + */ + public function current() + { + /** + * @see Zend_Service_Technorati_CosmosResult + */ + require_once 'Zend/Service/Technorati/CosmosResult.php'; + return new Zend_Service_Technorati_CosmosResult($this->_results->item($this->_currentIndex)); + } +}