public static function fromDomElement(DOMNode $domNode) { $status = new GWTSiteSyncStatus(); $xpath = new DOMXPath($domNode->ownerDocument); $contentSrc = $xpath->query($domNode->getNodePath() . "//*[local-name()='content']/@src"); $verified = $xpath->query($domNode->getNodePath() . "//*[local-name()='verified']"); $verificationMethod = $xpath->query($domNode->getNodePath() . "//*[local-name()='verification-method']"); for ($i = 0; $i < $verificationMethod->length; $i++) { $node = $verificationMethod->item($i); if (preg_match('/google([a-f0-9]+)\\.html/', $node->nodeValue, $matches)) { $status->setPageVerificationCode($matches[1]); } } if ($contentSrc->length > 0) { $status->setUrl($contentSrc->item(0)->nodeValue); } if ($verified->length > 0) { $status->setVerified(self::parseBoolean($verified->item(0)->nodeValue)); } return $status; }
/** * @param $xml * @return GWTSiteSyncStatus * @throws GWTException */ private function put_verify($xml) { global $wgHTTPTimeout, $wgHTTPProxy, $wgTitle, $wgVersion; $request = MWHttpRequest::factory($this->mSiteURI, array('postData' => $xml, 'method' => 'PUT')); $request->setHeader('Content-type', 'application/atom+xml'); $request->setHeader('Authorization', 'GoogleLogin auth=' . $this->mAuth); $status = $request->execute(); if ($status->isOK()) { $text = $request->getContent(); GWTLogHelper::debug($text); } else { throw new GWTException("Non 200 response.\n" . "\n" . "message:" . $status->getMessage() . "\n" . $request->getContent()); } $doc = new DOMDocument(); $doc->loadXML($text); $e = $doc->documentElement; return GWTSiteSyncStatus::fromDomElement($e); }