This allows for proper PATH_INFO path parsing.
Special care is taken to handle "+" and " ".
public static pathEncode ( string $path ) : string | ||
$path | string | Path to be urlencode()d. |
return | string | URL-encoded string with '/' preserved. |
/** * 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; }