nextcloud/lib/search/provider/file.php

35 lines
1.2 KiB
PHP
Raw Normal View History

2011-07-29 23:03:53 +04:00
<?php
class OC_Search_Provider_File extends OC_Search_Provider{
function search($query){
2012-01-31 19:12:49 +04:00
$files=OC_FileCache::search($query,true);
2011-07-29 23:03:53 +04:00
$results=array();
2012-01-31 19:12:49 +04:00
foreach($files as $fileData){
$file=$fileData['path'];
if($fileData['mime']=='httpd/unix-directory'){
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php' ).'?dir='.$file,'Files');
2011-07-29 23:03:53 +04:00
}else{
2012-01-31 19:12:49 +04:00
$mime=$fileData['mime'];
$mimeBase=$fileData['mimepart'];
2011-07-31 04:20:34 +04:00
switch($mimeBase){
case 'audio':
break;
case 'text':
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Text');
break;
2011-07-31 04:20:34 +04:00
case 'image':
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Images');
2011-07-31 04:20:34 +04:00
break;
default:
if($mime=='application/xml'){
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Text');
}else{
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php' ).'?file='.$file,'Files');
}
2011-07-31 04:20:34 +04:00
}
2011-07-29 23:03:53 +04:00
}
}
return $results;
}
}