Blame view

sources/lib/private/search/provider/file.php 1.13 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
  <?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);
31b7f2792   Kload   Upgrade to ownclo...
13
  			$container = dirname($path);
03e52840d   Kload   Init
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  			$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) {
31b7f2792   Kload   Upgrade to ownclo...
41
  				$results[] = new OC_Search_Result($name, $text, $link, $type, $container);
03e52840d   Kload   Init
42
43
44
45
46
  			}
  		}
  		return $results;
  	}
  }