[ui] fix #1231 controllable folder icon, ref #1061

Case 1
------

**Grant the class name by the client setting**

```javascript
        uiOptions : {
            tree : {
                getClass: function(item) {
                    return 'elfinder-tree-' + item.name.replace(/[ "]/g,
'').toLowerCase();
                }
            }
            cwd : {
                getClass: function(item) {
                    return 'elfinder-cwd-' + item.name.replace(/[ "]/g,
'').toLowerCase();
                }
            }
        }
```

Case 2
------

**Specifying the file name to be detected as an icon**

**LocalFileSystem ONLY** If there is a ".diricon.png" in a directory it
with the directory icon.
```php
	'roots' => array(
        array(
            'driver'        => 'LocalFileSystem',
            'path'          => '/path/to/files/',
            'URL'           => 'http://localhost/to/files/',
            'detectDirIcon' => '.diricon.png'
        )
	)
```
This commit is contained in:
nao-pon
2016-03-15 18:06:48 +09:00
parent 3caf56beb1
commit 329593b46d
5 changed files with 44 additions and 10 deletions
+15 -3
View File
@@ -62,9 +62,10 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$this->options['alias'] = ''; // alias to replace root dir name
$this->options['dirMode'] = 0755; // new dirs mode
$this->options['fileMode'] = 0644; // new files mode
$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
$this->options['rootCssClass'] = 'elfinder-navbar-root-local';
$this->options['followSymLinks'] = true;
$this->options['detectDirIcon'] = ''; // file name that is detected as a folder icon e.g. '.diricon.png'
}
/*********************************************************************/
@@ -473,7 +474,12 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
}
$dir = is_dir($path);
if ($dir = is_dir($path) && $this->options['detectDirIcon']) {
$favicon = $path . DIRECTORY_SEPARATOR . $this->options['detectDirIcon'];
if ($this->URL && file_exists($favicon)) {
$stat['icon'] = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($favicon, strlen($this->root) + 1));
}
}
if (!isset($stat['mime'])) {
$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
@@ -675,7 +681,13 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$stat['mime'] = $dir ? 'directory' : $this->mimetype($stat['alias']);
}
} else {
$dir = $file->isDir();
if ($dir = $file->isDir() && $this->options['detectDirIcon']) {
$path = $file->getPathname();
$favicon = $path . DIRECTORY_SEPARATOR . $this->options['detectDirIcon'];
if ($this->URL && file_exists($favicon)) {
$stat['icon'] = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($favicon, strlen($this->root) + 1));
}
}
$stat['mime'] = $dir ? 'directory' : $this->mimetype($fpath);
}
$size = sprintf('%u', $file->getSize());