本文整理汇总了PHP中Sabre_DAV_XMLUtil类的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_XMLUtil类的具体用法?PHP Sabre_DAV_XMLUtil怎么用?PHP Sabre_DAV_XMLUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sabre_DAV_XMLUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testSerialize
function testSerialize()
{
$dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC'));
$lastMod = new Sabre_DAV_Property_GetLastModified($dt);
$doc = new DOMDocument();
$root = $doc->createElement('d:getlastmodified');
$root->setAttribute('xmlns:d', 'DAV:');
$doc->appendChild($root);
$objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir'));
$server = new Sabre_DAV_Server($objectTree);
$lastMod->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals('<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">' . Sabre_HTTP_Util::toHTTPDate($dt) . '</d:getlastmodified>
', $xml);
$ok = false;
try {
Sabre_DAV_Property_GetLastModified::unserialize(Sabre_DAV_XMLUtil::loadDOMDocument($xml)->firstChild);
} catch (Sabre_DAV_Exception $e) {
$ok = true;
}
if (!$ok) {
$this->markTestFailed('Unserialize should not be supported');
}
}
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:25,代码来源:GetLastModifiedTest.php
示例2: parse
function parse($xml)
{
$xml = implode("\n", $xml);
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$q = new Sabre_CardDAV_AddressBookQueryParser($dom);
$q->parse();
return $q;
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:8,代码来源:AddressBookQueryParserTest.php
示例3: testUnserializer
/**
* @depends testSimple
*/
function testUnserializer()
{
$xml = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:cal="' . Sabre_CalDAV_Plugin::NS_CALDAV . '">' . '<cal:comp name="VEVENT"/>' . '<cal:comp name="VJOURNAL"/>' . '</d:root>';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$property = Sabre_CalDAV_Property_SupportedCalendarComponentSet::unserialize($dom->firstChild);
$this->assertTrue($property instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet);
$this->assertEquals(array('VEVENT', 'VJOURNAL'), $property->getValue());
}
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:12,代码来源:SupportedCalendarComponentSetTest.php
示例4: testUnserialize
/**
* @depends testConstruct
*/
function testUnserialize()
{
$xml = '<?xml version="1.0"?>
<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$resourceType = Sabre_DAV_Property_ResourceType::unserialize($dom->firstChild);
$this->assertEquals(array('{DAV:}collection', '{DAV:}principal'), $resourceType->getValue());
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:12,代码来源:ResourceTypeTest.php
示例5: unserialize
/**
* Unserializes this property from a DOM Element
*
* This method returns an instance of this class.
* It will only decode {DAV:}href values.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_Href
*/
static function unserialize(DOMElement $dom)
{
$hrefs = array();
foreach ($dom->childNodes as $child) {
if (Sabre_DAV_XMLUtil::toClarkNotation($child) === '{DAV:}href') {
$hrefs[] = $child->textContent;
}
}
return new self($hrefs, false);
}
开发者ID:RobertWang,项目名称:sabre-zarafa,代码行数:19,代码来源:HrefList.php
示例6: unserialize
/**
* Unserializes the DOMElement back into a Property class.
*
* @param DOMElement $node
* @return void
*/
static function unserialize(DOMElement $node)
{
$components = array();
foreach ($node->childNodes as $childNode) {
if (Sabre_DAV_XMLUtil::toClarkNotation($childNode) === '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}comp') {
$components[] = $childNode->getAttribute('name');
}
}
return new self($components);
}
开发者ID:mover5,项目名称:imobackup,代码行数:16,代码来源:SupportedCalendarComponentSet.php
示例7: parseCalendarQueryFilters
/**
* This function parses the calendar-query report request body
*
* The body is quite complicated, so we're turning it into a PHP
* array.
*
* The resulting associative array has xpath expressions as keys.
* By default the xpath expressions should simply be checked for existance
* The xpath expressions can point to elements or attributes.
*
* The array values can contain a number of items, which alters the query
* filter.
*
* * time-range. Must also check if the todo or event falls within the
* specified timerange. How this is interpreted depends on
* the type of object (VTODO, VEVENT, VJOURNAL, etc)
* * is-not-defined
* Instead of checking if the attribute or element exist,
* we must check if it doesn't.
* * text-match
* Checks if the value of the attribute or element matches
* the specified value. This is actually another array with
* the 'collation', 'value' and 'negate-condition' items.
*
* Refer to the CalDAV spec for more information.
*
* @param DOMNode $domNode
* @param string $basePath used for recursive calls.
* @param array $filters used for recursive calls.
* @return array
*/
public static function parseCalendarQueryFilters($domNode, $basePath = '/c:iCalendar', &$filters = array())
{
foreach ($domNode->childNodes as $child) {
switch (Sabre_DAV_XMLUtil::toClarkNotation($child)) {
case '{urn:ietf:params:xml:ns:caldav}comp-filter':
case '{urn:ietf:params:xml:ns:caldav}prop-filter':
$filterName = $basePath . '/' . 'c:' . strtolower($child->getAttribute('name'));
$filters[$filterName] = array();
self::parseCalendarQueryFilters($child, $filterName, $filters);
break;
case '{urn:ietf:params:xml:ns:caldav}time-range':
if ($start = $child->getAttribute('start')) {
$start = self::parseICalendarDateTime($start);
} else {
$start = null;
}
if ($end = $child->getAttribute('end')) {
$end = self::parseICalendarDateTime($end);
} else {
$end = null;
}
if (!is_null($start) && !is_null($end) && $end <= $start) {
throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the time-range filter');
}
$filters[$basePath]['time-range'] = array('start' => $start, 'end' => $end);
break;
case '{urn:ietf:params:xml:ns:caldav}is-not-defined':
$filters[$basePath]['is-not-defined'] = true;
break;
case '{urn:ietf:params:xml:ns:caldav}param-filter':
$filterName = $basePath . '/@' . strtolower($child->getAttribute('name'));
$filters[$filterName] = array();
self::parseCalendarQueryFilters($child, $filterName, $filters);
break;
case '{urn:ietf:params:xml:ns:caldav}text-match':
$collation = $child->getAttribute('collation');
if (!$collation) {
$collation = 'i;ascii-casemap';
}
$filters[$basePath]['text-match'] = array('collation' => $collation == 'default' ? 'i;ascii-casemap' : $collation, 'negate-condition' => $child->getAttribute('negate-condition') === 'yes', 'value' => $child->nodeValue);
break;
}
}
return $filters;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:76,代码来源:owncloud_3rdparty_Sabre_CalDAV_XMLUtil.php
示例8: parse
/**
* Parses the request.
*
* @return void
*/
public function parse()
{
$filterNode = null;
$filter = $this->xpath->query('/cal:calendar-query/cal:filter');
if ($filter->length !== 1) {
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
}
$compFilters = $this->parseCompFilters($filter->item(0));
if (count($compFilters) !== 1) {
throw new Sabre_DAV_Exception_BadRequest('There must be exactly 1 top-level comp-filter.');
}
$this->filters = $compFilters[0];
$this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
$expand = $this->xpath->query('/cal:calendar-query/dav:prop/cal:calendar-data/cal:expand');
if ($expand->length > 0) {
$this->expand = $this->parseExpand($expand->item(0));
}
}
开发者ID:RobertWang,项目名称:sabre-zarafa,代码行数:23,代码来源:CalendarQueryParser.php
示例9: unserialize
/**
* Unserializes the DOMElement back into a Property class.
*
* @param DOMElement $node
* @return Sabre_CalDAV_Property_ScheduleCalendarTransp
*/
static function unserialize(DOMElement $node)
{
$value = null;
foreach ($node->childNodes as $childNode) {
switch (Sabre_DAV_XMLUtil::toClarkNotation($childNode)) {
case '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}opaque':
$value = self::OPAQUE;
break;
case '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}transparent':
$value = self::TRANSPARENT;
break;
}
}
if (is_null($value)) {
return null;
}
return new self($value);
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:24,代码来源:ScheduleCalendarTransp.php
示例10: unserialize
/**
* Unserializes this property from a DOM Element
*
* This method returns an instance of this class.
* It will only decode {DAV:}href values. For non-compatible elements null will be returned.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_Href
*/
static function unserialize(DOMElement $dom)
{
if (Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild) === '{DAV:}href') {
return new self($dom->firstChild->textContent, false);
}
}
开发者ID:kumarsivarajan,项目名称:mollify,代码行数:15,代码来源:Href.php
示例11: unserialize
/**
* Unserializes a DOM element into a ResourceType property.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_ResourceType
*/
public static function unserialize(DOMElement $dom)
{
$value = array();
foreach ($dom->childNodes as $child) {
$value[] = Sabre_DAV_XMLUtil::toClarkNotation($child);
}
return new self($value);
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:ResourceType.php
示例12: freeBusyQueryReport
/**
* This method is responsible for parsing the request and generating the
* response for the CALDAV:free-busy-query REPORT.
*
* @param DOMNode $dom
* @return void
*/
protected function freeBusyQueryReport(DOMNode $dom)
{
$start = null;
$end = null;
foreach ($dom->firstChild->childNodes as $childNode) {
$clark = Sabre_DAV_XMLUtil::toClarkNotation($childNode);
if ($clark == '{' . self::NS_CALDAV . '}time-range') {
$start = $childNode->getAttribute('start');
$end = $childNode->getAttribute('end');
break;
}
}
if ($start) {
$start = Sabre_VObject_DateTimeParser::parseDateTime($start);
}
if ($end) {
$end = Sabre_VObject_DateTimeParser::parseDateTime($end);
}
if (!$start && !$end) {
throw new Sabre_DAV_Exception_BadRequest('The freebusy report must have a time-range filter');
}
$acl = $this->server->getPlugin('acl');
if (!$acl) {
throw new Sabre_DAV_Exception('The ACL plugin must be loaded for free-busy queries to work');
}
$uri = $this->server->getRequestUri();
$acl->checkPrivileges($uri, '{' . self::NS_CALDAV . '}read-free-busy');
$calendar = $this->server->tree->getNodeForPath($uri);
if (!$calendar instanceof Sabre_CalDAV_ICalendar) {
throw new Sabre_DAV_Exception_NotImplemented('The free-busy-query REPORT is only implemented on calendars');
}
$objects = array_map(function ($child) {
$obj = $child->get();
if (is_resource($obj)) {
$obj = stream_get_contents($obj);
}
return $obj;
}, $calendar->getChildren());
$generator = new Sabre_VObject_FreeBusyGenerator();
$generator->setObjects($objects);
$generator->setTimeRange($start, $end);
$result = $generator->getResult();
$result = $result->serialize();
$this->server->httpResponse->sendStatus(200);
$this->server->httpResponse->setHeader('Content-Type', 'text/calendar');
$this->server->httpResponse->setHeader('Content-Length', strlen($result));
$this->server->httpResponse->sendBody($result);
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:55,代码来源:Plugin.php
示例13: testUnserializeUnknown
/**
* @expectedException Sabre_DAV_Exception_BadRequest
*/
function testUnserializeUnknown()
{
$xml = '<?xml version="1.0"?>
<d:principal xmlns:d="DAV:">' . ' <d:foo />' . '</d:principal>';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
Sabre_DAVACL_Property_Principal::unserialize($dom->firstChild);
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:10,代码来源:PrincipalTest.php
示例14: testUndefinedNegation
/**
* @depends testParamFilter
*/
function testUndefinedNegation()
{
$xml = <<<XML
<?xml version="1.0"?>
<C:filter xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VTODO">
<C:prop-filter name="COMPLETED">
<C:is-not-defined />
</C:prop-filter>
<C:prop-filter name="STATUS">
<C:text-match negate-condition="yes">CANCELLED</C:text-match>
</C:prop-filter>
</C:comp-filter>
</C:comp-filter>
</C:filter>
XML;
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$expected = array('/c:iCalendar/c:vcalendar' => array(), '/c:iCalendar/c:vcalendar/c:vtodo' => array(), '/c:iCalendar/c:vcalendar/c:vtodo/c:completed' => array('is-not-defined' => true), '/c:iCalendar/c:vcalendar/c:vtodo/c:status' => array('text-match' => array('collation' => 'i;ascii-casemap', 'negate-condition' => true, 'value' => 'CANCELLED')));
$result = Sabre_CalDAV_XMLUtil::parseCalendarQueryFilters($dom->firstChild);
$this->assertEquals($expected, $result);
}
开发者ID:Gninety,项目名称:Microweber,代码行数:25,代码来源:XMLUtilTest.php
示例15: 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;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:17,代码来源:Plugin.php
示例16: 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]);
}
}
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:25,代码来源:PluginTest.php
示例17: parsePrincipalPropertySearchReportRequest
/**
* parsePrincipalPropertySearchReportRequest
*
* This method parses the request body from a
* {DAV:}principal-property-search report.
*
* This method returns an array with two elements:
* 1. an array with properties to search on, and their values
* 2. a list of propertyvalues that should be returned for the request.
*
* @param DOMDocument $dom
* @return array
*/
protected function parsePrincipalPropertySearchReportRequest($dom)
{
$httpDepth = $this->server->getHTTPDepth(0);
if ($httpDepth !== 0) {
throw new Sabre_DAV_Exception_BadRequest('This report is only defined when Depth: 0');
}
$searchProperties = array();
$applyToPrincipalCollectionSet = false;
// Parsing the search request
foreach ($dom->firstChild->childNodes as $searchNode) {
if (Sabre_DAV_XMLUtil::toClarkNotation($searchNode) == '{DAV:}apply-to-principal-collection-set') {
$applyToPrincipalCollectionSet = true;
}
if (Sabre_DAV_XMLUtil::toClarkNotation($searchNode) !== '{DAV:}property-search') {
continue;
}
$propertyName = null;
$propertyValue = null;
foreach ($searchNode->childNodes as $childNode) {
switch (Sabre_DAV_XMLUtil::toClarkNotation($childNode)) {
case '{DAV:}prop':
$property = Sabre_DAV_XMLUtil::parseProperties($searchNode);
reset($property);
$propertyName = key($property);
break;
case '{DAV:}match':
$propertyValue = $childNode->textContent;
break;
}
}
if (is_null($propertyName) || is_null($propertyValue)) {
throw new Sabre_DAV_Exception_BadRequest('Invalid search request. propertyname: ' . $propertyName . '. propertvvalue: ' . $propertyValue);
}
$searchProperties[$propertyName] = $propertyValue;
}
return array($searchProperties, array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild)), $applyToPrincipalCollectionSet);
}
开发者ID:nyarla,项目名称:fluxflex-sample,代码行数:50,代码来源:Plugin.php
示例18: addressbookMultiGetReport
/**
* This function handles the addressbook-multiget REPORT.
*
* This report is used by the client to fetch the content of a series
* of urls. Effectively avoiding a lot of redundant requests.
*
* @param DOMNode $dom
* @return void
*/
public function addressbookMultiGetReport($dom)
{
$properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild));
$hrefElems = $dom->getElementsByTagNameNS('urn:DAV', 'href');
$propertyList = array();
foreach ($hrefElems as $elem) {
$uri = $this->server->calculateUri($elem->nodeValue);
list($propertyList[]) = $this->server->getPropertiesForPath($uri, $properties);
}
$this->server->httpResponse->sendStatus(207);
$this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
$this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList));
}
开发者ID:paullarrow,项目名称:CDN-Sync-Tool,代码行数:22,代码来源:Plugin.php
示例19: parse
/**
* Parses the request.
*
* @return void
*/
public function parse()
{
$filterNode = null;
$limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
if (is_nan($limit)) {
$limit = null;
}
$filter = $this->xpath->query('/card:addressbook-query/card:filter');
// According to the CardDAV spec there needs to be exactly 1 filter
// element. However, KDE 4.8.2 contains a bug that will encode 0 filter
// elements, so this is a workaround for that.
//
// See: https://bugs.kde.org/show_bug.cgi?id=300047
if ($filter->length === 0) {
$test = null;
$filter = null;
} elseif ($filter->length === 1) {
$filter = $filter->item(0);
$test = $this->xpath->evaluate('string(@test)', $filter);
} else {
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
}
if (!$test) {
$test = self::TEST_ANYOF;
}
if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"');
}
$propFilters = array();
$propFilterNodes = $this->xpath->query('card:prop-filter', $filter);
for ($ii = 0; $ii < $propFilterNodes->length; $ii++) {
$propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii));
}
$this->filters = $propFilters;
$this->limit = $limit;
$this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
$this->test = $test;
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:43,代码来源:AddressBookQueryParser.php
示例20: parsePropFindRequest
/**
* This method parses the PROPFIND request and returns its information
*
* This will either be a list of properties, or an empty array; in which case
* an {DAV:}allprop was requested.
*
* @param string $body
* @return array
*/
public function parsePropFindRequest($body)
{
// If the propfind body was empty, it means IE is requesting 'all' properties
if (!$body) {
return array();
}
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($body);
$elem = $dom->getElementsByTagNameNS('urn:DAV', 'propfind')->item(0);
return array_keys(Sabre_DAV_XMLUtil::parseProperties($elem));
}
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:19,代码来源:Server.php
注:本文中的Sabre_DAV_XMLUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论