summaryrefslogtreecommitdiffstats
path: root/lib/search/provider/file.php
blob: 50e16457672d2541912f78afc8219052d8f9ce14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

class OC_Search_Provider_File extends OC_Search_Provider{
	function search($query) {
		$files=OC_FileCache::search($query,true);
		$results=array();
		foreach($files as $fileData) {
			$file=$fileData['path'];
			$mime=$fileData['mimetype'];
			if($mime=='httpd/unix-directory') {
				$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php', array('dir' => $file)),'Files');
			}else{
				$mimeBase=$fileData['mimepart'];
				switch($mimeBase) {
					case 'audio':
						break;
					case 'text':
						$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
						break;
					case 'image':
						$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Images');
						break;
					default:
						if($mime=='application/xml') {
							$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
						}else{
							$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Files');
						}
				}
			}
		}
		return $results;
	}
}