List the current folder.
public static listFolder ( string $dir ) : array | ||
$dir | string | The directory name. |
Résultat | array | The sorted list of files. |
} } } $session->set('gollem', 'selectlist/' . $cacheid, $selectlist); $filelist = array_keys(array_flip($selectlist['files'])); } break; } try { $info = array('list' => Gollem::listFolder(Gollem::$backend['dir'])); } catch (Gollem_Exception $e) { /* If that didn't work, fall back to the parent or the home directory. */ $notification->push(sprintf(_("Permission denied to %s: %s"), Gollem::$backend['dir'], $e->getMessage()), 'horde.error'); $loc = strrpos(Gollem::$backend['dir'], '/'); Gollem::setDir($loc !== false ? substr(Gollem::$backend['dir'], 0, $loc) : Gollem::$backend['home']); $info = array('list' => Gollem::listFolder(Gollem::$backend['dir'])); } $info['title'] = htmlspecialchars(Gollem::$backend['label']); /* Commonly used URLs. */ $self_url = Horde::url('selectlist.php'); /* Set up the template object. */ $view = $injector->createInstance('Horde_View'); $view->self_url = $self_url; $view->forminput = Horde_Util::formInput(); $view->cacheid = $cacheid; $view->currdir = htmlspecialchars(Gollem::$backend['dir']); $view->formid = htmlspecialchars($vars->formid); $view->navlink = Gollem::directoryNavLink(Gollem::$backend['dir'], $self_url->copy()->add(array('cacheid' => $cacheid, 'formid' => $vars->formid))); if ($GLOBALS['conf']['backend']['backend_list'] == 'shown') { // TODO //$view->changeserver = Horde::link(htmlspecialchars(Horde_Auth::addLogoutParameters(Horde::url('login.php')->add(array('url' => Horde::url('selectlist.php')->add(array('formid' => $vars->formid)))), Horde_Auth::REASON_LOGOUT)), _("Change Server")) . Horde::img('logout.png', _("Change Server")) . '</a>', true;
/** * Browses through the VFS tree. * * Each VFS backend is listed as a directory at the top level. No modify * operations are allowed outside any VFS area. * * @param string $path The level of the tree to browse. * @param array $properties The item properties to return. Defaults to * 'name', 'icon', and 'browseable'. * * @return array The contents of $path. * @throws Gollem_Exception */ public function browse($path = '', $properties = array('name', 'icon', 'browseable')) { $path = Gollem::stripAPIPath($path); $results = array(); if ($path == '') { // We are at the root of gollem. Return a set of folders, one for // each backend available. foreach (Gollem_Auth::getBackend() as $backend => $curBackend) { $results['gollem/' . $backend]['name'] = $curBackend['name']; $results['gollem/' . $backend]['browseable'] = true; } } else { $backend_key = $this->_getBackend($path); throw new Gollem_Exception('Permssion checks not implemented yet.'); // Trim off the backend_key (and '/') to get the VFS relative path $fullpath = substr($path, strlen($backend_key) + 1); // Get the VFS-standard $name,$path pair list($name, $path) = Gollem::getVFSPath($fullpath); // Check to see if the request is a file or folder $gollem_vfs = $GLOBALS['injector']->getInstance('Gollem_Vfs'); if ($gollem_vfs->isFolder($path, $name)) { // This is a folder request. Return a directory listing. $list = Gollem::listFolder($path . '/' . $name); // Iterate over the directory contents if (is_array($list) && count($list)) { $index = 'gollem/' . $backend_key . '/' . $fullpath; foreach ($list as $key => $val) { $entry = Gollem::pathEncode($index . '/' . $val['name']); $results[$entry]['name'] = $val['name']; $results[$entry]['modified'] = $val['date']; if ($val['type'] == '**dir') { $results[$entry]['browseable'] = true; } else { $results[$entry]['browseable'] = false; $results[$entry]['contentlength'] = $val['size']; } } } } else { // A file has been requested. Return the contents of the file. // Get the file meta-data $list = Gollem::listFolder($path); $i = false; foreach ($list as $key => $file) { if ($file['name'] == $name) { $i = $key; break; } } if ($i === false) { // File not found return $i; } // Send the file $results['name'] = $name; $results['data'] = $gollem_vfs->read($path, $name); $results['contentlength'] = $list[$i]['size']; $results['mtime'] = $list[$i]['date']; } } return $results; }
try { $list = Gollem::listFolder(Gollem::$backend['dir']); } catch (Horde_Exception $e) { /* If this is a user's home directory, try autocreating it. */ if (Gollem::$backend['dir'] == Gollem::$backend['home']) { try { Gollem::createFolder('', Gollem::$backend['dir']); try { $list = Gollem::listFolder(Gollem::$backend['dir']); } catch (Horde_Exception $e) { /* If that didn't work, fall back to the parent or the home * directory. */ $notification->push(sprintf(_("Permission denied to folder \"%s\": %s"), Gollem::$backend['dir'], $e->getMessage()), 'horde.error'); $loc = strrpos(Gollem::$backend['dir'], '/'); Gollem::setDir($loc !== false ? substr(Gollem::$backend['dir'], 0, $loc) : Gollem::$backend['home']); $list = Gollem::listFolder(Gollem::$backend['dir']); } } catch (Gollem_Exception $e) { $notification->push(sprintf(_("Cannot create home directory: %s"), $e->getMessage()), 'horde.error'); } } } $numitem = count($list); $title = Gollem::$backend['name']; /* Commonly used URLs. */ $view_url = Horde::url('view.php'); $edit_url = Horde::url('edit.php'); $manager_url = Horde::url('manager.php'); $refresh_url = Horde::selfUrl(true, true); /* Init some form vars. */ if ($session->get('gollem', 'filter') != $vars->searchfield) {