Exemplo n.º 1
0
 /**
  * Checks if the current file folder path is valid.
  *
  * @return bool `true` if the path is valid.
  */
 public function hasValidPath()
 {
     return Path::isValid($this->getPath());
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param CKFinder     $app
  *
  * @throws \Exception
  */
 public function __construct(CKFinder $app)
 {
     $this->app = $app;
     /* @var $request \Symfony\Component\HttpFoundation\Request */
     $request = $app['request_stack']->getCurrentRequest();
     $resourceType = $app['resource_type_factory']->getResourceType((string) $request->get('type'));
     $this->clientCurrentFolder = Path::normalize(trim((string) $request->get('currentFolder')));
     if (!Path::isValid($this->clientCurrentFolder)) {
         throw new InvalidNameException('Invalid path');
     }
     $resourceTypeDirectory = $resourceType->getDirectory();
     parent::__construct($resourceType, $this->clientCurrentFolder);
     $this->backend = $this->resourceType->getBackend();
     $this->thumbnailRepository = $app['thumbnail_repository'];
     $backend = $this->getBackend();
     // Check if folder path is not hidden
     if ($backend->isHiddenPath($this->getClientCurrentFolder())) {
         throw new InvalidRequestException('Hidden folder path used');
     }
     // Check if resource type folder exists - if not then create it
     $currentCommand = (string) $request->query->get('command');
     $omitForCommands = array('Thumbnail');
     if (!in_array($currentCommand, $omitForCommands) && !empty($resourceTypeDirectory) && !$backend->hasDirectory($this->path)) {
         if ($this->clientCurrentFolder === '/') {
             @$backend->createDir($resourceTypeDirectory);
             if (!$backend->hasDirectory($resourceTypeDirectory)) {
                 throw new AccessDeniedException("Couldn't create resource type directory. Please check permissions.");
             }
         } else {
             throw new FolderNotFoundException();
         }
     }
 }