Add downloadURL to files templates for both public links and files

This commit is contained in:
Michael Gapczynski 2011-08-18 19:32:24 -04:00
parent 498356fcb8
commit d1aebcddf2
4 changed files with 12 additions and 11 deletions

View File

@ -13,14 +13,13 @@ if ($source !== false) {
$user = substr($source, 1, strpos($source, "/", 1) - 1);
OC_Util::setupFS($user);
$source = substr($source, strlen("/".$user."/files"));
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
print_r($dir);
$subPath = isset( $_GET['path'] ) ? $_GET['path'] : '';
$root = $source;
$source .= $dir;
$source .= $subPath;
if (!OC_Filesystem::file_exists($source)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template("", "404", "guest");
$tmpl->assign("file", $dir);
$tmpl->assign("file", $subPath);
$tmpl->printPage();
exit;
}
@ -42,7 +41,7 @@ if ($source !== false) {
// Make breadcrumb
$breadcrumb = array();
$pathtohere = "/";
foreach (explode("/", $dir) as $i) {
foreach (explode("/", $subPath) as $i) {
if ($i != "") {
$pathtohere .= "$i/";
$breadcrumb[] = array("dir" => $pathtohere, "name" => $i);
@ -54,10 +53,11 @@ if ($source !== false) {
OC_Util::addScript("files", "filelist");
$breadcrumbNav = new OC_Template("files", "part.breadcrumb", "");
$breadcrumbNav->assign("breadcrumb", $breadcrumb);
$breadcrumbNav->assign("baseUrl", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&");
$breadcrumbNav->assign("baseURL", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$list = new OC_Template("files", "part.list", "");
$list->assign("files", $files);
$list->assign("baseUrl", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&");
$list->assign("baseURL", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$list->assign("downloadURL", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$tmpl = new OC_Template("files", "index", "user");
$tmpl->assign("fileList", $list->fetchPage());
$tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage());

View File

@ -69,10 +69,11 @@ foreach( explode( "/", $dir ) as $i ){
// make breadcrumb und filelist markup
$list = new OC_Template( "files", "part.list", "" );
$list->assign( "files", $files );
$list->assign( "baseUrl", OC_Helper::linkTo("files", "index.php?"));
$list->assign( "baseURL", OC_Helper::linkTo("files", "index.php?dir="));
$list->assign( "downloadURL", OC_Helper::linkTo("files", "download.php?file="));
$breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" );
$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
$breadcrumbNav->assign( "baseUrl", OC_Helper::linkTo("files", "index.php?"));
$breadcrumbNav->assign( "baseURL", OC_Helper::linkTo("files", "index.php?dir="));
$maxUploadFilesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));

View File

@ -1,5 +1,5 @@
<?php foreach($_["breadcrumb"] as $crumb): ?>
<div class="crumb svg" data-dir='<?php echo $crumb["dir"];?>' style='background-image:url("<?php echo image_path('core','breadcrumb.png');?>")'>
<a href="<?php echo $_['baseUrl']."dir=".$crumb["dir"]; ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
<a href="<?php echo $_['baseURL'].$crumb["dir"]; ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
</div>
<?php endforeach; ?>

View File

@ -9,7 +9,7 @@
<tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'>
<td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)">
<input type="checkbox" />
<a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseUrl'].'dir='.$file['directory'].'/'.$file['name']; else echo link_to('files', 'download.php?file='.$file['directory'].'/'.$file['name']); ?>" title="">
<a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$file['directory'].'/'.$file['name']; else echo $_['downloadURL'].$file['directory'].'/'.$file['name']; ?>" title="">
<span class="nametext">
<?php if($file['type'] == 'dir'):?>
<?php echo htmlspecialchars($file['name']);?>