本文整理汇总了PHP中elFinderVolumeDriver::doSearch方法的典型用法代码示例。如果您正苦于以下问题:PHP elFinderVolumeDriver::doSearch方法的具体用法?PHP elFinderVolumeDriver::doSearch怎么用?PHP elFinderVolumeDriver::doSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elFinderVolumeDriver
的用法示例。
在下文中一共展示了elFinderVolumeDriver::doSearch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSearch
/**
* Recursive files search
*
* @param string $path dir path
* @param string $q search string
* @param array $mimes
* @return array
* @author Dmitry (dio) Levashov
* @author Naoki Sawada
**/
protected function doSearch($path, $q, $mimes)
{
if ($this->encoding) {
// non UTF-8 has problem of glob() results
return parent::doSearch($path, $q, $mimes);
}
static $escaper;
if (!$escaper) {
$escaper = array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?');
}
$result = array();
$path = strtr($path, $escaper);
$_q = strtr($q, $escaper);
$dirs = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);
$match = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*' . $_q . '*', GLOB_NOSORT);
if ($match) {
foreach ($match as $p) {
$stat = $this->stat($p);
if (!$stat) {
// invalid links
continue;
}
if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) {
continue;
}
$name = $stat['name'];
if (!$mimes || $stat['mime'] !== 'directory') {
$stat['path'] = $this->path($stat['hash']);
if ($this->URL && !isset($stat['url'])) {
$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
$stat['url'] = $this->URL . $path;
}
$result[] = $stat;
}
}
}
if ($dirs) {
foreach ($dirs as $dir) {
$stat = $this->stat($dir);
if ($stat['read'] && !isset($stat['alias'])) {
@set_time_limit(30);
$result = array_merge($result, $this->doSearch($dir, $q, $mimes));
}
}
}
return $result;
}
示例2: doSearch
/**
* Recursive files search
*
* @param string $path dir path
* @param string $q search string
* @param array $mimes
* @return array
* @author Dmitry (dio) Levashov
* @author Naoki Sawada
**/
protected function doSearch($path, $q, $mimes)
{
if ($this->encoding || !class_exists('FilesystemIterator', false)) {
// non UTF-8 use elFinderVolumeDriver::doSearch()
return parent::doSearch($path, $q, $mimes);
}
$match = array();
try {
$iterator = new RecursiveIteratorIterator(new RecursiveCallbackFilterIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::SKIP_DOTS | (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') && $this->options['followSymLinks'] ? RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0)), array($this, 'localFileSystemSearchIteratorFilter')), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
foreach ($iterator as $key => $node) {
if ($node->isDir()) {
if ($this->stripos($node->getFilename(), $q) !== false) {
$match[] = $key;
}
} else {
$match[] = $key;
}
}
} catch (Exception $e) {
}
$result = array();
if ($match) {
foreach ($match as $p) {
$stat = $this->stat($p);
if (!$stat) {
// invalid links
continue;
}
if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) {
continue;
}
$name = $stat['name'];
if (!$mimes || $stat['mime'] !== 'directory') {
$stat['path'] = $this->path($stat['hash']);
if ($this->URL && !isset($stat['url'])) {
$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
$stat['url'] = $this->URL . $path;
}
$result[] = $stat;
}
}
}
return $result;
}
示例3: doSearch
/**
* Recursive files search
*
* @param string $path dir path
* @param string $q search string
* @param array $mimes
* @return array
* @author Naoki Sawada
**/
protected function doSearch($path, $q, $mimes)
{
if ($path != $this->root) {
return parent::doSearch($path, $q, $mimes);
} else {
$result = array();
$q = '%' . mysql_real_escape_string($q) . '%';
$sql = 'SELECT `file_id`, `mime`, `uid`, `gid`, `gids`, `perm`, `home_of` FROM ' . $this->tbf . ' WHERE `name` LIKE \'' . $q . '\'';
$res = $this->query($sql);
if ($res) {
while ($stat = $this->db->fetchArray($res)) {
if ($stat['mime'] === 'directory' || !$this->mimeAccepted($stat['mime'], $mimes)) {
continue;
}
$this->setAuthByPerm($stat);
if (empty($stat['hidden'])) {
$result[] = $this->stat($stat['file_id']);
}
}
}
return $result;
}
}