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