*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Service / Technorati / Weblog.php
blobc0a5e88cb1b119150d3287f2ef8d79b363626f3a
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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 $
24 /**
25 * @see Zend_Service_Technorati_Author
27 require_once 'Zend/Service/Technorati/Author.php';
29 /**
30 * @see Zend_Service_Technorati_Utils
32 require_once 'Zend/Service/Technorati/Utils.php';
35 /**
36 * Represents a Weblog object successful recognized by Technorati.
38 * @category Zend
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
46 /**
47 * Blog name as written in the feed.
49 * @var string
50 * @access protected
52 protected $_name;
54 /**
55 * Base blog URL.
57 * @var Zend_Uri_Http
58 * @access protected
60 protected $_url;
62 /**
63 * RSS feed URL, if any.
65 * @var null|Zend_Uri_Http
66 * @access protected
68 protected $_rssUrl;
70 /**
71 * Atom feed URL, if any.
73 * @var null|Zend_Uri_Http
74 * @access protected
76 protected $_atomUrl;
78 /**
79 * Number of unique blogs linking this blog.
81 * @var integer
82 * @access protected
84 protected $_inboundBlogs;
86 /**
87 * Number of incoming links to this blog.
89 * @var integer
90 * @access protected
92 protected $_inboundLinks;
94 /**
95 * Last blog update UNIX timestamp.
97 * @var null|Zend_Date
98 * @access protected
100 protected $_lastUpdate;
103 * Technorati rank value for this weblog.
105 * Note. This property has no official documentation.
107 * @var integer
108 * @access protected
110 protected $_rank;
113 * Blog latitude coordinate.
115 * Note. This property has no official documentation.
117 * @var float
118 * @access protected
120 protected $_lat;
123 * Blog longitude coordinate.
125 * Note. This property has no official documentation.
127 * @var float
128 * @access protected
130 protected $_lon;
133 * Whether the author who claimed this weblog has a photo.
135 * Note. This property has no official documentation.
137 * @var bool
138 * @access protected
139 * @see Zend_Service_Technorati_Author::$thumbnailPicture
141 protected $_hasPhoto = false;
144 * An array of Zend_Service_Technorati_Author who claimed this blog
146 * @var array
147 * @access protected
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()
219 return $this->_name;
223 * Returns weblog URL.
225 * @return null|Zend_Uri_Http object representing weblog base URL
227 public function getUrl()
229 return $this->_url;
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()
293 return $this->_rank;
297 * Returns weblog latitude coordinate.
299 * Note. This property is not documented.
301 * @return float weblog latitude coordinate
303 public function getLat() {
304 return $this->_lat;
308 * Returns weblog longitude coordinate.
310 * Note. This property is not documented.
312 * @return float weblog longitude coordinate
314 public function getLon()
316 return $this->_lon;
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,
325 * FALSE otherwise.
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;
344 * Sets weblog name.
346 * @param string $name
347 * @return Zend_Service_Technorati_Weblog $this instance
349 public function setName($name)
351 $this->_name = (string) $name;
352 return $this;
356 * Sets weblog URL.
358 * @param string|Zend_Uri_Http $url
359 * @return void
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);
366 return $this;
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;
378 return $this;
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;
390 return $this;
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);
404 return $this;
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);
418 return $this;
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);
435 return $this;
439 * Sets weblog Rank.
441 * @param integer $rank
442 * @return Zend_Service_Technorati_Weblog $this instance
444 public function setRank($rank)
446 $this->_rank = (int) $rank;
447 return $this;
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;
459 return $this;
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;
471 return $this;
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;
483 return $this;