Skip to content

Commit

Permalink
Merge branch 'hotfix/ZF2-106' of https://github.com/Maks3w/zf2 into h…
Browse files Browse the repository at this point in the history
…otfix/zf2-106
  • Loading branch information
weierophinney committed Feb 28, 2012
2 parents a5795d8 + 9df6cd4 commit 49de8e0
Show file tree
Hide file tree
Showing 42 changed files with 1,133 additions and 979 deletions.
71 changes: 39 additions & 32 deletions library/Zend/Service/Technorati/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,66 +19,73 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Service\Technorati;

use \DomElement,
\DOMXPath,
Zend\Uri;

/**
* Represents a weblog Author object. It usually belongs to a Technorati account.
*
* @uses DOMXPath
* @uses Zend_Service_Technorati_Utils
* @category Zend
* @package Zend_Service
* @subpackage Technorati
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Technorati_Author
class Author
{
/**
* Author first name
*
* @var string
* @access protected
*/
protected $_firstName;
protected $firstName;

/**
* Author last name
*
* @var string
* @access protected
*/
protected $_lastName;
protected $lastName;

/**
* Technorati account username
*
* @var string
* @access protected
*/
protected $_username;
protected $username;

/**
* Technorati account description
*
* @var string
* @access protected
*/
protected $_description;
protected $description;

/**
* Technorati account biography
*
* @var string
* @access protected
*/
protected $_bio;
protected $bio;

/**
* Technorati account thumbnail picture URL, if any
*
* @var null|Zend_Uri_Http
* @var null|Uri\Http
* @access protected
*/
protected $_thumbnailPicture;
protected $thumbnailPicture;


/**
Expand Down Expand Up @@ -116,7 +123,7 @@ public function __construct(DomElement $dom)
* @return string Author first name
*/
public function getFirstName() {
return $this->_firstName;
return $this->firstName;
}

/**
Expand All @@ -125,7 +132,7 @@ public function getFirstName() {
* @return string Author last name
*/
public function getLastName() {
return $this->_lastName;
return $this->lastName;
}

/**
Expand All @@ -134,7 +141,7 @@ public function getLastName() {
* @return string Technorati account username
*/
public function getUsername() {
return $this->_username;
return $this->username;
}

/**
Expand All @@ -143,7 +150,7 @@ public function getUsername() {
* @return string Technorati account description
*/
public function getDescription() {
return $this->_description;
return $this->description;
}

/**
Expand All @@ -152,84 +159,84 @@ public function getDescription() {
* @return string Technorati account biography
*/
public function getBio() {
return $this->_bio;
return $this->bio;
}

/**
* Returns Technorati account thumbnail picture.
*
* @return null|Zend_Uri_Http Technorati account thumbnail picture
* @return null|Uri\Http Technorati account thumbnail picture
*/
public function getThumbnailPicture() {
return $this->_thumbnailPicture;
return $this->thumbnailPicture;
}


/**
* Sets author first name.
*
* @param string $input first Name input value
* @return Zend_Service_Technorati_Author $this instance
* @return Author $this instance
*/
public function setFirstName($input) {
$this->_firstName = (string) $input;
$this->firstName = (string) $input;
return $this;
}

/**
* Sets author last name.
*
* @param string $input last Name input value
* @return Zend_Service_Technorati_Author $this instance
* @return Author $this instance
*/
public function setLastName($input) {
$this->_lastName = (string) $input;
$this->lastName = (string) $input;
return $this;
}

/**
* Sets Technorati account username.
*
* @param string $input username input value
* @return Zend_Service_Technorati_Author $this instance
* @return Author $this instance
*/
public function setUsername($input) {
$this->_username = (string) $input;
$this->username = (string) $input;
return $this;
}

/**
* Sets Technorati account biography.
*
* @param string $input biography input value
* @return Zend_Service_Technorati_Author $this instance
* @return Author $this instance
*/
public function setBio($input) {
$this->_bio = (string) $input;
$this->bio = (string) $input;
return $this;
}

/**
* Sets Technorati account description.
*
* @param string $input description input value
* @return Zend_Service_Technorati_Author $this instance
* @return Author $this instance
*/
public function setDescription($input) {
$this->_description = (string) $input;
$this->description = (string) $input;
return $this;
}

/**
* Sets Technorati account thumbnail picture.
*
* @param string|Zend_Uri_Http $input thumbnail picture URI
* @return Zend_Service_Technorati_Author $this instance
* @throws Zend_Service_Technorati_Exception if $input is an invalid URI
* (via Zend_Service_Technorati_Utils::normalizeUriHttp)
* @param string|Uri\Http $input thumbnail picture URI
* @return Author $this instance
* @throws Exception\RuntimeException if $input is an invalid URI
* (via Utils::normalizeUriHttp)
*/
public function setThumbnailPicture($input) {
$this->_thumbnailPicture = Zend_Service_Technorati_Utils::normalizeUriHttp($input);
$this->thumbnailPicture = Utils::normalizeUriHttp($input);
return $this;
}

Expand Down
55 changes: 30 additions & 25 deletions library/Zend/Service/Technorati/BlogInfoResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,57 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Service\Technorati;

use \DomDocument,
\DOMXPath,
Zend\Uri;

/**
* Represents a single Technorati BlogInfo query result object.
*
* @uses DOMXPath
* @uses Zend_Service_Technorati_Exception
* @uses Zend_Service_Technorati_Utils
* @uses Zend_Service_Technorati_Weblog
* @category Zend
* @package Zend_Service
* @subpackage Technorati
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Technorati_BlogInfoResult
class BlogInfoResult
{
/**
* Technorati weblog url, if queried URL is a valid weblog.
*
* @var Zend_Uri_Http
* @var Uri\Http
* @access protected
*/
protected $_url;
protected $url;

/**
* Technorati weblog, if queried URL is a valid weblog.
*
* @var Zend_Service_Technorati_Weblog
* @var Weblog
* @access protected
*/
protected $_weblog;
protected $weblog;

/**
* Number of unique blogs linking this blog
*
* @var integer
* @access protected
*/
protected $_inboundBlogs;
protected $inboundBlogs;

/**
* Number of incoming links to this blog
*
* @var integer
* @access protected
*/
protected $_inboundLinks;
protected $inboundLinks;


/**
Expand All @@ -77,11 +82,11 @@ public function __construct(DomDocument $dom)
$xpath = new DOMXPath($dom);
$result = $xpath->query('//result/weblog');
if ($result->length == 1) {
$this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0));
$this->weblog = new Weblog($result->item(0));
} else {
// follow the same behavior of blogPostTags
// and raise an Exception if the URL is not a valid weblog
throw new Zend_Service_Technorati_Exception(
throw new Exception\RuntimeException(
"Your URL is not a recognized Technorati weblog");
}

Expand All @@ -90,39 +95,39 @@ public function __construct(DomDocument $dom)
try {
// fetched URL often doens't include schema
// and this issue causes the following line to fail
$this->_url = Zend_Service_Technorati_Utils::normalizeUriHttp($result->item(0)->data);
} catch(Zend_Service_Technorati_Exception $e) {
if ($this->getWeblog() instanceof Zend_Service_Technorati_Weblog) {
$this->_url = $this->getWeblog()->getUrl();
$this->url = Utils::normalizeUriHttp($result->item(0)->data);
} catch(Exception $e) {
if ($this->getWeblog() instanceof Weblog) {
$this->url = $this->getWeblog()->getUrl();
}
}
}

$result = $xpath->query('//result/inboundblogs/text()');
if ($result->length == 1) $this->_inboundBlogs = (int) $result->item(0)->data;
if ($result->length == 1) $this->inboundBlogs = (int) $result->item(0)->data;

$result = $xpath->query('//result/inboundlinks/text()');
if ($result->length == 1) $this->_inboundLinks = (int) $result->item(0)->data;
if ($result->length == 1) $this->inboundLinks = (int) $result->item(0)->data;

}


/**
* Returns the weblog URL.
*
* @return Zend_Uri_Http
* @return Uri\Http
*/
public function getUrl() {
return $this->_url;
return $this->url;
}

/**
* Returns the weblog.
*
* @return Zend_Service_Technorati_Weblog
* @return Weblog
*/
public function getWeblog() {
return $this->_weblog;
return $this->weblog;
}

/**
Expand All @@ -132,7 +137,7 @@ public function getWeblog() {
*/
public function getInboundBlogs()
{
return (int) $this->_inboundBlogs;
return (int) $this->inboundBlogs;
}

/**
Expand All @@ -142,7 +147,7 @@ public function getInboundBlogs()
*/
public function getInboundLinks()
{
return (int) $this->_inboundLinks;
return (int) $this->inboundLinks;
}

}
Loading

0 comments on commit 49de8e0

Please sign in to comment.