本文整理汇总了PHP中Sabre_DAV_XMLUtil::convertDAVNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_XMLUtil::convertDAVNamespace方法的具体用法?PHP Sabre_DAV_XMLUtil::convertDAVNamespace怎么用?PHP Sabre_DAV_XMLUtil::convertDAVNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre_DAV_XMLUtil
的用法示例。
在下文中一共展示了Sabre_DAV_XMLUtil::convertDAVNamespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConvertDAVNamespaceMixedQuotes
function testConvertDAVNamespaceMixedQuotes()
{
$xml = '<?xml version="1.0"?><document xmlns=\'DAV:" xmlns="Another attribute\'>blablabla</document>';
$this->assertEquals($xml, Sabre_DAV_XMLUtil::convertDAVNamespace($xml));
}
示例2: testCalendarQueryReport1ObjectNoCalData
/**
* @depends testSupportedReportSetProperty
* @depends testCalendarMultiGetReport
*/
function testCalendarQueryReport1ObjectNoCalData()
{
$body = '<?xml version="1.0"?>' . '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . '<d:prop>' . ' <d:getetag />' . '</d:prop>' . '<c:filter>' . ' <c:comp-filter name="VCALENDAR">' . ' <c:comp-filter name="VEVENT" />' . ' </c:comp-filter>' . '</c:filter>' . '</c:calendar-query>';
$request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/calendars/user1/UUID-123467/UUID-2345', 'HTTP_DEPTH' => '0'));
$request->setBody($body);
$this->server->httpRequest = $request;
$this->server->exec();
$this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
$xml = simplexml_load_string(Sabre_DAV_XMLUtil::convertDAVNamespace($this->response->body));
$xml->registerXPathNamespace('d', 'urn:DAV');
$xml->registerXPathNamespace('c', 'urn:ietf:params:xml:ns:caldav');
$check = array('/d:multistatus', '/d:multistatus/d:response', '/d:multistatus/d:response/d:href', '/d:multistatus/d:response/d:propstat', '/d:multistatus/d:response/d:propstat/d:prop', '/d:multistatus/d:response/d:propstat/d:prop/d:getetag', '/d:multistatus/d:response/d:propstat/d:status' => 'HTTP/1.1 200 OK');
foreach ($check as $v1 => $v2) {
$xpath = is_int($v1) ? $v2 : $v1;
$result = $xml->xpath($xpath);
$this->assertEquals(1, count($result), 'We expected 1 ' . $xpath . ' elements. We\'ve found ' . count($result) . '. Full result: ' . $this->response->body);
if (!is_int($v1)) {
$this->assertEquals($v2, (string) $result[0]);
}
}
}
示例3: parseLockRequest
/**
* Parses a webdav lock xml body, and returns a new Sabre_DAV_Locks_LockInfo object
*
* @param string $body
* @return Sabre_DAV_Locks_LockInfo
*/
protected function parseLockRequest($body)
{
$xml = simplexml_load_string(Sabre_DAV_XMLUtil::convertDAVNamespace($body), null, LIBXML_NOWARNING);
$xml->registerXPathNamespace('d', 'urn:DAV');
$lockInfo = new Sabre_DAV_Locks_LockInfo();
$children = $xml->children("urn:DAV");
$lockInfo->owner = (string) $children->owner;
$lockInfo->token = Sabre_DAV_UUIDUtil::getUUID();
$lockInfo->scope = count($xml->xpath('d:lockscope/d:exclusive')) > 0 ? Sabre_DAV_Locks_LockInfo::EXCLUSIVE : Sabre_DAV_Locks_LockInfo::SHARED;
return $lockInfo;
}
示例4: parseMultiStatus
/**
* Parses a WebDAV multistatus response body
*
* This method returns an array with the following structure
*
* array(
* 'url/to/resource' => array(
* '200' => array(
* '{DAV:}property1' => 'value1',
* '{DAV:}property2' => 'value2',
* ),
* '404' => array(
* '{DAV:}property1' => null,
* '{DAV:}property2' => null,
* ),
* )
* 'url/to/resource2' => array(
* .. etc ..
* )
* )
*
*
* @param string $body xml body
* @return array
*/
public function parseMultiStatus($body)
{
$body = Sabre_DAV_XMLUtil::convertDAVNamespace($body);
$responseXML = simplexml_load_string($body, null, LIBXML_NOBLANKS | LIBXML_NOCDATA);
if ($responseXML === false) {
throw new InvalidArgumentException('The passed data is not valid XML');
}
$responseXML->registerXPathNamespace('d', 'urn:DAV');
$propResult = array();
foreach ($responseXML->xpath('d:response') as $response) {
$response->registerXPathNamespace('d', 'urn:DAV');
$href = $response->xpath('d:href');
$href = (string) $href[0];
$properties = array();
foreach ($response->xpath('d:propstat') as $propStat) {
$propStat->registerXPathNamespace('d', 'urn:DAV');
$status = $propStat->xpath('d:status');
list($httpVersion, $statusCode, $message) = explode(' ', (string) $status[0], 3);
$properties[$statusCode] = Sabre_DAV_XMLUtil::parseProperties(dom_import_simplexml($propStat), $this->propertyMap);
}
$propResult[$href] = $properties;
}
return $propResult;
}