Elfinder: [cmd:empty] change title "Empty the folder" to "Delete All" in the trash volume

Created on 26 Jun 2018  路  5Comments  路  Source: Studio-42/elFinder

Is it possible to have "Delete All" option in Trash volume?

howto question

All 5 comments

@hardiktailored Is that about "Empty the folder"? If right, please add 'empty' to roots option disabled.

Disabled will remove option, right? I wanted to add option "Delete All" so I added "empty" cmd in toolbar options and it works the same. However I would like to rename it like "All Into Trash" in main and "Delete All" in Trash volume. Is that possible? Thanks for your response.

Sorry, I misread the question. I will check the source code.

@hardiktailored I fixed to make possible to commands.empty become superclass. Please try with the nightly build.

Create a subclass command.deleteAll of command.empty that only changes the title, add 'empty' => 'deleteAll' to the uiCmdMap option of the Trash volume so that the command title can be changed.

/** It from default elfinder.html **/
bootCallback : function(fm, extraObj) {
    /* add commands.deleteAll function */
    // Class commands.deleteAll extends commands.empty
    (fm.commands.deleteAll = function() {
        "use strict";
        this.init = function() {
            // call parent.init()
            (Object.getPrototypeOf? Object.getPrototypeOf(this) : this.__proto__).init.call(this);
            // set my title
            this.title = this.fm.i18n('Delete All');
        };
    }).prototype = { extendsCmd : 'empty', forceLoad : true };
    /* Up to this point is appended */

    /* any bind functions etc. */
    fm.bind('init', function() {
        // any your code
    });
    // for example set document.title dynamically.
    var title = document.title;
    fm.bind('open', function() {
        var path = '',
            cwd  = fm.cwd();
        if (cwd) {
            path = fm.path(cwd.hash) || null;
        }
        document.title = path? path + ':' + title : title;
    }).bind('destroy', function() {
        document.title = title;
    });
}

In tha connector root option

/** It from default connector.minimal.php **/
// Trash volume
array(
    'id'            => '1',
    'driver'        => 'Trash',
    'path'          => '../files/.trash/',
    'tmbURL'        => dirname($_SERVER['PHP_SELF']) .
'/../files/.trash/.tmb/',
    'winHashFix'    => DIRECTORY_SEPARATOR !== '/', // to make hash same
to Linux one on windows too
    'uploadDeny'    => array('all'),                // Recomend the same
settings as the original volume that uses the trash
    'uploadAllow'   => array('image', 'text/plain'),// Same as above
    'uploadOrder'   => array('deny', 'allow'),      // Same as above
    'accessControl' => 'access',                    // Same as above
    // add `'empty' => 'deleteAll'` to default option
    'uiCmdMap'      => array('paste' => 'hidden', 'mkdir' => 'hidden', 'copy' => 'restore', 'empty' => 'deleteAll'),
)

Okay, understood. Made subclass of "Empty" cmd and then give title we want to the new command. And then map empty to the new command. Cool. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shiyee picture shiyee  路  3Comments

ahmadbadpey picture ahmadbadpey  路  4Comments

golee picture golee  路  3Comments

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  4Comments

yinmingming picture yinmingming  路  3Comments