本文整理汇总了PHP中OC\Files\Filesystem::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::search方法的具体用法?PHP Filesystem::search怎么用?PHP Filesystem::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Search for files and folders matching the given query
* @param string $query
* @return \OCP\Search\Result
*/
function search($query)
{
$files = Filesystem::search($query);
$results = array();
// edit results
foreach ($files as $fileData) {
// skip versions
if (strpos($fileData['path'], '_versions') === 0) {
continue;
}
// skip top-level folder
if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
continue;
}
// create audio result
if ($fileData['mimepart'] === 'audio') {
$result = new \OC\Search\Result\Audio($fileData);
} elseif ($fileData['mimepart'] === 'image') {
$result = new \OC\Search\Result\Image($fileData);
} elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
$result = new \OC\Search\Result\Folder($fileData);
} else {
$result = new \OC\Search\Result\File($fileData);
}
// add to results
$results[] = $result;
}
// return
return $results;
}
示例2: search
function search($query)
{
$files = \OC\Files\Filesystem::search($query, true);
$results = array();
$l = OC_L10N::get('lib');
foreach ($files as $fileData) {
$path = $fileData['path'];
$mime = $fileData['mimetype'];
$name = basename($path);
$container = dirname($path);
$text = '';
$skip = false;
if ($mime == 'httpd/unix-directory') {
$link = OC_Helper::linkTo('files', 'index.php', array('dir' => $path));
$type = (string) $l->t('Files');
} else {
$link = OC_Helper::linkToRoute('download', array('file' => $path));
$mimeBase = $fileData['mimepart'];
switch ($mimeBase) {
case 'audio':
$skip = true;
break;
case 'text':
$type = (string) $l->t('Text');
break;
case 'image':
$type = (string) $l->t('Images');
break;
default:
if ($mime == 'application/xml') {
$type = (string) $l->t('Text');
} else {
$type = (string) $l->t('Files');
}
}
}
if (!$skip) {
$results[] = new OC_Search_Result($name, $text, $link, $type, $container);
}
}
return $results;
}
示例3: search
/**
* @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
*/
public static function search($query)
{
return \OC\Files\Filesystem::search($query);
}