Gollem::listFolder PHP Method

listFolder() public static method

List the current folder.
public static listFolder ( string $dir ) : array
$dir string The directory name.
return array The sorted list of files.
    public static function listFolder($dir)
    {
        global $conf;
        if (!empty($conf['foldercache']['use_cache']) && !empty($conf['cache']['driver']) && $conf['cache']['driver'] != 'none') {
            $key = self::_getCacheID($dir);
            $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
            $res = $cache->get($key, $conf['foldercache']['lifetime']);
            if ($res !== false) {
                $res = Horde_Serialize::unserialize($res, Horde_Serialize::BASIC);
                if (is_array($res)) {
                    return $res;
                }
            }
        }
        try {
            $files = $GLOBALS['injector']->getInstance('Gollem_Vfs')->listFolder($dir, isset(self::$backend['filter']) ? self::$backend['filter'] : null, $GLOBALS['prefs']->getValue('show_dotfiles'));
        } catch (Horde_Vfs_Exception $e) {
            throw new Gollem_Exception($e);
        }
        $sortcols = array(self::SORT_TYPE => 'sortType', self::SORT_NAME => 'sortName', self::SORT_DATE => 'sortDate', self::SORT_SIZE => 'sortSize');
        usort($files, array('Gollem', $sortcols[$GLOBALS['prefs']->getValue('sortby')]));
        if (isset($cache)) {
            $cache->set($key, Horde_Serialize::serialize($files, Horde_Serialize::BASIC), $conf['foldercache']['lifetime']);
        }
        return $files;
    }

Usage Example

Ejemplo n.º 1
0
                    }
                }
            }
            $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;
All Usage Examples Of Gollem::listFolder