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


PHP XMLUtil::parseClarkNotation方法代码示例

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


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

示例1: drawPropertyRow

 /**
  * Draws a table row for a property
  *
  * @param string $name
  * @param mixed $value
  * @return string
  */
 private function drawPropertyRow($name, $value)
 {
     $view = 'unknown';
     if (is_string($value)) {
         $view = 'string';
     } elseif ($value instanceof DAV\Property) {
         $mapping = ['Sabre\\DAV\\Property\\IHref' => 'href', 'Sabre\\DAV\\Property\\HrefList' => 'hreflist', 'Sabre\\DAV\\Property\\SupportedMethodSet' => 'valuelist', 'Sabre\\DAV\\Property\\ResourceType' => 'xmlvaluelist', 'Sabre\\DAV\\Property\\SupportedReportSet' => 'xmlvaluelist', 'Sabre\\DAVACL\\Property\\CurrentUserPrivilegeSet' => 'xmlvaluelist', 'Sabre\\DAVACL\\Property\\SupportedPrivilegeSet' => 'supported-privilege-set'];
         $view = 'complex';
         foreach ($mapping as $class => $val) {
             if ($value instanceof $class) {
                 $view = $val;
                 break;
             }
         }
     }
     list($ns, $localName) = DAV\XMLUtil::parseClarkNotation($name);
     $realName = $name;
     if (isset($this->server->xmlNamespaces[$ns])) {
         $name = $this->server->xmlNamespaces[$ns] . ':' . $localName;
     }
     ob_start();
     $xmlValueDisplay = function ($propName) {
         $realPropName = $propName;
         list($ns, $localName) = DAV\XMLUtil::parseClarkNotation($propName);
         if (isset($this->server->xmlNamespaces[$ns])) {
             $propName = $this->server->xmlNamespaces[$ns] . ':' . $localName;
         }
         return "<span title=\"" . $this->escapeHTML($realPropName) . "\">" . $this->escapeHTML($propName) . "</span>";
     };
     echo "<tr><th><span title=\"", $this->escapeHTML($realName), "\">", $this->escapeHTML($name), "</span></th><td>";
     switch ($view) {
         case 'href':
             echo "<a href=\"" . $this->server->getBaseUri() . $value->getHref() . '">' . $this->server->getBaseUri() . $value->getHref() . '</a>';
             break;
         case 'hreflist':
             echo implode('<br />', array_map(function ($href) {
                 if (stripos($href, 'mailto:') === 0 || stripos($href, '/') === 0 || stripos($href, 'http:') === 0 || stripos($href, 'https:') === 0) {
                     return "<a href=\"" . $this->escapeHTML($href) . '">' . $this->escapeHTML($href) . '</a>';
                 } else {
                     return "<a href=\"" . $this->escapeHTML($this->server->getBaseUri() . $href) . '">' . $this->escapeHTML($this->server->getBaseUri() . $href) . '</a>';
                 }
             }, $value->getHrefs()));
             break;
         case 'xmlvaluelist':
             echo implode(', ', array_map($xmlValueDisplay, $value->getValue()));
             break;
         case 'valuelist':
             echo $this->escapeHTML(implode(', ', $value->getValue()));
             break;
         case 'supported-privilege-set':
             $traverse = function ($priv) use(&$traverse, $xmlValueDisplay) {
                 echo "<li>";
                 echo $xmlValueDisplay($priv['privilege']);
                 if (isset($priv['abstract']) && $priv['abstract']) {
                     echo " <i>(abstract)</i>";
                 }
                 if (isset($priv['description'])) {
                     echo " " . $this->escapeHTML($priv['description']);
                 }
                 if (isset($priv['aggregates'])) {
                     echo "\n<ul>\n";
                     foreach ($priv['aggregates'] as $subPriv) {
                         $traverse($subPriv);
                     }
                     echo "</ul>";
                 }
                 echo "</li>\n";
             };
             echo "<ul class=\"tree\">";
             $traverse($value->getValue(), '');
             echo "</ul>\n";
             break;
         case 'string':
             echo $this->escapeHTML($value);
             break;
         case 'complex':
             echo '<em title="' . get_class($value) . '">complex</em>';
             break;
         default:
             echo '<em>unknown</em>';
             break;
     }
     return ob_get_clean();
 }
开发者ID:LobbyOS,项目名称:server,代码行数:91,代码来源:Plugin.php

示例2: propPatch

 /**
  * Updates a list of properties on the server
  *
  * The list of properties must have clark-notation properties for the keys,
  * and the actual (string) value for the value. If the value is null, an
  * attempt is made to delete the property.
  *
  * @param string $url
  * @param array $properties
  * @return void
  */
 function propPatch($url, array $properties)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $root = $dom->createElementNS('DAV:', 'd:propertyupdate');
     foreach ($properties as $propName => $propValue) {
         list($namespace, $elementName) = XMLUtil::parseClarkNotation($propName);
         if ($propValue === null) {
             $remove = $dom->createElement('d:remove');
             $prop = $dom->createElement('d:prop');
             if ($namespace === 'DAV:') {
                 $element = $dom->createElement('d:' . $elementName);
             } else {
                 $element = $dom->createElementNS($namespace, 'x:' . $elementName);
             }
             $root->appendChild($remove)->appendChild($prop)->appendChild($element);
         } else {
             $set = $dom->createElement('d:set');
             $prop = $dom->createElement('d:prop');
             if ($namespace === 'DAV:') {
                 $element = $dom->createElement('d:' . $elementName);
             } else {
                 $element = $dom->createElementNS($namespace, 'x:' . $elementName);
             }
             if ($propValue instanceof Property) {
                 $propValue->serialize(new Server(), $element);
             } else {
                 $element->nodeValue = htmlspecialchars($propValue, ENT_NOQUOTES, 'UTF-8');
             }
             $root->appendChild($set)->appendChild($prop)->appendChild($element);
         }
     }
     $dom->appendChild($root);
     $body = $dom->saveXML();
     $url = $this->getAbsoluteUrl($url);
     $request = new HTTP\Request('PROPPATCH', $url, ['Content-Type' => 'application/xml'], $body);
     $this->send($request);
 }
开发者ID:mattes,项目名称:sabre-dav,代码行数:49,代码来源:Client.php

示例3: propReport

 /**
  * Executes a REPORT request to calDAV server
  *
  * @param       $url
  * @param array $properties
  * @param int   $depth
  *
  * @return array
  * @throws Exception
  * @throws \Sabre\HTTP\ClientException
  * @throws \Sabre\HTTP\ClientHttpException
  */
 public function propReport($url, array $properties, $depth = 0)
 {
     //create dom
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $root = $dom->createElementNS('urn:ietf:params:xml:ns:caldav', 'c:calendar-query');
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:d', 'DAV:');
     $prop = $dom->createElement('d:prop');
     $filter = $dom->createElement('c:filter');
     $dat = $dom->createElement('c:comp-filter');
     $dat->setAttribute('name', 'VCALENDAR');
     $filter->appendChild($dat);
     foreach ($properties as $property) {
         list($namespace, $elementName) = XMLUtil::parseClarkNotation($property);
         if ($namespace === 'DAV:') {
             $element = $dom->createElement('d:' . $elementName);
         } else {
             $element = $dom->createElement('c:' . $elementName);
         }
         $prop->appendChild($element);
     }
     $bla = $dom->appendChild($root);
     $bla->appendChild($prop);
     $bla->appendChild($filter);
     $body = $dom->saveXML();
     $url = $this->getAbsoluteUrl($url);
     $request = new Request('REPORT', $url, ['Depth' => $depth, 'Content-Type' => 'application/xml'], $body);
     $response = $this->send($request);
     if ((int) $response->getStatus() >= 400) {
         throw new Exception('HTTP error: ' . $response->getStatus());
     }
     $result = $this->parseMultiStatus($response->getBodyAsString());
     // If depth was 0, we only return the top item
     if ($depth === 0) {
         reset($result);
         $result = current($result);
         return isset($result[200]) ? $result[200] : [];
     }
     $newResult = [];
     foreach ($result as $href => $statusList) {
         $newResult[$href] = isset($statusList[200]) ? $statusList[200] : [];
     }
     return $newResult;
 }
开发者ID:Syren7,项目名称:owncloudApiBundle,代码行数:56,代码来源:CalDavClient.php


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