diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-09-28 21:14:59 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-09-28 21:18:20 +0200 |
commit | 366ae6661d1491a7f3db9396e05fd24034a1102f (patch) | |
tree | 8cd8d9a75f5a3b013393fc4612df1b5f65064a6c /lib/search/provider | |
parent | 4e2f575938f565f8589919bece6f6da3c313eb4d (diff) | |
download | nextcloud-server-366ae6661d1491a7f3db9396e05fd24034a1102f.tar.gz nextcloud-server-366ae6661d1491a7f3db9396e05fd24034a1102f.zip |
Simplify generating file search results
Diffstat (limited to 'lib/search/provider')
-rw-r--r-- | lib/search/provider/file.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php index 135e40667b1..e21278f3918 100644 --- a/lib/search/provider/file.php +++ b/lib/search/provider/file.php @@ -5,29 +5,35 @@ class OC_Search_Provider_File extends OC_Search_Provider{ $files=OC_FileCache::search($query,true); $results=array(); foreach($files as $fileData) { - $file=$fileData['path']; - $mime=$fileData['mimetype']; + $path = $fileData['path']; + $mime = $fileData['mimetype']; + + $name = basename($path); + $text = ''; if($mime=='httpd/unix-directory') { - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php', array('dir' => $file)),'Files'); + $link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path)); + $type = 'Files'; }else{ - $mimeBase=$fileData['mimepart']; + $link = OC_Helper::linkTo( 'files', 'download.php', array('file' => $path)); + $mimeBase = $fileData['mimepart']; switch($mimeBase) { case 'audio': break; case 'text': - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Text'); + $type = 'Text'; break; case 'image': - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Images'); + $type = 'Images'; break; default: if($mime=='application/xml') { - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Text'); + $type = 'Text'; }else{ - $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Files'); + $type = 'Files'; } } } + $results[] = new OC_Search_Result($name, $text, $link, $type); } return $results; } |