From 253d4b48ec708eb42033862dc15c8576f44a48ed Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 15:32:05 +0200 Subject: more PHPDocs, unused var, small bit code reformatting --- lib/plugins/extension/helper/extension.php | 8 ++++++-- lib/plugins/extension/helper/list.php | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 2aca0e218..dfa624907 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -799,7 +799,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(); @@ -1079,7 +1079,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { * * @author Andreas Gohr * @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 +1095,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; diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 9b1988d84..6fc8c63b1 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -333,7 +333,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { * Shortens the URL for display * * @param string $url - * * @return string HTML link */ function shortlink($url){ -- cgit v1.2.3 From 7e8500eea1e53b1de0e0f70400664afa442cd08d Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 2 Oct 2014 14:55:24 +0200 Subject: PHPDocs and some improvements --- lib/plugins/extension/helper/repository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/plugins/extension/helper') 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(); -- cgit v1.2.3 From 48b5d5e92851161ee3b3ebc7bf5b6ae6d1f0914d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 3 Dec 2014 16:50:16 +0100 Subject: warn about enabled, but not used auth plugins --- lib/plugins/extension/helper/list.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 9b1988d84..f7e6eb2ca 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -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 .= '

'.$this->getLang('git').'

'; } + if ($extension->isEnabled() && in_array('Auth', $extension->getTypes()) && $conf['auth'] != $extension->getID()) { + $errors .= '

'.$this->getLang('auth').'

'; + } + }else{ if (($canmod = $extension->canModify()) === true) { if ($extension->getDownloadURL()) { -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- lib/plugins/extension/helper/extension.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index dfa624907..6c0946b09 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -707,7 +707,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; } @@ -907,12 +907,12 @@ 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)) { @@ -1117,7 +1117,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']); -- cgit v1.2.3 From 208f4580295554c94e23377a4e02288bd5251908 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 15 Jan 2015 12:06:09 +0100 Subject: fixed wrong config check in extension manager #1006 --- lib/plugins/extension/helper/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 872cccc8c..8bcd00ec6 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -492,7 +492,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $errors .= '

'.$this->getLang('git').'

'; } - if ($extension->isEnabled() && in_array('Auth', $extension->getTypes()) && $conf['auth'] != $extension->getID()) { + if ($extension->isEnabled() && in_array('Auth', $extension->getTypes()) && $conf['authtype'] != $extension->getID()) { $errors .= '

'.$this->getLang('auth').'

'; } -- cgit v1.2.3 From a7ec353091498e86d606c27f5ca7a808c2d096c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Tue, 14 Apr 2015 10:12:02 +0200 Subject: Add display options to extension manger Allows tho show/hide extensions that are: enabled, disabled, updatable --- lib/plugins/extension/helper/gui.php | 9 +++++++++ lib/plugins/extension/helper/list.php | 1 + 2 files changed, 10 insertions(+) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php index 3a0f0c589..2dbb3d5e5 100644 --- a/lib/plugins/extension/helper/gui.php +++ b/lib/plugins/extension/helper/gui.php @@ -38,6 +38,15 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin { echo '
'; echo $this->locale_xhtml('intro_plugins'); + + $options = new Doku_Form( "viewoptions" ); + $options->addElement( form_makeOpenTag( "p" ) ); + $options->addElement( $this->getLang('display_viewoptions') ); + $options->addElement( form_makeCheckboxField( "enabled", 1, $this->getLang('display_enabled') ) ); + $options->addElement( form_makeCheckboxField( "disabled", 1, $this->getLang('display_disabled') ) ); + $options->addElement( form_makeCheckboxField( "updatable", 1, $this->getLang('display_updatable') ) ); + $options->addElement( form_makeCloseTag( "p" ) ); + $options->printForm(); echo '
'; $pluginlist = $plugin_controller->getList('', true); diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 8bcd00ec6..11aea1d0e 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'; -- cgit v1.2.3 From 79a3bed0a23b6bef35eb12c6ccbb1f3301f6c621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Mon, 27 Apr 2015 08:00:12 +0200 Subject: Generate display options via JS Since it is a JS function only, the form will be generated by it too. --- lib/plugins/extension/helper/gui.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php index 2dbb3d5e5..3a0f0c589 100644 --- a/lib/plugins/extension/helper/gui.php +++ b/lib/plugins/extension/helper/gui.php @@ -38,15 +38,6 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin { echo '
'; echo $this->locale_xhtml('intro_plugins'); - - $options = new Doku_Form( "viewoptions" ); - $options->addElement( form_makeOpenTag( "p" ) ); - $options->addElement( $this->getLang('display_viewoptions') ); - $options->addElement( form_makeCheckboxField( "enabled", 1, $this->getLang('display_enabled') ) ); - $options->addElement( form_makeCheckboxField( "disabled", 1, $this->getLang('display_disabled') ) ); - $options->addElement( form_makeCheckboxField( "updatable", 1, $this->getLang('display_updatable') ) ); - $options->addElement( form_makeCloseTag( "p" ) ); - $options->printForm(); echo '
'; $pluginlist = $plugin_controller->getList('', true); -- cgit v1.2.3 From c594265e447bf705dae05f5e59560ea4c3afea0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Thu, 7 May 2015 11:30:00 +0200 Subject: Add class name using tab name --- lib/plugins/extension/helper/gui.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/plugins/extension/helper') 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 '
  • '.$this->getLang('tab_'.$tab).'
  • '; + echo '
  • '.$this->getLang('tab_'.$tab).'
  • '; } echo ''; } -- cgit v1.2.3 From 605f8e8d0e501057749c50581087ce05089c1af3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 15 May 2015 15:17:39 +0200 Subject: added composer setup and the first composer package php-archive --- lib/plugins/extension/helper/extension.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 6c0946b09..d089245b5 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -1035,33 +1035,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; -- cgit v1.2.3 From 18f4ec973d8b711f6687adb71ce03e77e5ab1f41 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 25 May 2015 10:41:49 +0200 Subject: fixed isBundled() check when remote info is unavailable --- lib/plugins/extension/helper/extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index d089245b5..719249fbe 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -105,7 +105,7 @@ 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' -- cgit v1.2.3 From ae614416a5d7f5cab6c5b82a0c45f587d7fa9c01 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 12 Jul 2015 19:05:43 +0100 Subject: changed all input type=submit buttons to button type=submit button for better stylability --- lib/plugins/extension/helper/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 11aea1d0e..bf099d308 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -535,7 +535,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $classes = 'button '.$action; $name = 'fn['.$action.']['.hsc($extension->getID()).']'; - return ''; + return ' '; } /** -- cgit v1.2.3 From 1afa9ba84a2a44f66944dfc754dd8b8662c987fb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 16 Jul 2015 22:14:13 +0200 Subject: remove deleted files on update of extension Resolves #1192 `/lib/plugins//deleted.files` which list files that can be removed e.g. ``` # This is a list of files that were present in previous plugin releases # but were removed later. An up to date plugin should not have any of # the files installed action.php folder/file.txt ``` --- lib/plugins/extension/helper/extension.php | 41 +++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 719249fbe..7d723490e 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -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; @@ -918,7 +921,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { 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'], @@ -1117,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: -- cgit v1.2.3 From b28801bc7f36b024f1051c1e7afd9be8a4c5171e Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 18 Jul 2015 12:51:25 +0200 Subject: added plugin to list of bundled extensions --- lib/plugins/extension/helper/extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 719249fbe..c23840805 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -108,7 +108,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { 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' ) ); } -- cgit v1.2.3 From fcf2eb0eee7dc56b5ef5ef429b54a504ca229f41 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 26 Jul 2015 17:03:51 +0100 Subject: fixed missing bug icon in extension manager (since #1247) --- lib/plugins/extension/helper/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/extension/helper') diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index bf099d308..6ca72f7ce 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -266,7 +266,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $return = '