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


PHP Sabre_DAV_URLUtil::encodePath方法代码示例

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


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

示例1: serialize

 /**
  * serialize
  *
  * @param Sabre_DAV_Server $server
  * @param DOMElement $dom
  * @return void
  */
 public function serialize(Sabre_DAV_Server $server, DOMElement $dom)
 {
     $document = $dom->ownerDocument;
     $properties = $this->responseProperties;
     $xresponse = $document->createElement('d:response');
     $dom->appendChild($xresponse);
     $uri = Sabre_DAV_URLUtil::encodePath($this->href);
     // Adding the baseurl to the beginning of the url
     $uri = $server->getBaseUri() . $uri;
     $xresponse->appendChild($document->createElement('d:href', $uri));
     // The properties variable is an array containing properties, grouped by
     // HTTP status
     foreach ($properties as $httpStatus => $propertyGroup) {
         // The 'href' is also in this array, and it's special cased.
         // We will ignore it
         if ($httpStatus == 'href') {
             continue;
         }
         // If there are no properties in this group, we can also just carry on
         if (!count($propertyGroup)) {
             continue;
         }
         $xpropstat = $document->createElement('d:propstat');
         $xresponse->appendChild($xpropstat);
         $xprop = $document->createElement('d:prop');
         $xpropstat->appendChild($xprop);
         $nsList = $server->xmlNamespaces;
         foreach ($propertyGroup as $propertyName => $propertyValue) {
             $propName = null;
             preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName);
             // special case for empty namespaces
             if ($propName[1] == '') {
                 $currentProperty = $document->createElement($propName[2]);
                 $xprop->appendChild($currentProperty);
                 $currentProperty->setAttribute('xmlns', '');
             } else {
                 if (!isset($nsList[$propName[1]])) {
                     $nsList[$propName[1]] = 'x' . count($nsList);
                 }
                 // If the namespace was defined in the top-level xml namespaces, it means
                 // there was already a namespace declaration, and we don't have to worry about it.
                 if (isset($server->xmlNamespaces[$propName[1]])) {
                     $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
                 } else {
                     $currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]);
                 }
                 $xprop->appendChild($currentProperty);
             }
             if (is_scalar($propertyValue)) {
                 $text = $document->createTextNode($propertyValue);
                 $currentProperty->appendChild($text);
             } elseif ($propertyValue instanceof Sabre_DAV_PropertyInterface) {
                 $propertyValue->serialize($server, $currentProperty);
             } elseif (!is_null($propertyValue)) {
                 throw new Sabre_DAV_Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
             }
         }
         $xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:67,代码来源:Response.php

示例2: generateDirectoryIndex

 /**
  * Generates the html directory index for a given url
  *
  * @param string $path
  * @return string
  */
 public function generateDirectoryIndex($path)
 {
     $version = '';
     if (Sabre_DAV_Server::$exposeVersion) {
         $version = Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY;
     }
     $html = "<html>\n<head>\n  <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title>\n  <style type=\"text/css\">\n  body { Font-family: arial}\n  h1 { font-size: 150% }\n  </style>\n        ";
     if ($this->enableAssets) {
         $html .= '<link rel="shortcut icon" href="' . $this->getAssetUrl('favicon.ico') . '" type="image/vnd.microsoft.icon" />';
     }
     $html .= "</head>\n<body>\n  <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n  <table>\n    <tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n    <tr><td colspan=\"5\"><hr /></td></tr>";
     $files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
     $parent = $this->server->tree->getNodeForPath($path);
     if ($path) {
         list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
         $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
         $icon = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>' : '';
         $html .= "<tr>\n    <td>{$icon}</td>\n    <td><a href=\"{$fullPath}\">..</a></td>\n    <td>[parent]</td>\n    <td></td>\n    <td></td>\n    </tr>";
     }
     foreach ($files as $file) {
         // This is the current directory, we can skip it
         if (rtrim($file['href'], '/') == $path) {
             continue;
         }
         list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
         $type = null;
         if (isset($file[200]['{DAV:}resourcetype'])) {
             $type = $file[200]['{DAV:}resourcetype']->getValue();
             // resourcetype can have multiple values
             if (!is_array($type)) {
                 $type = array($type);
             }
             foreach ($type as $k => $v) {
                 // Some name mapping is preferred
                 switch ($v) {
                     case '{DAV:}collection':
                         $type[$k] = 'Collection';
                         break;
                     case '{DAV:}principal':
                         $type[$k] = 'Principal';
                         break;
                     case '{urn:ietf:params:xml:ns:carddav}addressbook':
                         $type[$k] = 'Addressbook';
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}calendar':
                         $type[$k] = 'Calendar';
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}schedule-inbox':
                         $type[$k] = 'Schedule Inbox';
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}schedule-outbox':
                         $type[$k] = 'Schedule Outbox';
                         break;
                     case '{http://calendarserver.org/ns/}calendar-proxy-read':
                         $type[$k] = 'Proxy-Read';
                         break;
                     case '{http://calendarserver.org/ns/}calendar-proxy-write':
                         $type[$k] = 'Proxy-Write';
                         break;
                 }
             }
             $type = implode(', ', $type);
         }
         // If no resourcetype was found, we attempt to use
         // the contenttype property
         if (!$type && isset($file[200]['{DAV:}getcontenttype'])) {
             $type = $file[200]['{DAV:}getcontenttype'];
         }
         if (!$type) {
             $type = 'Unknown';
         }
         $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
         $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM) : '';
         $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
         $displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
         $displayName = $this->escapeHTML($displayName);
         $type = $this->escapeHTML($type);
         $icon = '';
         if ($this->enableAssets) {
             $node = $this->server->tree->getNodeForPath(($path ? $path . '/' : '') . $name);
             foreach (array_reverse($this->iconMap) as $class => $iconName) {
                 if ($node instanceof $class) {
                     $icon = '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl($iconName . $this->iconExtension) . '" alt="" width="24" /></a>';
                     break;
                 }
             }
         }
         $html .= "<tr>\n    <td>{$icon}</td>\n    <td><a href=\"{$fullPath}\">{$displayName}</a></td>\n    <td>{$type}</td>\n    <td>{$size}</td>\n    <td>{$lastmodified}</td>\n    </tr>";
     }
     $html .= "<tr><td colspan=\"5\"><hr /></td></tr>";
     $output = '';
     if ($this->enablePost) {
         $this->server->broadcastEvent('onHTMLActionsPanel', array($parent, &$output));
     }
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:isle-web-framework,代码行数:101,代码来源:Plugin.php

示例3: generateDirectoryIndex

 /**
  * Generates the html directory index for a given url 
  *
  * @param string $path 
  * @return string 
  */
 public function generateDirectoryIndex($path)
 {
     $html = "<html>\n<head>\n  <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "</title>\n  <style type=\"text/css\"> body { Font-family: arial}</style>\n</head>\n<body>\n  <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n  <table>\n    <tr><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n    <tr><td colspan=\"4\"><hr /></td></tr>";
     $files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
     $parent = $this->server->tree->getNodeForPath($path);
     if ($path) {
         list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
         $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
         $html .= "<tr>\n<td><a href=\"{$fullPath}\">..</a></td>\n<td>[parent]</td>\n<td></td>\n<td></td>\n</tr>";
     }
     foreach ($files as $k => $file) {
         // This is the current directory, we can skip it
         if (rtrim($file['href'], '/') == $path) {
             continue;
         }
         list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
         $type = null;
         if (isset($file[200]['{DAV:}resourcetype'])) {
             $type = $file[200]['{DAV:}resourcetype']->getValue();
             // resourcetype can have multiple values
             if (!is_array($type)) {
                 $type = array($type);
             }
             foreach ($type as $k => $v) {
                 // Some name mapping is preferred
                 switch ($v) {
                     case '{DAV:}collection':
                         $type[$k] = 'Collection';
                         break;
                     case '{DAV:}principal':
                         $type[$k] = 'Principal';
                         break;
                     case '{urn:ietf:params:xml:ns:carddav}addressbook':
                         $type[$k] = 'Addressbook';
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}calendar':
                         $type[$k] = 'Calendar';
                         break;
                 }
             }
             $type = implode(', ', $type);
         }
         // If no resourcetype was found, we attempt to use
         // the contenttype property
         if (!$type && isset($file[200]['{DAV:}getcontenttype'])) {
             $type = $file[200]['{DAV:}getcontenttype'];
         }
         if (!$type) {
             $type = 'Unknown';
         }
         $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
         $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM) : '';
         $fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
         $displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
         $name = $this->escapeHTML($name);
         $displayName = $this->escapeHTML($displayName);
         $type = $this->escapeHTML($type);
         $html .= "<tr>\n<td><a href=\"{$fullPath}\">{$displayName}</a></td>\n<td>{$type}</td>\n<td>{$size}</td>\n<td>{$lastmodified}</td>\n</tr>";
     }
     $html .= "<tr><td colspan=\"4\"><hr /></td></tr>";
     if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) {
         $html .= '<tr><td><form method="post" action="">
         <h3>Create new folder</h3>
         <input type="hidden" name="sabreAction" value="mkcol" />
         Name: <input type="text" name="name" /><br />
         <input type="submit" value="create" />
         </form>
         <form method="post" action="" enctype="multipart/form-data">
         <h3>Upload file</h3>
         <input type="hidden" name="sabreAction" value="put" />
         Name (optional): <input type="text" name="name" /><br />
         File: <input type="file" name="file" /><br />
         <input type="submit" value="upload" />
         </form>
    </td></tr>';
     }
     $html .= "</table>\n  <address>Generated by SabreDAV " . Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY . " (c)2007-2012 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>\n</body>\n</html>";
     return $html;
 }
开发者ID:kumarsivarajan,项目名称:mollify,代码行数:85,代码来源:Plugin.php

示例4: beforeGetProperties

 /**
  * Adds all CardDAV-specific properties
  *
  * @param string $path
  * @param Sabre_DAV_INode $node
  * @param array $requestedProperties
  * @param array $returnedProperties
  * @return void
  */
 public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties)
 {
     if ($node instanceof Sabre_DAVACL_IPrincipal) {
         // calendar-home-set property
         $addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set';
         if (in_array($addHome, $requestedProperties)) {
             $principalId = $node->getName();
             $addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/';
             unset($requestedProperties[array_search($addHome, $requestedProperties)]);
             $returnedProperties[200][$addHome] = new Sabre_DAV_Property_Href(Sabre_DAV_URLUtil::encodePath($addressbookHomePath));
         }
         $directories = '{' . self::NS_CARDDAV . '}directory-gateway';
         if ($this->directories && in_array($directories, $requestedProperties)) {
             unset($requestedProperties[array_search($directories, $requestedProperties)]);
             $returnedProperties[200][$directories] = new Sabre_DAV_Property_HrefList($this->directories);
         }
     }
     if ($node instanceof Sabre_CardDAV_ICard) {
         // The address-data property is not supposed to be a 'real'
         // property, but in large chunks of the spec it does act as such.
         // Therefore we simply expose it as a property.
         $addressDataProp = '{' . self::NS_CARDDAV . '}address-data';
         if (in_array($addressDataProp, $requestedProperties)) {
             unset($requestedProperties[$addressDataProp]);
             $val = $node->get();
             if (is_resource($val)) {
                 $val = stream_get_contents($val);
             }
             $returnedProperties[200][$addressDataProp] = $val;
         }
     }
     if ($node instanceof Sabre_CardDAV_UserAddressBooks) {
         $meCardProp = '{http://calendarserver.org/ns/}me-card';
         if (in_array($meCardProp, $requestedProperties)) {
             $props = $this->server->getProperties($node->getOwner(), array('{http://sabredav.org/ns}vcard-url'));
             if (isset($props['{http://sabredav.org/ns}vcard-url'])) {
                 $returnedProperties[200][$meCardProp] = new Sabre_DAV_Property_Href($props['{http://sabredav.org/ns}vcard-url']);
                 $pos = array_search($meCardProp, $requestedProperties);
                 unset($requestedProperties[$pos]);
             }
         }
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:52,代码来源:Plugin.php

示例5: testDecodeAccentsWindows7

 /**
  * This testcase was sent by a bug reporter
  *
  * @depends testDecode
  */
 function testDecodeAccentsWindows7()
 {
     $str = '/webdav/%C3%A0fo%C3%B3';
     $newStr = Sabre_DAV_URLUtil::decodePath($str);
     $this->assertEquals(strtolower($str), Sabre_DAV_URLUtil::encodePath($newStr));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:11,代码来源:URLUtilTest.php

示例6: generateDirectoryIndex

 /**
  * Rewriting for SabreDAV Browser plugin
  *
  * @param String $path
  *
  * @return String
  *
  * @see plugins/webdav/lib/Sabre/DAV/Browser/Sabre_DAV_Browser_Plugin#generateDirectoryIndex($path)
  */
 public function generateDirectoryIndex($path)
 {
     $node = $this->server->tree->getNodeForPath($path);
     $class = get_class($node);
     echo $GLOBALS['HTML']->pv_header(array('title' => ' WebDAV : ' . $node->getName()));
     ob_start();
     echo "<h3>" . $node->getName() . "</h3>";
     echo '';
     echo "<table>\n        <tr><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'name') . "</th><th>Type</th>";
     if ($class == 'WebDAVFRS' && $node->userCanWrite()) {
         echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>";
     }
     if ($class == 'WebDAVFRSPackage') {
         echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>";
         if ($node->userCanWrite()) {
             echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>";
             /*<th>".$GLOBALS['Language']->getText('plugin_webdav_html', 'move')."</th>";*/
         }
     }
     if ($class == 'WebDAVFRSRelease') {
         echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'size') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>";
         if ($node->userCanWrite()) {
             echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th>";
             /*<th>".$GLOBALS['Language']->getText('plugin_webdav_html', 'move')."</th>";*/
         }
     }
     if ($class == 'WebDAVDocmanFolder') {
         echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'size') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'last_modified') . "</th>";
         $docmanPermissionManager = $node->getUtils()->getDocmanPermissionsManager($node->getProject());
         if ($node->getUtils()->isWriteEnabled() && $docmanPermissionManager->userCanWrite($node->getUser(), $node->getItem()->getId())) {
             echo "<th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'delete') . "</th><th>" . $GLOBALS['Language']->getText('plugin_webdav_html', 'rename') . "</th>";
         }
     }
     echo "</tr><tr><td colspan=\"6\"><hr /></td></tr>";
     $files = $this->server->getPropertiesForPath($path, array('{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
     if ($path) {
         list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
         $fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
         echo "<tr><td><a href=\"{$fullPath}\">..</a></td></tr>";
     }
     foreach ($files as $file) {
         // This is the current directory, we can skip it
         if (rtrim($file['href'], '/') == $path) {
             continue;
         }
         list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
         $type = null;
         if (isset($file[200]['{DAV:}resourcetype'])) {
             $type = $file[200]['{DAV:}resourcetype']->getValue();
             // resourcetype can have multiple values
             if (!is_array($type)) {
                 $type = array($type);
             }
             foreach ($type as $k => $v) {
                 // Some name mapping is preferred
                 if ($v == '{DAV:}collection') {
                     $type[$k] = $GLOBALS["Language"]->getText("plugin_webdav_html", "directory");
                 } elseif ($v == '') {
                     if (isset($file[200]['{DAV:}getcontenttype'])) {
                         $type[$k] = $file[200]['{DAV:}getcontenttype'];
                     } else {
                         $type[$k] = $GLOBALS["Language"]->getText("plugin_webdav_html", "unknown");
                     }
                 }
             }
             $type = implode(', ', $type);
         }
         $type = $this->escapeHTML($type);
         $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
         $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DATE_ATOM) : '';
         $fullPath = '/' . trim($this->server->getBaseUri() . ($path ? $this->escapeHTML($path) . '/' : '') . $name, '/');
         echo str_replace("%", "%25", "<tr><td><a href=\"{$fullPath}\">{$name}</a></td>");
         echo "<td>{$type}</td>";
         if ($class == 'WebDAVFRS' && $node->userCanWrite()) {
             $this->deleteForm($file);
             $this->renameForm($file);
         }
         if ($class == 'WebDAVFRSPackage') {
             echo "<td>{$lastmodified}</td>";
             if ($node->userCanWrite()) {
                 $this->deleteForm($file);
                 $this->renameForm($file);
                 $destinations = $this->getReleaseDestinations($file);
                 //$this->moveForm($file, $destinations);
             }
         }
         if ($class == 'WebDAVFRSRelease') {
             echo "<td>{$size}</td>";
             echo "<td>{$lastmodified}</td>";
             if ($node->userCanWrite()) {
                 $this->deleteForm($file);
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:tuleap,代码行数:101,代码来源:BrowserPlugin.class.php


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