class ElFinder2::Command::Open
Returns information about requested directory and its content, optionally can return directory tree as files, and options for the current volume.
Public Instance Methods
Response:
api: (Number) The version number of the protocol, must be >= 2,
ATTENTION - return api ONLY for init request!
cwd: (Object) Current Working Directory - information about the
current directory. Information about File/Directory
files: (Array) array of objects - files and directories in current
directory. If parameter tree == true, then added to the folder of the directory tree to a given depth. The order of files is not important. Note you must include the top-level volume objects here as well (i.e. cwd is repeated here, in addition to other volumes) Information about File/Directory
netDrivers: (Array) Network protocols list which can be mounted on the
fly (using netmount command). Now only ftp supported.
Optional
uplMaxSize: (String) Allowed upload max size. For example “32M”
options: (Object) Further information about the folder and its volume {
options: { // (String) Current folder path path: "files/folder42", // (String) Current folder URL url: "http://localhost/elfinder/files/folder42/", // (String) Thumbnails folder URL tmbURL: "http://localhost/elfinder/files/folder42/.tmb/", // (String) Разделитель пути для текущего тома separator: "/", // (Array) List of commands not allowed (disabled) on this volume disabled: [], // (Number) Whether or not to overwrite files with the same name on // the current volume copyOverwrite: 1, // (Object) Archive settings archivers: { // (Array) List of the mime type of archives which can be created create: [ 0: "application/x-tar", 1: "application/x-gzip" ], // (Array) List of the mime types that can be extracted / unpacked extract: [ 0: "application/x-tar", 1: "application/x-gzip" ] } }
}
debug: (Object) Debug information, if you specify the corresponding
connector option.
{
debug: { // (String) Connector type connector: "php", // (String) php version phpver: "5.3.6", // (Number) Execution time time: 0.0749430656433, // (String) Used / Free / Available Memory memory: "3348Kb / 2507Kb / 128M", // (Array) Debugging by volume volumes: [ { // (String) ID of the Volume id: "l1_", // (String) Driver type (class name) driver: "localfilesystem", // (String) Method for determining mime type mimeDetect: "internal", // (String) Library for working with images imgLib: "gd" } ], // (Array) List of errors for not mounted volumes mountErrors: [ 0: "Root folder has not read and write permissions." ] }
}
# File lib/el_finder2/command/open.rb, line 88 def execute files = @folder.self_and_descendants files = files.where('parent_id = :id OR id = :id', id: @folder.id) unless @tree response = { cwd: ElFinder2::FolderSerializer.new(@folder).as_json, files: ActiveModel::ArraySerializer.new(files).as_json, options: {} } response.merge!( api: ElFinder2::API_VERSION ) if @init render json: response end
Private Instance Methods
init : (true|false|not set), optional parameter. If true indicates
that this request is an initialization request and its response must include the value api (number or string >= 2) and should include the options object, but will still work without it. Also, this option affects the processing of parameter target hash value. If init == true and target is not set or that directory doesn't exist, then the data connector must return the root directory of the default volume. Otherwise it must return error "File not found".
target : (string) Hash of directory to open. Required if init == false
or init is not set
tree : (true|false), optional. If true, response must contain
subfolders trees of roots directories.
# File lib/el_finder2/command/open.rb, line 119 def parse_params!(params) @init = params[:init] == '1' @tree = params[:tree] == '1' fail ElFinder2::Error.new(%w(errCmdParams open)) unless @init || params.key?(:target) path = to_path(params[:target]) @folder = ElFinder2::Folder.find_by_path(path) if path @folder = ElFinder2::Folder.root if @init && !@folder fail ElFinder2::Error.new('errFolderNotFound') unless @folder end