7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Service
17 * @subpackage Technorati
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Weblog.php 16211 2009-06-21 19:23:55Z thomas $
25 * @see Zend_Service_Technorati_Author
27 require_once 'Zend/Service/Technorati/Author.php';
30 * @see Zend_Service_Technorati_Utils
32 require_once 'Zend/Service/Technorati/Utils.php';
36 * Represents a Weblog object successful recognized by Technorati.
39 * @package Zend_Service
40 * @subpackage Technorati
41 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
44 class Zend_Service_Technorati_Weblog
47 * Blog name as written in the feed.
63 * RSS feed URL, if any.
65 * @var null|Zend_Uri_Http
71 * Atom feed URL, if any.
73 * @var null|Zend_Uri_Http
79 * Number of unique blogs linking this blog.
84 protected $_inboundBlogs;
87 * Number of incoming links to this blog.
92 protected $_inboundLinks;
95 * Last blog update UNIX timestamp.
100 protected $_lastUpdate;
103 * Technorati rank value for this weblog.
105 * Note. This property has no official documentation.
113 * Blog latitude coordinate.
115 * Note. This property has no official documentation.
123 * Blog longitude coordinate.
125 * Note. This property has no official documentation.
133 * Whether the author who claimed this weblog has a photo.
135 * Note. This property has no official documentation.
139 * @see Zend_Service_Technorati_Author::$thumbnailPicture
141 protected $_hasPhoto = false;
144 * An array of Zend_Service_Technorati_Author who claimed this blog
149 protected $_authors = array();
153 * Constructs a new object from DOM Element.
155 * @param DomElement $dom the ReST fragment for this object
157 public function __construct(DomElement
$dom)
159 $xpath = new DOMXPath($dom->ownerDocument
);
161 $result = $xpath->query('./name/text()', $dom);
162 if ($result->length
== 1) $this->setName($result->item(0)->data
);
164 $result = $xpath->query('./url/text()', $dom);
165 if ($result->length
== 1) $this->setUrl($result->item(0)->data
);
167 $result = $xpath->query('./inboundblogs/text()', $dom);
168 if ($result->length
== 1) $this->setInboundBlogs($result->item(0)->data
);
170 $result = $xpath->query('./inboundlinks/text()', $dom);
171 if ($result->length
== 1) $this->setInboundLinks($result->item(0)->data
);
173 $result = $xpath->query('./lastupdate/text()', $dom);
174 if ($result->length
== 1) $this->setLastUpdate($result->item(0)->data
);
176 /* The following elements need more attention */
178 $result = $xpath->query('./rssurl/text()', $dom);
179 if ($result->length
== 1) $this->setRssUrl($result->item(0)->data
);
181 $result = $xpath->query('./atomurl/text()', $dom);
182 if ($result->length
== 1) $this->setAtomUrl($result->item(0)->data
);
184 $result = $xpath->query('./author', $dom);
185 if ($result->length
>= 1) {
186 foreach ($result as $author) {
187 $this->_authors
[] = new Zend_Service_Technorati_Author($author);
192 * The following are optional elements
194 * I can't find any official documentation about the following properties
195 * however they are included in response DTD and/or test responses.
198 $result = $xpath->query('./rank/text()', $dom);
199 if ($result->length
== 1) $this->setRank($result->item(0)->data
);
201 $result = $xpath->query('./lat/text()', $dom);
202 if ($result->length
== 1) $this->setLat($result->item(0)->data
);
204 $result = $xpath->query('./lon/text()', $dom);
205 if ($result->length
== 1) $this->setLon($result->item(0)->data
);
207 $result = $xpath->query('./hasphoto/text()', $dom);
208 if ($result->length
== 1) $this->setHasPhoto($result->item(0)->data
);
213 * Returns weblog name.
215 * @return string Weblog name
217 public function getName()
223 * Returns weblog URL.
225 * @return null|Zend_Uri_Http object representing weblog base URL
227 public function getUrl()
233 * Returns number of unique blogs linking this blog.
235 * @return integer the number of inbound blogs
237 public function getInboundBlogs()
239 return $this->_inboundBlogs
;
243 * Returns number of incoming links to this blog.
245 * @return integer the number of inbound links
247 public function getInboundLinks()
249 return $this->_inboundLinks
;
253 * Returns weblog Rss URL.
255 * @return null|Zend_Uri_Http object representing the URL
256 * of the RSS feed for given blog
258 public function getRssUrl()
260 return $this->_rssUrl
;
264 * Returns weblog Atom URL.
266 * @return null|Zend_Uri_Http object representing the URL
267 * of the Atom feed for given blog
269 public function getAtomUrl()
271 return $this->_atomUrl
;
275 * Returns UNIX timestamp of the last weblog update.
277 * @return integer UNIX timestamp of the last weblog update
279 public function getLastUpdate()
281 return $this->_lastUpdate
;
285 * Returns weblog rank value.
287 * Note. This property is not documented.
289 * @return integer weblog rank value
291 public function getRank()
297 * Returns weblog latitude coordinate.
299 * Note. This property is not documented.
301 * @return float weblog latitude coordinate
303 public function getLat() {
308 * Returns weblog longitude coordinate.
310 * Note. This property is not documented.
312 * @return float weblog longitude coordinate
314 public function getLon()
320 * Returns whether the author who claimed this weblog has a photo.
322 * Note. This property is not documented.
324 * @return bool TRUE if the author who claimed this weblog has a photo,
327 public function hasPhoto()
329 return (bool) $this->_hasPhoto
;
333 * Returns the array of weblog authors.
335 * @return array of Zend_Service_Technorati_Author authors
337 public function getAuthors()
339 return (array) $this->_authors
;
346 * @param string $name
347 * @return Zend_Service_Technorati_Weblog $this instance
349 public function setName($name)
351 $this->_name
= (string) $name;
358 * @param string|Zend_Uri_Http $url
360 * @throws Zend_Service_Technorati_Exception if $input is an invalid URI
361 * (via Zend_Service_Technorati_Utils::normalizeUriHttp)
363 public function setUrl($url)
365 $this->_url
= Zend_Service_Technorati_Utils
::normalizeUriHttp($url);
370 * Sets number of inbound blogs.
372 * @param integer $number
373 * @return Zend_Service_Technorati_Weblog $this instance
375 public function setInboundBlogs($number)
377 $this->_inboundBlogs
= (int) $number;
382 * Sets number of Iinbound links.
384 * @param integer $number
385 * @return Zend_Service_Technorati_Weblog $this instance
387 public function setInboundLinks($number)
389 $this->_inboundLinks
= (int) $number;
394 * Sets weblog Rss URL.
396 * @param string|Zend_Uri_Http $url
397 * @return Zend_Service_Technorati_Weblog $this instance
398 * @throws Zend_Service_Technorati_Exception if $input is an invalid URI
399 * (via Zend_Service_Technorati_Utils::normalizeUriHttp)
401 public function setRssUrl($url)
403 $this->_rssUrl
= Zend_Service_Technorati_Utils
::normalizeUriHttp($url);
408 * Sets weblog Atom URL.
410 * @param string|Zend_Uri_Http $url
411 * @return Zend_Service_Technorati_Weblog $this instance
412 * @throws Zend_Service_Technorati_Exception if $input is an invalid URI
413 * (via Zend_Service_Technorati_Utils::normalizeUriHttp)
415 public function setAtomUrl($url)
417 $this->_atomUrl
= Zend_Service_Technorati_Utils
::normalizeUriHttp($url);
422 * Sets weblog Last Update timestamp.
424 * $datetime can be any value supported by
425 * Zend_Service_Technorati_Utils::normalizeDate().
427 * @param mixed $datetime A string representing the last update date time
428 * in a valid date time format
429 * @return Zend_Service_Technorati_Weblog $this instance
430 * @throws Zend_Service_Technorati_Exception
432 public function setLastUpdate($datetime)
434 $this->_lastUpdate
= Zend_Service_Technorati_Utils
::normalizeDate($datetime);
441 * @param integer $rank
442 * @return Zend_Service_Technorati_Weblog $this instance
444 public function setRank($rank)
446 $this->_rank
= (int) $rank;
451 * Sets weblog latitude coordinate.
453 * @param float $coordinate
454 * @return Zend_Service_Technorati_Weblog $this instance
456 public function setLat($coordinate)
458 $this->_lat
= (float) $coordinate;
463 * Sets weblog longitude coordinate.
465 * @param float $coordinate
466 * @return Zend_Service_Technorati_Weblog $this instance
468 public function setLon($coordinate)
470 $this->_lon
= (float) $coordinate;
475 * Sets hasPhoto property.
477 * @param bool $hasPhoto
478 * @return Zend_Service_Technorati_Weblog $this instance
480 public function setHasPhoto($hasPhoto)
482 $this->_hasPhoto
= (bool) $hasPhoto;