当前位置: 首页>>代码示例>>PHP>>正文


PHP DAV\XMLUtil类代码示例

本文整理汇总了PHP中Sabre\DAV\XMLUtil的典型用法代码示例。如果您正苦于以下问题:PHP XMLUtil类的具体用法?PHP XMLUtil怎么用?PHP XMLUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XMLUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSerialize

    function testSerialize()
    {
        $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
        $lastMod = new GetLastModified($dt);
        $doc = new \DOMDocument();
        $root = $doc->createElement('d:getlastmodified');
        $root->setAttribute('xmlns:d', 'DAV:');
        $doc->appendChild($root);
        $server = new DAV\Server();
        $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">' .
        HTTP\Util::toHTTPDate($dt) .
        '</d:getlastmodified>
        ', $xml);
        */
        $this->assertEquals('<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:">' . HTTP\Util::toHTTPDate($dt) . '</d:getlastmodified>
', $xml);
        $ok = false;
        try {
            GetLastModified::unserialize(DAV\XMLUtil::loadDOMDocument($xml)->firstChild, array());
        } catch (DAV\Exception $e) {
            $ok = true;
        }
        if (!$ok) {
            $this->markTestFailed('Unserialize should not be supported');
        }
    }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:32,代码来源:GetLastModifiedTest.php

示例2: testUnserializerBadData

    /**
     * @depends testSimple
     */
    function testUnserializerBadData()
    {
        $xml = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:cal="' . CalDAV\Plugin::NS_CALDAV . '">' . '<cal:foo/>' . '</d:root>';
        $dom = DAV\XMLUtil::loadDOMDocument($xml);
        $this->assertNull(ScheduleCalendarTransp::unserialize($dom->firstChild));
    }
开发者ID:samj1912,项目名称:repo,代码行数:10,代码来源:ScheduleCalendarTranspTest.php

示例3: parse

 function parse($xml)
 {
     $xml = implode("\n", $xml);
     $dom = DAV\XMLUtil::loadDOMDocument($xml);
     $q = new AddressBookQueryParser($dom);
     $q->parse();
     return $q;
 }
开发者ID:samj1912,项目名称:repo,代码行数:8,代码来源:AddressBookQueryParserTest.php

示例4: 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 = SupportedCalendarComponentSet::unserialize($dom->firstChild);
        $this->assertTrue($property instanceof SupportedCalendarComponentSet);
        $this->assertEquals(array('VEVENT', 'VJOURNAL'), $property->getValue());
    }
开发者ID:TamirAl,项目名称:hubzilla,代码行数:12,代码来源:SupportedCalendarComponentSetTest.php

示例5: testUnserialize

    /**
     * @depends testConstruct
     */
    function testUnserialize()
    {
        $xml = '<?xml version="1.0"?>
<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
';
        $dom = DAV\XMLUtil::loadDOMDocument($xml);
        $resourceType = ResourceType::unserialize($dom->firstChild, array());
        $this->assertEquals(array('{DAV:}collection', '{DAV:}principal'), $resourceType->getValue());
    }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:12,代码来源:ResourceTypeTest.php

示例6: 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
  * @param array $propertyMap
  * @return DAV\Property\HrefList
  */
 static function unserialize(\DOMElement $dom, array $propertyMap)
 {
     $hrefs = [];
     foreach ($dom->childNodes as $child) {
         if (DAV\XMLUtil::toClarkNotation($child) === '{DAV:}href') {
             $hrefs[] = $child->textContent;
         }
     }
     return new self($hrefs, false);
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:20,代码来源:HrefList.php

示例7: unserialize

 /**
  * Unserializes this property from a DOM Element
  *
  * This method returns an instance of this class.
  * It will only decode tag values.
  *
  * @param \DOMElement $dom
  * @param array $propertyMap
  * @return \OCA\DAV\Connector\Sabre\TagList
  */
 static function unserialize(\DOMElement $dom, array $propertyMap)
 {
     $tags = array();
     foreach ($dom->childNodes as $child) {
         if (DAV\XMLUtil::toClarkNotation($child) === '{' . self::NS_OWNCLOUD . '}tag') {
             $tags[] = $child->textContent;
         }
     }
     return new self($tags);
 }
开发者ID:nem0xff,项目名称:core,代码行数:20,代码来源:taglist.php

示例8: unserialize

 /**
  * Unserializes the DOMElement back into a Property class.
  *
  * @param \DOMElement $node
  * @return Property_SupportedCalendarComponentSet
  */
 static function unserialize(\DOMElement $node)
 {
     $components = array();
     foreach ($node->childNodes as $childNode) {
         if (DAV\XMLUtil::toClarkNotation($childNode) === '{' . CalDAV\Plugin::NS_CALDAV . '}comp') {
             $components[] = $childNode->getAttribute('name');
         }
     }
     return new self($components);
 }
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:16,代码来源:SupportedCalendarComponentSet.php

示例9: calendarMultiGetReport

 /**
  * This function handles the calendar-multiget REPORT.
  *
  * prefetch events into calendar container class, to avoid single lookup of events
  *
  * @param \DOMNode $dom
  * @return void
  */
 public function calendarMultiGetReport($dom)
 {
     $properties = array_keys(\Sabre\DAV\XMLUtil::parseProperties($dom->firstChild));
     $hrefElems = $dom->getElementsByTagNameNS('urn:DAV', 'href');
     $filters = array('name' => 'VCALENDAR', 'comp-filters' => array(array('name' => 'VEVENT', 'prop-filters' => array())));
     foreach ($hrefElems as $elem) {
         list($dirName, $baseName) = \Sabre\DAV\URLUtil::splitPath($elem->nodeValue);
         $filters['comp-filters'][0]['prop-filters'][] = array('name' => 'UID', 'text-match' => array('value' => $baseName));
     }
     $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
     $node->calendarQuery($filters);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:20,代码来源:SpeedUpPlugin.php

示例10: parse

 /**
  * Parses the request.
  *
  * @return void
  */
 function parse()
 {
     $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:enoch85,项目名称:owncloud-testserver,代码行数:22,代码来源:CalendarQueryParser.php

示例11: testUnserialize

    function testUnserialize()
    {
        $source = '<?xml version="1.0"?>
<d:root xmlns:d="DAV:">
    <d:privilege>
        <d:write-properties />
    </d:privilege>
    <d:privilege>
        <d:read />
    </d:privilege>
</d:root>
';
        $dom = DAV\XMLUtil::loadDOMDocument($source);
        $result = CurrentUserPrivilegeSet::unserialize($dom->firstChild, array());
        $this->assertTrue($result->has('{DAV:}read'));
        $this->assertTrue($result->has('{DAV:}write-properties'));
        $this->assertFalse($result->has('{DAV:}bind'));
    }
开发者ID:TamirAl,项目名称:hubzilla,代码行数:18,代码来源:CurrentUserPrivilegeSetTest.php

示例12: unserialize

 /**
  * Unserializes the DOMElement back into a Property class.
  *
  * @param \DOMElement $node
  * @param array $propertyMap
  * @return ScheduleCalendarTransp
  */
 static function unserialize(\DOMElement $node, array $propertyMap)
 {
     $value = null;
     foreach ($node->childNodes as $childNode) {
         switch (DAV\XMLUtil::toClarkNotation($childNode)) {
             case '{' . CalDAV\Plugin::NS_CALDAV . '}opaque':
                 $value = self::OPAQUE;
                 break;
             case '{' . CalDAV\Plugin::NS_CALDAV . '}transparent':
                 $value = self::TRANSPARENT;
                 break;
         }
     }
     if (is_null($value)) {
         return null;
     }
     return new self($value);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:25,代码来源:ScheduleCalendarTransp.php

示例13: parse

 /**
  * Parses the request.
  *
  * @return void
  */
 function parse()
 {
     $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 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 DAV\Exception\BadRequest('The test attribute must either hold "anyof" or "allof"');
     }
     $propFilters = [];
     if (!is_null($filter)) {
         $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(DAV\XMLUtil::parseProperties($this->dom->firstChild));
     $this->test = $test;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:44,代码来源:AddressBookQueryParser.php

示例14: httpReport

 /**
  * HTTP REPORT method implementation
  *
  * Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253)
  * It's used in a lot of extensions, so it made sense to implement it into the core.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpReport(RequestInterface $request, ResponseInterface $response)
 {
     $path = $request->getPath();
     $body = $request->getBodyAsString();
     $dom = XMLUtil::loadDOMDocument($body);
     $reportName = XMLUtil::toClarkNotation($dom->firstChild);
     if ($this->server->emit('report', [$reportName, $dom, $path])) {
         // If emit returned true, it means the report was not supported
         throw new Exception\ReportNotSupported();
     }
     // Sending back false will interupt the event chain and tell the server
     // we've handled this method.
     return false;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:24,代码来源:CorePlugin.php

示例15: unserialize

 /**
  * Unserializes the {DAV:}acl xml element.
  *
  * @param \DOMElement $dom
  * @param array $propertyMap
  * @return Acl
  */
 static function unserialize(\DOMElement $dom, array $propertyMap)
 {
     $privileges = [];
     $xaces = $dom->getElementsByTagNameNS('urn:DAV', 'ace');
     for ($ii = 0; $ii < $xaces->length; $ii++) {
         $xace = $xaces->item($ii);
         $principal = $xace->getElementsByTagNameNS('urn:DAV', 'principal');
         if ($principal->length !== 1) {
             throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
         }
         $principal = Principal::unserialize($principal->item(0), $propertyMap);
         switch ($principal->getType()) {
             case Principal::HREF:
                 $principal = $principal->getHref();
                 break;
             case Principal::AUTHENTICATED:
                 $principal = '{DAV:}authenticated';
                 break;
             case Principal::UNAUTHENTICATED:
                 $principal = '{DAV:}unauthenticated';
                 break;
             case Principal::ALL:
                 $principal = '{DAV:}all';
                 break;
         }
         $protected = false;
         if ($xace->getElementsByTagNameNS('urn:DAV', 'protected')->length > 0) {
             $protected = true;
         }
         $grants = $xace->getElementsByTagNameNS('urn:DAV', 'grant');
         if ($grants->length < 1) {
             throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
         }
         $grant = $grants->item(0);
         $xprivs = $grant->getElementsByTagNameNS('urn:DAV', 'privilege');
         for ($jj = 0; $jj < $xprivs->length; $jj++) {
             $xpriv = $xprivs->item($jj);
             $privilegeName = null;
             for ($kk = 0; $kk < $xpriv->childNodes->length; $kk++) {
                 $childNode = $xpriv->childNodes->item($kk);
                 if ($t = DAV\XMLUtil::toClarkNotation($childNode)) {
                     $privilegeName = $t;
                     break;
                 }
             }
             if (is_null($privilegeName)) {
                 throw new DAV\Exception\BadRequest('{DAV:}privilege elements must have a privilege element contained within them.');
             }
             $privileges[] = ['principal' => $principal, 'protected' => $protected, 'privilege' => $privilegeName];
         }
     }
     return new self($privileges);
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:60,代码来源:Acl.php


注:本文中的Sabre\DAV\XMLUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。