From: Jerome Jutteau Date: Tue, 10 Mar 2015 22:49:25 +0000 (+0100) Subject: Fixes #17 Add links for preview and direct download after uploading X-Git-Tag: 1.1~158 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/045f02b53953998c9cb0cff34f7f62664bdd66cd Fixes #17 Add links for preview and direct download after uploading - Also fixe previewable files types - Fixe problem with download page and previewable files - Only show preview link if the content is previewable - Don't propose preview and direct download links when a password is set --- diff --git a/f.php b/f.php index e57c18f..a5c6228 100644 --- a/f.php +++ b/f.php @@ -145,16 +145,16 @@ if (!empty ($link['key'])) echo '&k=' . urlencode($crypt_key); ?>'; document.getElementById('submit_download').submit ();"/>'; + document.getElementById('submit_preview').submit ();"/>'; require (JIRAFEAU_ROOT.'lib/template/footer.php'); @@ -200,7 +200,7 @@ if ($cfg['download_page'] && !$password_challenged && !$do_download && !$do_prev ?>'; document.getElementById('submit_download').submit ();"/> -

- : +


- + + +
+ +


-

+
+ -

- : +

+

:

+

+
+
+ + +
+

:

+

+
+
+ + +
+

:

+

+
+
+ +

:

+


- -

: diff --git a/lib/config.original.php b/lib/config.original.php index 8c30f5e..7323814 100644 --- a/lib/config.original.php +++ b/lib/config.original.php @@ -35,16 +35,10 @@ $cfg['var_root'] = ''; $cfg['lang'] = 'auto'; /* Select your style :) See media folder */ $cfg['style'] = 'modern'; -/* Set preview option. - * true: will propose user's browser to preview file if possible. - * false: will just download the file, whatever the content is. - */ +/* Propose a preview link if file type is previewable is set to true. */ $cfg['preview'] = true; -/* Download page: - * true: Will show a download page (with preview if permited and possible). - * false: Will directly download file or preview (if permited and possible). - */ -$cfg['download_page'] = false; +/* Download page: propose a link to a download page is set to true. */ +$cfg['download_page'] = true; /* Encryption feature. disable it by default. * By enabling it, file-level deduplication won't work. */ diff --git a/lib/functions.js b/lib/functions.js index ee8c6e8..ccd13d3 100644 --- a/lib/functions.js +++ b/lib/functions.js @@ -18,6 +18,7 @@ function show_link (url, reference, delete_code, crypt_key, date) { + // Download page if element exists var download_link = url + 'f.php?h=' + reference; var download_link_href = url + 'f.php?h=' + reference; if (crypt_key.length > 0) @@ -25,14 +26,71 @@ function show_link (url, reference, delete_code, crypt_key, date) download_link += '&k=' + crypt_key; download_link_href += '&k=' + crypt_key; } + if (!!document.getElementById('upload_finished_download_page')) + { + document.getElementById('upload_link').innerHTML = download_link; + document.getElementById('upload_link').href = download_link_href; + } + + // Is the preview allowed ? + if (!!document.getElementById('preview_link')) + { + document.getElementById('upload_finished_preview').style.display = 'none'; + var preview_link = url + 'f.php?h=' + reference + '&p=1'; + var preview_link_href = url + 'f.php?h=' + reference + '&p=1'; + if (crypt_key.length > 0) + { + preview_link += '&k=' + crypt_key; + preview_link_href += '&k=' + crypt_key; + } + + // Test if content can be previewed + type = document.getElementById('file_select').files[0].type; + if (type.indexOf("image") > -1 || + type.indexOf("audio") > -1 || + type.indexOf("text") > -1 || + type.indexOf("video") > -1) + { + document.getElementById('preview_link').innerHTML = preview_link; + document.getElementById('preview_link').href = preview_link_href; + document.getElementById('upload_finished_preview').style.display = ''; + } + } + + // Only show link to password page if password is set + document.getElementById('upload_password_page').style.display = 'none'; + if (document.getElementById('input_key').value.length > 0) + { + if (!!document.getElementById('upload_finished_download_page')) + document.getElementById('upload_finished_download_page').style.display = 'none'; + document.getElementById('upload_password_page').style.display = ''; + if (!!document.getElementById('upload_finished_preview')) + document.getElementById('upload_finished_preview').style.display = 'none'; + document.getElementById('upload_direct_download').style.display = 'none'; + document.getElementById('password_link').innerHTML = download_link; + document.getElementById('password_link').href = download_link_href; + } + // Direct download link + else + { + var direct_download_link = url + 'f.php?h=' + reference + '&d=1'; + var direct_download_link_href = url + 'f.php?h=' + reference + '&d=1'; + if (crypt_key.length > 0) + { + direct_download_link += '&k=' + crypt_key; + direct_download_link_href += '&k=' + crypt_key; + } + document.getElementById('direct_link').innerHTML = direct_download_link; + document.getElementById('direct_link').href = direct_download_link_href; + } + + // Delete link var delete_link = url + 'f.php?h=' + reference + '&d=' + delete_code; var delete_link_href = url + 'f.php?h=' + reference + '&d=' + delete_code; - - document.getElementById('upload_link').innerHTML = download_link; - document.getElementById('upload_link').href = download_link_href; document.getElementById('delete_link').innerHTML = delete_link; document.getElementById('delete_link').href = delete_link_href; + if (date) { document.getElementById('date').innerHTML = date; diff --git a/lib/functions.php b/lib/functions.php index 6f84649..3a304a4 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -453,7 +453,7 @@ jirafeau_is_viewable ($mime) if (!empty ($mime)) { /* Actually, verify if mime-type is an image or a text. */ - $viewable = array ('image', 'text'); + $viewable = array ('image', 'text', 'video', 'audio'); $decomposed = explode ('/', $mime); return in_array ($decomposed[0], $viewable); } diff --git a/lib/lang/fr.php b/lib/lang/fr.php index d806dc9..4efcccb 100644 --- a/lib/lang/fr.php +++ b/lib/lang/fr.php @@ -44,11 +44,15 @@ $tr = array ( 'Installer script still present' => 'Le script d\'installation est toujours présent', 'Please make sure to delete the installer script "install.php" before continuing.' => 'Merci de supprimer le fichier "install.php" avant de continuer.', 'An error occurred.' => 'Une erreur s\'est produite', - 'File uploaded! Copy the following URL to get it' => 'Fichier envoyé! Le fichier sera accessible à l\'adresse suivante', + 'File uploaded !' => 'Fichier envoyé !', + 'Download page' => 'Page de téléchargement', 'This file is valid until the following date' => 'Ce fichier est valable jusqu\'à la date suivante', - 'Keep the following URL to delete it at any moment' => 'Vous pouvez supprimer le fichier lorsque vous le désirez via l\'adresse suivante', + 'View link' => 'Lien d\'affichage', + 'Direct download link' => 'Lien de téléchargement direct', + 'Delete link' => 'Lien de suppression', /* f.php */ 'Download' => 'Télécharger', + 'Preview' => 'Prévisualiser', 'Sorry, the requested file is not found' => 'Désolé, le fichier que vous demandez n\'existe pas ou n\'existe plus', 'File not available.' => 'Fichier non disponible', 'File has been deleted.' => 'Le fichier a été supprimé.',