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


PHP Site::splitPath方法代码示例

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


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

示例1: getSourceNodes

 public static function getSourceNodes($paths, $root, $contentType = null)
 {
     $paths = static::splitMultipath($paths);
     if (is_string($root)) {
         $root = Site::splitPath($root);
     }
     $sourceFiles = array();
     foreach ($paths as $path) {
         $path = array_merge($root, $path);
         list($filename) = array_slice($path, -1);
         if ($filename == '*') {
             array_pop($path);
             Emergence_FS::cacheTree($path);
             foreach (Emergence_FS::getTreeFiles($path, false, $contentType ? array('Type' => $contentType) : null) as $path => $fileData) {
                 $sourceFiles[$path] = $fileData;
             }
         } else {
             $node = Site::resolvePath($path);
             if (!$node || !is_a($node, 'SiteFile')) {
                 throw new Exception('Source file "' . implode('/', $path) . '" does not exist', self::ERROR_NOT_FOUND);
             }
             if ($node->Type != $contentType) {
                 throw new Exception('Source file "' . implode('/', $path) . '" does not match requested content type "' . $contentType . '"', self::ERROR_TYPE_MISMATCH);
             }
             $sourceFiles[join('/', $path)] = array('ID' => $node->ID, 'SHA1' => $node->SHA1);
         }
     }
     return $sourceFiles;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:29,代码来源:MinifiedRequestHandler.class.php

示例2: getByEmergenceVFS

 public static function getByEmergenceVFS($path)
 {
     $vfsPath = static::get_virtual_path(str_replace('vfs://', '', $path));
     $templateNode = false;
     $streamPath = Site::splitPath($vfsPath);
     if (!empty($streamPath[0])) {
         $topFolder = array_shift($streamPath);
         $localRoot = Site::getRootCollection($topFolder);
         $searchStack = array_filter($streamPath);
         while (true) {
             $searchPath = $searchStack;
             if ($templateNode = $localRoot->resolvePath($searchPath)) {
                 break;
             }
             if ($templateNode = Emergence::resolveFileFromParent($topFolder, $searchPath)) {
                 break;
             }
             if (count($searchStack)) {
                 array_pop($searchStack);
             } else {
                 break;
             }
         }
     }
     return $templateNode;
 }
开发者ID:JarvusInnovations,项目名称:Emergence-preview,代码行数:26,代码来源:Emergence_Stream_Wrapper.class.php

示例3: httpGetInterceptor

 public function httpGetInterceptor($method, $uri)
 {
     if ($method !== 'GET' || DevelopRequestHandler::getResponseMode() != 'json') {
         return true;
     }
     $pathParts = \Site::splitPath($uri);
     $rootPath = RootCollection::filterName($pathParts[0]);
     if (count($pathParts) && array_key_exists($rootPath, RootCollection::$siteDirectories)) {
         $className = RootCollection::$siteDirectories[$rootPath];
         $node = new $className($pathParts[0]);
         if (count($pathParts) > 1) {
             $node = $node->resolvePath(array_splice($pathParts, 1));
         }
     } else {
         $node = \Site::resolvePath($uri, false);
     }
     if (!$node) {
         throw new \Sabre\DAV\Exception\FileNotFound();
     }
     $children = array();
     foreach ($node->getChildren() as $child) {
         $children[] = $child->getData();
     }
     $this->server->httpResponse->sendStatus(200);
     $this->server->httpResponse->setHeader('Content-Type', 'application/json');
     $this->server->httpResponse->sendBody(json_encode(array('path' => $uri, 'children' => $children)));
     return false;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:28,代码来源:ServerPlugin.php

示例4: export

 function export($path = null, $destination = null)
 {
     set_time_limit(0);
     if (!is_array($path) && !empty($path)) {
         $path = Site::splitPath($path);
     }
     if (empty($path)) {
         $files = DB::allRecords('SELECT MAX(`ID`) as `RID`' . ' FROM `_e_files`' . ' GROUP BY  `Handle`,`CollectionID`');
         foreach ($files as $file) {
             $SiteFile = SiteFile::getByID($file['RID'])->getData();
             if (strpos($SiteFile['FullPath'], '_parent') !== 0 && $SiteFile['Status'] != 'Deleted') {
                 $SiteFiles[$SiteFile['FullPath']] = Site::$rootPath . '/data/' . $SiteFile['ID'];
             }
         }
     } else {
         throw new Exception('Sub directories not yet supported.');
     }
     if (count($SiteFiles)) {
         $zip = new ZipArchive();
         $tmp = $destination ? $destination : tempnam("/tmp", "emr");
         if ($zip->open($tmp) === TRUE) {
             foreach ($SiteFiles as $virtualPath => $realPath) {
                 $zip->addFromString($virtualPath, file_get_contents($realPath));
             }
         }
         $zip->close();
         return $tmp;
     } else {
         throw new Exception('Nothing to compress found.');
     }
 }
开发者ID:JarvusInnovations,项目名称:Emergence-preview,代码行数:31,代码来源:EmergenceIO.class.php

示例5: resolvePath

 public function resolvePath($path)
 {
     if (!is_array($path)) {
         $path = \Site::splitPath($path);
     }
     $node = $this;
     while ($childHandle = array_shift($path)) {
         if (method_exists($node, 'getChild') && ($nextNode = $node->getChild($childHandle))) {
             $node = $nextNode;
         } else {
             $node = false;
             break;
         }
     }
     return $node;
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:16,代码来源:ParentCollection.php

示例6: createFromPath

 public static function createFromPath($path, $data = null, $ancestorID = null)
 {
     if (!is_array($path)) {
         $path = Site::splitPath($path);
     }
     $parentCollection = null;
     // create collections
     while (count($path) > 1) {
         $parentCollection = SiteCollection::getOrCreateCollection(array_shift($path), $parentCollection);
     }
     return static::create($parentCollection->ID, $path[0], $data, $ancestorID);
 }
开发者ID:KnightAR,项目名称:Emergence,代码行数:12,代码来源:SiteFile.class.php

示例7: getCollectionLayers

 public static function getCollectionLayers($path, $localOnly = false)
 {
     // split path into array
     if (is_string($path)) {
         $path = Site::splitPath($path);
     }
     // resolve local and remote collections
     $rootHandle = array_shift($path);
     $localCollection = SiteCollection::getByHandle($rootHandle, null, false);
     if (!$localOnly) {
         $remoteCollection = SiteCollection::getByHandle($rootHandle, null, true);
     }
     while ($handle = array_shift($path)) {
         if ($localCollection) {
             $localCollection = SiteCollection::getByHandle($handle, $localCollection->ID, false);
         }
         if ($remoteCollection) {
             $remoteCollection = SiteCollection::getByHandle($handle, $remoteCollection->ID, true);
         }
     }
     return array_filter(array('remote' => $remoteCollection, 'local' => $localCollection));
 }
开发者ID:JarvusInnovations,项目名称:Emergence,代码行数:22,代码来源:Emergence_FS.class.php

示例8: resolveFileFromParent

 public static function resolveFileFromParent($collection, $path, $forceRemote = false, $params = array())
 {
     if (!Site::getConfig('parent_hostname')) {
         return false;
     }
     // get collection for parent site
     if (is_string($collection)) {
         $collection = SiteCollection::getOrCreateRootCollection($collection, true);
     }
     if (is_string($path)) {
         $path = Site::splitPath($path);
     }
     // try to get existing cached file
     $fileNode = $collection->resolvePath($path);
     // try to download from parent site
     if ($forceRemote || !$fileNode) {
         if (!Site::$autoPull) {
             return false;
         }
         $remoteURL = static::buildUrl(array_merge($collection->getFullPath(null, false), $path), $params);
         $cachedStatus = Cache::rawFetch($remoteURL);
         if ($cachedStatus) {
             return false;
         }
         $fp = fopen('php://memory', 'w+');
         $ch = curl_init($remoteURL);
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_HEADER, true);
         if (curl_exec($ch) === false || curl_errno($ch)) {
             throw new Exception('Failed to query parent site for file: ' . curl_error($ch));
         }
         // read response
         fseek($fp, 0);
         // read and check status
         list($protocol, $status, $message) = explode(' ', trim(fgetss($fp)));
         if ($status != '200') {
             fclose($fp);
             Cache::rawStore($remoteURL, (int) $status);
             return false;
         }
         // read headers until a blank line is found
         while ($header = trim(fgetss($fp))) {
             if (!$header) {
                 break;
             }
             list($key, $value) = preg_split('/:\\s*/', $header, 2);
             $key = strtolower($key);
             // if etag found, use it to skip write if existing file matches
             if ($key == 'etag' && $fileNode && $fileNode->SHA1 == $value) {
                 fclose($fp);
                 return $fileNode;
             }
         }
         // write remaining buffer to file
         $fileRecord = $collection->createFile($path, $fp);
         $fileNode = new SiteFile($fileRecord['Handle'], $fileRecord);
     }
     return $fileNode;
 }
开发者ID:JarvusInnovations,项目名称:Emergence,代码行数:59,代码来源:Emergence.class.php

示例9: getOrCreatePath

 public static function getOrCreatePath($path, SiteCollection $root = null)
 {
     if (!is_array($path)) {
         $path = Site::splitPath($path);
     }
     $collection = $root;
     // create collections
     while (count($path)) {
         $collection = static::getOrCreateCollection(array_shift($path), $collection);
     }
     return $collection;
 }
开发者ID:KnightAR,项目名称:Emergence,代码行数:12,代码来源:SiteCollection.class.php

示例10: getVersionedPath

 public function getVersionedPath($filePath, $useCache = false)
 {
     if (is_string($filePath)) {
         $filePath = Site::splitPath($filePath);
     }
     $Asset = $this->getAsset($filePath);
     $assetPath = Sencha_RequestHandler::$externalRoot . '/' . $this->getName() . '/' . implode('/', $filePath);
     if ($Asset) {
         return $assetPath . '?_sha1=' . $Asset->SHA1;
     } else {
         return $assetPath;
     }
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:13,代码来源:Sencha_App.class.php

示例11: createFile

 public function createFile($path, $data = null, $ancestorID = null)
 {
     if (!is_array($path)) {
         $path = Site::splitPath($path);
     }
     $parentCollection = $this;
     // create collections
     while (count($path) > 1) {
         $parentCollection = static::getOrCreateCollection(array_shift($path), $parentCollection);
     }
     $fileClass = static::$fileClass;
     $fileClass::create($parentCollection->ID, $path[0], $data, $ancestorID);
 }
开发者ID:JarvusInnovations,项目名称:Emergence-preview,代码行数:13,代码来源:SiteCollection.class.php

示例12: getVersionedLibraryPath

 public static function getVersionedLibraryPath($filePath)
 {
     if (is_string($filePath)) {
         $filePath = Site::splitPath($filePath);
     }
     $assetPath = Sencha_RequestHandler::$externalRoot . '/x/' . implode('/', $filePath);
     array_unshift($filePath, 'ext-library');
     $Asset = Site::resolvePath($filePath);
     if ($Asset) {
         return $assetPath . '?_sha1=' . $Asset->SHA1;
     } else {
         return $assetPath;
     }
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:14,代码来源:Sencha.class.php


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