protected function doSearch($path, $q, $mimes)
{
$result = array();
foreach ($this->_scandir($path) as $p) {
$stat = $this->stat($p);
if (!$stat) {
// invalid links
continue;
}
if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'])) {
continue;
}
$name = $stat['name'];
if ($this->stripos($name, $q) !== false) {
$stat['path'] = $this->_path($p);
if ($this->URL && !isset($stat['url'])) {
$stat['url'] = $this->URL . str_replace($this->separator, '/', substr($p, strlen($this->root) + 1));
}
$result[] = $stat;
}
if ($stat['mime'] == 'directory' && $stat['read'] && !isset($stat['alias'])) {
$result = array_merge($result, $this->doSearch($p, $q, $mimes));
}
}
return $result;
}