[VD] fix #1266 exclusion serach (SQL, Dropbox are not supported now)

- volume root option `searchExDirReg` for excludes directores
```php
// Search exclusion directory regex pattern (require demiliter e.g. '#/path/to/exclude_directory#i')
'searchExDirReg'  => '',
```
- Excludes word in serach query with prefix "-" (e.g. "SerachWord -ExcludesWord")
This commit is contained in:
nao-pon
2016-03-16 19:14:28 +09:00
parent 69f23b4a89
commit 16146ac1b8
2 changed files with 64 additions and 10 deletions
+12 -9
View File
@@ -44,13 +44,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
**/
protected $archiveSize = 0;
/**
* Current query word on doSearch
*
* @var string
**/
private $doSearchCurrentQuery = '';
/**
* Constructor
* Extend options with required fields
@@ -1149,7 +1142,6 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
return parent::doSearch($path, $q, $mimes);
}
$this->doSearchCurrentQuery = $q;
$match = array();
try {
$iterator = new RecursiveIteratorIterator(
@@ -1210,10 +1202,21 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
/******************** Original local functions *************************/
public function localFileSystemSearchIteratorFilter($file, $key, $iterator) {
$name = $file->getFilename();
if ($this->doSearchCurrentQuery['excludes']) {
foreach($this->doSearchCurrentQuery['excludes'] as $exclude) {
if ($this->stripos($name, $exclude) !== false) {
return false;
}
}
}
if ($iterator->hasChildren()) {
if ($this->options['searchExDirReg'] && preg_match($this->options['searchExDirReg'], $key)) {
return false;
}
return (bool)$this->attr($key, 'read', null, true);
}
return ($this->stripos($file->getFilename(), $this->doSearchCurrentQuery) === false)? false : true;
return ($this->stripos($name, $this->doSearchCurrentQuery['q']) === false)? false : true;
}
} // END class