コード例 #1
0
 /**
  * Constructs a new object object from DOM Document.
  *
  * @param   DomDocument $dom the ReST fragment for this object
  */
 public function __construct(DomDocument $dom)
 {
     $xpath = new DOMXPath($dom);
     $result = $xpath->query('//result/weblog');
     if ($result->length == 1) {
         $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 Exception\RuntimeException("Your URL is not a recognized Technorati weblog");
     }
     $result = $xpath->query('//result/url/text()');
     if ($result->length == 1) {
         try {
             // fetched URL often doens't include schema
             // and this issue causes the following line to fail
             $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;
     }
     $result = $xpath->query('//result/inboundlinks/text()');
     if ($result->length == 1) {
         $this->inboundLinks = (int) $result->item(0)->data;
     }
 }
コード例 #2
0
ファイル: SearchResult.php プロジェクト: robertodormepoco/zf2
 /**
  * Constructs a new object object from DOM Element.
  *
  * @param   DomElement $dom the ReST fragment for this object
  */
 public function __construct(DomElement $dom)
 {
     $this->fields = array('permalink' => 'permalink', 'excerpt' => 'excerpt', 'created' => 'created', 'title' => 'title');
     parent::__construct($dom);
     // weblog object field
     $this->parseWeblog();
     // filter fields
     $this->permalink = Utils::normalizeUriHttp($this->permalink);
     $this->created = Utils::normalizeDate($this->created);
 }
コード例 #3
0
ファイル: UtilsTest.php プロジェクト: robertodormepoco/zf2
 /**
  * @return void
  */
 public function testSetDateInputInvalidThrowsException()
 {
     $inputInvalid = "2007foo";
     try {
         Technorati\Utils::normalizeDate($inputInvalid);
         $this->fail('Expected Zend\\Service\\Technorati\\Exception\\RuntimeException not thrown');
     } catch (\Exception $e) {
         $this->assertContains($inputInvalid, $e->getMessage());
     }
 }
コード例 #4
0
ファイル: CosmosResult.php プロジェクト: navassouza/zf2
 /**
  * Constructs a new object object from DOM Element.
  *
  * @param   DomElement $dom the ReST fragment for this object
  */
 public function __construct(DomElement $dom)
 {
     $this->fields = array('nearestPermalink' => 'nearestpermalink', 'excerpt' => 'excerpt', 'linkCreated' => 'linkcreated', 'linkUrl' => 'linkurl');
     parent::__construct($dom);
     // weblog object field
     $this->parseWeblog();
     // filter fields
     $this->nearestPermalink = Utils::normalizeUriHttp($this->nearestPermalink);
     $this->linkUrl = Utils::normalizeUriHttp($this->linkUrl);
     $this->linkCreated = Utils::normalizeDate($this->linkCreated);
 }
コード例 #5
0
 /**
  * Parses the search response and retrieve the results for iteration.
  *
  * @param   DomDocument $dom    the ReST fragment for this object
  * @param   array $options      query options as associative array
  */
 public function __construct(DomDocument $dom, $options = array())
 {
     parent::__construct($dom, $options);
     $result = $this->xpath->query('/tapi/document/result/days/text()');
     if ($result->length == 1) {
         $this->days = (int) $result->item(0)->data;
     }
     $result = $this->xpath->query('/tapi/document/result/searchurl/text()');
     if ($result->length == 1) {
         $this->searchUrl = Utils::normalizeUriHttp($result->item(0)->data);
     }
     $this->totalResultsReturned = (int) $this->xpath->evaluate("count(/tapi/document/items/item)");
     $this->totalResultsAvailable = (int) $this->getDays();
 }
コード例 #6
0
 /**
  * Parses the search response and retrieve the results for iteration.
  *
  * @param   DomDocument $dom    the ReST fragment for this object
  * @param   array $options      query options as associative array
  */
 public function __construct(DomDocument $dom, $options = array())
 {
     parent::__construct($dom, $options);
     $result = $this->xpath->query('/tapi/document/result/inboundlinks/text()');
     if ($result->length == 1) {
         $this->inboundLinks = (int) $result->item(0)->data;
     }
     $result = $this->xpath->query('/tapi/document/result/inboundblogs/text()');
     if ($result->length == 1) {
         $this->inboundBlogs = (int) $result->item(0)->data;
     }
     $result = $this->xpath->query('/tapi/document/result/weblog');
     if ($result->length == 1) {
         $this->weblog = new Weblog($result->item(0));
     }
     $result = $this->xpath->query('/tapi/document/result/url/text()');
     if ($result->length == 1) {
         try {
             // fetched URL often doens't include schema
             // and this issue causes the following line to fail
             $this->url = Utils::normalizeUriHttp($result->item(0)->data);
         } catch (Exception $e) {
             if ($this->getWeblog() instanceof Weblog) {
                 $this->url = $this->getWeblog()->getUrl();
             }
         }
     }
     $this->totalResultsReturned = (int) $this->xpath->evaluate("count(/tapi/document/item)");
     // total number of results depends on query type
     // for now check only getInboundLinks() and getInboundBlogs() value
     if ((int) $this->getInboundLinks() > 0) {
         $this->totalResultsAvailable = $this->getInboundLinks();
     } elseif ((int) $this->getInboundBlogs() > 0) {
         $this->totalResultsAvailable = $this->getInboundBlogs();
     } else {
         $this->totalResultsAvailable = 0;
     }
 }
コード例 #7
0
ファイル: Weblog.php プロジェクト: robertodormepoco/zf2
 /**
  * Sets weblog Last Update timestamp.
  *
  * $datetime can be any value supported by
  * Utils::normalizeDate().
  *
  * @param   mixed $datetime A string representing the last update date time
  *                          in a valid date time format
  * @return  Weblog $this instance
  * @throws  Exception\RuntimeException
  */
 public function setLastUpdate($datetime)
 {
     $this->lastUpdate = Utils::normalizeDate($datetime);
     return $this;
 }
コード例 #8
0
ファイル: Author.php プロジェクト: navassouza/zf2
 /**
  * Sets Technorati account thumbnail picture.
  *
  * @param   string|\Zend\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 = Utils::normalizeUriHttp($input);
     return $this;
 }