|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00027 require_once 'Zend/Service/Technorati/ResultSet.php'; 00028 00029 00039 class Zend_Service_Technorati_CosmosResultSet extends Zend_Service_Technorati_ResultSet 00040 { 00047 protected $_url; 00048 00055 protected $_weblog; 00056 00063 protected $_inboundBlogs; 00064 00071 protected $_inboundLinks; 00072 00079 public function __construct(DomDocument $dom, $options = array()) 00080 { 00081 parent::__construct($dom, $options); 00082 00083 $result = $this->_xpath->query('/tapi/document/result/inboundlinks/text()'); 00084 if ($result->length == 1) $this->_inboundLinks = (int) $result->item(0)->data; 00085 00086 $result = $this->_xpath->query('/tapi/document/result/inboundblogs/text()'); 00087 if ($result->length == 1) $this->_inboundBlogs = (int) $result->item(0)->data; 00088 00089 $result = $this->_xpath->query('/tapi/document/result/weblog'); 00090 if ($result->length == 1) { 00094 require_once 'Zend/Service/Technorati/Weblog.php'; 00095 $this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0)); 00096 } 00097 00098 $result = $this->_xpath->query('/tapi/document/result/url/text()'); 00099 if ($result->length == 1) { 00100 try { 00101 // fetched URL often doens't include schema 00102 // and this issue causes the following line to fail 00103 $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data); 00104 } catch(Zend_Service_Technorati_Exception $e) { 00105 if ($this->getWeblog() instanceof Zend_Service_Technorati_Weblog) { 00106 $this->_url = $this->getWeblog()->getUrl(); 00107 } 00108 } 00109 } 00110 00111 $this->_totalResultsReturned = (int) $this->_xpath->evaluate("count(/tapi/document/item)"); 00112 00113 // total number of results depends on query type 00114 // for now check only getInboundLinks() and getInboundBlogs() value 00115 if ((int) $this->getInboundLinks() > 0) { 00116 $this->_totalResultsAvailable = $this->getInboundLinks(); 00117 } elseif ((int) $this->getInboundBlogs() > 0) { 00118 $this->_totalResultsAvailable = $this->getInboundBlogs(); 00119 } else { 00120 $this->_totalResultsAvailable = 0; 00121 } 00122 } 00123 00124 00130 public function getUrl() { 00131 return $this->_url; 00132 } 00133 00139 public function getWeblog() { 00140 return $this->_weblog; 00141 } 00142 00148 public function getInboundBlogs() 00149 { 00150 return $this->_inboundBlogs; 00151 } 00152 00158 public function getInboundLinks() 00159 { 00160 return $this->_inboundLinks; 00161 } 00162 00168 public function current() 00169 { 00173 require_once 'Zend/Service/Technorati/CosmosResult.php'; 00174 return new Zend_Service_Technorati_CosmosResult($this->_results->item($this->_currentIndex)); 00175 } 00176 }