| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Service
- * @subpackage Technorati
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Service_Technorati_Author
- */
- require_once 'Zend/Service/Technorati/Author.php';
- /**
- * @see Zend_Service_Technorati_Utils
- */
- require_once 'Zend/Service/Technorati/Utils.php';
- /**
- * Represents a Weblog object successful recognized by Technorati.
- *
- * @category Zend
- * @package Zend_Service
- * @subpackage Technorati
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Service_Technorati_Weblog
- {
- /**
- * Blog name as written in the feed.
- *
- * @var string
- * @access protected
- */
- protected $_name;
- /**
- * Base blog URL.
- *
- * @var Zend_Uri_Http
- * @access protected
- */
- protected $_url;
- /**
- * RSS feed URL, if any.
- *
- * @var null|Zend_Uri_Http
- * @access protected
- */
- protected $_rssUrl;
- /**
- * Atom feed URL, if any.
- *
- * @var null|Zend_Uri_Http
- * @access protected
- */
- protected $_atomUrl;
- /**
- * Number of unique blogs linking this blog.
- *
- * @var integer
- * @access protected
- */
- protected $_inboundBlogs;
- /**
- * Number of incoming links to this blog.
- *
- * @var integer
- * @access protected
- */
- protected $_inboundLinks;
- /**
- * Last blog update UNIX timestamp.
- *
- * @var null|Zend_Date
- * @access protected
- */
- protected $_lastUpdate;
- /**
- * Technorati rank value for this weblog.
- *
- * Note. This property has no official documentation.
- *
- * @var integer
- * @access protected
- */
- protected $_rank;
- /**
- * Blog latitude coordinate.
- *
- * Note. This property has no official documentation.
- *
- * @var float
- * @access protected
- */
- protected $_lat;
- /**
- * Blog longitude coordinate.
- *
- * Note. This property has no official documentation.
- *
- * @var float
- * @access protected
- */
- protected $_lon;
- /**
- * Whether the author who claimed this weblog has a photo.
- *
- * Note. This property has no official documentation.
- *
- * @var bool
- * @access protected
- * @see Zend_Service_Technorati_Author::$thumbnailPicture
- */
- protected $_hasPhoto = false;
- /**
- * An array of Zend_Service_Technorati_Author who claimed this blog
- *
- * @var array
- * @access protected
- */
- protected $_authors = array();
- /**
- * Constructs a new object from DOM Element.
- *
- * @param DomElement $dom the ReST fragment for this object
- */
- public function __construct(DomElement $dom)
- {
- $xpath = new DOMXPath($dom->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;
- }
- }
|