2011-07-29 23:03:53 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class OC_Search_Provider_File extends OC_Search_Provider{
|
|
|
|
function search($query){
|
2011-07-29 23:36:03 +04:00
|
|
|
$files=OC_Filesystem::search($query);
|
2011-07-29 23:03:53 +04:00
|
|
|
$results=array();
|
|
|
|
foreach($files as $file){
|
2011-07-29 23:36:03 +04:00
|
|
|
if(OC_Filesystem::is_dir($file)){
|
2011-07-31 03:26:13 +04:00
|
|
|
$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{
|
2011-07-31 04:20:34 +04:00
|
|
|
$mime=OC_Filesystem::getMimeType($file);
|
|
|
|
$mimeBase=substr($mime,0,strpos($mime,'/'));
|
|
|
|
switch($mimeBase){
|
|
|
|
case 'audio':
|
|
|
|
break;
|
2011-08-03 02:30:21 +04:00
|
|
|
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');
|
|
|
|
break;
|
|
|
|
default:
|
2011-08-03 02:30:21 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|