Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display different icon for empty folders #1643

Closed
marcomarsala opened this issue Sep 8, 2016 · 4 comments
Closed

Display different icon for empty folders #1643

marcomarsala opened this issue Sep 8, 2016 · 4 comments
Labels

Comments

@marcomarsala
Copy link

It would be useful to have an option to display a different icon for empty folders.

@nao-pon nao-pon added the howto label Sep 11, 2016
@nao-pon
Copy link
Member

nao-pon commented Sep 11, 2016

@marcomarsala This is possible with connector main option bind.

e.g. - add CSS class name elfinder-dir-empty to empty folder of the LocalFileSystem volume.

function setEmptyFolderCssName($cmd, &$result, $args, $elfinder, $volume) {
    if ($volume && $volume instanceof elFinderVolumeLocalFileSystem && $result) {
        $key = '';
        if (! empty($result['files'])) {
            $key = 'files';
        } else if (! empty($result['tree'])) {
            $key = 'tree';
        } else if (! empty($result['added'])) {
            $key = 'added';
        }
        if ($key) {
            foreach($result[$key] as $i => $file) {
                if (isset($file['mime']) && $file['mime'] === 'directory') {
                    $path = $volume->getPath($file['hash']);
                    if (($items = scandir($path)) && count($items) === 2) {
                        $result[$key][$i]['csscls'] = 'elfinder-dir-empty';
                    }
                }
            }
        }
    }
}
$opts = array(
    'bind' => array( 'open tree parent mkdir' => array( 'setEmptyFolderCssName' ) ),
    'roots'  => array(
        array(
            'driver' => 'LocalFileSystem',
            'path'   => '/path/to/files/',
            'URL'    => 'http://localhost/to/files/'
        )
    )
);

// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();

@nao-pon nao-pon closed this as completed Sep 11, 2016
@Ange7
Copy link

Ange7 commented Jan 27, 2018

this patch don't work with new elFinder version ? :(

@lajones89
Copy link

lajones89 commented Dec 21, 2018

There is just a typing error in "lbind".

$opts = array(
    'bind' => array( 'open tree parent mkdir' => array( 'setEmptyFolderCssName' ) ),
    'roots'  => array(
        array(
            'driver' => 'LocalFileSystem',
            'path'   => '/path/to/files/',
            'URL'    => 'http://localhost/to/files/'
        )
    )
);

@nao-pon
Copy link
Member

nao-pon commented Dec 27, 2018

@lajones89 Thanks! I edited it. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants