Browse Source

Implement route for download in OC_Search_Provider_File

tags/v5.0.0alpha1
Bart Visscher 11 years ago
parent
commit
dbdf3bde7c
3 changed files with 18 additions and 2 deletions
  1. 12
    0
      apps/files/appinfo/routes.php
  2. 5
    0
      lib/route.php
  3. 1
    2
      lib/search/provider/file.php

+ 12
- 0
apps/files/appinfo/routes.php View File

@@ -0,0 +1,12 @@
<?php
/**
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/

$this->create('download', 'download{file}')
->requirements(array('file' => '.*'))
->actionInclude('files/download.php');


+ 5
- 0
lib/route.php View File

@@ -64,4 +64,9 @@ class OC_Route extends Route {
$this->setDefault('action', $action);
return $this;
}

public function actionInclude($file) {
$function = create_function('$param', 'unset($param["_route"]);$_GET=$param;unset($param);require_once "'.$file.'";');
$this->action($function);
}
}

+ 1
- 2
lib/search/provider/file.php View File

@@ -10,12 +10,11 @@ class OC_Search_Provider_File extends OC_Search_Provider{

$name = basename($path);
$text = '';
$path = urlencode($path);
if($mime=='httpd/unix-directory') {
$link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path));
$type = 'Files';
}else{
$link = OC_Helper::linkTo( 'files', 'download.php', array('file' => $path));
$link = OC_Helper::linkToRoute( 'download', array('file' => $path));
$mimeBase = $fileData['mimepart'];
switch($mimeBase) {
case 'audio':

Loading…
Cancel
Save