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


PHP Path::combine方法代码示例

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


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

示例1: execute

 public function execute(Request $request, WorkingFolder $workingFolder, Config $config, CacheManager $cache)
 {
     $fileName = (string) $request->get('fileName');
     if (null === $fileName || !File::isValidName($fileName, $config->get('disallowUnsafeCharacters'))) {
         throw new InvalidRequestException('Invalid file name');
     }
     if (!Image::isSupportedExtension(pathinfo($fileName, PATHINFO_EXTENSION))) {
         throw new InvalidNameException('Invalid source file name');
     }
     if (!$workingFolder->containsFile($fileName)) {
         throw new FileNotFoundException();
     }
     $cachePath = Path::combine($workingFolder->getResourceType()->getName(), $workingFolder->getClientCurrentFolder(), $fileName);
     $imageInfo = array();
     $cachedInfo = $cache->get($cachePath);
     if ($cachedInfo && isset($cachedInfo['width']) && isset($cachedInfo['height'])) {
         $imageInfo = $cachedInfo;
     } else {
         $file = new DownloadedFile($fileName, $this->app);
         if ($file->isValid()) {
             $image = Image::create($file->getContents());
             $imageInfo = $image->getInfo();
             $cache->set($cachePath, $imageInfo);
         }
     }
     return $imageInfo;
 }
开发者ID:knodejs,项目名称:ckfinder_gulp,代码行数:27,代码来源:ImageInfo.php

示例2: execute

 public function execute(Request $request, WorkingFolder $workingFolder, EventDispatcher $dispatcher, CacheManager $cache, ResizedImageRepository $resizedImageRepository, ThumbnailRepository $thumbnailRepository, Acl $acl)
 {
     $fileName = (string) $request->query->get('fileName');
     $editedImage = new EditedImage($fileName, $this->app);
     $saveAsNew = false;
     if (!$editedImage->exists()) {
         $saveAsNew = true;
         $editedImage->saveAsNew(true);
     } else {
         // If file exists check for FILE_DELETE permission
         $resourceTypeName = $workingFolder->getResourceType()->getName();
         $path = $workingFolder->getClientCurrentFolder();
         if (!$acl->isAllowed($resourceTypeName, $path, Permission::FILE_DELETE)) {
             throw new UnauthorizedException(sprintf('Unauthorized: no FILE_DELETE permission in %s:%s', $resourceTypeName, $path));
         }
     }
     if (!Image::isSupportedExtension($editedImage->getExtension())) {
         throw new InvalidExtensionException('Unsupported image type or not image file');
     }
     $imageFormat = Image::mimeTypeFromExtension($editedImage->getExtension());
     $uploadedData = (string) $request->request->get('content');
     if (null === $uploadedData || strpos($uploadedData, 'data:image/png;base64,') !== 0) {
         throw new InvalidUploadException('Invalid upload. Expected base64 encoded PNG image.');
     }
     $data = explode(',', $uploadedData);
     $data = isset($data[1]) ? base64_decode($data[1]) : false;
     if (!$data) {
         throw new InvalidUploadException();
     }
     try {
         $uploadedImage = Image::create($data);
     } catch (\Exception $e) {
         // No need to check if secureImageUploads is enabled - image must be valid here
         throw new InvalidUploadException('Invalid upload: corrupted image', Error::UPLOADED_CORRUPT, array(), $e);
     }
     $editedImage->setNewContents($uploadedImage->getData($imageFormat));
     $editedImage->setNewDimensions($uploadedImage->getWidth(), $uploadedImage->getHeight());
     if (!$editedImage->isValid()) {
         throw new InvalidUploadException('Invalid file provided');
     }
     $editFileEvent = new EditFileEvent($this->app, $editedImage);
     $imageInfo = $uploadedImage->getInfo();
     $cache->set(Path::combine($workingFolder->getResourceType()->getName(), $workingFolder->getClientCurrentFolder(), $fileName), $uploadedImage->getInfo());
     $dispatcher->dispatch(CKFinderEvent::SAVE_IMAGE, $editFileEvent);
     $saved = false;
     if (!$editFileEvent->isPropagationStopped()) {
         $saved = $editedImage->save($editFileEvent->getNewContents());
         if (!$saved) {
             throw new AccessDeniedException("Couldn't save image file");
         }
         //Remove thumbnails and resized images in case if file is overwritten
         if (!$saveAsNew && $saved) {
             $resourceType = $workingFolder->getResourceType();
             $thumbnailRepository->deleteThumbnails($resourceType, $workingFolder->getClientCurrentFolder(), $fileName);
             $resizedImageRepository->deleteResizedImages($resourceType, $workingFolder->getClientCurrentFolder(), $fileName);
         }
     }
     return array('saved' => (int) $saved, 'date' => Utils::formatDate(time()), 'size' => Utils::formatSize($imageInfo['size']));
 }
开发者ID:slion0725,项目名称:admin_ci303,代码行数:59,代码来源:SaveImage.php

示例3: execute

 /**
  * Main command method.
  *
  * @param Request       $request       Current request object
  * @param WorkingFolder $workingFolder Current working folder object
  *
  * @return array
  *
  * @throws \Exception
  */
 public function execute(Request $request, WorkingFolder $workingFolder)
 {
     $fileName = $request->get('fileName');
     $backend = $workingFolder->getBackend();
     if (!$workingFolder->containsFile($fileName)) {
         throw new \Exception('File not found', Error::FILE_NOT_FOUND);
     }
     $fileMetadada = $backend->getMetadata(Path::combine($workingFolder->getPath(), $fileName));
     return $fileMetadada;
 }
开发者ID:ckfinder,项目名称:ckfinder-docs-samples-php,代码行数:20,代码来源:GetFileInfo.php

示例4: doDelete

 /**
  * Deletes the current file.
  *
  * @return bool `true` if the file was deleted successfully.
  *
  * @throws \Exception
  */
 public function doDelete()
 {
     if ($this->resourceType->getBackend()->delete($this->getFilePath())) {
         $this->deleteThumbnails();
         $this->deleteResizedImages();
         $this->getCache()->delete(Path::combine($this->resourceType->getName(), $this->folder, $this->getFilename()));
         return true;
     } else {
         $this->addError(Error::ACCESS_DENIED);
         return false;
     }
 }
开发者ID:slion0725,项目名称:admin_ci303,代码行数:19,代码来源:DeletedFile.php

示例5: execute

 public function execute(Request $request, Config $config, WorkingFolder $workingFolder, ResizedImageRepository $resizedImageRepository, CacheManager $cache)
 {
     $fileName = (string) $request->query->get('fileName');
     list($requestedWidth, $requestedHeight) = Image::parseSize((string) $request->get('size'));
     $downloadedFile = new DownloadedFile($fileName, $this->app);
     $downloadedFile->isValid();
     if (!Image::isSupportedExtension(pathinfo($fileName, PATHINFO_EXTENSION), $config->get('thumbnails.bmpSupported'))) {
         throw new InvalidExtensionException('Unsupported image type or not image file');
     }
     Utils::removeSessionCacheHeaders();
     $response = new Response();
     $response->setPublic();
     $response->setEtag(dechex($downloadedFile->getTimestamp()) . "-" . dechex($downloadedFile->getSize()));
     $lastModificationDate = new \DateTime();
     $lastModificationDate->setTimestamp($downloadedFile->getTimestamp());
     $response->setLastModified($lastModificationDate);
     if ($response->isNotModified($request)) {
         return $response;
     }
     $imagePreviewCacheExpires = (int) $config->get('cache.imagePreview');
     if ($imagePreviewCacheExpires > 0) {
         $response->setMaxAge($imagePreviewCacheExpires);
         $expireTime = new \DateTime();
         $expireTime->modify('+' . $imagePreviewCacheExpires . 'seconds');
         $response->setExpires($expireTime);
     }
     $cachedInfoPath = Path::combine($workingFolder->getResourceType()->getName(), $workingFolder->getClientCurrentFolder(), $fileName);
     $cachedInfo = $cache->get($cachedInfoPath);
     $resultImage = null;
     // Try to reuse existing resized image
     if ($cachedInfo && isset($cachedInfo['width']) && isset($cachedInfo['height'])) {
         // Fix received aspect ratio
         $size = Image::calculateAspectRatio($requestedWidth, $requestedHeight, $cachedInfo['width'], $cachedInfo['height']);
         $resizedImage = $resizedImageRepository->getResizedImageBySize($workingFolder->getResourceType(), $workingFolder->getClientCurrentFolder(), $fileName, $size['width'], $size['height']);
         if ($resizedImage) {
             $resultImage = Image::create($resizedImage->getImageData());
         }
     }
     // Fallback - get and resize the original image
     if (null === $resultImage) {
         $resultImage = Image::create($downloadedFile->getContents(), $config->get('thumbnails.bmpSupported'));
         $cache->set($cachedInfoPath, $resultImage->getInfo());
         $resultImage->resize($requestedWidth, $requestedHeight);
     }
     $mimeType = $resultImage->getMimeType();
     if (in_array($mimeType, array('image/bmp', 'image/x-ms-bmp'))) {
         $mimeType = 'image/jpeg';
         // Image::getData() by default converts resized images to JPG
     }
     $response->headers->set('Content-Type', $mimeType . '; name="' . $downloadedFile->getFileName() . '"');
     $response->setContent($resultImage->getData());
     return $response;
 }
开发者ID:knodejs,项目名称:ckfinder_gulp,代码行数:53,代码来源:ImagePreview.php

示例6: doRename

 /**
  * Renames current file
  *
  * @return bool true if file was renamed successfully
  *
  * @throws \Exception
  */
 public function doRename()
 {
     $oldPath = Path::combine($this->getPath(), $this->getFilename());
     $newPath = Path::combine($this->getPath(), $this->newFileName);
     $backend = $this->resourceType->getBackend();
     if ($backend->has($newPath)) {
         throw new AlreadyExistsException('Target file already exists');
     }
     $this->deleteThumbnails();
     $this->resourceType->getResizedImageRepository()->renameResizedImages($this->resourceType, $this->folder, $this->getFilename(), $this->newFileName);
     $this->getCache()->move(Path::combine($this->resourceType->getName(), $this->folder, $this->getFilename()), Path::combine($this->resourceType->getName(), $this->folder, $this->newFileName));
     return $backend->rename($oldPath, $newPath);
 }
开发者ID:valodiapilquevitch,项目名称:Relatorio-de-alunos,代码行数:20,代码来源:RenamedFile.php

示例7: doMove

 /**
  * Moves the current file.
  *
  * @return bool `true` if the file was moved successfully.
  *
  * @throws \Exception
  */
 public function doMove()
 {
     $originalFilePath = $this->getFilePath();
     $originalFileName = $this->getFilename();
     // Save original file name - it may be autorenamed when copied
     if (parent::doCopy()) {
         // Remove source file
         $this->deleteThumbnails();
         $this->resourceType->getResizedImageRepository()->deleteResizedImages($this->resourceType, $this->folder, $originalFileName);
         $this->getCache()->delete(Path::combine($this->resourceType->getName(), $this->folder, $originalFileName));
         return $this->resourceType->getBackend()->delete($originalFilePath);
     }
     return false;
 }
开发者ID:knodejs,项目名称:ckfinder_gulp,代码行数:21,代码来源:MovedFile.php

示例8: execute

 public function execute(WorkingFolder $workingFolder)
 {
     $directories = $workingFolder->listDirectories();
     $data = new \stdClass();
     $data->folders = array();
     $backend = $workingFolder->getBackend();
     $resourceType = $workingFolder->getResourceType();
     foreach ($directories as $directory) {
         $data->folders[] = array('name' => $directory['basename'], 'hasChildren' => $backend->containsDirectories($resourceType, Path::combine($workingFolder->getClientCurrentFolder(), $directory['basename'])), 'acl' => $directory['acl']);
     }
     // Sort folders
     usort($data->folders, function ($a, $b) {
         return strnatcasecmp($a['name'], $b['name']);
     });
     return $data;
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:16,代码来源:GetFolders.php

示例9: execute

 public function execute(Request $request, WorkingFolder $workingFolder, EventDispatcher $dispatcher, CacheManager $cache, ResizedImageRepository $resizedImageRepository, ThumbnailRepository $thumbnailRepository)
 {
     $fileName = $request->query->get('fileName');
     $editedFile = new EditedFile($fileName, $this->app);
     $saveAsNew = false;
     if (!$editedFile->exists()) {
         $saveAsNew = true;
         $editedFile->saveAsNew(true);
     }
     if (!$editedFile->isValid()) {
         throw new InvalidUploadException('Invalid file provided');
     }
     if (!Image::isSupportedExtension($editedFile->getExtension())) {
         throw new InvalidExtensionException('Unsupported image type or not image file');
     }
     $imageFormat = Image::mimeTypeFromExtension($editedFile->getExtension());
     $uploadedData = $request->get('content');
     if (null === $uploadedData || strpos($uploadedData, 'data:image/png;base64,') !== 0) {
         throw new InvalidUploadException('Invalid upload. Expected base64 encoded PNG image.');
     }
     $data = explode(',', $uploadedData);
     $data = isset($data[1]) ? base64_decode($data[1]) : false;
     if (!$data) {
         throw new InvalidUploadException();
     }
     $uploadedImage = Image::create($data);
     $newContents = $uploadedImage->getData($imageFormat);
     $editFileEvent = new EditFileEvent($this->app, $editedFile, $newContents);
     $cache->set(Path::combine($workingFolder->getResourceType()->getName(), $workingFolder->getClientCurrentFolder(), $fileName), $uploadedImage->getInfo());
     $dispatcher->dispatch(CKFinderEvent::SAVE_IMAGE, $editFileEvent);
     $saved = false;
     if (!$editFileEvent->isPropagationStopped()) {
         $saved = $editedFile->setContents($editFileEvent->getNewContents());
         //Remove thumbnails and resized images in case if file is overwritten
         if (!$saveAsNew && $saved) {
             $resourceType = $workingFolder->getResourceType();
             $thumbnailRepository->deleteThumbnails($resourceType, $workingFolder->getClientCurrentFolder(), $fileName);
             $resizedImageRepository->deleteResizedImages($resourceType, $workingFolder->getClientCurrentFolder(), $fileName);
         }
     }
     return array('saved' => (int) $saved, 'date' => Utils::formatDate(time()));
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:42,代码来源:SaveImage.php

示例10: execute

 public function execute(Request $request, WorkingFolder $workingFolder, ResizedImageRepository $resizedImageRepository, Config $config, CacheManager $cache)
 {
     $fileName = $request->get('fileName');
     $sizes = $request->get('sizes');
     $ext = pathinfo($fileName, PATHINFO_EXTENSION);
     if (!Image::isSupportedExtension($ext)) {
         throw new InvalidRequestException('Invalid file extension');
     }
     if ($sizes) {
         $sizes = explode(',', $sizes);
         if (array_diff($sizes, array_keys($config->get('images.sizes')))) {
             throw new InvalidRequestException(sprintf('Invalid size requested (%s)', $request->get('sizes')));
         }
     }
     $data = array();
     $cachedInfo = $cache->get(Path::combine($workingFolder->getResourceType()->getName(), $workingFolder->getClientCurrentFolder(), $fileName));
     if ($cachedInfo && isset($cachedInfo['width']) && isset($cachedInfo['height'])) {
         $data['originalSize'] = sprintf("%dx%d", $cachedInfo['width'], $cachedInfo['height']);
     }
     $resizedImages = $resizedImageRepository->getResizedImagesList($workingFolder->getResourceType(), $workingFolder->getClientCurrentFolder(), $fileName, $sizes ?: array());
     $data['resized'] = $resizedImages;
     return $data;
 }
开发者ID:valodiapilquevitch,项目名称:Relatorio-de-alunos,代码行数:23,代码来源:GetResizedImages.php

示例11: execute

 public function execute(WorkingFolder $workingFolder, Request $request, Config $config)
 {
     $fileName = $request->get('fileName');
     $thumbnail = $request->get('thumbnail');
     $fileNames = (array) $request->get('fileNames');
     if (!empty($fileNames)) {
         $urls = array();
         foreach ($fileNames as $fileName) {
             if (!File::isValidName($fileName, $config->get('disallowUnsafeCharacters'))) {
                 throw new InvalidRequestException(sprintf('Invalid file name: %s', $fileName));
             }
             $urls[$fileName] = $workingFolder->getFileUrl($fileName);
         }
         return array('urls' => $urls);
     }
     if (!File::isValidName($fileName, $config->get('disallowUnsafeCharacters')) || $thumbnail && !File::isValidName($thumbnail, $config->get('disallowUnsafeCharacters'))) {
         throw new InvalidRequestException('Invalid file name');
     }
     if (!$workingFolder->containsFile($fileName)) {
         throw new FileNotFoundException();
     }
     return array('url' => $workingFolder->getFileUrl($thumbnail ? Path::combine(ResizedImage::DIR, $fileName, $thumbnail) : $fileName));
 }
开发者ID:valodiapilquevitch,项目名称:Relatorio-de-alunos,代码行数:23,代码来源:GetFileUrl.php

示例12: getFilePath

 /**
  * Returns backend-relative file path.
  *
  * @return string file path
  */
 public function getFilePath()
 {
     return Path::combine($this->getPath(), $this->getFilename());
 }
开发者ID:mat33470,项目名称:PFA,代码行数:9,代码来源:ExistingFile.php

示例13: registerStreamLogger

 /**
  * Registers stream handler for errors logging
  */
 public function registerStreamLogger()
 {
     $app = $this;
     /* @var $logsBackend \CKSource\CKFinder\Backend\Backend */
     $logsBackend = $app['backend_factory']->getPrivateDirBackend('logs');
     $adapter = $logsBackend->getAdapter();
     if ($adapter instanceof LocalFSAdapter) {
         $logsDir = $app['config']->getPrivateDirPath('logs');
         $errorLogPath = Path::combine($logsDir, 'error.log');
         $logPath = $adapter->applyPathPrefix($errorLogPath);
         $app['logger']->pushHandler(new StreamHandler($logPath));
     }
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:16,代码来源:CKFinder.php

示例14: create

 /**
  * Creates a thumbnail
  *
  * @return bool
  *
  * @throws \Exception
  */
 public function create()
 {
     $sourceBackend = $this->sourceFileResourceType->getBackend();
     $sourceFilePath = Path::combine($this->sourceFileResourceType->getDirectory(), $this->sourceFileDir, $this->sourceFileName);
     if ($sourceBackend->isHiddenFile($this->sourceFileName) || !$sourceBackend->has($sourceFilePath)) {
         throw new FileNotFoundException('Thumbnail::create(): Source file not found');
     }
     $image = Image::create($sourceBackend->read($sourceFilePath), $this->thumbnailRepository->isBitmapSupportEnabled());
     // Update cached info about image
     $app = $this->thumbnailRepository->getContainer();
     $app['cache']->set(Path::combine($this->sourceFileResourceType->getName(), $this->sourceFileDir, $this->sourceFileName), $image->getInfo());
     $image->resize($this->adjustedSizeInfo['width'], $this->adjustedSizeInfo['height'], $this->adjustedSizeInfo['quality']);
     $this->resizedImageData = $image->getData();
     $this->resizedImageSize = $image->getDataSize();
     $this->resizedImageMimeType = $image->getMimeType();
     unset($image);
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:24,代码来源:Thumbnail.php

示例15: getFilePath

 /**
  * Returns backend-relative resized image file path
  *
  * @return string
  */
 public function getFilePath()
 {
     return Path::combine($this->getDirectory(), $this->getFileName());
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:9,代码来源:ResizedImageAbstract.php


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