Exemple #1
0
 /**
  * Operation handler: newfolder.
  */
 public function opNewfolder(ImceFM $fm)
 {
     $folder = $fm->activeFolder;
     if (!$folder || !$folder->getPermission('create_subfolders')) {
         return;
     }
     // Create folder
     $name = $fm->getPost('newfolder');
     if (is_string($name) && $fm->validateFileName($name)) {
         // Check existence
         $uri = Imce::joinPaths($folder->getUri(), $name);
         if (file_exists($uri)) {
             $fm->setMessage(t('%filename already exists.', array('%filename' => $name)));
         } elseif (mkdir($uri, $fm->getConf('chmod_directory', 0775))) {
             $folder->addSubfolder($name)->addToJs();
         }
     }
 }
 /**
  * Returns the item path relative to the root.
  */
 public function getPath()
 {
     if (isset($this->path)) {
         return $this->path;
     }
     if ($this->parent) {
         $path = $this->parent->getPath();
         if (isset($path)) {
             return Imce::joinPaths($path, $this->name);
         }
     }
 }
 /**
  * Creates an uri from a relative path.
  */
 public function createUri($path)
 {
     return Imce::joinPaths($this->getConf('root_uri'), $path);
 }
 /**
  * Sets the folder path.
  */
 public function setPath($path)
 {
     $oldpath = $this->path;
     if ($path !== $oldpath) {
         // Remove oldpath references
         if (isset($oldpath)) {
             unset($this->fm()->tree[$oldpath]);
             foreach ($this->subfolders as $name => $item) {
                 $item->setPath(NULL);
             }
         }
         // Add new path references
         $this->path = $path;
         if (isset($path)) {
             $this->fm()->tree[$path] = $this;
             foreach ($this->subfolders as $name => $item) {
                 $item->setPath(Imce::joinPaths($path, $name));
             }
         }
     }
 }