fixed button logic

This commit is contained in:
Andreas Gohr 2013-08-11 11:19:34 +02:00
parent 347e1146ca
commit e445eeb3b6
5 changed files with 43 additions and 15 deletions

View File

@ -107,7 +107,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
* @return bool if the extension is protected
*/
public function isProtected() {
return in_array($this->base, array('acl', 'config', 'info', 'plugin', 'revert', 'usermanager'));
return in_array($this->id, array('acl', 'config', 'info', 'plugin', 'revert', 'usermanager', 'template:dokuwiki'));
}
/**
@ -513,20 +513,21 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
/**
* If the extension can probably be installed/updated or uninstalled
*
* @return bool|string True or one of "nourl", "noparentperms" (template/plugin install path not writable), "noperms" (extension itself not writable)
* @return bool|string True or error string
*/
public function canModify() {
if ($this->isInstalled()) {
if (!is_writable($this->getInstallDir())) {
if($this->isInstalled()) {
if(!is_writable($this->getInstallDir())) {
return 'noperms';
}
}
$parent_path = ($this->isTemplate() ? DOKU_TPLLIB : DOKU_PLUGIN);
if (!is_writable($parent_path)) {
return 'noparentperms';
}
if (!$this->getDownloadURL()) return 'nourl';
if($this->isTemplate() && !is_writable(DOKU_TPLLIB)) {
return 'notplperms';
} elseif(!is_writable(DOKU_PLUGIN)) {
return 'nopluginperms';
}
return true;
}

View File

@ -444,11 +444,13 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
*/
function make_actions(helper_plugin_extension_extension $extension) {
$return = '';
if (!$extension->isInstalled() && $extension->canModify() === true) {
$return .= $this->make_action('install', $extension);
} elseif ($extension->canModify() === true) {
if (!$extension->isBundled()) {
$return .= $this->make_action('uninstall', $extension);
$errors = '';
if ($extension->isInstalled()) {
if (($canmod = $extension->canModify()) === true) {
if (!$extension->isProtected()) {
$return .= $this->make_action('uninstall', $extension);
}
if ($extension->getDownloadURL()) {
if ($extension->updateAvailable()) {
$return .= $this->make_action('update', $extension);
@ -456,7 +458,10 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$return .= $this->make_action('reinstall', $extension);
}
}
}else{
$errors .= '<p class="permerror">'.$this->getLang($canmod).'</p>';
}
if (!$extension->isProtected()) {
if ($extension->isEnabled()) {
if(!$extension->isTemplate()){ // templates can't be disabled, only another can be enabled
@ -466,6 +471,15 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$return .= $this->make_action('enable', $extension);
}
}
}else{
if (($canmod = $extension->canModify()) === true) {
if ($extension->getDownloadURL()) {
$return .= $this->make_action('install', $extension);
}
}else{
$errors .= '<div class="permerror">'.$this->getLang($canmod).'</div>';
}
}
if (!$extension->isInstalled()) {
@ -473,7 +487,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$return .= ($extension->getLastUpdate() ? hsc($extension->getLastUpdate()) : $this->getLang('unknown')).'</span>';
}
return $return;
return $return.' '.$errors;
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

View File

@ -74,3 +74,7 @@ $lang['error_download'] = 'Unable to download the file: %s';
$lang['error_decompress'] = 'Unable to decompress the downloaded file. This maybe as a result of a bad download, in which case you should try again; or the compression format may be unknown, in which case you will need to download and install manually.';
$lang['error_findfolder'] = 'Unable to identify extension directory, you need to download and install manually';
$lang['error_copy'] = 'There was a file copy error while attempting to install files for directory <em>%s</em>: the disk could be full or file access permissions may be incorrect. This may have resulted in a partially installed plugin and leave your wiki installation unstable';
$lang['noperms'] = 'Extension directory is not writable';
$lang['notplperms'] = 'Template directory is not writable';
$lang['nopluginperms'] = 'Plugin directory is not writable';

View File

@ -258,6 +258,15 @@
margin: 0.2em 0;
text-align: center;
}
p.permerror {
margin-left: 0.4em;
text-align: left;
padding-left: 19px;
background: transparent url(images/warning.png) center left no-repeat;
line-height: 18px;
font-size: 12px;
}
}
/**