From bc1db7916a84fe2bd5f90bd932c1a640df861206 Mon Sep 17 00:00:00 2001 From: Thomas Steur <thomas.steur@gmail.com> Date: Tue, 1 Oct 2013 01:31:46 +0000 Subject: [PATCH] refs #607 make sure user uploads a ZIP file --- lang/en.json | 3 ++- plugins/CorePluginsAdmin/CorePluginsAdmin.php | 6 ++++++ plugins/CorePluginsAdmin/javascripts/pluginExtend.js | 7 ++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lang/en.json b/lang/en.json index 6aefd3199d..725ff8a0f0 100644 --- a/lang/en.json +++ b/lang/en.json @@ -718,7 +718,8 @@ "MenuExtend": "Extend", "PluginNotCompatibleWith": "%1$s plugin is not compatible with %2$s.", "PluginAskDevToUpdate": "If you enjoyed this plugin, maybe you can ask the developers to update it to work on the latest Piwik. ", - "UninstallConfirm": "You are about to uninstall a plugin %s. The plugin will be completely removed from your platform and it won't be recoverable. Are you sure you want to do this?" + "UninstallConfirm": "You are about to uninstall a plugin %s. The plugin will be completely removed from your platform and it won't be recoverable. Are you sure you want to do this?", + "NoZipFileSelected": "Please select a ZIP file." }, "CoreUpdater": { "PluginDescription": "Piwik updating mechanism", diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php index 6fb999a1ce..c0221c712f 100644 --- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php +++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php @@ -30,6 +30,7 @@ class CorePluginsAdmin extends \Piwik\Plugin 'AssetManager.getJsFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', + 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } @@ -93,4 +94,9 @@ class CorePluginsAdmin extends \Piwik\Plugin $jsFiles[] = "plugins/CorePluginsAdmin/javascripts/pluginExtend.js"; } + public function getClientSideTranslationKeys(&$translations) + { + $translations[] = 'CorePluginsAdmin_NoZipFileSelected'; + } + } diff --git a/plugins/CorePluginsAdmin/javascripts/pluginExtend.js b/plugins/CorePluginsAdmin/javascripts/pluginExtend.js index b67e95ab07..560cbc1700 100644 --- a/plugins/CorePluginsAdmin/javascripts/pluginExtend.js +++ b/plugins/CorePluginsAdmin/javascripts/pluginExtend.js @@ -19,11 +19,12 @@ $(document).ready(function () { $('#uploadPluginForm').submit(function (event) { - $zipFile = $('[name=pluginZip]'); + var $zipFile = $('[name=pluginZip]'); + var fileName = $zipFile.val(); - if (!$zipFile.val()) { + if (!fileName || '.zip' != fileName.slice(-4)) { event.preventDefault(); - alert('Please select a ZIP file.'); + alert(_pk_translate('CorePluginsAdmin_NoZipFileSelected')); } }); -- GitLab