/** * 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(); }
/** * 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/postsmatched/text()'); if ($result->length == 1) { $this->postsMatched = (int) $result->item(0)->data; } $result = $this->xpath->query('/tapi/document/result/blogsmatched/text()'); if ($result->length == 1) { $this->blogsMatched = (int) $result->item(0)->data; } $this->totalResultsReturned = (int) $this->xpath->evaluate("count(/tapi/document/item)"); /** @todo Validate the following assertion */ $this->totalResultsAvailable = (int) $this->getPostsMatched(); }
/** * 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; } }
/** * Constructs a new object object from DOM Document. * * @param DomDocument $dom the ReST fragment for this object */ public function __construct(DomDocument $dom, $options = array()) { parent::__construct($dom, $options); $this->totalResultsReturned = (int) $this->xpath->evaluate("count(/tapi/document/item)"); $this->totalResultsAvailable = (int) $this->totalResultsReturned; }