本文整理汇总了PHP中Sabre_DAV_XMLUtil类的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_XMLUtil类的具体用法?PHP Sabre_DAV_XMLUtil怎么用?PHP Sabre_DAV_XMLUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sabre_DAV_XMLUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}