summaryrefslogtreecommitdiff
path: root/lib/plugins/extension/helper/extension.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-08-09 21:26:20 +0200
committerAndreas Gohr <andi@splitbrain.org>2013-08-09 21:26:20 +0200
commit5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1 (patch)
treea2e495c06c63dbb9d0116694a240783c9c0b1184 /lib/plugins/extension/helper/extension.php
parent519895b5625277197a88748c515919515f1113b8 (diff)
downloadrpg-5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1.tar.gz
rpg-5c0b30bf48d7f8e5f3d5764cfab94d0d09c0a8b1.tar.bz2
installation now works
Diffstat (limited to 'lib/plugins/extension/helper/extension.php')
-rw-r--r--lib/plugins/extension/helper/extension.php33
1 files changed, 20 insertions, 13 deletions
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;
}
/**