[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 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 [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Service 17 * @subpackage Technorati 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 21 */ 22 23 24 /** 25 * @see Zend_Service_Technorati_Author 26 */ 27 require_once 'Zend/Service/Technorati/Author.php'; 28 29 /** 30 * @see Zend_Service_Technorati_Utils 31 */ 32 require_once 'Zend/Service/Technorati/Utils.php'; 33 34 35 /** 36 * Represents a Weblog object successful recognized by Technorati. 37 * 38 * @category Zend 39 * @package Zend_Service 40 * @subpackage Technorati 41 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 42 * @license http://framework.zend.com/license/new-bsd New BSD License 43 */ 44 class Zend_Service_Technorati_Weblog 45 { 46 /** 47 * Blog name as written in the feed. 48 * 49 * @var string 50 * @access protected 51 */ 52 protected $_name; 53 54 /** 55 * Base blog URL. 56 * 57 * @var Zend_Uri_Http 58 * @access protected 59 */ 60 protected $_url; 61 62 /** 63 * RSS feed URL, if any. 64 * 65 * @var null|Zend_Uri_Http 66 * @access protected 67 */ 68 protected $_rssUrl; 69 70 /** 71 * Atom feed URL, if any. 72 * 73 * @var null|Zend_Uri_Http 74 * @access protected 75 */ 76 protected $_atomUrl; 77 78 /** 79 * Number of unique blogs linking this blog. 80 * 81 * @var integer 82 * @access protected 83 */ 84 protected $_inboundBlogs; 85 86 /** 87 * Number of incoming links to this blog. 88 * 89 * @var integer 90 * @access protected 91 */ 92 protected $_inboundLinks; 93 94 /** 95 * Last blog update UNIX timestamp. 96 * 97 * @var null|Zend_Date 98 * @access protected 99 */ 100 protected $_lastUpdate; 101 102 /** 103 * Technorati rank value for this weblog. 104 * 105 * Note. This property has no official documentation. 106 * 107 * @var integer 108 * @access protected 109 */ 110 protected $_rank; 111 112 /** 113 * Blog latitude coordinate. 114 * 115 * Note. This property has no official documentation. 116 * 117 * @var float 118 * @access protected 119 */ 120 protected $_lat; 121 122 /** 123 * Blog longitude coordinate. 124 * 125 * Note. This property has no official documentation. 126 * 127 * @var float 128 * @access protected 129 */ 130 protected $_lon; 131 132 /** 133 * Whether the author who claimed this weblog has a photo. 134 * 135 * Note. This property has no official documentation. 136 * 137 * @var bool 138 * @access protected 139 * @see Zend_Service_Technorati_Author::$thumbnailPicture 140 */ 141 protected $_hasPhoto = false; 142 143 /** 144 * An array of Zend_Service_Technorati_Author who claimed this blog 145 * 146 * @var array 147 * @access protected 148 */ 149 protected $_authors = array(); 150 151 152 /** 153 * Constructs a new object from DOM Element. 154 * 155 * @param DomElement $dom the ReST fragment for this object 156 */ 157 public function __construct(DomElement $dom) 158 { 159 $xpath = new DOMXPath($dom->ownerDocument); 160 161 $result = $xpath->query('./name/text()', $dom); 162 if ($result->length == 1) $this->setName($result->item(0)->data); 163 164 $result = $xpath->query('./url/text()', $dom); 165 if ($result->length == 1) $this->setUrl($result->item(0)->data); 166 167 $result = $xpath->query('./inboundblogs/text()', $dom); 168 if ($result->length == 1) $this->setInboundBlogs($result->item(0)->data); 169 170 $result = $xpath->query('./inboundlinks/text()', $dom); 171 if ($result->length == 1) $this->setInboundLinks($result->item(0)->data); 172 173 $result = $xpath->query('./lastupdate/text()', $dom); 174 if ($result->length == 1) $this->setLastUpdate($result->item(0)->data); 175 176 /* The following elements need more attention */ 177 178 $result = $xpath->query('./rssurl/text()', $dom); 179 if ($result->length == 1) $this->setRssUrl($result->item(0)->data); 180 181 $result = $xpath->query('./atomurl/text()', $dom); 182 if ($result->length == 1) $this->setAtomUrl($result->item(0)->data); 183 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); 188 } 189 } 190 191 /** 192 * The following are optional elements 193 * 194 * I can't find any official documentation about the following properties 195 * however they are included in response DTD and/or test responses. 196 */ 197 198 $result = $xpath->query('./rank/text()', $dom); 199 if ($result->length == 1) $this->setRank($result->item(0)->data); 200 201 $result = $xpath->query('./lat/text()', $dom); 202 if ($result->length == 1) $this->setLat($result->item(0)->data); 203 204 $result = $xpath->query('./lon/text()', $dom); 205 if ($result->length == 1) $this->setLon($result->item(0)->data); 206 207 $result = $xpath->query('./hasphoto/text()', $dom); 208 if ($result->length == 1) $this->setHasPhoto($result->item(0)->data); 209 } 210 211 212 /** 213 * Returns weblog name. 214 * 215 * @return string Weblog name 216 */ 217 public function getName() 218 { 219 return $this->_name; 220 } 221 222 /** 223 * Returns weblog URL. 224 * 225 * @return null|Zend_Uri_Http object representing weblog base URL 226 */ 227 public function getUrl() 228 { 229 return $this->_url; 230 } 231 232 /** 233 * Returns number of unique blogs linking this blog. 234 * 235 * @return integer the number of inbound blogs 236 */ 237 public function getInboundBlogs() 238 { 239 return $this->_inboundBlogs; 240 } 241 242 /** 243 * Returns number of incoming links to this blog. 244 * 245 * @return integer the number of inbound links 246 */ 247 public function getInboundLinks() 248 { 249 return $this->_inboundLinks; 250 } 251 252 /** 253 * Returns weblog Rss URL. 254 * 255 * @return null|Zend_Uri_Http object representing the URL 256 * of the RSS feed for given blog 257 */ 258 public function getRssUrl() 259 { 260 return $this->_rssUrl; 261 } 262 263 /** 264 * Returns weblog Atom URL. 265 * 266 * @return null|Zend_Uri_Http object representing the URL 267 * of the Atom feed for given blog 268 */ 269 public function getAtomUrl() 270 { 271 return $this->_atomUrl; 272 } 273 274 /** 275 * Returns UNIX timestamp of the last weblog update. 276 * 277 * @return integer UNIX timestamp of the last weblog update 278 */ 279 public function getLastUpdate() 280 { 281 return $this->_lastUpdate; 282 } 283 284 /** 285 * Returns weblog rank value. 286 * 287 * Note. This property is not documented. 288 * 289 * @return integer weblog rank value 290 */ 291 public function getRank() 292 { 293 return $this->_rank; 294 } 295 296 /** 297 * Returns weblog latitude coordinate. 298 * 299 * Note. This property is not documented. 300 * 301 * @return float weblog latitude coordinate 302 */ 303 public function getLat() { 304 return $this->_lat; 305 } 306 307 /** 308 * Returns weblog longitude coordinate. 309 * 310 * Note. This property is not documented. 311 * 312 * @return float weblog longitude coordinate 313 */ 314 public function getLon() 315 { 316 return $this->_lon; 317 } 318 319 /** 320 * Returns whether the author who claimed this weblog has a photo. 321 * 322 * Note. This property is not documented. 323 * 324 * @return bool TRUE if the author who claimed this weblog has a photo, 325 * FALSE otherwise. 326 */ 327 public function hasPhoto() 328 { 329 return (bool) $this->_hasPhoto; 330 } 331 332 /** 333 * Returns the array of weblog authors. 334 * 335 * @return array of Zend_Service_Technorati_Author authors 336 */ 337 public function getAuthors() 338 { 339 return (array) $this->_authors; 340 } 341 342 343 /** 344 * Sets weblog name. 345 * 346 * @param string $name 347 * @return Zend_Service_Technorati_Weblog $this instance 348 */ 349 public function setName($name) 350 { 351 $this->_name = (string) $name; 352 return $this; 353 } 354 355 /** 356 * Sets weblog URL. 357 * 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) 362 */ 363 public function setUrl($url) 364 { 365 $this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($url); 366 return $this; 367 } 368 369 /** 370 * Sets number of inbound blogs. 371 * 372 * @param integer $number 373 * @return Zend_Service_Technorati_Weblog $this instance 374 */ 375 public function setInboundBlogs($number) 376 { 377 $this->_inboundBlogs = (int) $number; 378 return $this; 379 } 380 381 /** 382 * Sets number of Iinbound links. 383 * 384 * @param integer $number 385 * @return Zend_Service_Technorati_Weblog $this instance 386 */ 387 public function setInboundLinks($number) 388 { 389 $this->_inboundLinks = (int) $number; 390 return $this; 391 } 392 393 /** 394 * Sets weblog Rss URL. 395 * 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) 400 */ 401 public function setRssUrl($url) 402 { 403 $this->_rssUrl = Zend_Service_Technorati_Utils::normalizeUriHttp($url); 404 return $this; 405 } 406 407 /** 408 * Sets weblog Atom URL. 409 * 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) 414 */ 415 public function setAtomUrl($url) 416 { 417 $this->_atomUrl = Zend_Service_Technorati_Utils::normalizeUriHttp($url); 418 return $this; 419 } 420 421 /** 422 * Sets weblog Last Update timestamp. 423 * 424 * $datetime can be any value supported by 425 * Zend_Service_Technorati_Utils::normalizeDate(). 426 * 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 431 */ 432 public function setLastUpdate($datetime) 433 { 434 $this->_lastUpdate = Zend_Service_Technorati_Utils::normalizeDate($datetime); 435 return $this; 436 } 437 438 /** 439 * Sets weblog Rank. 440 * 441 * @param integer $rank 442 * @return Zend_Service_Technorati_Weblog $this instance 443 */ 444 public function setRank($rank) 445 { 446 $this->_rank = (int) $rank; 447 return $this; 448 } 449 450 /** 451 * Sets weblog latitude coordinate. 452 * 453 * @param float $coordinate 454 * @return Zend_Service_Technorati_Weblog $this instance 455 */ 456 public function setLat($coordinate) 457 { 458 $this->_lat = (float) $coordinate; 459 return $this; 460 } 461 462 /** 463 * Sets weblog longitude coordinate. 464 * 465 * @param float $coordinate 466 * @return Zend_Service_Technorati_Weblog $this instance 467 */ 468 public function setLon($coordinate) 469 { 470 $this->_lon = (float) $coordinate; 471 return $this; 472 } 473 474 /** 475 * Sets hasPhoto property. 476 * 477 * @param bool $hasPhoto 478 * @return Zend_Service_Technorati_Weblog $this instance 479 */ 480 public function setHasPhoto($hasPhoto) 481 { 482 $this->_hasPhoto = (bool) $hasPhoto; 483 return $this; 484 } 485 486 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |