summaryrefslogtreecommitdiffstats
path: root/lib/private/search/provider/file.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/search/provider/file.php')
-rw-r--r--lib/private/search/provider/file.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/private/search/provider/file.php b/lib/private/search/provider/file.php
new file mode 100644
index 00000000000..9bd50931517
--- /dev/null
+++ b/lib/private/search/provider/file.php
@@ -0,0 +1,46 @@
+<?php
+
+class OC_Search_Provider_File extends OC_Search_Provider{
+ function search($query) {
+ $files=\OC\Files\Filesystem::search($query, true);
+ $results=array();
+ $l=OC_L10N::get('lib');
+ foreach($files as $fileData) {
+ $path = $fileData['path'];
+ $mime = $fileData['mimetype'];
+
+ $name = basename($path);
+ $container = dirname($path);
+ $text = '';
+ $skip = false;
+ if($mime=='httpd/unix-directory') {
+ $link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path));
+ $type = (string)$l->t('Files');
+ }else{
+ $link = OC_Helper::linkToRoute( 'download', array('file' => $path));
+ $mimeBase = $fileData['mimepart'];
+ switch($mimeBase) {
+ case 'audio':
+ $skip = true;
+ break;
+ case 'text':
+ $type = (string)$l->t('Text');
+ break;
+ case 'image':
+ $type = (string)$l->t('Images');
+ break;
+ default:
+ if($mime=='application/xml') {
+ $type = (string)$l->t('Text');
+ }else{
+ $type = (string)$l->t('Files');
+ }
+ }
+ }
+ if(!$skip) {
+ $results[] = new OC_Search_Result($name, $text, $link, $type, $container);
+ }
+ }
+ return $results;
+ }
+}