aboutsummaryrefslogtreecommitdiffstatshomepage
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.php217
-rw-r--r--lib/plugins/extension/helper/gui.php51
-rw-r--r--lib/plugins/extension/helper/list.php219
-rw-r--r--lib/plugins/extension/helper/repository.php57
4 files changed, 275 insertions, 269 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 1d06f0482..84c731fcc 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -1,4 +1,5 @@
<?php
+
/**
* DokuWiki Plugin extension (Helper Component)
*
@@ -6,13 +7,19 @@
* @author Michael Hamann <michael@content-space.de>
*/
+use dokuwiki\Extension\Plugin;
+use dokuwiki\Extension\PluginInterface;
+use dokuwiki\Utf8\PhpString;
+use splitbrain\PHPArchive\Tar;
+use splitbrain\PHPArchive\ArchiveIOException;
+use splitbrain\PHPArchive\Zip;
use dokuwiki\HTTP\DokuHTTPClient;
use dokuwiki\Extension\PluginController;
/**
* Class helper_plugin_extension_extension represents a single extension (plugin or template)
*/
-class helper_plugin_extension_extension extends DokuWiki_Plugin
+class helper_plugin_extension_extension extends Plugin
{
private $id;
private $base;
@@ -21,10 +28,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
private $remoteInfo;
private $managerData;
/** @var helper_plugin_extension_repository $repository */
- private $repository = null;
+ private $repository;
/** @var array list of temporary directories */
- private $temporary = array();
+ private $temporary = [];
/** @var string where templates are installed to */
private $tpllib = '';
@@ -34,7 +41,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
public function __construct()
{
- $this->tpllib = dirname(tpl_incdir()).'/';
+ $this->tpllib = dirname(tpl_incdir()) . '/';
}
/**
@@ -67,6 +74,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
{
$id = cleanID($id);
$this->id = $id;
+
$this->base = $id;
if (substr($id, 0, 9) == 'template:') {
@@ -76,9 +84,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$this->is_template = false;
}
- $this->localInfo = array();
- $this->managerData = array();
- $this->remoteInfo = array();
+ $this->localInfo = [];
+ $this->managerData = [];
+ $this->remoteInfo = [];
if ($this->isInstalled()) {
$this->readLocalData();
@@ -112,7 +120,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function isGitControlled()
{
if (!$this->isInstalled()) return false;
- return file_exists($this->getInstallDir().'/.git');
+ return file_exists($this->getInstallDir() . '/.git');
}
/**
@@ -125,12 +133,24 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (!empty($this->remoteInfo['bundled'])) return $this->remoteInfo['bundled'];
return in_array(
$this->id,
- array(
- 'authad', 'authldap', 'authpdo', 'authplain',
- 'acl', 'config', 'extension', 'info', 'popularity', 'revert',
- 'safefnrecode', 'styling', 'testing', 'usermanager', 'logviewer',
- 'template:dokuwiki',
- )
+ [
+ 'authad',
+ 'authldap',
+ 'authpdo',
+ 'authplain',
+ 'acl',
+ 'config',
+ 'extension',
+ 'info',
+ 'popularity',
+ 'revert',
+ 'safefnrecode',
+ 'styling',
+ 'testing',
+ 'usermanager',
+ 'logviewer',
+ 'template:dokuwiki'
+ ]
);
}
@@ -306,8 +326,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getURL()
{
if (!empty($this->localInfo['url'])) return $this->localInfo['url'];
- return 'https://www.dokuwiki.org/'.
- ($this->isTemplate() ? 'template' : 'plugin').':'.$this->getBase();
+ return 'https://www.dokuwiki.org/' .
+ ($this->isTemplate() ? 'template' : 'plugin') . ':' . $this->getBase();
}
/**
@@ -352,7 +372,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getDependencies()
{
if (!empty($this->remoteInfo['dependencies'])) return $this->remoteInfo['dependencies'];
- return array();
+ return [];
}
/**
@@ -365,7 +385,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
/* @var PluginController $plugin_controller */
global $plugin_controller;
$dependencies = $this->getDependencies();
- $missing_dependencies = array();
+ $missing_dependencies = [];
foreach ($dependencies as $dependency) {
if (!$plugin_controller->isEnabled($dependency)) {
$missing_dependencies[] = $dependency;
@@ -382,7 +402,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getConflicts()
{
if (!empty($this->remoteInfo['conflicts'])) return $this->remoteInfo['conflicts'];
- return array();
+ return [];
}
/**
@@ -393,7 +413,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getSimilarExtensions()
{
if (!empty($this->remoteInfo['similar'])) return $this->remoteInfo['similar'];
- return array();
+ return [];
}
/**
@@ -404,7 +424,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getTags()
{
if (!empty($this->remoteInfo['tags'])) return $this->remoteInfo['tags'];
- return array();
+ return [];
}
/**
@@ -537,8 +557,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getTypes()
{
if (!empty($this->remoteInfo['types'])) return $this->remoteInfo['types'];
- if ($this->isTemplate()) return array(32 => 'template');
- return array();
+ if ($this->isTemplate()) return [32 => 'template'];
+ return [];
}
/**
@@ -549,7 +569,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getCompatibleVersions()
{
if (!empty($this->remoteInfo['compatible'])) return $this->remoteInfo['compatible'];
- return array();
+ return [];
}
/**
@@ -571,9 +591,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function getInstallDir()
{
if ($this->isTemplate()) {
- return $this->tpllib.$this->base;
+ return $this->tpllib . $this->base;
} else {
- return DOKU_PLUGIN.$this->base;
+ return DOKU_PLUGIN . $this->base;
}
}
@@ -586,7 +606,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
{
if (!$this->isInstalled()) return 'none';
if (!empty($this->managerData)) return 'automatic';
- if (is_dir($this->getInstallDir().'/.git')) return 'git';
+ if (is_dir($this->getInstallDir() . '/.git')) return 'git';
return 'manual';
}
@@ -622,7 +642,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
public function installFromUpload($field, $overwrite = true)
{
if ($_FILES[$field]['error']) {
- throw new Exception($this->getLang('msg_upload_failed').' ('.$_FILES[$field]['error'].')');
+ throw new Exception($this->getLang('msg_upload_failed') . ' (' . $_FILES[$field]['error'] . ')');
}
$tmp = $this->mkTmpDir();
@@ -636,16 +656,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (!move_uploaded_file($_FILES[$field]['tmp_name'], "$tmp/upload.archive")) {
throw new Exception($this->getLang('msg_upload_failed'));
}
-
- try {
- $installed = $this->installArchive("$tmp/upload.archive", $overwrite, $basename);
- $this->updateManagerData('', $installed);
- $this->removeDeletedfiles($installed);
- // purge cache
- $this->purgeCache();
- } catch (Exception $e) {
- throw $e;
- }
+ $installed = $this->installArchive("$tmp/upload.archive", $overwrite, $basename);
+ $this->updateManagerData('', $installed);
+ $this->removeDeletedfiles($installed);
+ $this->purgeCache();
return $installed;
}
@@ -659,17 +673,11 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
public function installFromURL($url, $overwrite = true)
{
- try {
- $path = $this->download($url);
- $installed = $this->installArchive($path, $overwrite);
- $this->updateManagerData($url, $installed);
- $this->removeDeletedfiles($installed);
-
- // purge cache
- $this->purgeCache();
- } catch (Exception $e) {
- throw $e;
- }
+ $path = $this->download($url);
+ $installed = $this->installArchive($path, $overwrite);
+ $this->updateManagerData($url, $installed);
+ $this->removeDeletedfiles($installed);
+ $this->purgeCache();
return $installed;
}
@@ -767,37 +775,36 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
protected function readLocalData()
{
if ($this->isTemplate()) {
- $infopath = $this->getInstallDir().'/template.info.txt';
+ $infopath = $this->getInstallDir() . '/template.info.txt';
} else {
- $infopath = $this->getInstallDir().'/plugin.info.txt';
+ $infopath = $this->getInstallDir() . '/plugin.info.txt';
}
if (is_readable($infopath)) {
$this->localInfo = confToHash($infopath);
} elseif (!$this->isTemplate() && $this->isEnabled()) {
- $path = $this->getInstallDir().'/';
+ $path = $this->getInstallDir() . '/';
$plugin = null;
foreach (PluginController::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;
+ if ($plugin instanceof PluginInterface) break;
}
- if ($dh = @opendir($path.$type.'/')) {
+ if ($dh = @opendir($path . $type . '/')) {
while (false !== ($cp = readdir($dh))) {
if ($cp == '.' || $cp == '..' || strtolower(substr($cp, -4)) != '.php') continue;
- $plugin = plugin_load($type, $this->base.'_'.substr($cp, 0, -4));
- if ($plugin) break;
+ $plugin = plugin_load($type, $this->base . '_' . substr($cp, 0, -4));
+ if ($plugin instanceof PluginInterface) break;
}
- if ($plugin) break;
+ if ($plugin instanceof PluginInterface) break;
closedir($dh);
}
}
- if ($plugin) {
- /* @var DokuWiki_Plugin $plugin */
+ if ($plugin instanceof PluginInterface) {
$this->localInfo = $plugin->getInfo();
}
}
@@ -814,10 +821,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$origID = $this->getID();
if (is_null($installed)) {
- $installed = array($origID);
+ $installed = [$origID];
}
- foreach ($installed as $ext => $info) {
+ foreach (array_keys($installed) as $ext) {
if ($this->getID() != $ext) $this->setExtension($ext);
if ($url) {
$this->managerData['downloadurl'] = $url;
@@ -840,12 +847,12 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
protected function readManagerData()
{
- $managerpath = $this->getInstallDir().'/manager.dat';
+ $managerpath = $this->getInstallDir() . '/manager.dat';
if (is_readable($managerpath)) {
$file = @file($managerpath);
if (!empty($file)) {
foreach ($file as $line) {
- list($key, $value) = sexplode('=', trim($line, DOKU_LF), 2, '');
+ [$key, $value] = sexplode('=', trim($line, DOKU_LF), 2, '');
$key = trim($key);
$value = trim($value);
// backwards compatible with old plugin manager
@@ -861,10 +868,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
protected function writeManagerData()
{
- $managerpath = $this->getInstallDir().'/manager.dat';
+ $managerpath = $this->getInstallDir() . '/manager.dat';
$data = '';
foreach ($this->managerData as $k => $v) {
- $data .= $k.'='.$v.DOKU_LF;
+ $data .= $k . '=' . $v . DOKU_LF;
}
io_saveFile($managerpath, $data);
}
@@ -913,13 +920,13 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$name = '';
if (isset($http->resp_headers['content-disposition'])) {
$content_disposition = $http->resp_headers['content-disposition'];
- $match = array();
- if (is_string($content_disposition) &&
+ $match = [];
+ if (
+ is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
) {
- $name = \dokuwiki\Utf8\PhpString::basename($match[1]);
+ $name = PhpString::basename($match[1]);
}
-
}
if (!$name) {
@@ -927,14 +934,14 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$name = $defaultName;
}
- $file = $file.$name;
+ $file .= $name;
$fileexists = file_exists($file);
- $fp = @fopen($file,"w");
+ $fp = @fopen($file, "w");
if (!$fp) return false;
fwrite($fp, $data);
fclose($fp);
- if (!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
+ if (!$fileexists && $conf['fperm']) chmod($file, $conf['fperm']);
return $name;
}
@@ -957,7 +964,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (is_null($file)) {
$file = md5($url);
} else {
- $file = \dokuwiki\Utf8\PhpString::basename($file);
+ $file = PhpString::basename($file);
}
// create tmp directory for download
@@ -966,14 +973,15 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
}
// download
- if (!$file = $this->downloadToFile($url, $tmp.'/', $file)) {
+ if (!$file = $this->downloadToFile($url, $tmp . '/', $file)) {
io_rmdir($tmp, true);
- throw new Exception(sprintf($this->getLang('error_download'),
- '<bdi>'.hsc($url).'</bdi>')
- );
+ throw new Exception(sprintf(
+ $this->getLang('error_download'),
+ '<bdi>' . hsc($url) . '</bdi>'
+ ));
}
- return $tmp.'/'.$file;
+ return $tmp . '/' . $file;
}
/**
@@ -985,7 +993,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
public function installArchive($file, $overwrite = false, $base = '')
{
- $installed_extensions = array();
+ $installed_extensions = [];
// create tmp directory for decompression
if (!($tmp = $this->mkTmpDir())) {
@@ -993,18 +1001,18 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
}
// add default base folder if specified to handle case where zip doesn't contain this
- if ($base && !@mkdir($tmp.'/'.$base)) {
+ if ($base && !@mkdir($tmp . '/' . $base)) {
throw new Exception($this->getLang('error_dircreate'));
}
// decompress
- $this->decompress($file, "$tmp/".$base);
+ $this->decompress($file, "$tmp/" . $base);
// search $tmp/$base for the folder(s) that has been created
// move the folder(s) to lib/..
- $result = array('old'=>array(), 'new'=>array());
+ $result = ['old' => [], 'new' => []];
$default = ($this->isTemplate() ? 'template' : 'plugin');
- if (!$this->findFolders($result, $tmp.'/'.$base, $default)) {
+ if (!$this->findFolders($result, $tmp . '/' . $base, $default)) {
throw new Exception($this->getLang('error_findfolder'));
}
@@ -1040,7 +1048,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
}
// check to make sure we aren't overwriting anything
- $target = $target_base_dir.$item['base'];
+ $target = $target_base_dir . $item['base'];
if (!$overwrite && file_exists($target)) {
// this info message is not being exposed via exception,
// so that it's not interrupting the installation
@@ -1055,17 +1063,18 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// return info
$id = $item['base'];
if ($item['type'] == 'template') {
- $id = 'template:'.$id;
+ $id = 'template:' . $id;
}
- $installed_extensions[$id] = array(
+ $installed_extensions[$id] = [
'base' => $item['base'],
'type' => $item['type'],
'action' => $action
- );
+ ];
} else {
- throw new Exception(sprintf($this->getLang('error_copy').DOKU_LF,
- '<bdi>'.$item['base'].'</bdi>')
- );
+ throw new Exception(sprintf(
+ $this->getLang('error_copy') . DOKU_LF,
+ '<bdi>' . $item['base'] . '</bdi>'
+ ));
}
}
@@ -1105,7 +1114,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$dh = @opendir($this_dir);
if (!$dh) return false;
- $found_dirs = array();
+ $found_dirs = [];
$found_files = 0;
$found_template_parts = 0;
while (false !== ($f = readdir($dh))) {
@@ -1120,7 +1129,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
case 'plugin.info.txt':
case 'template.info.txt':
// we have found a clear marker, save and return
- $info = array();
+ $info = [];
$type = explode('.', $f, 2);
$info['type'] = $type[0];
$info['tmp'] = $this_dir;
@@ -1142,7 +1151,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// files where found but no info.txt - use old method
if ($found_files) {
- $info = array();
+ $info = [];
$info['tmp'] = $this_dir;
// does this look like a template or should we use the default type?
if ($found_template_parts >= 2) {
@@ -1178,23 +1187,23 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (substr($target, -1) == "/") $target = substr($target, 0, -1);
$ext = $this->guessArchiveType($file);
- if (in_array($ext, array('tar', 'bz', 'gz'))) {
+ if (in_array($ext, ['tar', 'bz', 'gz'])) {
try {
- $tar = new \splitbrain\PHPArchive\Tar();
+ $tar = new Tar();
$tar->open($file);
$tar->extract($target);
- } catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
- throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
+ } catch (ArchiveIOException $e) {
+ throw new Exception($this->getLang('error_decompress') . ' ' . $e->getMessage(), $e->getCode(), $e);
}
return true;
} elseif ($ext == 'zip') {
try {
- $zip = new \splitbrain\PHPArchive\Zip();
+ $zip = new Zip();
$zip->open($file);
$zip->extract($target);
- } catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
- throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
+ } catch (ArchiveIOException $e) {
+ throw new Exception($this->getLang('error_decompress') . ' ' . $e->getMessage(), $e->getCode(), $e);
}
return true;
@@ -1202,7 +1211,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// the only case when we don't get one of the recognized archive types is
// when the archive file can't be read
- throw new Exception($this->getLang('error_decompress').' Couldn\'t read archive file');
+ throw new Exception($this->getLang('error_decompress') . ' Couldn\'t read archive file');
}
/**
@@ -1269,7 +1278,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
*/
private function removeDeletedfiles($installed)
{
- foreach ($installed as $id => $extension) {
+ foreach ($installed as $extension) {
// only on update
if ($extension['action'] == 'install') continue;
@@ -1279,7 +1288,7 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
} else {
$extensiondir = DOKU_PLUGIN;
}
- $extensiondir = $extensiondir . $extension['base'] .'/';
+ $extensiondir = $extensiondir . $extension['base'] . '/';
$definitionfile = $extensiondir . 'deleted.files';
if (!file_exists($definitionfile)) continue;
diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php
index 919eb2c0b..4495af1e5 100644
--- a/lib/plugins/extension/helper/gui.php
+++ b/lib/plugins/extension/helper/gui.php
@@ -1,4 +1,5 @@
<?php
+
/**
* DokuWiki Plugin extension (Helper Component)
*
@@ -6,14 +7,15 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
+use dokuwiki\Extension\Plugin;
use dokuwiki\Form\Form;
/**
* Class helper_plugin_extension_list takes care of the overall GUI
*/
-class helper_plugin_extension_gui extends DokuWiki_Plugin
+class helper_plugin_extension_gui extends Plugin
{
- protected $tabs = array('plugins', 'templates', 'search', 'install');
+ protected $tabs = ['plugins', 'templates', 'search', 'install'];
/** @var string the extension that should have an open info window FIXME currently broken */
protected $infoFor = '';
@@ -45,8 +47,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
- 'action' => $this->tabURL('', [], '&'),
- 'id' => 'extension__list',
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
]);
$list->startForm();
foreach ($pluginlist as $name) {
@@ -68,7 +70,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
echo '</div>';
// FIXME do we have a real way?
- $tpllist = glob(DOKU_INC.'lib/tpl/*', GLOB_ONLYDIR);
+ $tpllist = glob(DOKU_INC . 'lib/tpl/*', GLOB_ONLYDIR);
$tpllist = array_map('basename', $tpllist);
sort($tpllist);
@@ -78,8 +80,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
- 'action' => $this->tabURL('', [], '&'),
- 'id' => 'extension__list',
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
]);
$list->startForm();
foreach ($tpllist as $name) {
@@ -102,8 +104,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
echo '</div>';
$form = new Form([
- 'action' => $this->tabURL('', [], '&'),
- 'class' => 'search',
+ 'action' => $this->tabURL('', [], '&'),
+ 'class' => 'search',
]);
$form->addTagOpen('div')->addClass('no');
$form->addTextInput('q', $this->getLang('search_for'))
@@ -118,7 +120,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
/* @var helper_plugin_extension_repository $repository FIXME should we use some gloabl instance? */
$repository = $this->loadHelper('extension_repository');
- $result = $repository->search($INPUT->str('q'));
+ $result = $repository->search($INPUT->str('q'));
/* @var helper_plugin_extension_extension $extension */
$extension = $this->loadHelper('extension_extension');
@@ -126,8 +128,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
- 'action' => $this->tabURL('', [], '&'),
- 'id' => 'extension__list',
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
]);
$list->startForm();
if ($result) {
@@ -154,9 +156,9 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
echo '</div>';
$form = new Form([
- 'action' => $this->tabURL('', [], '&'),
- 'enctype' => 'multipart/form-data',
- 'class' => 'install',
+ 'action' => $this->tabURL('', [], '&'),
+ 'enctype' => 'multipart/form-data',
+ 'class' => 'install',
]);
$form->addTagOpen('div')->addClass('no');
$form->addTextInput('installurl', $this->getLang('install_url'))
@@ -191,7 +193,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
} else {
$class = '';
}
- echo '<li class="'.$tab.$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>';
}
@@ -213,10 +216,10 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
/**
* Create an URL inside the extension manager
*
- * @param string $tab tab to load, empty for current tab
- * @param array $params associative array of parameter to set
- * @param string $sep seperator to build the URL
- * @param bool $absolute create absolute URLs?
+ * @param string $tab tab to load, empty for current tab
+ * @param array $params associative array of parameter to set
+ * @param string $sep seperator to build the URL
+ * @param bool $absolute create absolute URLs?
* @return string
*/
public function tabURL($tab = '', $params = [], $sep = '&', $absolute = false)
@@ -225,11 +228,11 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
global $INPUT;
if (!$tab) $tab = $this->currentTab();
- $defaults = array(
- 'do' => 'admin',
+ $defaults = [
+ 'do' => 'admin',
'page' => 'extension',
- 'tab' => $tab,
- );
+ 'tab' => $tab
+ ];
if ($tab == 'search') $defaults['q'] = $INPUT->str('q');
return wl($ID, array_merge($defaults, $params), $absolute, $sep);
diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php
index 647575b10..ec5db0e1d 100644
--- a/lib/plugins/extension/helper/list.php
+++ b/lib/plugins/extension/helper/list.php
@@ -1,15 +1,17 @@
<?php
+
+use dokuwiki\Extension\Plugin;
+
/**
* DokuWiki Plugin extension (Helper Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michael Hamann <michael@content-space.de>
*/
-
/**
* Class helper_plugin_extension_list takes care of creating a HTML list of extensions
*/
-class helper_plugin_extension_list extends DokuWiki_Plugin
+class helper_plugin_extension_list extends Plugin
{
protected $form = '';
/** @var helper_plugin_extension_gui */
@@ -56,7 +58,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function addHeader($id, $header, $level = 2)
{
- $this->form .='<h'.$level.' id="'.$id.'">'.hsc($header).'</h'.$level.'>'.DOKU_LF;
+ $this->form .= '<h' . $level . ' id="' . $id . '">' . hsc($header) . '</h' . $level . '>' . DOKU_LF;
}
/**
@@ -66,7 +68,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function addParagraph($data)
{
- $this->form .= '<p>'.hsc($data).'</p>'.DOKU_LF;
+ $this->form .= '<p>' . hsc($data) . '</p>' . DOKU_LF;
}
/**
@@ -78,9 +80,9 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
{
$this->form .= '<div class="no">';
foreach ($data as $key => $value) {
- $this->form .= '<input type="hidden" name="'.hsc($key).'" value="'.hsc($value).'" />';
+ $this->form .= '<input type="hidden" name="' . hsc($key) . '" value="' . hsc($value) . '" />';
}
- $this->form .= '</div>'.DOKU_LF;
+ $this->form .= '</div>' . DOKU_LF;
}
/**
@@ -97,7 +99,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
public function nothingFound()
{
global $lang;
- $this->form .= '<li class="notfound">'.$lang['nothingfound'].'</li>';
+ $this->form .= '<li class="notfound">' . $lang['nothingfound'] . '</li>';
}
/**
@@ -118,8 +120,8 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
private function startRow(helper_plugin_extension_extension $extension)
{
- $this->form .= '<li id="extensionplugin__'.hsc($extension->getID()).
- '" class="'.$this->makeClass($extension).'">';
+ $this->form .= '<li id="extensionplugin__' . hsc($extension->getID()) .
+ '" class="' . $this->makeClass($extension) . '">';
}
/**
@@ -129,7 +131,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
private function populateColumn($class, $html)
{
- $this->form .= '<div class="'.$class.' col">'.$html.'</div>'.DOKU_LF;
+ $this->form .= '<div class="' . $class . ' col">' . $html . '</div>' . DOKU_LF;
}
/**
@@ -137,7 +139,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
private function endRow()
{
- $this->form .= '</li>'.DOKU_LF;
+ $this->form .= '</li>' . DOKU_LF;
}
/**
@@ -155,18 +157,18 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
} else {
$linktype = 'extern';
}
- $param = array(
+ $param = [
'href' => $url,
'title' => $url,
'class' => ($linktype == 'extern') ? 'urlextern' : 'interwiki iw_doku',
'target' => $conf['target'][$linktype],
- 'rel' => ($linktype == 'extern') ? 'noopener' : '',
- );
+ 'rel' => ($linktype == 'extern') ? 'noopener' : ''
+ ];
if ($linktype == 'extern' && $conf['relnofollow']) {
$param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
}
- $html = ' <a '. buildAttributes($param, true).'>'.
- $this->getLang('homepage_link').'</a>';
+ $html = ' <a ' . buildAttributes($param, true) . '>' .
+ $this->getLang('homepage_link') . '</a>';
return $html;
}
@@ -180,12 +182,12 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
{
$class = ($extension->isTemplate()) ? 'template' : 'plugin';
if ($extension->isInstalled()) {
- $class.=' installed';
- $class.= ($extension->isEnabled()) ? ' enabled':' disabled';
+ $class .= ' installed';
+ $class .= ($extension->isEnabled()) ? ' enabled' : ' disabled';
if ($extension->updateAvailable()) $class .= ' updatable';
}
- if (!$extension->canModify()) $class.= ' notselect';
- if ($extension->isProtected()) $class.= ' protected';
+ if (!$extension->canModify()) $class .= ' notselect';
+ if ($extension->isProtected()) $class .= ' protected';
//if($this->showinfo) $class.= ' showinfo';
return $class;
}
@@ -201,17 +203,17 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
if ($extension->getAuthor()) {
$mailid = $extension->getEmailID();
if ($mailid) {
- $url = $this->gui->tabURL('search', array('q' => 'authorid:'.$mailid));
- $html = '<a href="'.$url.'" class="author" title="'.$this->getLang('author_hint').'" >'.
- '<img src="//www.gravatar.com/avatar/'.$mailid.
- '?s=20&amp;d=mm" width="20" height="20" alt="" /> '.
- hsc($extension->getAuthor()).'</a>';
+ $url = $this->gui->tabURL('search', ['q' => 'authorid:' . $mailid]);
+ $html = '<a href="' . $url . '" class="author" title="' . $this->getLang('author_hint') . '" >' .
+ '<img src="//www.gravatar.com/avatar/' . $mailid .
+ '?s=20&amp;d=mm" width="20" height="20" alt="" /> ' .
+ hsc($extension->getAuthor()) . '</a>';
} else {
- $html = '<span class="author">'.hsc($extension->getAuthor()).'</span>';
+ $html = '<span class="author">' . hsc($extension->getAuthor()) . '</span>';
}
- $html = '<bdi>'.$html.'</bdi>';
+ $html = '<bdi>' . $html . '</bdi>';
} else {
- $html = '<em class="author">'.$this->getLang('unknown_author').'</em>'.DOKU_LF;
+ $html = '<em class="author">' . $this->getLang('unknown_author') . '</em>' . DOKU_LF;
}
return $html;
}
@@ -233,17 +235,17 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$thumb = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $thumb);
$title = sprintf($this->getLang('screenshot'), hsc($extension->getDisplayName()));
- $img = '<a href="'.hsc($screen).'" target="_blank" class="extension_screenshot">'.
- '<img alt="'.$title.'" width="120" height="70" src="'.hsc($thumb).'" />'.
+ $img = '<a href="' . hsc($screen) . '" target="_blank" class="extension_screenshot">' .
+ '<img alt="' . $title . '" width="120" height="70" src="' . hsc($thumb) . '" />' .
'</a>';
} elseif ($extension->isTemplate()) {
- $img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
+ $img = '<img alt="" width="120" height="70" src="' . DOKU_BASE .
'lib/plugins/extension/images/template.png" />';
} else {
- $img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
+ $img = '<img alt="" width="120" height="70" src="' . DOKU_BASE .
'lib/plugins/extension/images/plugin.png" />';
}
- $html = '<div class="screenshot" >'.$img.'<span></span></div>'.DOKU_LF;
+ $html = '<div class="screenshot" >' . $img . '<span></span></div>' . DOKU_LF;
return $html;
}
@@ -260,26 +262,26 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$html .= '<h2>';
$html .= sprintf(
$this->getLang('extensionby'),
- '<bdi>'.hsc($extension->getDisplayName()).'</bdi>',
+ '<bdi>' . hsc($extension->getDisplayName()) . '</bdi>',
$this->makeAuthor($extension)
);
- $html .= '</h2>'.DOKU_LF;
+ $html .= '</h2>' . DOKU_LF;
$html .= $this->makeScreenshot($extension);
$popularity = $extension->getPopularity();
if ($popularity !== false && !$extension->isBundled()) {
- $popularityText = sprintf($this->getLang('popularity'), round($popularity*100, 2));
- $html .= '<div class="popularity" title="'.$popularityText.'">'.
- '<div style="width: '.($popularity * 100).'%;">'.
- '<span class="a11y">'.$popularityText.'</span>'.
- '</div></div>'.DOKU_LF;
+ $popularityText = sprintf($this->getLang('popularity'), round($popularity * 100, 2));
+ $html .= '<div class="popularity" title="' . $popularityText . '">' .
+ '<div style="width: ' . ($popularity * 100) . '%;">' .
+ '<span class="a11y">' . $popularityText . '</span>' .
+ '</div></div>' . DOKU_LF;
}
if ($extension->getDescription()) {
$html .= '<p><bdi>';
- $html .= hsc($extension->getDescription()).' ';
- $html .= '</bdi></p>'.DOKU_LF;
+ $html .= hsc($extension->getDescription()) . ' ';
+ $html .= '</bdi></p>' . DOKU_LF;
}
$html .= $this->makeLinkbar($extension);
@@ -288,18 +290,18 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$url = $this->gui->tabURL('');
$class = 'close';
} else {
- $url = $this->gui->tabURL('', array('info' => $extension->getID()));
+ $url = $this->gui->tabURL('', ['info' => $extension->getID()]);
$class = '';
}
- $html .= ' <a href="'.$url.'#extensionplugin__'.$extension->getID().
- '" class="info '.$class.'" title="'.$this->getLang('btn_info').
- '" data-extid="'.$extension->getID().'">'.$this->getLang('btn_info').'</a>';
+ $html .= ' <a href="' . $url . '#extensionplugin__' . $extension->getID() .
+ '" class="info ' . $class . '" title="' . $this->getLang('btn_info') .
+ '" data-extid="' . $extension->getID() . '">' . $this->getLang('btn_info') . '</a>';
if ($showinfo) {
$html .= $this->makeInfo($extension);
}
$html .= $this->makeNoticeArea($extension);
- $html .= '</div>'.DOKU_LF;
+ $html .= '</div>' . DOKU_LF;
return $html;
}
@@ -322,34 +324,34 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
} else {
$linktype = 'extern';
}
- $param = array(
+ $param = [
'href' => $bugtrackerURL,
'title' => $bugtrackerURL,
'class' => 'bugs',
'target' => $conf['target'][$linktype],
- 'rel' => ($linktype == 'extern') ? 'noopener' : '',
- );
+ 'rel' => ($linktype == 'extern') ? 'noopener' : ''
+ ];
if ($conf['relnofollow']) {
$param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
}
- $html .= ' <a '.buildAttributes($param, true).'>'.
- $this->getLang('bugs_features').'</a>';
+ $html .= ' <a ' . buildAttributes($param, true) . '>' .
+ $this->getLang('bugs_features') . '</a>';
}
if ($extension->getTags()) {
$first = true;
- $html .= ' <span class="tags">'.$this->getLang('tags').' ';
+ $html .= ' <span class="tags">' . $this->getLang('tags') . ' ';
foreach ($extension->getTags() as $tag) {
if (!$first) {
$html .= ', ';
} else {
$first = false;
}
- $url = $this->gui->tabURL('search', ['q' => 'tag:'.$tag]);
- $html .= '<bdi><a href="'.$url.'">'.hsc($tag).'</a></bdi>';
+ $url = $this->gui->tabURL('search', ['q' => 'tag:' . $tag]);
+ $html .= '<bdi><a href="' . $url . '">' . hsc($tag) . '</a></bdi>';
}
$html .= '</span>';
}
- $html .= '</div>'.DOKU_LF;
+ $html .= '</div>' . DOKU_LF;
return $html;
}
@@ -381,18 +383,18 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
'</div>';
}
if (($securityissue = $extension->getSecurityIssue()) !== false) {
- $html .= '<div class="msg error">'.
- sprintf($this->getLang('security_issue'), '<bdi>'.hsc($securityissue).'</bdi>').
+ $html .= '<div class="msg error">' .
+ sprintf($this->getLang('security_issue'), '<bdi>' . hsc($securityissue) . '</bdi>') .
'</div>';
}
if (($securitywarning = $extension->getSecurityWarning()) !== false) {
- $html .= '<div class="msg notify">'.
- sprintf($this->getLang('security_warning'), '<bdi>'.hsc($securitywarning).'</bdi>').
+ $html .= '<div class="msg notify">' .
+ sprintf($this->getLang('security_warning'), '<bdi>' . hsc($securitywarning) . '</bdi>') .
'</div>';
}
if ($extension->updateAvailable()) {
- $html .= '<div class="msg notify">'.
- sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())).
+ $html .= '<div class="msg notify">' .
+ sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())) .
'</div>';
}
if ($extension->hasDownloadURLChanged()) {
@@ -404,7 +406,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
) .
'</div>';
}
- return $html.DOKU_LF;
+ return $html . DOKU_LF;
}
/**
@@ -420,13 +422,13 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$link = parse_url($url);
$base = $link['host'];
- if (!empty($link['port'])) $base .= $base.':'.$link['port'];
+ if (!empty($link['port'])) $base .= $base . ':' . $link['port'];
$long = $link['path'];
if (!empty($link['query'])) $long .= $link['query'];
$name = shorten($base, $long, 55);
- $html = '<a href="'.hsc($url).'" class="urlextern">'.hsc($name).'</a>';
+ $html = '<a href="' . hsc($url) . '" class="urlextern">' . hsc($name) . '</a>';
return $html;
}
@@ -441,26 +443,26 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$default = $this->getLang('unknown');
$html = '<dl class="details">';
- $html .= '<dt>'.$this->getLang('status').'</dt>';
- $html .= '<dd>'.$this->makeStatus($extension).'</dd>';
+ $html .= '<dt>' . $this->getLang('status') . '</dt>';
+ $html .= '<dd>' . $this->makeStatus($extension) . '</dd>';
if ($extension->getDonationURL()) {
- $html .= '<dt>'.$this->getLang('donate').'</dt>';
+ $html .= '<dt>' . $this->getLang('donate') . '</dt>';
$html .= '<dd>';
- $html .= '<a href="'.$extension->getDonationURL().'" class="donate">'.
- $this->getLang('donate_action').'</a>';
+ $html .= '<a href="' . $extension->getDonationURL() . '" class="donate">' .
+ $this->getLang('donate_action') . '</a>';
$html .= '</dd>';
}
if (!$extension->isBundled()) {
- $html .= '<dt>'.$this->getLang('downloadurl').'</dt>';
+ $html .= '<dt>' . $this->getLang('downloadurl') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getDownloadURL()
? $this->shortlink($extension->getDownloadURL())
: $default);
$html .= '</bdi></dd>';
- $html .= '<dt>'.$this->getLang('repository').'</dt>';
+ $html .= '<dt>' . $this->getLang('repository') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getSourcerepoURL()
? $this->shortlink($extension->getSourcerepoURL())
@@ -470,13 +472,13 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
if ($extension->isInstalled()) {
if ($extension->getInstalledVersion()) {
- $html .= '<dt>'.$this->getLang('installed_version').'</dt>';
+ $html .= '<dt>' . $this->getLang('installed_version') . '</dt>';
$html .= '<dd>';
$html .= hsc($extension->getInstalledVersion());
$html .= '</dd>';
}
if (!$extension->isBundled()) {
- $html .= '<dt>'.$this->getLang('install_date').'</dt>';
+ $html .= '<dt>' . $this->getLang('install_date') . '</dt>';
$html .= '<dd>';
$html .= ($extension->getUpdateDate()
? hsc($extension->getUpdateDate())
@@ -485,7 +487,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
}
}
if (!$extension->isInstalled() || $extension->updateAvailable()) {
- $html .= '<dt>'.$this->getLang('available_version').'</dt>';
+ $html .= '<dt>' . $this->getLang('available_version') . '</dt>';
$html .= '<dd>';
$html .= ($extension->getLastUpdate()
? hsc($extension->getLastUpdate())
@@ -493,7 +495,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$html .= '</dd>';
}
- $html .= '<dt>'.$this->getLang('provides').'</dt>';
+ $html .= '<dt>' . $this->getLang('provides') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getTypes()
? hsc(implode(', ', $extension->getTypes()))
@@ -501,35 +503,35 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$html .= '</bdi></dd>';
if (!$extension->isBundled() && $extension->getCompatibleVersions()) {
- $html .= '<dt>'.$this->getLang('compatible').'</dt>';
+ $html .= '<dt>' . $this->getLang('compatible') . '</dt>';
$html .= '<dd>';
foreach ($extension->getCompatibleVersions() as $date => $version) {
- $html .= '<bdi>'.$version['label'].' ('.$date.')</bdi>, ';
+ $html .= '<bdi>' . $version['label'] . ' (' . $date . ')</bdi>, ';
}
$html = rtrim($html, ', ');
$html .= '</dd>';
}
if ($extension->getDependencies()) {
- $html .= '<dt>'.$this->getLang('depends').'</dt>';
+ $html .= '<dt>' . $this->getLang('depends') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getDependencies());
$html .= '</dd>';
}
if ($extension->getSimilarExtensions()) {
- $html .= '<dt>'.$this->getLang('similar').'</dt>';
+ $html .= '<dt>' . $this->getLang('similar') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getSimilarExtensions());
$html .= '</dd>';
}
if ($extension->getConflicts()) {
- $html .= '<dt>'.$this->getLang('conflicts').'</dt>';
+ $html .= '<dt>' . $this->getLang('conflicts') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getConflicts());
$html .= '</dd>';
}
- $html .= '</dl>'.DOKU_LF;
+ $html .= '</dl>' . DOKU_LF;
return $html;
}
@@ -543,9 +545,9 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
{
$html = '';
foreach ($ext as $link) {
- $html .= '<bdi><a href="'.
- $this->gui->tabURL('search', array('q'=>'ext:'.$link)).'">'.
- hsc($link).'</a></bdi>, ';
+ $html .= '<bdi><a href="' .
+ $this->gui->tabURL('search', ['q' => 'ext:' . $link]) . '">' .
+ hsc($link) . '</a></bdi>, ';
}
return rtrim($html, ', ');
}
@@ -575,9 +577,8 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
}
}
} else {
- $errors .= '<p class="permerror">'.$this->getLang($canmod).'</p>';
+ $errors .= '<p class="permerror">' . $this->getLang($canmod) . '</p>';
}
-
if (!$extension->isProtected() && !$extension->isTemplate()) { // no enable/disable for templates
if ($extension->isEnabled()) {
$html .= $this->makeAction('disable', $extension);
@@ -585,35 +586,32 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$html .= $this->makeAction('enable', $extension);
}
}
-
if ($extension->isGitControlled()) {
- $errors .= '<p class="permerror">'.$this->getLang('git').'</p>';
+ $errors .= '<p class="permerror">' . $this->getLang('git') . '</p>';
}
-
- if ($extension->isEnabled() &&
+ if (
+ $extension->isEnabled() &&
in_array('Auth', $extension->getTypes()) &&
$conf['authtype'] != $extension->getID()
) {
- $errors .= '<p class="permerror">'.$this->getLang('auth').'</p>';
+ $errors .= '<p class="permerror">' . $this->getLang('auth') . '</p>';
}
- } else {
- if (($canmod = $extension->canModify()) === true) {
- if ($extension->getDownloadURL()) {
- $html .= $this->makeAction('install', $extension);
- }
- } else {
- $errors .= '<div class="permerror">'.$this->getLang($canmod).'</div>';
+ } elseif (($canmod = $extension->canModify()) === true) {
+ if ($extension->getDownloadURL()) {
+ $html .= $this->makeAction('install', $extension);
}
+ } else {
+ $errors .= '<div class="permerror">' . $this->getLang($canmod) . '</div>';
}
if (!$extension->isInstalled() && $extension->getDownloadURL()) {
- $html .= ' <span class="version">'.$this->getLang('available_version').' ';
+ $html .= ' <span class="version">' . $this->getLang('available_version') . ' ';
$html .= ($extension->getLastUpdate()
? hsc($extension->getLastUpdate())
- : $this->getLang('unknown')).'</span>';
+ : $this->getLang('unknown')) . '</span>';
}
- return $html.' '.$errors.DOKU_LF;
+ return $html . ' ' . $errors . DOKU_LF;
}
/**
@@ -627,18 +625,15 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
{
$title = '';
- switch ($action) {
- case 'install':
- case 'reinstall':
- $title = 'title="'.hsc($extension->getDownloadURL()).'"';
- break;
+ if ($action == 'install' || $action == 'reinstall') {
+ $title = 'title="' . hsc($extension->getDownloadURL()) . '"';
}
- $classes = 'button '.$action;
- $name = 'fn['.$action.']['.hsc($extension->getID()).']';
+ $classes = 'button ' . $action;
+ $name = 'fn[' . $action . '][' . hsc($extension->getID()) . ']';
- $html = '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.
- $this->getLang('btn_'.$action).'</button> ';
+ $html = '<button class="' . $classes . '" name="' . $name . '" type="submit" ' . $title . '>' .
+ $this->getLang('btn_' . $action) . '</button> ';
return $html;
}
@@ -650,7 +645,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeStatus(helper_plugin_extension_extension $extension)
{
- $status = array();
+ $status = [];
if ($extension->isInstalled()) {
$status[] = $this->getLang('status_installed');
diff --git a/lib/plugins/extension/helper/repository.php b/lib/plugins/extension/helper/repository.php
index 0bca6c975..9d7f61f3e 100644
--- a/lib/plugins/extension/helper/repository.php
+++ b/lib/plugins/extension/helper/repository.php
@@ -1,4 +1,5 @@
<?php
+
/**
* DokuWiki Plugin extension (Helper Component)
*
@@ -6,6 +7,7 @@
* @author Michael Hamann <michael@content-space.de>
*/
+use dokuwiki\Extension\Plugin;
use dokuwiki\Cache\Cache;
use dokuwiki\HTTP\DokuHTTPClient;
use dokuwiki\Extension\PluginController;
@@ -13,13 +15,12 @@ use dokuwiki\Extension\PluginController;
/**
* Class helper_plugin_extension_repository provides access to the extension repository on dokuwiki.org
*/
-class helper_plugin_extension_repository extends DokuWiki_Plugin
+class helper_plugin_extension_repository extends Plugin
{
+ public const EXTENSION_REPOSITORY_API = 'https://www.dokuwiki.org/lib/plugins/pluginrepo/api.php';
- const EXTENSION_REPOSITORY_API = 'https://www.dokuwiki.org/lib/plugins/pluginrepo/api.php';
-
- private $loaded_extensions = array();
- private $has_access = null;
+ private $loaded_extensions = [];
+ private $has_access;
/**
* Initialize the repository (cache), fetches data for all installed plugins
@@ -30,14 +31,15 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
global $plugin_controller;
if ($this->hasAccess()) {
$list = $plugin_controller->getList('', true);
- $request_data = array('fmt' => 'php');
+ $request_data = ['fmt' => 'php'];
$request_needed = false;
foreach ($list as $name) {
- $cache = new Cache('##extension_manager##'.$name, '.repo');
+ $cache = new Cache('##extension_manager##' . $name, '.repo');
- if (!isset($this->loaded_extensions[$name]) &&
+ if (
+ !isset($this->loaded_extensions[$name]) &&
$this->hasAccess() &&
- !$cache->useCache(array('age' => 3600 * 24))
+ !$cache->useCache(['age' => 3600 * 24])
) {
$this->loaded_extensions[$name] = true;
$request_data['ext'][] = $name;
@@ -51,7 +53,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
if ($data !== false) {
$extensions = unserialize($data);
foreach ($extensions as $extension) {
- $cache = new Cache('##extension_manager##'.$extension['plugin'], '.repo');
+ $cache = new Cache('##extension_manager##' . $extension['plugin'], '.repo');
$cache->storeCache(serialize($extension));
}
} else {
@@ -67,14 +69,15 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
* @param bool $usecache use cached result if still valid
* @return bool If repository access is available
*/
- public function hasAccess($usecache = true) {
+ public function hasAccess($usecache = true)
+ {
if ($this->has_access === null) {
$cache = new Cache('##extension_manager###hasAccess', '.repo');
- if (!$cache->useCache(array('age' => 60*10, 'purge' => !$usecache))) {
+ if (!$cache->useCache(['age' => 60 * 10, 'purge' => !$usecache])) {
$httpclient = new DokuHTTPClient();
$httpclient->timeout = 5;
- $data = $httpclient->get(self::EXTENSION_REPOSITORY_API.'?cmd=ping');
+ $data = $httpclient->get(self::EXTENSION_REPOSITORY_API . '?cmd=ping');
if ($data !== false) {
$this->has_access = true;
$cache->storeCache(1);
@@ -97,22 +100,23 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
*/
public function getData($name)
{
- $cache = new Cache('##extension_manager##'.$name, '.repo');
+ $cache = new Cache('##extension_manager##' . $name, '.repo');
- if (!isset($this->loaded_extensions[$name]) &&
+ if (
+ !isset($this->loaded_extensions[$name]) &&
$this->hasAccess() &&
- !$cache->useCache(array('age' => 3600 * 24))
+ !$cache->useCache(['age' => 3600 * 24])
) {
$this->loaded_extensions[$name] = true;
$httpclient = new DokuHTTPClient();
- $data = $httpclient->get(self::EXTENSION_REPOSITORY_API.'?fmt=php&ext[]='.urlencode($name));
+ $data = $httpclient->get(self::EXTENSION_REPOSITORY_API . '?fmt=php&ext[]=' . urlencode($name));
if ($data !== false) {
$result = unserialize($data);
- if(count($result)) {
+ if (count($result)) {
$cache->storeCache(serialize($result[0]));
return $result[0];
}
- return array();
+ return [];
} else {
$this->has_access = false;
}
@@ -120,7 +124,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
if (file_exists($cache->cache)) {
return unserialize($cache->retrieveCache(false));
}
- return array();
+ return [];
}
/**
@@ -136,15 +140,15 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
$httpclient = new DokuHTTPClient();
$data = $httpclient->post(self::EXTENSION_REPOSITORY_API, $query);
- if ($data === false) return array();
+ if ($data === false) return [];
$result = unserialize($data);
- $ids = array();
+ $ids = [];
// store cache info for each extension
foreach ($result as $ext) {
$name = $ext['plugin'];
- $cache = new Cache('##extension_manager##'.$name, '.repo');
+ $cache = new Cache('##extension_manager##' . $name, '.repo');
$cache->storeCache(serialize($ext));
$ids[] = $name;
}
@@ -160,12 +164,7 @@ class helper_plugin_extension_repository extends DokuWiki_Plugin
*/
protected function parseQuery($q)
{
- $parameters = array(
- 'tag' => array(),
- 'mail' => array(),
- 'type' => array(),
- 'ext' => array()
- );
+ $parameters = ['tag' => [], 'mail' => [], 'type' => [], 'ext' => []];
// extract tags
if (preg_match_all('/(^|\s)(tag:([\S]+))/', $q, $matches, PREG_SET_ORDER)) {