|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00027 require_once 'Zend/Service/Technorati/Utils.php'; 00028 00029 00039 class Zend_Service_Technorati_BlogInfoResult 00040 { 00047 protected $_url; 00048 00055 protected $_weblog; 00056 00063 protected $_inboundBlogs; 00064 00071 protected $_inboundLinks; 00072 00073 00079 public function __construct(DomDocument $dom) 00080 { 00081 $xpath = new DOMXPath($dom); 00085 require_once 'Zend/Service/Technorati/Weblog.php'; 00086 00087 $result = $xpath->query('//result/weblog'); 00088 if ($result->length == 1) { 00089 $this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0)); 00090 } else { 00091 // follow the same behavior of blogPostTags 00092 // and raise an Exception if the URL is not a valid weblog 00096 require_once 'Zend/Service/Technorati/Exception.php'; 00097 throw new Zend_Service_Technorati_Exception( 00098 "Your URL is not a recognized Technorati weblog"); 00099 } 00100 00101 $result = $xpath->query('//result/url/text()'); 00102 if ($result->length == 1) { 00103 try { 00104 // fetched URL often doens't include schema 00105 // and this issue causes the following line to fail 00106 $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data); 00107 } catch(Zend_Service_Technorati_Exception $e) { 00108 if ($this->getWeblog() instanceof Zend_Service_Technorati_Weblog) { 00109 $this->_url = $this->getWeblog()->getUrl(); 00110 } 00111 } 00112 } 00113 00114 $result = $xpath->query('//result/inboundblogs/text()'); 00115 if ($result->length == 1) $this->_inboundBlogs = (int) $result->item(0)->data; 00116 00117 $result = $xpath->query('//result/inboundlinks/text()'); 00118 if ($result->length == 1) $this->_inboundLinks = (int) $result->item(0)->data; 00119 00120 } 00121 00122 00128 public function getUrl() { 00129 return $this->_url; 00130 } 00131 00137 public function getWeblog() { 00138 return $this->_weblog; 00139 } 00140 00146 public function getInboundBlogs() 00147 { 00148 return (int) $this->_inboundBlogs; 00149 } 00150 00156 public function getInboundLinks() 00157 { 00158 return (int) $this->_inboundLinks; 00159 } 00160 00161 }