コード例 #1
0
ファイル: WorkingFolder.php プロジェクト: vobinh/PHP
 /**
  * Adds current folder info to the response
  *
  * @param FilterResponseEvent $event
  */
 public function addCurrentFolderInfo(FilterResponseEvent $event)
 {
     /* @var JsonResponse $response */
     $response = $event->getResponse();
     if ($response instanceof JsonResponse) {
         $responseData = (array) $response->getData();
         $responseData = array('resourceType' => $this->getResourceTypeName(), 'currentFolder' => array('path' => $this->getClientCurrentFolder(), 'acl' => $this->getAclMask())) + $responseData;
         $baseUrl = $this->backend->getBaseUrl();
         if (null !== $baseUrl) {
             $folderUrl = Path::combine($baseUrl, Utils::encodeURLParts(Path::combine($this->resourceType->getDirectory(), $this->getClientCurrentFolder())));
             $responseData['currentFolder']['url'] = rtrim($folderUrl, '/') . '/';
         }
         $response->setData($responseData);
     }
 }
コード例 #2
0
ファイル: Backend.php プロジェクト: mat33470/PFA
 /**
  * Returns a URL to a file.
  *
  * If the useProxyCommand option is set for a backend, the returned
  * URL will point to the CKFinder connector Proxy command.
  *
  * @param ResourceType $resourceType      the file resource type
  * @param string       $folderPath        the resource-type relative folder path
  * @param string       $fileName          the file name
  * @param string|null  $thumbnailFileName the thumbnail file name - if the file is a thumbnail
  *
  * @return string|null URL to a file or `null` if the backend does not support it.
  */
 public function getFileUrl(ResourceType $resourceType, $folderPath, $fileName, $thumbnailFileName = null)
 {
     if (isset($this->backendConfig['useProxyCommand'])) {
         $connectorUrl = $this->app->getConnectorUrl();
         $queryParameters = array('command' => 'Proxy', 'type' => $resourceType->getName(), 'currentFolder' => $folderPath, 'fileName' => $fileName);
         if ($thumbnailFileName) {
             $queryParameters['thumbnail'] = $thumbnailFileName;
         }
         $proxyCacheLifetime = (int) $this->ckConfig->get('cache.proxyCommand');
         if ($proxyCacheLifetime > 0) {
             $queryParameters['cache'] = $proxyCacheLifetime;
         }
         return $connectorUrl . '?' . http_build_query($queryParameters, '', '&');
     }
     $path = $thumbnailFileName ? Path::combine($resourceType->getDirectory(), $folderPath, ResizedImage::DIR, $fileName, $thumbnailFileName) : Path::combine($resourceType->getDirectory(), $folderPath, $fileName);
     if (isset($this->backendConfig['baseUrl'])) {
         return Path::combine($this->backendConfig['baseUrl'], Utils::encodeURLParts($path));
     }
     $baseAdapter = $this->getBaseAdapter();
     if (method_exists($baseAdapter, 'getFileUrl')) {
         return $baseAdapter->getFileUrl($path);
     }
     return null;
 }
コード例 #3
0
ファイル: Backend.php プロジェクト: SevenMonks/100cities-dev
 /**
  * Returns a direct url to a file
  *
  * @param string $path
  *
  * @return string|null direct url to a file or null if backend
  *                     doesn't support direct access
  */
 public function getFileUrl($path)
 {
     if (method_exists($this->adapter, 'getFileUrl')) {
         return $this->adapter->getFileUrl($path);
     }
     if (isset($this->backendConfig['baseUrl'])) {
         return Path::combine($this->backendConfig['baseUrl'], Utils::encodeURLParts($path));
     }
     return null;
 }