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


PHP URLUtil::encodePath方法代码示例

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


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

示例1: generateDirectoryIndex

 /**
  * @brief Creates the directory listing for the given path.
  *
  * @param string $path which should be displayed
  */
 public function generateDirectoryIndex($path)
 {
     // (owner_id = channel_id) is visitor owner of this directory?
     $is_owner = local_channel() && $this->auth->owner_id == local_channel() ? true : false;
     if ($this->auth->getTimezone()) {
         date_default_timezone_set($this->auth->getTimezone());
     }
     require_once 'include/conversation.php';
     require_once 'include/text.php';
     if ($this->auth->owner_nick) {
         $html = profile_tabs(get_app(), $is_owner ? true : false, $this->auth->owner_nick);
     }
     $files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
     $parent = $this->server->tree->getNodeForPath($path);
     $parentpath = array();
     // only show parent if not leaving /cloud/; TODO how to improve this?
     if ($path && $path != "cloud") {
         list($parentUri) = \Sabre\HTTP\URLUtil::splitPath($path);
         $fullPath = \Sabre\HTTP\URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
         $parentpath['icon'] = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
         $parentpath['path'] = $fullPath;
     }
     $f = array();
     foreach ($files as $file) {
         $ft = array();
         $type = null;
         // This is the current directory, we can skip it
         if (rtrim($file['href'], '/') == $path) {
             continue;
         }
         list(, $name) = \Sabre\HTTP\URLUtil::splitPath($file['href']);
         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] = t('Collection');
                         break;
                     case '{DAV:}principal':
                         $type[$k] = t('Principal');
                         break;
                     case '{urn:ietf:params:xml:ns:carddav}addressbook':
                         $type[$k] = t('Addressbook');
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}calendar':
                         $type[$k] = t('Calendar');
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}schedule-inbox':
                         $type[$k] = t('Schedule Inbox');
                         break;
                     case '{urn:ietf:params:xml:ns:caldav}schedule-outbox':
                         $type[$k] = t('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 = t('Unknown');
         }
         $size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
         $lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format('Y-m-d H:i:s') : '';
         $fullPath = \Sabre\HTTP\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;
                 }
             }
         }
         $parentHash = '';
         $owner = $this->auth->owner_id;
         $splitPath = explode('/', $fullPath);
//.........这里部分代码省略.........
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:101,代码来源:Browser.php

示例2: serialize

 /**
  * serialize
  *
  * @param DAV\Server $server
  * @param \DOMElement $dom
  * @return void
  */
 function serialize(DAV\Server $server, \DOMElement $dom)
 {
     $document = $dom->ownerDocument;
     $properties = $this->responseProperties;
     $xresponse = $document->createElement('d:response');
     $dom->appendChild($xresponse);
     $uri = URLUtil::encodePath($this->href);
     if ($uri === '/') {
         $uri = '';
     }
     // Adding the baseurl to the beginning of the url
     $uri = $server->getBaseUri() . $uri;
     $xresponse->appendChild($document->createElement('d:href', $uri));
     if ($this->httpStatus) {
         $statusString = "HTTP/1.1 " . $this->httpStatus . " " . HTTP\Response::$statusCodes[$this->httpStatus];
         $xresponse->appendChild($document->createElement('d:status', $statusString));
     }
     // 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)) {
                 if ($propertyValue !== '') {
                     // we want a self-closing xml element for empty strings.
                     $text = $document->createTextNode($propertyValue);
                     $currentProperty->appendChild($text);
                 }
             } elseif ($propertyValue instanceof DAV\PropertyInterface) {
                 $propertyValue->serialize($server, $currentProperty);
             } elseif (!is_null($propertyValue)) {
                 throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
             }
         }
         $xpropstat->appendChild($document->createElement('d:status', 'HTTP/1.1 ' . $httpStatus . ' ' . HTTP\Response::$statusCodes[$httpStatus]));
     }
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:77,代码来源:Response.php

示例3: generateDirectoryIndex

    /**
     * Generates the html directory index for a given url
     *
     * @param string $path
     * @return string
     */
    function generateDirectoryIndex($path)
    {
        $version = '';
        if (DAV\Server::$exposeVersion) {
            $version = DAV\Version::VERSION;
        }
        $vars = ['path' => $this->escapeHTML($path), 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')), 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), 'baseUrl' => $this->server->getBaseUri()];
        $html = <<<HTML
<!DOCTYPE html>
<html>
<head>
    <title>{$vars['path']}/ - sabre/dav {$version}</title>
    <link rel="shortcut icon" href="{$vars['favicon']}"   type="image/vnd.microsoft.icon" />
    <link rel="stylesheet"    href="{$vars['style']}"     type="text/css" />
    <link rel="stylesheet"    href="{$vars['iconstyle']}" type="text/css" />

</head>
<body>
    <header>
        <div class="logo">
            <a href="{$vars['baseUrl']}"><img src="{$vars['logo']}" alt="sabre/dav" /> {$vars['path']}/</a>
        </div>
    </header>

    <nav>
HTML;
        // If the path is empty, there's no parent.
        if ($path) {
            list($parentUri) = URLUtil::splitPath($path);
            $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
            $html .= '<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>';
        } else {
            $html .= '<span class="btn disabled">⇤ Go to parent</span>';
        }
        $html .= "</nav>";
        $node = $this->server->tree->getNodeForPath($path);
        if ($node instanceof DAV\ICollection) {
            $html .= "<section><h1>Nodes</h1>\n";
            $html .= "<table class=\"nodeTable\">";
            $subNodes = $this->server->getPropertiesForChildren($path, ['{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified']);
            foreach ($subNodes as $subPath => $subProps) {
                $subNode = $this->server->tree->getNodeForPath($subPath);
                $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $subPath);
                list(, $displayPath) = URLUtil::splitPath($subPath);
                $subNodes[$subPath]['subNode'] = $subNode;
                $subNodes[$subPath]['fullPath'] = $fullPath;
                $subNodes[$subPath]['displayPath'] = $displayPath;
            }
            uasort($subNodes, [$this, 'compareNodes']);
            foreach ($subNodes as $subProps) {
                $type = ['string' => 'Unknown', 'icon' => 'cog'];
                if (isset($subProps['{DAV:}resourcetype'])) {
                    $type = $this->mapResourceType($subProps['{DAV:}resourcetype']->getValue(), $subProps['subNode']);
                }
                $html .= '<tr>';
                $html .= '<td class="nameColumn"><a href="' . $this->escapeHTML($subProps['fullPath']) . '"><span class="oi" data-glyph="' . $type['icon'] . '"></span> ' . $this->escapeHTML($subProps['displayPath']) . '</a></td>';
                $html .= '<td class="typeColumn">' . $type['string'] . '</td>';
                $html .= '<td>';
                if (isset($subProps['{DAV:}getcontentlength'])) {
                    $html .= $subProps['{DAV:}getcontentlength'] . ' bytes';
                }
                $html .= '</td><td>';
                if (isset($subProps['{DAV:}getlastmodified'])) {
                    $lastMod = $subProps['{DAV:}getlastmodified']->getTime();
                    $html .= $lastMod->format('F j, Y, g:i a');
                }
                $html .= '</td></tr>';
            }
            $html .= '</table>';
        }
        $html .= "</section>";
        $html .= "<section><h1>Properties</h1>";
        $html .= "<table class=\"propTable\">";
        // Allprops request
        $propFind = new PropFindAll($path);
        $properties = $this->server->getPropertiesByNode($propFind, $node);
        $properties = $propFind->getResultForMultiStatus()[200];
        foreach ($properties as $propName => $propValue) {
            $html .= $this->drawPropertyRow($propName, $propValue);
        }
        $html .= "</table>";
        $html .= "</section>";
        /* Start of generating actions */
        $output = '';
        if ($this->enablePost) {
            $this->server->emit('onHTMLActionsPanel', [$node, &$output]);
        }
        if ($output) {
            $html .= "<section><h1>Actions</h1>";
            $html .= "<div class=\"actions\">\n";
            $html .= $output;
            $html .= "</div>\n";
            $html .= "</section>\n";
        }
//.........这里部分代码省略.........
开发者ID:LobbyOS,项目名称:server,代码行数:101,代码来源:Plugin.php

示例4: generateHeader

    /**
     * Generates the first block of HTML, including the <head> tag and page
     * header.
     *
     * Returns footer.
     *
     * @param string $title
     * @param string $path
     * @return void
     */
    function generateHeader($title, $path = null)
    {
        $version = DAV\Version::VERSION;
        $vars = ['title' => $this->escapeHTML($title), 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')), 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')), 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')), 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')), 'baseUrl' => $this->server->getBaseUri()];
        $html = <<<HTML
<!DOCTYPE html>
<html>
<head>
    <title>{$vars['title']} - sabre/dav {$version}</title>
    <link rel="shortcut icon" href="{$vars['favicon']}"   type="image/vnd.microsoft.icon" />
    <link rel="stylesheet"    href="{$vars['style']}"     type="text/css" />
    <link rel="stylesheet"    href="{$vars['iconstyle']}" type="text/css" />

</head>
<body>
    <header>
        <div class="logo">
            <a href="{$vars['baseUrl']}"><img src="{$vars['logo']}" alt="sabre/dav" /> {$vars['title']}</a>
        </div>
    </header>

    <nav>
HTML;
        // If the path is empty, there's no parent.
        if ($path) {
            list($parentUri) = URLUtil::splitPath($path);
            $fullPath = $this->server->getBaseUri() . URLUtil::encodePath($parentUri);
            $html .= '<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>';
        } else {
            $html .= '<span class="btn disabled">⇤ Go to parent</span>';
        }
        $html .= ' <a href="?sabreAction=plugins" class="btn"><span class="oi" data-glyph="puzzle-piece"></span> Plugins</a>';
        $html .= "</nav>";
        return $html;
    }
开发者ID:pageer,项目名称:sabre-dav,代码行数:45,代码来源:Plugin.php

示例5: generateDirectoryIndex

    public function generateDirectoryIndex($path)
    {
        $version = DAV\Server::$exposeVersion ? DAV\Version::VERSION : '';
        $node = $this->server->tree->getNodeForPath($path);
        $html = <<<HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Index for {$this->escapeHTML($path)}/ - SambaDAV</title>
    <link rel="stylesheet" href="{$this->server->getBaseUri()}style.css"/>
    <link rel="shortcut icon" href="{$this->server->getBaseUri()}favicon.ico" type="image/vnd.microsoft.icon"/>
  </head>
  <body>

HTML;
        if ($this->config->anonymous_only === false) {
            $html .= "\n    <p id=\"logout\"><a href=\"?logout\">switch user (logout)</a></p>";
        }
        $html .= <<<HTML
    <h1>{$this->escapeHTML($node->uri->uriFull())}</h1>
    <table id="actions">
      <tbody>

HTML;
        $output = '';
        if ($this->enablePost) {
            $this->server->emit('onHTMLActionsPanel', [$node, &$output]);
        }
        if ($output) {
            $html .= $output;
        }
        $html .= <<<HTML
      </tbody>
    </table>
    <table>
      <colgroup>
        <col width="15px"/>
        <col/>
        <col/>
        <col/>
        <col/>
      </colgroup>
      <thead>
        <tr>
          <th></th>
          <th>Name</th>
          <th>Type</th>
          <th>Size</th>
          <th>Last modified</th>
HTML;
        if ($this->config->browserplugin_enable_delete === true) {
            $html .= "<th>Delete</th>";
        }
        $html .= <<<HTML
        </tr>
      </thead>
      <tbody>

HTML;
        // If path is empty, there is no parent:
        if ($path) {
            list($parentUri) = URLUtil::splitPath($path);
            $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
            $html .= <<<HTML
        <tr class="dir">
          <td><a href="{$fullPath}"><img src="{$this->server->getBaseUri()}dir.png" alt="Parent"/></a></td>
          <td><a href="{$fullPath}">..</a></td>
          <td>[parent]</td>
          <td></td>
          <td></td>
HTML;
            if ($this->config->browserplugin_enable_delete === true) {
                $html .= "<td></td>";
            }
            $html .= <<<HTML
        </tr>

HTML;
        }
        if ($node instanceof DAV\ICollection) {
            $subNodes = $this->server->getPropertiesForChildren($path, ['{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified']);
            foreach ($subNodes as $subPath => $subProps) {
                $subNode = $this->server->tree->getNodeForPath($subPath);
                $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $subPath);
                list(, $displayPath) = URLUtil::splitPath($subPath);
                $subNodes[$subPath]['subNode'] = $subNode;
                $subNodes[$subPath]['fullPath'] = $fullPath;
                $subNodes[$subPath]['displayPath'] = $displayPath;
            }
            uasort($subNodes, [$this, 'compareNodes']);
            foreach ($subNodes as $subProps) {
                $size = isset($subProps['{DAV:}getcontentlength']) ? $subProps['{DAV:}getcontentlength'] : '';
                $lastmodified = isset($subProps['{DAV:}getlastmodified']) ? $subProps['{DAV:}getlastmodified']->getTime()->format('F j, Y, H:i:s') : '';
                $fullPath_decoded = URLUtil::decodePath($subProps['fullPath']);
                $fullPath = $this->escapeHTML($subProps['fullPath']);
                if (isset($subProps['{DAV:}resourcetype']) && in_array('{DAV:}collection', $subProps['{DAV:}resourcetype']->getValue())) {
                    $trclass = 'class="dir"';
                    $icon = 'dir.png';
                    $type = 'Directory';
//.........这里部分代码省略.........
开发者ID:krekike,项目名称:sambadav,代码行数:101,代码来源:BrowserPlugin.php


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