diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-08-09 21:26:20 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-08-09 21:26:20 +0200 |
commit | 5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1 (patch) | |
tree | a2e495c06c63dbb9d0116694a240783c9c0b1184 /lib/plugins/extension | |
parent | 519895b5625277197a88748c515919515f1113b8 (diff) | |
download | rpg-5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1.tar.gz rpg-5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1.tar.bz2 |
installation now works
Diffstat (limited to 'lib/plugins/extension')
-rw-r--r-- | lib/plugins/extension/admin.php | 14 | ||||
-rw-r--r-- | lib/plugins/extension/helper/extension.php | 33 | ||||
-rw-r--r-- | lib/plugins/extension/lang/en/lang.php | 9 |
3 files changed, 36 insertions, 20 deletions
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php index e28fd612c..f1ed83591 100644 --- a/lib/plugins/extension/admin.php +++ b/lib/plugins/extension/admin.php @@ -69,12 +69,14 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin { case 'install': case 'reinstall': case 'update': - $extension->setExtension($extname); - $status = $extension->installOrUpdate(); - if ($status !== true) { - msg($status, -1); - } else { - msg(sprintf($this->getLang('msg_update_success'), hsc($extension->getDisplayName())), 1); + try { + $extension->setExtension($extname); + $installed = $extension->installOrUpdate(); + foreach($installed as $extension => $info){ + msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1); + } + }catch (Exception $e){ + msg($e->getMessage(), -1); } break; case 'uninstall': diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 62f950cac..8438253f9 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -528,7 +528,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { $installed = $this->installArchive($path, $this->isInstalled(), $this->getBase()); // refresh extension information - if (!isset($installed[$this->getBase()])) { + if (!isset($installed[$this->getID()])) { throw new Exception('Error, the requested extension hasn\'t been installed or updated'); } $this->setExtension($this->getID()); @@ -734,7 +734,6 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { * @return bool|string True on success, an error message on failure */ public function installArchive($file, $overwrite=false, $base = '') { - $error = false; // create tmp directory for decompression if(!($tmp = io_mktmpdir())) { @@ -747,14 +746,21 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { } // decompress - if(!$this->decompress("$tmp/$file", "$tmp/".$base)) { + if(!$this->decompress($file, "$tmp/".$base)) { throw new Exception(sprintf($this->getLang('error_decompress'), $file)); } // search $tmp/$base for the folder(s) that has been created // move the folder(s) to lib/.. $result = array('old'=>array(), 'new'=>array()); - if(!$this->find_folders($result, $tmp.'/'.$base, ($this->isTemplate() ? 'template' : 'plugin'))) { + if($base){ + // when a base was set it came from the current extension setup #fixme this is a bit hacky + $default = ($this->isTemplate() ? 'template' : 'plugin'); + }else{ + // assume a default of plugin, find_folders will autodetect templates + $default = 'plugin'; + } + if(!$this->find_folders($result, $tmp.'/'.$base, $default)) { throw new Exception($this->getLang('error_findfolder')); } @@ -796,22 +802,23 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { // copy action if($this->dircopy($item['tmp'], $target)) { - // TODO: write manager.dat! - $installed_extensions[$item['base']] = array('type' => $item['type'], 'action' => $action); + // return info + $id = $item['base']; + if($item['type'] == 'template') $id = 'template:'.$id; + $installed_extensions[$id] = array( + 'base' => $item['base'], + 'type' => $item['type'], + 'action' => $action + ); } else { - $error = sprintf($this->getLang('error_copy').DOKU_LF, $item['base']); - break; + throw new Exception(sprintf($this->getLang('error_copy').DOKU_LF, $item['base'])); } } // cleanup if($tmp) $this->dir_delete($tmp); - if($error) { - return $error; - } - - return true; + return $installed_extensions; } /** diff --git a/lib/plugins/extension/lang/en/lang.php b/lib/plugins/extension/lang/en/lang.php index 24cabe1fa..1a5c90923 100644 --- a/lib/plugins/extension/lang/en/lang.php +++ b/lib/plugins/extension/lang/en/lang.php @@ -73,11 +73,18 @@ $lang['msg_notenabled'] = 'Plugin %s could not be enabled, check file pe $lang['msg_disabled'] = 'Plugin %s disabled'; $lang['msg_notdisabled'] = 'Plugin %s could not be disabled, check file permissions'; + +$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'; +$lang['msg_plugin_update_success'] = 'Plugin %s updated successfully'; + + $lang['msg_url_failed'] = 'URL [%s] could not be downloaded.<br /> %s'; $lang['msg_download_failed'] = 'Plugin %s could not be downloaded.<br /> %s'; $lang['msg_download_success'] = 'Plugin %s installed successfully'; $lang['msg_tpl_download_failed'] = 'Template %s could not be downloaded.<br /> %s'; -$lang['msg_tpl_download_success'] = 'Template %s installed successfully'; + $lang['msg_download_pkg_success'] = '%s extension package successfully installed (%s)'; $lang['msg_tpl_download_pkg_success'] = '%s extension package successfully installed (%s)'; |