file.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class OC_Search_Provider_File extends OC_Search_Provider{
  3. function search($query){
  4. $files=OC_FileCache::search($query,true);
  5. $results=array();
  6. foreach($files as $fileData){
  7. $file=$fileData['path'];
  8. $mime=$fileData['mimetype'];
  9. if($mime=='httpd/unix-directory'){
  10. $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php', array('dir' => $file)),'Files');
  11. }else{
  12. $mimeBase=$fileData['mimepart'];
  13. switch($mimeBase){
  14. case 'audio':
  15. break;
  16. case 'text':
  17. $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
  18. break;
  19. case 'image':
  20. $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Images');
  21. break;
  22. default:
  23. if($mime=='application/xml'){
  24. $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
  25. }else{
  26. $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Files');
  27. }
  28. }
  29. }
  30. }
  31. return $results;
  32. }
  33. }