diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-08-10 11:11:14 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-08-10 11:11:14 +0200 |
commit | 32fdfac2cd446733436dc1b344d7f73b78655cb1 (patch) | |
tree | 40272ed6281f95990066fd487ba594937f9e2252 /lib/plugins | |
parent | df7751c6c456e0107b11d547c159266b470470d9 (diff) | |
download | rpg-32fdfac2cd446733436dc1b344d7f73b78655cb1.tar.gz rpg-32fdfac2cd446733436dc1b344d7f73b78655cb1.tar.bz2 |
changed exception handling, redirect after post actions
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/extension/admin.php | 98 | ||||
-rw-r--r-- | lib/plugins/extension/helper/gui.php | 5 | ||||
-rw-r--r-- | lib/plugins/extension/lang/en/lang.php | 2 |
3 files changed, 53 insertions, 52 deletions
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php index 62d94e899..99c74848b 100644 --- a/lib/plugins/extension/admin.php +++ b/lib/plugins/extension/admin.php @@ -57,73 +57,71 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin { /* @var helper_plugin_extension_extension $extension */ $extension = $this->loadHelper('extension_extension'); - if($INPUT->post->has('fn') && checkSecurityToken()) { - $actions = $INPUT->post->arr('fn'); - foreach($actions as $action => $extensions) { - foreach($extensions as $extname => $label) { - switch($action) { - case 'install': - case 'reinstall': - case 'update': - try { + try { + if($INPUT->post->has('fn') && checkSecurityToken()) { + $actions = $INPUT->post->arr('fn'); + foreach($actions as $action => $extensions) { + foreach($extensions as $extname => $label) { + switch($action) { + case 'install': + case 'reinstall': + case 'update': $extension->setExtension($extname); $installed = $extension->installOrUpdate(); foreach($installed as $ext => $info) { msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1); } - } catch(Exception $e) { - msg($e->getMessage(), -1); - } - break; - case 'uninstall': - $extension->setExtension($extname); - $status = $extension->uninstall(); - if($status !== true) { - msg($status, -1); - } else { - msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getDisplayName())), 1); - } - break; - case 'enable'; - $extension->setExtension($extname); - $status = $extension->enable(); - if($status !== true) { - msg($status, -1); - } else { - msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1); - } - break; - case 'disable'; - $extension->setExtension($extname); - $status = $extension->disable(); - if($status !== true) { - msg($status, -1); - } else { - msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1); - } - break; + break; + case 'uninstall': + $extension->setExtension($extname); + $status = $extension->uninstall(); + if($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getDisplayName())), 1); + } + break; + case 'enable'; + $extension->setExtension($extname); + $status = $extension->enable(); + if($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1); + } + break; + case 'disable'; + $extension->setExtension($extname); + $status = $extension->disable(); + if($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1); + } + break; + } } } - } - } elseif($INPUT->post->str('installurl') && checkSecurityToken()) { - try { + send_redirect($this->gui->tabURL('', array(), '&', true)); + } elseif($INPUT->post->str('installurl') && checkSecurityToken()) { $installed = $extension->installFromURL($INPUT->post->str('installurl')); foreach($installed as $ext => $info) { msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1); } - } catch(Exception $e) { - msg($e->getMessage(), -1); - } - } elseif(isset($_FILES['installfile']) && checkSecurityToken()) { - try { + send_redirect($this->gui->tabURL('', array(), '&', true)); + } elseif(isset($_FILES['installfile']) && checkSecurityToken()) { $installed = $extension->installFromUpload('installfile'); foreach($installed as $ext => $info) { msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1); } - } catch(Exception $e) { - msg($e->getMessage(), -1); + send_redirect($this->gui->tabURL('', array(), '&', true)); } + + } catch(Exception $e) { + msg($e->getMessage(), -1); + send_redirect($this->gui->tabURL('', array(), '&', true)); } + } /** diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php index 7ad238af4..2c2a19bf8 100644 --- a/lib/plugins/extension/helper/gui.php +++ b/lib/plugins/extension/helper/gui.php @@ -168,9 +168,10 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin { * @param string $tab tab to load, empty for current tab * @param array $params associative array of parameter to set * @param string $sep seperator to build the URL + * @param bool $absolute create absolute URLs? * @return string */ - public function tabURL($tab = '', $params = array(), $sep = '&') { + public function tabURL($tab = '', $params = array(), $sep = '&', $absolute=false) { global $ID; global $INPUT; @@ -181,7 +182,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin { 'tab' => $tab, 'q' => $INPUT->str('q') ); - return wl($ID, array_merge($defaults, $params), false, $sep); + return wl($ID, array_merge($defaults, $params), $absolute, $sep); } } diff --git a/lib/plugins/extension/lang/en/lang.php b/lib/plugins/extension/lang/en/lang.php index 0c4582124..8aaa0d8d2 100644 --- a/lib/plugins/extension/lang/en/lang.php +++ b/lib/plugins/extension/lang/en/lang.php @@ -74,6 +74,8 @@ $lang['msg_disabled'] = 'Plugin %s disabled'; $lang['msg_notdisabled'] = 'Plugin %s could not be disabled, check file permissions'; +$lang['msg_delete_success'] = 'Extension uninstalled'; + $lang['msg_template_install_success'] = 'Template %s installed successfully'; $lang['msg_template_update_success'] = 'Template %s updated successfully'; $lang['msg_plugin_install_success'] = 'Plugin %s installed successfully'; |