summaryrefslogtreecommitdiff
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.php88
-rw-r--r--lib/plugins/extension/helper/gui.php4
-rw-r--r--lib/plugins/extension/helper/list.php11
-rw-r--r--lib/plugins/extension/helper/repository.php6
4 files changed, 74 insertions, 35 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 2aca0e218..2f44f55ba 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -105,10 +105,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
*/
public function isBundled() {
if (!empty($this->remoteInfo['bundled'])) return $this->remoteInfo['bundled'];
- return in_array($this->base,
+ return in_array($this->id,
array(
'authad', 'authldap', 'authmysql', 'authpgsql', 'authplain', 'acl', 'info', 'extension',
- 'revert', 'popularity', 'config', 'safefnrecode', 'testing', 'template:dokuwiki'
+ 'revert', 'popularity', 'config', 'safefnrecode', 'styling', 'testing', 'template:dokuwiki'
)
);
}
@@ -578,6 +578,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
try {
$installed = $this->installArchive("$tmp/upload.archive", true, $basename);
$this->updateManagerData('', $installed);
+ $this->removeDeletedfiles($installed);
// purge cache
$this->purgeCache();
}catch (Exception $e){
@@ -598,6 +599,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
$path = $this->download($url);
$installed = $this->installArchive($path, true);
$this->updateManagerData($url, $installed);
+ $this->removeDeletedfiles($installed);
// purge cache
$this->purgeCache();
@@ -623,6 +625,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
if (!isset($installed[$this->getID()])) {
throw new Exception('Error, the requested extension hasn\'t been installed or updated');
}
+ $this->removeDeletedfiles($installed);
$this->setExtension($this->getID());
$this->purgeCache();
return $installed;
@@ -707,7 +710,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
$plugin = null;
foreach($plugin_types as $type) {
- if(@file_exists($path.$type.'.php')) {
+ if(file_exists($path.$type.'.php')) {
$plugin = plugin_load($type, $this->base);
if ($plugin) break;
}
@@ -799,7 +802,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
*
* The directory is registered for cleanup when the class is destroyed
*
- * @return bool|string
+ * @return false|string
*/
protected function mkTmpDir(){
$dir = io_mktmpdir();
@@ -907,18 +910,20 @@ 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)) {
+ if(!$overwrite && file_exists($target)) {
// TODO remember our settings, ask the user to confirm overwrite
continue;
}
- $action = @file_exists($target) ? 'update' : 'install';
+ $action = file_exists($target) ? 'update' : 'install';
// copy action
if($this->dircopy($item['tmp'], $target)) {
// return info
$id = $item['base'];
- if($item['type'] == 'template') $id = 'template:'.$id;
+ if($item['type'] == 'template') {
+ $id = 'template:'.$id;
+ }
$installed_extensions[$id] = array(
'base' => $item['base'],
'type' => $item['type'],
@@ -1035,33 +1040,24 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
$ext = $this->guess_archive($file);
if(in_array($ext, array('tar', 'bz', 'gz'))) {
- switch($ext) {
- case 'bz':
- $compress_type = Tar::COMPRESS_BZIP;
- break;
- case 'gz':
- $compress_type = Tar::COMPRESS_GZIP;
- break;
- default:
- $compress_type = Tar::COMPRESS_NONE;
- }
- $tar = new Tar();
try {
- $tar->open($file, $compress_type);
+ $tar = new \splitbrain\PHPArchive\Tar();
+ $tar->open($file);
$tar->extract($target);
- } catch (Exception $e) {
+ } catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
}
return true;
} elseif($ext == 'zip') {
- $zip = new ZipLib();
- $ok = $zip->Extract($file, $target);
-
- if($ok == -1){
- throw new Exception($this->getLang('error_decompress').' Error extracting the zip archive');
+ try {
+ $zip = new \splitbrain\PHPArchive\Zip();
+ $zip->open($file);
+ $zip->extract($target);
+ } catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
+ throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
}
return true;
@@ -1079,7 +1075,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $file The file to analyze
- * @return string|bool false if the file can't be read, otherwise an "extension"
+ * @return string|false false if the file can't be read, otherwise an "extension"
*/
private function guess_archive($file) {
$fh = fopen($file, 'rb');
@@ -1095,6 +1091,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
/**
* Copy with recursive sub-directory support
+ *
+ * @param string $src filename path to file
+ * @param string $dst filename path to file
+ * @return bool|int|string
*/
private function dircopy($src, $dst) {
global $conf;
@@ -1113,7 +1113,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
return $ok;
} else {
- $exists = @file_exists($dst);
+ $exists = file_exists($dst);
if(!@copy($src, $dst)) return false;
if(!$exists && !empty($conf['fperm'])) chmod($dst, $conf['fperm']);
@@ -1122,6 +1122,40 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin {
return true;
}
+
+ /**
+ * Delete outdated files from updated plugins
+ *
+ * @param array $installed
+ */
+ private function removeDeletedfiles($installed) {
+ foreach($installed as $id => $extension) {
+ // only on update
+ if($extension['action'] == 'install') continue;
+
+ // get definition file
+ if($extension['type'] == 'template') {
+ $extensiondir = DOKU_TPLLIB;
+ }else{
+ $extensiondir = DOKU_PLUGIN;
+ }
+ $extensiondir = $extensiondir . $extension['base'] .'/';
+ $definitionfile = $extensiondir . 'deleted.files';
+ if(!file_exists($definitionfile)) continue;
+
+ // delete the old files
+ $list = file($definitionfile);
+
+ foreach($list as $line) {
+ $line = trim(preg_replace('/#.*$/', '', $line));
+ if(!$line) continue;
+ $file = $extensiondir . $line;
+ if(!file_exists($file)) continue;
+
+ io_rmdir($file, true);
+ }
+ }
+ }
}
// vim:ts=4:sw=4:et:
diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php
index 3a0f0c589..4ec6fec85 100644
--- a/lib/plugins/extension/helper/gui.php
+++ b/lib/plugins/extension/helper/gui.php
@@ -144,11 +144,11 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin {
foreach($this->tabs as $tab) {
$url = $this->tabURL($tab);
if($this->currentTab() == $tab) {
- $class = 'class="active"';
+ $class = ' active';
} else {
$class = '';
}
- echo '<li '.$class.'><a href="'.$url.'">'.$this->getLang('tab_'.$tab).'</a></li>';
+ echo '<li class="'.$tab.$class.'"><a href="'.$url.'">'.$this->getLang('tab_'.$tab).'</a></li>';
}
echo '</ul>';
}
diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php
index 9b1988d84..6ca72f7ce 100644
--- a/lib/plugins/extension/helper/list.php
+++ b/lib/plugins/extension/helper/list.php
@@ -151,6 +151,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
if($extension->isInstalled()) {
$class.=' installed';
$class.= ($extension->isEnabled()) ? ' enabled':' disabled';
+ if($extension->updateAvailable()) $class .= ' updatable';
}
if(!$extension->canModify()) $class.= ' notselect';
if($extension->isProtected()) $class.= ' protected';
@@ -265,7 +266,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$return = '<div class="linkbar">';
$return .= $this->make_homepagelink($extension);
if ($extension->getBugtrackerURL()) {
- $return .= ' <a href="'.hsc($extension->getBugtrackerURL()).'" title="'.hsc($extension->getBugtrackerURL()).'" class ="interwiki iw_dokubug">'.$this->getLang('bugs_features').'</a> ';
+ $return .= ' <a href="'.hsc($extension->getBugtrackerURL()).'" title="'.hsc($extension->getBugtrackerURL()).'" class ="bugs">'.$this->getLang('bugs_features').'</a> ';
}
if ($extension->getTags()){
$first = true;
@@ -333,7 +334,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
* Shortens the URL for display
*
* @param string $url
- *
* @return string HTML link
*/
function shortlink($url){
@@ -461,6 +461,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
* @return string The HTML code
*/
function make_actions(helper_plugin_extension_extension $extension) {
+ global $conf;
$return = '';
$errors = '';
@@ -492,6 +493,10 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$errors .= '<p class="permerror">'.$this->getLang('git').'</p>';
}
+ if ($extension->isEnabled() && in_array('Auth', $extension->getTypes()) && $conf['authtype'] != $extension->getID()) {
+ $errors .= '<p class="permerror">'.$this->getLang('auth').'</p>';
+ }
+
}else{
if (($canmod = $extension->canModify()) === true) {
if ($extension->getDownloadURL()) {
@@ -530,7 +535,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin {
$classes = 'button '.$action;
$name = 'fn['.$action.']['.hsc($extension->getID()).']';
- return '<input class="'.$classes.'" name="'.$name.'" type="submit" value="'.$this->getLang('btn_'.$action).'" '.$title.' />';
+ return '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.$this->getLang('btn_'.$action).'</button> ';
}
/**
diff --git a/lib/plugins/extension/helper/repository.php b/lib/plugins/extension/helper/repository.php
index 6ffe89eb7..5dc2707cf 100644
--- a/lib/plugins/extension/helper/repository.php
+++ b/lib/plugins/extension/helper/repository.php
@@ -32,7 +32,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin {
$request_needed = false;
foreach ($list as $name) {
$cache = new cache('##extension_manager##'.$name, '.repo');
- $result = null;
+
if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) {
$this->loaded_extensions[$name] = true;
$request_data['ext'][] = $name;
@@ -64,7 +64,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin {
public function hasAccess() {
if ($this->has_access === null) {
$cache = new cache('##extension_manager###hasAccess', '.repo');
- $result = null;
+
if (!$cache->useCache(array('age' => 3600 * 24, 'purge'=>1))) {
$httpclient = new DokuHTTPClient();
$httpclient->timeout = 5;
@@ -91,7 +91,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin {
*/
public function getData($name) {
$cache = new cache('##extension_manager##'.$name, '.repo');
- $result = null;
+
if (!isset($this->loaded_extensions[$name]) && $this->hasAccess() && !$cache->useCache(array('age' => 3600 * 24))) {
$this->loaded_extensions[$name] = true;
$httpclient = new DokuHTTPClient();