Example #1
0
 /**
  * Sorts incoming file/folder data
  *
  * @return  array
  */
 private function getCollection()
 {
     // Incoming
     $files = $this->prune((array) Request::getVar('asset', []));
     $directories = $this->prune((array) Request::getVar('folder', []));
     $collection = new Collection();
     $entities = array_merge($files, $directories);
     if (!empty($entities) && is_array($entities)) {
         foreach ($entities as $entity) {
             $path = trim($this->subdir, '/') . '/' . urldecode($entity);
             $collection->add(Entity::fromPath($path, $this->connection->adapter()));
         }
     }
     return $collection;
 }
Example #2
0
 /**
  * Sorts incoming file/folder data
  *
  * @return  array
  */
 private function getCollection()
 {
     // Incoming
     $files = $this->prune((array) Request::getVar('asset', []));
     $directories = $this->prune((array) Request::getVar('folder', []));
     $collection = new Collection();
     $entities = array_merge($files, $directories);
     if (!empty($entities) && is_array($entities)) {
         foreach ($entities as $entity) {
             if (count(explode('/', $entity)) > 1) {
                 $path = urldecode($entity);
             } else {
                 $path = trim($this->subdir, '/') . '/' . urldecode($entity);
             }
             $file = Entity::fromPath($path, $this->connection->adapter());
             if (!$file->exists()) {
                 $view->setError(Lang::txt('Failed to find the file at ' . $path));
                 return $collection;
             }
             $collection->add(Entity::fromPath($path, $this->connection->adapter()));
         }
     }
     return $collection;
 }