aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/extension/helper
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins/extension/helper')
-rw-r--r--lib/plugins/extension/helper/extension.php14
-rw-r--r--lib/plugins/extension/helper/gui.php4
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 3e7087eba..fdbb14b3d 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -615,10 +615,11 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* Install an extension from a user upload
*
* @param string $field name of the upload file
+ * @param boolean $overwrite overwrite folder if the extension name is the same
* @throws Exception when something goes wrong
* @return array The list of installed extensions
*/
- public function installFromUpload($field)
+ public function installFromUpload($field, $overwrite = true)
{
if ($_FILES[$field]['error']) {
throw new Exception($this->getLang('msg_upload_failed').' ('.$_FILES[$field]['error'].')');
@@ -637,7 +638,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
}
try {
- $installed = $this->installArchive("$tmp/upload.archive", true, $basename);
+ $installed = $this->installArchive("$tmp/upload.archive", $overwrite, $basename);
$this->updateManagerData('', $installed);
$this->removeDeletedfiles($installed);
// purge cache
@@ -652,14 +653,15 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* Install an extension from a remote URL
*
* @param string $url
+ * @param boolean $overwrite overwrite folder if the extension name is the same
* @throws Exception when something goes wrong
* @return array The list of installed extensions
*/
- public function installFromURL($url)
+ public function installFromURL($url, $overwrite = true)
{
try {
$path = $this->download($url);
- $installed = $this->installArchive($path, true);
+ $installed = $this->installArchive($path, $overwrite);
$this->updateManagerData($url, $installed);
$this->removeDeletedfiles($installed);
@@ -1040,7 +1042,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// check to make sure we aren't overwriting anything
$target = $target_base_dir.$item['base'];
if (!$overwrite && file_exists($target)) {
- // TODO remember our settings, ask the user to confirm overwrite
+ // this info message is not being exposed via exception,
+ // so that it's not interrupting the installation
+ msg(sprintf($this->getLang('msg_nooverwrite'), $item['base']));
continue;
}
diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php
index d02c02a89..919eb2c0b 100644
--- a/lib/plugins/extension/helper/gui.php
+++ b/lib/plugins/extension/helper/gui.php
@@ -148,6 +148,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
*/
public function tabInstall()
{
+ global $lang;
echo '<div class="panelHeader">';
echo $this->locale_xhtml('intro_install');
echo '</div>';
@@ -166,6 +167,9 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
->addClass('block')
->attrs(['type' => 'file']);
$form->addTag('br');
+ $form->addCheckbox('overwrite', $lang['js']['media_overwrt'])
+ ->addClass('block');
+ $form->addTag('br');
$form->addButton('', $this->getLang('btn_install'))
->attrs(['type' => 'submit', 'title' => $this->getLang('btn_install')]);
$form->addTagClose('div');