<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="admin/widget/elfinder/css/elfinder.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="admin/widget/elfinder/css/theme.css">
<script src="admin/widget/elfinder/js/elfinder.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        elFinder.prototype.i18.en.messages['cmdfeature'] = 'Feature';
        elFinder.prototype._options.commands.push('feature');
        elFinder.prototype.commands.feature = function() {
            this.exec = function(hashes) {
                $('#' + hashes).css('background', '#eeeeee');
                $('input[name="value"]').val($('#' + hashes + ' .elfinder-cwd-filename').html());
            }
            this.getstate = function() {
                //return 0 to enable, -1 to disable icon access
                return 0;
            }
        }
        
        var elf = $('#media').elfinder({
            url: 'admin/widget/elfinder/php/connector.php',
            contextmenu : {
                navbar : ['open', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'info'],
                cwd    : ['reload', 'back', '|', 'upload', 'mkdir', 'mkfile', 'paste', '|', 'info'],
                files  : [
                    'getfile', '|','open', 'quicklook', '|', 'download', '|', 'copy', 'cut', 'paste', 'duplicate', '|',
                    'rm', '|', 'edit', 'rename', 'resize', '|', 'archive', 'extract', '|', 'info', '|', 'feature'
                ]
            },
            customData: {
                directory: '<?php echo isset($setting['parameters']['directory']) ? $setting['parameters']['directory'] : '/'; ?>'
            },
            onlyMimes: ['image/png', 'image/jpeg', 'image/gif']
        }).elfinder('instance');
    });
</script>