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


PHP Server::generateMultiStatus方法代码示例

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


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

示例1: httpMkcol

    /**
     * WebDAV MKCOL
     *
     * The MKCOL method is used to create a new collection (directory) on the server
     *
     * @param RequestInterface $request
     * @param ResponseInterface $response
     * @return bool
     */
    function httpMkcol(RequestInterface $request, ResponseInterface $response) {

        $requestBody = $request->getBodyAsString();
        $path = $request->getPath();

        if ($requestBody) {

            $contentType = $request->getHeader('Content-Type');
            if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {

                // We must throw 415 for unsupported mkcol bodies
                throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');

            }

            try {
                $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody);
            } catch (\Sabre\Xml\ParseException $e) {
                throw new Exception\BadRequest($e->getMessage(), null, $e);
            }

            $properties = $mkcol->getProperties();

            if (!isset($properties['{DAV:}resourcetype']))
                throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');

            $resourceType = $properties['{DAV:}resourcetype']->getValue();
            unset($properties['{DAV:}resourcetype']);

        } else {

            $properties = [];
            $resourceType = ['{DAV:}collection'];

        }

        $mkcol = new MkCol($resourceType, $properties);

        $result = $this->server->createCollection($path, $mkcol);

        if (is_array($result)) {
            $response->setStatus(207);
            $response->setHeader('Content-Type', 'application/xml; charset=utf-8');

            $response->setBody(
                $this->server->generateMultiStatus([$result])
            );

        } else {
            $response->setHeader('Content-Length', '0');
            $response->setStatus(201);
        }

        // Sending back false will interupt the event chain and tell the server
        // we've handled this method.
        return false;

    }
开发者ID:nikosv,项目名称:openeclass,代码行数:67,代码来源:CorePlugin.php

示例2: _principalSearchReport

 protected function _principalSearchReport(\DOMDocument $dom)
 {
     $requestedProperties = array_keys(\Sabre\DAV\XMLUtil::parseProperties($dom->firstChild));
     $searchTokens = $dom->firstChild->getElementsByTagName('search-token');
     $searchProperties = array();
     if ($searchTokens->length > 0) {
         $searchProperties['{http://calendarserver.org/ns/}search-token'] = $searchTokens->item(0)->nodeValue;
     }
     $result = $this->server->getPlugin('acl')->principalSearch($searchProperties, $requestedProperties);
     $prefer = $this->server->getHTTPPRefer();
     $this->server->httpResponse->sendStatus(207);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
     $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result, $prefer['return-minimal']));
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:15,代码来源:PrincipalSearch.php

示例3: httpMkcol

 /**
  * WebDAV MKCOL
  *
  * The MKCOL method is used to create a new collection (directory) on the server
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpMkcol(RequestInterface $request, ResponseInterface $response)
 {
     $requestBody = $request->getBodyAsString();
     $path = $request->getPath();
     if ($requestBody) {
         $contentType = $request->getHeader('Content-Type');
         if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {
             // We must throw 415 for unsupported mkcol bodies
             throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');
         }
         $dom = XMLUtil::loadDOMDocument($requestBody);
         if (XMLUtil::toClarkNotation($dom->firstChild) !== '{DAV:}mkcol') {
             // We must throw 415 for unsupported mkcol bodies
             throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must be a {DAV:}mkcol request construct.');
         }
         $properties = [];
         foreach ($dom->firstChild->childNodes as $childNode) {
             if (XMLUtil::toClarkNotation($childNode) !== '{DAV:}set') {
                 continue;
             }
             $properties = array_merge($properties, XMLUtil::parseProperties($childNode, $this->server->propertyMap));
         }
         if (!isset($properties['{DAV:}resourcetype'])) {
             throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');
         }
         $resourceType = $properties['{DAV:}resourcetype']->getValue();
         unset($properties['{DAV:}resourcetype']);
     } else {
         $properties = [];
         $resourceType = ['{DAV:}collection'];
     }
     $result = $this->server->createCollection($path, $resourceType, $properties);
     if (is_array($result)) {
         $response->setStatus(207);
         $response->setHeader('Content-Type', 'application/xml; charset=utf-8');
         $response->setBody($this->server->generateMultiStatus([$result]));
     } else {
         $response->setHeader('Content-Length', '0');
         $response->setStatus(201);
     }
     // Sending back false will interupt the event chain and tell the server
     // we've handled this method.
     return false;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:53,代码来源:CorePlugin.php

示例4: calendarQueryReport


//.........这里部分代码省略.........
 {
     $path = $this->server->getRequestUri();
     $needsJson = $report->contentType === 'application/calendar+json';
     $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
     $depth = $this->server->getHTTPDepth(0);
     // The default result is an empty array
     $result = [];
     $calendarTimeZone = null;
     if ($report->expand) {
         // We're expanding, and for that we need to figure out the
         // calendar's timezone.
         $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone';
         $tzResult = $this->server->getProperties($path, [$tzProp]);
         if (isset($tzResult[$tzProp])) {
             // This property contains a VCALENDAR with a single
             // VTIMEZONE.
             $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
             $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
             unset($vtimezoneObj);
         } else {
             // Defaulting to UTC.
             $calendarTimeZone = new DateTimeZone('UTC');
         }
     }
     // The calendarobject was requested directly. In this case we handle
     // this locally.
     if ($depth == 0 && $node instanceof ICalendarObject) {
         $requestedCalendarData = true;
         $requestedProperties = $report->properties;
         if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
             // We always retrieve calendar-data, as we need it for filtering.
             $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
             // If calendar-data wasn't explicitly requested, we need to remove
             // it after processing.
             $requestedCalendarData = false;
         }
         $properties = $this->server->getPropertiesForPath($path, $requestedProperties, 0);
         // This array should have only 1 element, the first calendar
         // object.
         $properties = current($properties);
         // If there wasn't any calendar-data returned somehow, we ignore
         // this.
         if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
             $validator = new CalendarQueryValidator();
             $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
             if ($validator->validate($vObject, $report->filters)) {
                 // If the client didn't require the calendar-data property,
                 // we won't give it back.
                 if (!$requestedCalendarData) {
                     unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
                 } else {
                     if ($report->expand) {
                         $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
                     }
                     if ($needsJson) {
                         $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize());
                     } elseif ($report->expand) {
                         $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
                     }
                 }
                 $result = [$properties];
             }
         }
     }
     if ($node instanceof ICalendarObjectContainer && $depth === 0) {
         if (strpos($this->server->httpRequest->getHeader('User-Agent'), 'MSFT-WP/') === 0) {
             // Windows phone incorrectly supplied depth as 0, when it actually
             // should have set depth to 1. We're implementing a workaround here
             // to deal with this.
             $depth = 1;
         } else {
             throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1');
         }
     }
     // If we're dealing with a calendar, the calendar itself is responsible
     // for the calendar-query.
     if ($node instanceof ICalendarObjectContainer && $depth == 1) {
         $nodePaths = $node->calendarQuery($report->filters);
         foreach ($nodePaths as $path) {
             list($properties) = $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $report->properties);
             if ($needsJson || $report->expand) {
                 $vObject = VObject\Reader::read($properties[200]['{' . self::NS_CALDAV . '}calendar-data']);
                 if ($report->expand) {
                     $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
                 }
                 if ($needsJson) {
                     $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize());
                 } else {
                     $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
                 }
             }
             $result[] = $properties;
         }
     }
     $prefer = $this->server->getHTTPPrefer();
     $this->server->httpResponse->setStatus(207);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
     $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return'] === 'minimal'));
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:101,代码来源:Plugin.php

示例5: calendarQueryReport


//.........这里部分代码省略.........
  * @return void
  */
 function calendarQueryReport($dom)
 {
     $parser = new CalendarQueryParser($dom);
     $parser->parse();
     $path = $this->server->getRequestUri();
     // TODO: move this into CalendarQueryParser
     $xpath = new \DOMXPath($dom);
     $xpath->registerNameSpace('cal', Plugin::NS_CALDAV);
     $xpath->registerNameSpace('dav', 'urn:DAV');
     $needsJson = $xpath->evaluate("boolean(/cal:calendar-query/dav:prop/cal:calendar-data[@content-type='application/calendar+json'])");
     $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
     $depth = $this->server->getHTTPDepth(0);
     // The default result is an empty array
     $result = [];
     $calendarTimeZone = null;
     if ($parser->expand) {
         // We're expanding, and for that we need to figure out the
         // calendar's timezone.
         $tzProp = '{' . self::NS_CALDAV . '}calendar-timezone';
         $tzResult = $this->server->getProperties($path, [$tzProp]);
         if (isset($tzResult[$tzProp])) {
             // This property contains a VCALENDAR with a single
             // VTIMEZONE.
             $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
             $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
             unset($vtimezoneObj);
         } else {
             // Defaulting to UTC.
             $calendarTimeZone = new DateTimeZone('UTC');
         }
     }
     // The calendarobject was requested directly. In this case we handle
     // this locally.
     if ($depth == 0 && $node instanceof ICalendarObject) {
         $requestedCalendarData = true;
         $requestedProperties = $parser->requestedProperties;
         if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
             // We always retrieve calendar-data, as we need it for filtering.
             $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
             // If calendar-data wasn't explicitly requested, we need to remove
             // it after processing.
             $requestedCalendarData = false;
         }
         $properties = $this->server->getPropertiesForPath($path, $requestedProperties, 0);
         // This array should have only 1 element, the first calendar
         // object.
         $properties = current($properties);
         // If there wasn't any calendar-data returned somehow, we ignore
         // this.
         if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
             $validator = new CalendarQueryValidator();
             $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
             if ($validator->validate($vObject, $parser->filters)) {
                 // If the client didn't require the calendar-data property,
                 // we won't give it back.
                 if (!$requestedCalendarData) {
                     unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
                 } else {
                     if ($parser->expand) {
                         $vObject->expand($parser->expand['start'], $parser->expand['end'], $calendarTimeZone);
                     }
                     if ($needsJson) {
                         $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize());
                     } elseif ($parser->expand) {
                         $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
                     }
                 }
                 $result = [$properties];
             }
         }
     }
     // If we're dealing with a calendar, the calendar itself is responsible
     // for the calendar-query.
     if ($node instanceof ICalendarObjectContainer && $depth == 1) {
         $nodePaths = $node->calendarQuery($parser->filters);
         $timeZones = [];
         foreach ($nodePaths as $path) {
             list($properties) = $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $parser->requestedProperties);
             if ($needsJson || $parser->expand) {
                 $vObject = VObject\Reader::read($properties[200]['{' . self::NS_CALDAV . '}calendar-data']);
                 if ($parser->expand) {
                     $vObject->expand($parser->expand['start'], $parser->expand['end'], $calendarTimeZone);
                 }
                 if ($needsJson) {
                     $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = json_encode($vObject->jsonSerialize());
                 } else {
                     $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
                 }
             }
             $result[] = $properties;
         }
     }
     $prefer = $this->server->getHTTPPRefer();
     $this->server->httpResponse->setStatus(207);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
     $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, $prefer['return-minimal']));
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:101,代码来源:Plugin.php

示例6: calendarQueryReport

 /**
  * This function handles the calendar-query REPORT
  *
  * This report is used by clients to request calendar objects based on
  * complex conditions.
  *
  * @param \DOMNode $dom
  * @return void
  */
 public function calendarQueryReport($dom)
 {
     $parser = new CalendarQueryParser($dom);
     $parser->parse();
     $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
     $depth = $this->server->getHTTPDepth(0);
     // The default result is an empty array
     $result = array();
     // The calendarobject was requested directly. In this case we handle
     // this locally.
     if ($depth == 0 && $node instanceof ICalendarObject) {
         $requestedCalendarData = true;
         $requestedProperties = $parser->requestedProperties;
         if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
             // We always retrieve calendar-data, as we need it for filtering.
             $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
             // If calendar-data wasn't explicitly requested, we need to remove
             // it after processing.
             $requestedCalendarData = false;
         }
         $properties = $this->server->getPropertiesForPath($this->server->getRequestUri(), $requestedProperties, 0);
         // This array should have only 1 element, the first calendar
         // object.
         $properties = current($properties);
         // If there wasn't any calendar-data returned somehow, we ignore
         // this.
         if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
             $validator = new CalendarQueryValidator();
             $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
             if ($validator->validate($vObject, $parser->filters)) {
                 // If the client didn't require the calendar-data property,
                 // we won't give it back.
                 if (!$requestedCalendarData) {
                     unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
                 } else {
                     if ($parser->expand) {
                         $vObject->expand($parser->expand['start'], $parser->expand['end']);
                         $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
                     }
                 }
                 $result = array($properties);
             }
         }
     }
     // If we're dealing with a calendar, the calendar itself is responsible
     // for the calendar-query.
     if ($node instanceof ICalendar && ($depth = 1)) {
         $nodePaths = $node->calendarQuery($parser->filters);
         foreach ($nodePaths as $path) {
             list($properties) = $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $parser->requestedProperties);
             if ($parser->expand) {
                 // We need to do some post-processing
                 $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
                 $vObject->expand($parser->expand['start'], $parser->expand['end']);
                 $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
             }
             $result[] = $properties;
         }
     }
     $prefer = $this->server->getHTTPPRefer();
     $this->server->httpResponse->sendStatus(207);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
     $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
     $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result, $prefer['return-minimal']));
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:74,代码来源:Plugin.php


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