Use HTML5 data attribute + fix undefined variable

This commit is contained in:
Lukas Reschke 2013-01-26 14:07:35 +01:00
parent 6c882d9806
commit 2e42c6f54f
6 changed files with 5 additions and 27 deletions

View File

@ -8,7 +8,4 @@
$this->create('download', 'download{file}')
->requirements(array('file' => '.*'))
->actionInclude('files/download.php');
// oC JS config
$this->create('publicListView', 'js/publiclistview.js')
->actionInclude('files/js/publiclistview.php');
->actionInclude('files/download.php');

View File

@ -76,6 +76,7 @@ $list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files, false);
$list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
$list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
$list->assign('disableSharing', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);

View File

@ -1,20 +0,0 @@
<?php
/**
* Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Set the content type to Javascript
header("Content-type: text/javascript");
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
if ( array_key_exists('disableSharing', $_) && $_['disableSharing'] == true ) {
echo "var disableSharing = true;";
} else {
echo "var disableSharing = false;";
}

View File

@ -1,4 +1,4 @@
<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('publicListView');?>"></script>
<input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>">
<?php foreach($_['files'] as $file):
$simple_file_size = OCP\simple_file_size($file['size']);

View File

@ -1,5 +1,7 @@
$(document).ready(function() {
var disableSharing = $('#disableSharing').data('status');
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {

View File

@ -1,5 +1,3 @@
<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('publicListView');?>"></script>
<input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
<input type="hidden" name="downloadURL" value="<?php echo $_['downloadURL'] ?>" id="downloadURL">
<input type="hidden" name="filename" value="<?php echo $_['filename'] ?>" id="filename">