diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Service/Technorati/Weblog.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Service/Technorati/Weblog.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,486 @@ +ownerDocument); + + $result = $xpath->query('./name/text()', $dom); + if ($result->length == 1) $this->setName($result->item(0)->data); + + $result = $xpath->query('./url/text()', $dom); + if ($result->length == 1) $this->setUrl($result->item(0)->data); + + $result = $xpath->query('./inboundblogs/text()', $dom); + if ($result->length == 1) $this->setInboundBlogs($result->item(0)->data); + + $result = $xpath->query('./inboundlinks/text()', $dom); + if ($result->length == 1) $this->setInboundLinks($result->item(0)->data); + + $result = $xpath->query('./lastupdate/text()', $dom); + if ($result->length == 1) $this->setLastUpdate($result->item(0)->data); + + /* The following elements need more attention */ + + $result = $xpath->query('./rssurl/text()', $dom); + if ($result->length == 1) $this->setRssUrl($result->item(0)->data); + + $result = $xpath->query('./atomurl/text()', $dom); + if ($result->length == 1) $this->setAtomUrl($result->item(0)->data); + + $result = $xpath->query('./author', $dom); + if ($result->length >= 1) { + foreach ($result as $author) { + $this->_authors[] = new Zend_Service_Technorati_Author($author); + } + } + + /** + * The following are optional elements + * + * I can't find any official documentation about the following properties + * however they are included in response DTD and/or test responses. + */ + + $result = $xpath->query('./rank/text()', $dom); + if ($result->length == 1) $this->setRank($result->item(0)->data); + + $result = $xpath->query('./lat/text()', $dom); + if ($result->length == 1) $this->setLat($result->item(0)->data); + + $result = $xpath->query('./lon/text()', $dom); + if ($result->length == 1) $this->setLon($result->item(0)->data); + + $result = $xpath->query('./hasphoto/text()', $dom); + if ($result->length == 1) $this->setHasPhoto($result->item(0)->data); + } + + + /** + * Returns weblog name. + * + * @return string Weblog name + */ + public function getName() + { + return $this->_name; + } + + /** + * Returns weblog URL. + * + * @return null|Zend_Uri_Http object representing weblog base URL + */ + public function getUrl() + { + return $this->_url; + } + + /** + * 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; + } + + /** + * Returns weblog Rss URL. + * + * @return null|Zend_Uri_Http object representing the URL + * of the RSS feed for given blog + */ + public function getRssUrl() + { + return $this->_rssUrl; + } + + /** + * Returns weblog Atom URL. + * + * @return null|Zend_Uri_Http object representing the URL + * of the Atom feed for given blog + */ + public function getAtomUrl() + { + return $this->_atomUrl; + } + + /** + * Returns UNIX timestamp of the last weblog update. + * + * @return integer UNIX timestamp of the last weblog update + */ + public function getLastUpdate() + { + return $this->_lastUpdate; + } + + /** + * Returns weblog rank value. + * + * Note. This property is not documented. + * + * @return integer weblog rank value + */ + public function getRank() + { + return $this->_rank; + } + + /** + * Returns weblog latitude coordinate. + * + * Note. This property is not documented. + * + * @return float weblog latitude coordinate + */ + public function getLat() { + return $this->_lat; + } + + /** + * Returns weblog longitude coordinate. + * + * Note. This property is not documented. + * + * @return float weblog longitude coordinate + */ + public function getLon() + { + return $this->_lon; + } + + /** + * Returns whether the author who claimed this weblog has a photo. + * + * Note. This property is not documented. + * + * @return bool TRUE if the author who claimed this weblog has a photo, + * FALSE otherwise. + */ + public function hasPhoto() + { + return (bool) $this->_hasPhoto; + } + + /** + * Returns the array of weblog authors. + * + * @return array of Zend_Service_Technorati_Author authors + */ + public function getAuthors() + { + return (array) $this->_authors; + } + + + /** + * Sets weblog name. + * + * @param string $name + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setName($name) + { + $this->_name = (string) $name; + return $this; + } + + /** + * Sets weblog URL. + * + * @param string|Zend_Uri_Http $url + * @return void + * @throws Zend_Service_Technorati_Exception if $input is an invalid URI + * (via Zend_Service_Technorati_Utils::normalizeUriHttp) + */ + public function setUrl($url) + { + $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($url); + return $this; + } + + /** + * Sets number of inbound blogs. + * + * @param integer $number + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setInboundBlogs($number) + { + $this->_inboundBlogs = (int) $number; + return $this; + } + + /** + * Sets number of Iinbound links. + * + * @param integer $number + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setInboundLinks($number) + { + $this->_inboundLinks = (int) $number; + return $this; + } + + /** + * Sets weblog Rss URL. + * + * @param string|Zend_Uri_Http $url + * @return Zend_Service_Technorati_Weblog $this instance + * @throws Zend_Service_Technorati_Exception if $input is an invalid URI + * (via Zend_Service_Technorati_Utils::normalizeUriHttp) + */ + public function setRssUrl($url) + { + $this->_rssUrl = Zend_Service_Technorati_Utils::normalizeUriHttp($url); + return $this; + } + + /** + * Sets weblog Atom URL. + * + * @param string|Zend_Uri_Http $url + * @return Zend_Service_Technorati_Weblog $this instance + * @throws Zend_Service_Technorati_Exception if $input is an invalid URI + * (via Zend_Service_Technorati_Utils::normalizeUriHttp) + */ + public function setAtomUrl($url) + { + $this->_atomUrl = Zend_Service_Technorati_Utils::normalizeUriHttp($url); + return $this; + } + + /** + * Sets weblog Last Update timestamp. + * + * $datetime can be any value supported by + * Zend_Service_Technorati_Utils::normalizeDate(). + * + * @param mixed $datetime A string representing the last update date time + * in a valid date time format + * @return Zend_Service_Technorati_Weblog $this instance + * @throws Zend_Service_Technorati_Exception + */ + public function setLastUpdate($datetime) + { + $this->_lastUpdate = Zend_Service_Technorati_Utils::normalizeDate($datetime); + return $this; + } + + /** + * Sets weblog Rank. + * + * @param integer $rank + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setRank($rank) + { + $this->_rank = (int) $rank; + return $this; + } + + /** + * Sets weblog latitude coordinate. + * + * @param float $coordinate + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setLat($coordinate) + { + $this->_lat = (float) $coordinate; + return $this; + } + + /** + * Sets weblog longitude coordinate. + * + * @param float $coordinate + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setLon($coordinate) + { + $this->_lon = (float) $coordinate; + return $this; + } + + /** + * Sets hasPhoto property. + * + * @param bool $hasPhoto + * @return Zend_Service_Technorati_Weblog $this instance + */ + public function setHasPhoto($hasPhoto) + { + $this->_hasPhoto = (bool) $hasPhoto; + return $this; + } + +}