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