aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2020-02-20 13:41:03 +0100
committerGitHub <noreply@github.com>2020-02-20 13:41:03 +0100
commit6d7e4f82694362b31bd8f7d81b79f9bc2935ab06 (patch)
treebcd063a0c015f8ea466868156bf1c8e260f90434
parentd4f6a7852c473169f2c3998e813e107bc6b0d9e0 (diff)
parentf11bfd36669978181eb2b2c80f18605a7bd10d25 (diff)
downloaddokuwiki-6d7e4f82694362b31bd8f7d81b79f9bc2935ab06.tar.gz
dokuwiki-6d7e4f82694362b31bd8f7d81b79f9bc2935ab06.zip
Merge pull request #2983 from ssahara/extension-manager
refactor Extension manager
-rw-r--r--lib/plugins/extension/action.php5
-rw-r--r--lib/plugins/extension/admin.php69
-rw-r--r--lib/plugins/extension/helper/extension.php51
-rw-r--r--lib/plugins/extension/helper/gui.php72
-rw-r--r--lib/plugins/extension/helper/list.php298
5 files changed, 293 insertions, 202 deletions
diff --git a/lib/plugins/extension/action.php b/lib/plugins/extension/action.php
index 3255f24b0..3bb044825 100644
--- a/lib/plugins/extension/action.php
+++ b/lib/plugins/extension/action.php
@@ -16,7 +16,6 @@ class action_plugin_extension extends DokuWiki_Action_Plugin
*/
public function register(Doku_Event_Handler $controller)
{
-
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info');
}
@@ -26,7 +25,7 @@ class action_plugin_extension extends DokuWiki_Action_Plugin
* @param Doku_Event $event
* @param $param
*/
- public function info(Doku_Event &$event, $param)
+ public function info(Doku_Event $event, $param)
{
global $USERINFO;
global $INPUT;
@@ -69,7 +68,7 @@ class action_plugin_extension extends DokuWiki_Action_Plugin
);
header('Content-Type: application/json');
- json_encode($return);
+ echo json_encode($return);
break;
case 'info':
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php
index 421b7138f..ded688a9b 100644
--- a/lib/plugins/extension/admin.php
+++ b/lib/plugins/extension/admin.php
@@ -51,9 +51,11 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
/* @var helper_plugin_extension_repository $repository */
$repository = $this->loadHelper('extension_repository');
- if(!$repository->hasAccess(!$INPUT->bool('purge'))) {
- $url = $this->gui->tabURL('', array('purge' => 1));
- msg($this->getLang('repo_error').' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1);
+ if (!$repository->hasAccess(!$INPUT->bool('purge'))) {
+ $url = $this->gui->tabURL('', ['purge' => 1], '&');
+ msg($this->getLang('repo_error').
+ ' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1
+ );
}
if (!in_array('ssl', stream_get_transports())) {
@@ -75,12 +77,9 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
$extension->setExtension($extname);
$installed = $extension->installOrUpdate();
foreach ($installed as $ext => $info) {
- msg(
- sprintf(
- $this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
- $info['base']
- ),
- 1
+ msg(sprintf(
+ $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
+ $info['base']), 1
);
}
break;
@@ -88,20 +87,14 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
$extension->setExtension($extname);
$status = $extension->uninstall();
if ($status) {
- msg(
- sprintf(
- $this->getLang('msg_delete_success'),
- hsc($extension->getDisplayName())
- ),
- 1
+ msg(sprintf(
+ $this->getLang('msg_delete_success'),
+ hsc($extension->getDisplayName())), 1
);
} else {
- msg(
- sprintf(
- $this->getLang('msg_delete_failed'),
- hsc($extension->getDisplayName())
- ),
- -1
+ msg(sprintf(
+ $this->getLang('msg_delete_failed'),
+ hsc($extension->getDisplayName())), -1
);
}
break;
@@ -111,7 +104,10 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
if ($status !== true) {
msg($status, -1);
} else {
- msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1);
+ msg(sprintf(
+ $this->getLang('msg_enabled'),
+ hsc($extension->getDisplayName())), 1
+ );
}
break;
case 'disable':
@@ -120,29 +116,38 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
if ($status !== true) {
msg($status, -1);
} else {
- msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1);
+ msg(sprintf(
+ $this->getLang('msg_disabled'),
+ hsc($extension->getDisplayName())), 1
+ );
}
break;
}
}
}
- send_redirect($this->gui->tabURL('', array(), '&', true));
+ send_redirect($this->gui->tabURL('', [], '&', true));
} elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
$installed = $extension->installFromURL($INPUT->post->str('installurl'));
foreach ($installed as $ext => $info) {
- msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1);
+ msg(sprintf(
+ $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
+ $info['base']), 1
+ );
}
- send_redirect($this->gui->tabURL('', array(), '&', true));
+ send_redirect($this->gui->tabURL('', [], '&', true));
} elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
$installed = $extension->installFromUpload('installfile');
foreach ($installed as $ext => $info) {
- msg(sprintf($this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'), $info['base']), 1);
+ msg(sprintf(
+ $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
+ $info['base']), 1
+ );
}
- send_redirect($this->gui->tabURL('', array(), '&', true));
+ send_redirect($this->gui->tabURL('', [], '&', true));
}
} catch (Exception $e) {
msg($e->getMessage(), -1);
- send_redirect($this->gui->tabURL('', array(), '&', true));
+ send_redirect($this->gui->tabURL('', [], '&', true));
}
}
@@ -151,8 +156,8 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
*/
public function html()
{
- ptln('<h1>'.$this->getLang('menu').'</h1>');
- ptln('<div id="extension__manager">');
+ echo '<h1>'.$this->getLang('menu').'</h1>'.DOKU_LF;
+ echo '<div id="extension__manager">'.DOKU_LF;
$this->gui->tabNavigation();
@@ -171,7 +176,7 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin
$this->gui->tabPlugins();
}
- ptln('</div>');
+ echo '</div>'.DOKU_LF;
}
}
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 0186620d0..47fe87373 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -126,11 +126,11 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
return in_array(
$this->id,
array(
- 'authad', 'authldap', 'authmysql', 'authpdo',
- 'authpgsql', 'authplain', 'acl', 'info', 'extension',
- 'revert', 'popularity', 'config', 'safefnrecode', 'styling',
- 'testing', 'template:dokuwiki'
- )
+ 'authad', 'authldap', 'authpdo', 'authplain',
+ 'acl', 'config', 'extension', 'info', 'popularity', 'revert',
+ 'safefnrecode', 'styling', 'testing', 'usermanager',
+ 'template:dokuwiki',
+ )
);
}
@@ -306,7 +306,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();
}
/**
@@ -772,8 +773,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
if (is_readable($infopath)) {
$this->localInfo = confToHash($infopath);
} elseif (!$this->isTemplate() && $this->isEnabled()) {
- $path = $this->getInstallDir().'/';
- $plugin = null;
+ $path = $this->getInstallDir().'/';
+ $plugin = null;
foreach (PluginController::PLUGIN_TYPES as $type) {
if (file_exists($path.$type.'.php')) {
@@ -895,7 +896,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
* @param string $defaultName fallback for name of download
* @return bool|string if failed false, otherwise true or the name of the file in the given dir
*/
- protected function downloadToFile($url,$file,$defaultName=''){
+ protected function downloadToFile($url, $file, $defaultName = '')
+ {
global $conf;
$http = new DokuHTTPClient();
$http->max_bodysize = 0;
@@ -909,10 +911,10 @@ 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();
+ $match = array();
if (is_string($content_disposition) &&
- preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) {
-
+ preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
+ ) {
$name = \dokuwiki\Utf8\PhpString::basename($match[1]);
}
@@ -927,10 +929,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
$fileexists = file_exists($file);
$fp = @fopen($file,"w");
- if(!$fp) return false;
- fwrite($fp,$data);
+ if (!$fp) return false;
+ fwrite($fp, $data);
fclose($fp);
- if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
+ if (!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
return $name;
}
@@ -964,7 +966,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// download
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;
@@ -1055,7 +1059,9 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
'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>')
+ );
}
}
@@ -1129,13 +1135,13 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
// files where found but no info.txt - use old method
if ($found_files) {
- $info = array();
- $info['tmp'] = $this_dir;
+ $info = array();
+ $info['tmp'] = $this_dir;
// does this look like a template or should we use the default type?
if ($found_template_parts >= 2) {
- $info['type'] = 'template';
+ $info['type'] = 'template';
} else {
- $info['type'] = $default_type;
+ $info['type'] = $default_type;
}
$result['old'][] = $info;
@@ -1187,7 +1193,8 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
return true;
}
- // the only case when we don't get one of the recognized archive types is when the archive file can't be read
+ // 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');
}
diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php
index 9d6783202..d02c02a89 100644
--- a/lib/plugins/extension/helper/gui.php
+++ b/lib/plugins/extension/helper/gui.php
@@ -6,14 +6,13 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
-use dokuwiki\Extension\PluginController;
+use dokuwiki\Form\Form;
/**
* Class helper_plugin_extension_list takes care of the overall GUI
*/
class helper_plugin_extension_gui extends DokuWiki_Plugin
{
-
protected $tabs = array('plugins', 'templates', 'search', 'install');
/** @var string the extension that should have an open info window FIXME currently broken */
@@ -44,13 +43,19 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$extension = $this->loadHelper('extension_extension');
/* @var helper_plugin_extension_list $list */
$list = $this->loadHelper('extension_list');
+
+ $form = new Form([
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
+ ]);
$list->startForm();
foreach ($pluginlist as $name) {
$extension->setExtension($name);
$list->addRow($extension, $extension->getID() == $this->infoFor);
}
$list->endForm();
- $list->render();
+ $form->addHTML($list->render(true));
+ echo $form->toHTML();
}
/**
@@ -71,13 +76,19 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$extension = $this->loadHelper('extension_extension');
/* @var helper_plugin_extension_list $list */
$list = $this->loadHelper('extension_list');
+
+ $form = new Form([
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
+ ]);
$list->startForm();
foreach ($tpllist as $name) {
$extension->setExtension("template:$name");
$list->addRow($extension, $extension->getID() == $this->infoFor);
}
$list->endForm();
- $list->render();
+ $form->addHTML($list->render(true));
+ echo $form->toHTML();
}
/**
@@ -90,10 +101,18 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
echo $this->locale_xhtml('intro_search');
echo '</div>';
- $form = new Doku_Form(array('action' => $this->tabURL('', array(), '&'), 'class' => 'search'));
- $form->addElement(form_makeTextField('q', $INPUT->str('q'), $this->getLang('search_for')));
- $form->addElement(form_makeButton('submit', '', $this->getLang('search')));
- $form->printForm();
+ $form = new Form([
+ 'action' => $this->tabURL('', [], '&'),
+ 'class' => 'search',
+ ]);
+ $form->addTagOpen('div')->addClass('no');
+ $form->addTextInput('q', $this->getLang('search_for'))
+ ->addClass('edit')
+ ->val($INPUT->str('q'));
+ $form->addButton('submit', $this->getLang('search'))
+ ->attrs(['type' => 'submit', 'title' => $this->getLang('search')]);
+ $form->addTagClose('div');
+ echo $form->toHTML();
if (!$INPUT->bool('q')) return;
@@ -105,6 +124,11 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$extension = $this->loadHelper('extension_extension');
/* @var helper_plugin_extension_list $list */
$list = $this->loadHelper('extension_list');
+
+ $form = new Form([
+ 'action' => $this->tabURL('', [], '&'),
+ 'id' => 'extension__list',
+ ]);
$list->startForm();
if ($result) {
foreach ($result as $name) {
@@ -115,7 +139,8 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
$list->nothingFound();
}
$list->endForm();
- $list->render();
+ $form->addHTML($list->render(true));
+ echo $form->toHTML();
}
/**
@@ -127,17 +152,24 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
echo $this->locale_xhtml('intro_install');
echo '</div>';
- $form = new Doku_Form(
- array(
- 'action' => $this->tabURL('', array(), '&'),
+ $form = new Form([
+ 'action' => $this->tabURL('', [], '&'),
'enctype' => 'multipart/form-data',
- 'class' => 'install'
- )
- );
- $form->addElement(form_makeTextField('installurl', '', $this->getLang('install_url'), '', 'block'));
- $form->addElement(form_makeFileField('installfile', $this->getLang('install_upload'), '', 'block'));
- $form->addElement(form_makeButton('submit', '', $this->getLang('btn_install')));
- $form->printForm();
+ 'class' => 'install',
+ ]);
+ $form->addTagOpen('div')->addClass('no');
+ $form->addTextInput('installurl', $this->getLang('install_url'))
+ ->addClass('block')
+ ->attrs(['type' => 'url']);
+ $form->addTag('br');
+ $form->addTextInput('installfile', $this->getLang('install_upload'))
+ ->addClass('block')
+ ->attrs(['type' => 'file']);
+ $form->addTag('br');
+ $form->addButton('', $this->getLang('btn_install'))
+ ->attrs(['type' => 'submit', 'title' => $this->getLang('btn_install')]);
+ $form->addTagClose('div');
+ echo $form->toHTML();
}
/**
@@ -183,7 +215,7 @@ class helper_plugin_extension_gui extends DokuWiki_Plugin
* @param bool $absolute create absolute URLs?
* @return string
*/
- public function tabURL($tab = '', $params = array(), $sep = '&amp;', $absolute = false)
+ public function tabURL($tab = '', $params = [], $sep = '&', $absolute = false)
{
global $ID;
global $INPUT;
diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php
index d895941cb..647575b10 100644
--- a/lib/plugins/extension/helper/list.php
+++ b/lib/plugins/extension/helper/list.php
@@ -30,13 +30,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function startForm()
{
- $this->form .= '<form id="extension__list" accept-charset="utf-8" method="post" action="">';
- $hidden = array(
- 'do'=>'admin',
- 'page'=>'extension',
- 'sectok'=>getSecurityToken()
- );
- $this->addHidden($hidden);
$this->form .= '<ul class="extensionList">';
}
@@ -96,7 +89,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
public function endForm()
{
$this->form .= '</ul>';
- $this->form .= '</form>'.DOKU_LF;
}
/**
@@ -110,9 +102,12 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
/**
* Print the form
+ *
+ * @param bool $returnonly whether to return html or print
*/
- public function render()
+ public function render($returnonly = false)
{
+ if ($returnonly) return $this->form;
echo $this->form;
}
@@ -153,13 +148,30 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeHomepageLink(helper_plugin_extension_extension $extension)
{
- $text = $this->getLang('homepage_link');
- $url = hsc($extension->getURL());
- return '<a href="'.$url.'" title="'.$url.'" class ="urlextern">'.$text.'</a> ';
+ global $conf;
+ $url = $extension->getURL();
+ if (strtolower(parse_url($url, PHP_URL_HOST)) == 'www.dokuwiki.org') {
+ $linktype = 'interwiki';
+ } else {
+ $linktype = 'extern';
+ }
+ $param = array(
+ 'href' => $url,
+ 'title' => $url,
+ 'class' => ($linktype == 'extern') ? 'urlextern' : 'interwiki iw_doku',
+ 'target' => $conf['target'][$linktype],
+ '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>';
+ return $html;
}
/**
- * Generate the class name for the row of the extensio
+ * Generate the class name for the row of the extension
*
* @param helper_plugin_extension_extension $extension The extension object
* @return string The class name
@@ -190,14 +202,18 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$mailid = $extension->getEmailID();
if ($mailid) {
$url = $this->gui->tabURL('search', array('q' => 'authorid:'.$mailid));
- return '<bdi><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></bdi>';
+ $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 {
- return '<bdi><span class="author">'.hsc($extension->getAuthor()).'</span></bdi>';
+ $html = '<span class="author">'.hsc($extension->getAuthor()).'</span>';
}
+ $html = '<bdi>'.$html.'</bdi>';
+ } else {
+ $html = '<em class="author">'.$this->getLang('unknown_author').'</em>'.DOKU_LF;
}
- return "<em class=\"author\">".$this->getLang('unknown_author')."</em>".DOKU_LF;
+ return $html;
}
/**
@@ -227,7 +243,8 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
'lib/plugins/extension/images/plugin.png" />';
}
- return '<div class="screenshot" >'.$img.'<span></span></div>'.DOKU_LF;
+ $html = '<div class="screenshot" >'.$img.'<span></span></div>'.DOKU_LF;
+ return $html;
}
/**
@@ -239,33 +256,33 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeLegend(helper_plugin_extension_extension $extension, $showinfo = false)
{
- $return = '<div>';
- $return .= '<h2>';
- $return .= sprintf(
+ $html = '<div>';
+ $html .= '<h2>';
+ $html .= sprintf(
$this->getLang('extensionby'),
'<bdi>'.hsc($extension->getDisplayName()).'</bdi>',
$this->makeAuthor($extension)
);
- $return .= '</h2>'.DOKU_LF;
+ $html .= '</h2>'.DOKU_LF;
- $return .= $this->makeScreenshot($extension);
+ $html .= $this->makeScreenshot($extension);
$popularity = $extension->getPopularity();
if ($popularity !== false && !$extension->isBundled()) {
$popularityText = sprintf($this->getLang('popularity'), round($popularity*100, 2));
- $return .= '<div class="popularity" title="'.$popularityText.'">'.
+ $html .= '<div class="popularity" title="'.$popularityText.'">'.
'<div style="width: '.($popularity * 100).'%;">'.
'<span class="a11y">'.$popularityText.'</span>'.
'</div></div>'.DOKU_LF;
}
if ($extension->getDescription()) {
- $return .= '<p><bdi>';
- $return .= hsc($extension->getDescription()).' ';
- $return .= '</bdi></p>'.DOKU_LF;
+ $html .= '<p><bdi>';
+ $html .= hsc($extension->getDescription()).' ';
+ $html .= '</bdi></p>'.DOKU_LF;
}
- $return .= $this->makeLinkbar($extension);
+ $html .= $this->makeLinkbar($extension);
if ($showinfo) {
$url = $this->gui->tabURL('');
@@ -274,16 +291,16 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$url = $this->gui->tabURL('', array('info' => $extension->getID()));
$class = '';
}
- $return .= ' <a href="'.$url.'#extensionplugin__'.$extension->getID().
+ $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) {
- $return .= $this->makeInfo($extension);
+ $html .= $this->makeInfo($extension);
}
- $return .= $this->makeNoticeArea($extension);
- $return .= '</div>'.DOKU_LF;
- return $return;
+ $html .= $this->makeNoticeArea($extension);
+ $html .= '</div>'.DOKU_LF;
+ return $html;
}
/**
@@ -294,29 +311,46 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeLinkbar(helper_plugin_extension_extension $extension)
{
- $return = '<div class="linkbar">';
- $return .= $this->makeHomepageLink($extension);
- if ($extension->getBugtrackerURL()) {
- $return .= ' <a href="'.hsc($extension->getBugtrackerURL()).
- '" title="'.hsc($extension->getBugtrackerURL()).'" class ="bugs">'.
- $this->getLang('bugs_features').'</a> ';
+ global $conf;
+ $html = '<div class="linkbar">';
+ $html .= $this->makeHomepageLink($extension);
+
+ $bugtrackerURL = $extension->getBugtrackerURL();
+ if ($bugtrackerURL) {
+ if (strtolower(parse_url($bugtrackerURL, PHP_URL_HOST)) == 'www.dokuwiki.org') {
+ $linktype = 'interwiki';
+ } else {
+ $linktype = 'extern';
+ }
+ $param = array(
+ 'href' => $bugtrackerURL,
+ 'title' => $bugtrackerURL,
+ 'class' => 'bugs',
+ 'target' => $conf['target'][$linktype],
+ 'rel' => ($linktype == 'extern') ? 'noopener' : '',
+ );
+ if ($conf['relnofollow']) {
+ $param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
+ }
+ $html .= ' <a '.buildAttributes($param, true).'>'.
+ $this->getLang('bugs_features').'</a>';
}
if ($extension->getTags()) {
$first = true;
- $return .= '<span class="tags">'.$this->getLang('tags').' ';
+ $html .= ' <span class="tags">'.$this->getLang('tags').' ';
foreach ($extension->getTags() as $tag) {
if (!$first) {
- $return .= ', ';
+ $html .= ', ';
} else {
$first = false;
}
- $url = $this->gui->tabURL('search', array('q' => 'tag:'.$tag));
- $return .= '<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>';
}
- $return .= '</span>';
+ $html .= '</span>';
}
- $return .= '</div>'.DOKU_LF;
- return $return;
+ $html .= '</div>'.DOKU_LF;
+ return $html;
}
/**
@@ -327,10 +361,10 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeNoticeArea(helper_plugin_extension_extension $extension)
{
- $return = '';
+ $html = '';
$missing_dependencies = $extension->getMissingDependencies();
if (!empty($missing_dependencies)) {
- $return .= '<div class="msg error">' .
+ $html .= '<div class="msg error">' .
sprintf(
$this->getLang('missing_dependency'),
'<bdi>' . implode(', ', $missing_dependencies) . '</bdi>'
@@ -338,7 +372,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
'</div>';
}
if ($extension->isInWrongFolder()) {
- $return .= '<div class="msg error">' .
+ $html .= '<div class="msg error">' .
sprintf(
$this->getLang('wrong_folder'),
'<bdi>' . hsc($extension->getInstallName()) . '</bdi>',
@@ -347,22 +381,22 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
'</div>';
}
if (($securityissue = $extension->getSecurityIssue()) !== false) {
- $return .= '<div class="msg error">'.
+ $html .= '<div class="msg error">'.
sprintf($this->getLang('security_issue'), '<bdi>'.hsc($securityissue).'</bdi>').
'</div>';
}
if (($securitywarning = $extension->getSecurityWarning()) !== false) {
- $return .= '<div class="msg notify">'.
+ $html .= '<div class="msg notify">'.
sprintf($this->getLang('security_warning'), '<bdi>'.hsc($securitywarning).'</bdi>').
'</div>';
}
if ($extension->updateAvailable()) {
- $return .= '<div class="msg notify">'.
+ $html .= '<div class="msg notify">'.
sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())).
'</div>';
}
if ($extension->hasDownloadURLChanged()) {
- $return .= '<div class="msg notify">' .
+ $html .= '<div class="msg notify">' .
sprintf(
$this->getLang('url_change'),
'<bdi>' . hsc($extension->getDownloadURL()) . '</bdi>',
@@ -370,7 +404,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
) .
'</div>';
}
- return $return.DOKU_LF;
+ return $html.DOKU_LF;
}
/**
@@ -392,7 +426,8 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$name = shorten($base, $long, 55);
- return '<a href="'.hsc($url).'" class="urlextern">'.hsc($name).'</a>';
+ $html = '<a href="'.hsc($url).'" class="urlextern">'.hsc($name).'</a>';
+ return $html;
}
/**
@@ -404,88 +439,98 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
public function makeInfo(helper_plugin_extension_extension $extension)
{
$default = $this->getLang('unknown');
- $return = '<dl class="details">';
+ $html = '<dl class="details">';
- $return .= '<dt>'.$this->getLang('status').'</dt>';
- $return .= '<dd>'.$this->makeStatus($extension).'</dd>';
+ $html .= '<dt>'.$this->getLang('status').'</dt>';
+ $html .= '<dd>'.$this->makeStatus($extension).'</dd>';
if ($extension->getDonationURL()) {
- $return .= '<dt>'.$this->getLang('donate').'</dt>';
- $return .= '<dd>';
- $return .= '<a href="'.$extension->getDonationURL().'" class="donate">'.
+ $html .= '<dt>'.$this->getLang('donate').'</dt>';
+ $html .= '<dd>';
+ $html .= '<a href="'.$extension->getDonationURL().'" class="donate">'.
$this->getLang('donate_action').'</a>';
- $return .= '</dd>';
+ $html .= '</dd>';
}
if (!$extension->isBundled()) {
- $return .= '<dt>'.$this->getLang('downloadurl').'</dt>';
- $return .= '<dd><bdi>';
- $return .= ($extension->getDownloadURL() ? $this->shortlink($extension->getDownloadURL()) : $default);
- $return .= '</bdi></dd>';
-
- $return .= '<dt>'.$this->getLang('repository').'</dt>';
- $return .= '<dd><bdi>';
- $return .= ($extension->getSourcerepoURL() ? $this->shortlink($extension->getSourcerepoURL()) : $default);
- $return .= '</bdi></dd>';
+ $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 .= '<dd><bdi>';
+ $html .= ($extension->getSourcerepoURL()
+ ? $this->shortlink($extension->getSourcerepoURL())
+ : $default);
+ $html .= '</bdi></dd>';
}
if ($extension->isInstalled()) {
if ($extension->getInstalledVersion()) {
- $return .= '<dt>'.$this->getLang('installed_version').'</dt>';
- $return .= '<dd>';
- $return .= hsc($extension->getInstalledVersion());
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('installed_version').'</dt>';
+ $html .= '<dd>';
+ $html .= hsc($extension->getInstalledVersion());
+ $html .= '</dd>';
}
if (!$extension->isBundled()) {
- $return .= '<dt>'.$this->getLang('install_date').'</dt>';
- $return .= '<dd>';
- $return .= ($extension->getUpdateDate() ? hsc($extension->getUpdateDate()) : $this->getLang('unknown'));
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('install_date').'</dt>';
+ $html .= '<dd>';
+ $html .= ($extension->getUpdateDate()
+ ? hsc($extension->getUpdateDate())
+ : $this->getLang('unknown'));
+ $html .= '</dd>';
}
}
if (!$extension->isInstalled() || $extension->updateAvailable()) {
- $return .= '<dt>'.$this->getLang('available_version').'</dt>';
- $return .= '<dd>';
- $return .= ($extension->getLastUpdate() ? hsc($extension->getLastUpdate()) : $this->getLang('unknown'));
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('available_version').'</dt>';
+ $html .= '<dd>';
+ $html .= ($extension->getLastUpdate()
+ ? hsc($extension->getLastUpdate())
+ : $this->getLang('unknown'));
+ $html .= '</dd>';
}
- $return .= '<dt>'.$this->getLang('provides').'</dt>';
- $return .= '<dd><bdi>';
- $return .= ($extension->getTypes() ? hsc(implode(', ', $extension->getTypes())) : $default);
- $return .= '</bdi></dd>';
+ $html .= '<dt>'.$this->getLang('provides').'</dt>';
+ $html .= '<dd><bdi>';
+ $html .= ($extension->getTypes()
+ ? hsc(implode(', ', $extension->getTypes()))
+ : $default);
+ $html .= '</bdi></dd>';
if (!$extension->isBundled() && $extension->getCompatibleVersions()) {
- $return .= '<dt>'.$this->getLang('compatible').'</dt>';
- $return .= '<dd>';
+ $html .= '<dt>'.$this->getLang('compatible').'</dt>';
+ $html .= '<dd>';
foreach ($extension->getCompatibleVersions() as $date => $version) {
- $return .= '<bdi>'.$version['label'].' ('.$date.')</bdi>, ';
+ $html .= '<bdi>'.$version['label'].' ('.$date.')</bdi>, ';
}
- $return = rtrim($return, ', ');
- $return .= '</dd>';
+ $html = rtrim($html, ', ');
+ $html .= '</dd>';
}
if ($extension->getDependencies()) {
- $return .= '<dt>'.$this->getLang('depends').'</dt>';
- $return .= '<dd>';
- $return .= $this->makeLinkList($extension->getDependencies());
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('depends').'</dt>';
+ $html .= '<dd>';
+ $html .= $this->makeLinkList($extension->getDependencies());
+ $html .= '</dd>';
}
if ($extension->getSimilarExtensions()) {
- $return .= '<dt>'.$this->getLang('similar').'</dt>';
- $return .= '<dd>';
- $return .= $this->makeLinkList($extension->getSimilarExtensions());
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('similar').'</dt>';
+ $html .= '<dd>';
+ $html .= $this->makeLinkList($extension->getSimilarExtensions());
+ $html .= '</dd>';
}
if ($extension->getConflicts()) {
- $return .= '<dt>'.$this->getLang('conflicts').'</dt>';
- $return .= '<dd>';
- $return .= $this->makeLinkList($extension->getConflicts());
- $return .= '</dd>';
+ $html .= '<dt>'.$this->getLang('conflicts').'</dt>';
+ $html .= '<dd>';
+ $html .= $this->makeLinkList($extension->getConflicts());
+ $html .= '</dd>';
}
- $return .= '</dl>'.DOKU_LF;
- return $return;
+ $html .= '</dl>'.DOKU_LF;
+ return $html;
}
/**
@@ -496,12 +541,13 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
*/
public function makeLinkList($ext)
{
- $return = '';
+ $html = '';
foreach ($ext as $link) {
- $return .= '<bdi><a href="'.
- $this->gui->tabURL('search', array('q'=>'ext:'.$link)).'">'.hsc($link).'</a></bdi>, ';
+ $html .= '<bdi><a href="'.
+ $this->gui->tabURL('search', array('q'=>'ext:'.$link)).'">'.
+ hsc($link).'</a></bdi>, ';
}
- return rtrim($return, ', ');
+ return rtrim($html, ', ');
}
/**
@@ -513,19 +559,19 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
public function makeActions(helper_plugin_extension_extension $extension)
{
global $conf;
- $return = '';
+ $html = '';
$errors = '';
if ($extension->isInstalled()) {
if (($canmod = $extension->canModify()) === true) {
if (!$extension->isProtected()) {
- $return .= $this->makeAction('uninstall', $extension);
+ $html .= $this->makeAction('uninstall', $extension);
}
if ($extension->getDownloadURL()) {
if ($extension->updateAvailable()) {
- $return .= $this->makeAction('update', $extension);
+ $html .= $this->makeAction('update', $extension);
} else {
- $return .= $this->makeAction('reinstall', $extension);
+ $html .= $this->makeAction('reinstall', $extension);
}
}
} else {
@@ -534,9 +580,9 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
if (!$extension->isProtected() && !$extension->isTemplate()) { // no enable/disable for templates
if ($extension->isEnabled()) {
- $return .= $this->makeAction('disable', $extension);
+ $html .= $this->makeAction('disable', $extension);
} else {
- $return .= $this->makeAction('enable', $extension);
+ $html .= $this->makeAction('enable', $extension);
}
}
@@ -553,7 +599,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
} else {
if (($canmod = $extension->canModify()) === true) {
if ($extension->getDownloadURL()) {
- $return .= $this->makeAction('install', $extension);
+ $html .= $this->makeAction('install', $extension);
}
} else {
$errors .= '<div class="permerror">'.$this->getLang($canmod).'</div>';
@@ -561,13 +607,13 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
}
if (!$extension->isInstalled() && $extension->getDownloadURL()) {
- $return .= ' <span class="version">'.$this->getLang('available_version').' ';
- $return .= ($extension->getLastUpdate()
+ $html .= ' <span class="version">'.$this->getLang('available_version').' ';
+ $html .= ($extension->getLastUpdate()
? hsc($extension->getLastUpdate())
: $this->getLang('unknown')).'</span>';
}
- return $return.' '.$errors.DOKU_LF;
+ return $html.' '.$errors.DOKU_LF;
}
/**
@@ -591,8 +637,9 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
$classes = 'button '.$action;
$name = 'fn['.$action.']['.hsc($extension->getID()).']';
- return '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.
+ $html = '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.
$this->getLang('btn_'.$action).'</button> ';
+ return $html;
}
/**
@@ -605,7 +652,6 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
{
$status = array();
-
if ($extension->isInstalled()) {
$status[] = $this->getLang('status_installed');
if ($extension->isProtected()) {
@@ -620,7 +666,9 @@ class helper_plugin_extension_list extends DokuWiki_Plugin
}
if (!$extension->canModify()) $status[] = $this->getLang('status_unmodifiable');
if ($extension->isBundled()) $status[] = $this->getLang('status_bundled');
- $status[] = $extension->isTemplate() ? $this->getLang('status_template') : $this->getLang('status_plugin');
- return join(', ', $status);
+ $status[] = $extension->isTemplate()
+ ? $this->getLang('status_template')
+ : $this->getLang('status_plugin');
+ return implode(', ', $status);
}
}