selecting a text file from the search results now activates the text viewer

This commit is contained in:
Robin Appelman 2011-08-03 00:30:21 +02:00
parent ad51328408
commit a2062036d3
2 changed files with 20 additions and 1 deletions

View File

@ -116,4 +116,16 @@ $(document).ready(function() {
}); });
FileActions.setDefault('application/xml','View'); FileActions.setDefault('application/xml','View');
} }
OC.search.customResults.Text=function(row,item){
var text=item.link.substr(item.link.indexOf('file=')+5);
var a=row.find('a');
a.data('file',text);
a.attr('href','#');
a.click(function(){
var file=$(this).data('file');
var text=file.split('/').pop();
var dir=file.substr(0,file.length-file.length-1);
TextViewer.showText(dir,text);
});
}
}); });

View File

@ -13,11 +13,18 @@ class OC_Search_Provider_File extends OC_Search_Provider{
switch($mimeBase){ switch($mimeBase){
case 'audio': case 'audio':
break; break;
case 'text':
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Text');
break;
case 'image': case 'image':
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Images'); $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Images');
break; break;
default: default:
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Files'); if($mime=='application/xml'){
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Text');
}else{
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Files');
}
} }
} }
} }