diff options
-rw-r--r-- | _test/tests/inc/Extension/Event.test.php | 43 | ||||
-rw-r--r-- | conf/dokuwiki.php | 3 | ||||
-rw-r--r-- | inc/Debug/DebugHelper.php | 42 | ||||
-rw-r--r-- | inc/Extension/Event.php | 7 | ||||
-rw-r--r-- | inc/Parsing/Parser.php | 16 | ||||
-rw-r--r-- | inc/common.php | 8 | ||||
-rw-r--r-- | inc/lang/nl/lang.php | 1 | ||||
-rw-r--r-- | inc/lang/sr/admin.txt | 2 | ||||
-rw-r--r-- | inc/parser/parser.php | 44 | ||||
-rw-r--r-- | inc/template.php | 11 | ||||
-rw-r--r-- | lib/plugins/authldap/lang/nl/settings.php | 2 | ||||
-rw-r--r-- | lib/plugins/config/lang/en/lang.php | 3 | ||||
-rw-r--r-- | lib/plugins/config/lang/nl/lang.php | 3 | ||||
-rw-r--r-- | lib/plugins/config/settings/config.metadata.php | 3 | ||||
-rw-r--r-- | lib/plugins/extension/action.php | 5 | ||||
-rw-r--r-- | lib/plugins/extension/admin.php | 69 | ||||
-rw-r--r-- | lib/plugins/extension/helper/extension.php | 51 | ||||
-rw-r--r-- | lib/plugins/extension/helper/gui.php | 72 | ||||
-rw-r--r-- | lib/plugins/extension/helper/list.php | 298 | ||||
-rw-r--r-- | lib/scripts/behaviour.js | 2 |
20 files changed, 465 insertions, 220 deletions
diff --git a/_test/tests/inc/Extension/Event.test.php b/_test/tests/inc/Extension/Event.test.php new file mode 100644 index 000000000..bc2268295 --- /dev/null +++ b/_test/tests/inc/Extension/Event.test.php @@ -0,0 +1,43 @@ +<?php + +namespace tests\inc\Extension; + +use dokuwiki\Extension\Event; + +class EventTest extends \DokuWikiTest +{ + static public function staticFunc(&$data) + { + $data['test'] = strtoupper($data['test']); + } + + public function dynamicFunc(&$data) + { + $data['test'] = strtoupper($data['test']); + } + + public function testGlobal() + { + $data = 'test'; + $result = Event::createAndTrigger('TESTTRIGGER', $data, 'strtoupper'); + $this->assertEquals('TEST', $result); + } + + public function testDynamic() + { + $data = ['test' => 'test']; + Event::createAndTrigger('TESTTRIGGER', $data, [$this, 'dynamicFunc']); + $this->assertEquals(['test' => 'TEST'], $data); + } + + public function testStatic() + { + $data = ['test' => 'test']; + Event::createAndTrigger('TESTTRIGGER', $data, 'tests\inc\Extension\EventTest::staticFunc'); + $this->assertEquals(['test' => 'TEST'], $data); + + $data = ['test' => 'test']; + Event::createAndTrigger('TESTTRIGGER', $data, ['tests\inc\Extension\EventTest', 'staticFunc']); + $this->assertEquals(['test' => 'TEST'], $data); + } +} diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index f138908a0..9b576f4cf 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -162,6 +162,9 @@ $conf['trustedproxy'] = '^(::1|[fF][eE]80:|127\.|10\.|192\.168\.|172\.((1[6-9])| //Regexp of trusted proxy address when reading IP using HTTP header // if blank, do not trust any proxy (including local IP) +/* Feature Flags */ +$conf['defer_js'] = 1; // Defer javascript to be executed after the page's HTML has been parsed. Setting will be removed in the next release. + /* Network Settings */ $conf['dnslookups'] = 1; //disable to disallow IP to hostname lookups $conf['jquerycdn'] = 0; //use a CDN for delivering jQuery? diff --git a/inc/Debug/DebugHelper.php b/inc/Debug/DebugHelper.php index 3d4b20d62..74dfa9420 100644 --- a/inc/Debug/DebugHelper.php +++ b/inc/Debug/DebugHelper.php @@ -84,6 +84,48 @@ class DebugHelper } /** + * Trigger a custom deprecation event + * + * Usually dbgDeprecatedFunction() or dbgDeprecatedProperty() should be used instead. + * This method is intended only for those situation where they are not applicable. + * + * @param string $alternative + * @param string $deprecatedThing + * @param string $caller + * @param string $file + * @param int $line + * @param int $callerOffset How many lines should be removed from the beginning of the backtrace + */ + public static function dbgCustomDeprecationEvent( + $alternative, + $deprecatedThing, + $caller, + $file, + $line, + $callerOffset = 1 + ) { + global $conf; + /** @var EventHandler $EVENT_HANDLER */ + global $EVENT_HANDLER; + if (!$conf['allowdebug'] && !$EVENT_HANDLER->hasHandlerForEvent(self::INFO_DEPRECATION_LOG_EVENT)) { + // avoid any work if no one cares + return; + } + + $backtrace = array_slice(debug_backtrace(), $callerOffset); + + self::triggerDeprecationEvent( + $backtrace, + $alternative, + $deprecatedThing, + $caller, + $file, + $line + ); + + } + + /** * @param array $backtrace * @param string $alternative * @param string $deprecatedThing diff --git a/inc/Extension/Event.php b/inc/Extension/Event.php index bbaa52e55..32f346c72 100644 --- a/inc/Extension/Event.php +++ b/inc/Extension/Event.php @@ -126,12 +126,7 @@ class Event } if ($this->advise_before($enablePrevent) && is_callable($action)) { - if (is_array($action)) { - list($obj, $method) = $action; - $this->result = $obj->$method($this->data); - } else { - $this->result = $action($this->data); - } + $this->result = call_user_func_array($action, [&$this->data]); } $this->advise_after(); diff --git a/inc/Parsing/Parser.php b/inc/Parsing/Parser.php index b2070569f..63f014161 100644 --- a/inc/Parsing/Parser.php +++ b/inc/Parsing/Parser.php @@ -107,7 +107,21 @@ class Parser { // Normalize CRs and pad doc $doc = "\n" . str_replace("\r\n", "\n", $doc) . "\n"; $this->lexer->parse($doc); - $this->handler->finalize(); + + if (!method_exists($this->handler, 'finalize')) { + /** @deprecated 2019-10 we have a legacy handler from a plugin, assume legacy _finalize exists */ + + \dokuwiki\Debug\DebugHelper::dbgCustomDeprecationEvent( + 'finalize()', + get_class($this->handler) . '::_finalize()', + __METHOD__, + __FILE__, + __LINE__ + ); + $this->handler->_finalize(); + } else { + $this->handler->finalize(); + } return $this->handler->calls; } diff --git a/inc/common.php b/inc/common.php index 7ed8d0b19..c462934b2 100644 --- a/inc/common.php +++ b/inc/common.php @@ -369,16 +369,16 @@ function buildURLparams($params, $sep = '&') { * * @author Andreas Gohr * - * @param array $params array with (attribute name-attribute value) pairs - * @param bool $skipempty skip empty string values? + * @param array $params array with (attribute name-attribute value) pairs + * @param bool $skipEmptyStrings skip empty string values? * @return string */ -function buildAttributes($params, $skipempty = false) { +function buildAttributes($params, $skipEmptyStrings = false) { $url = ''; $white = false; foreach($params as $key => $val) { if($key[0] == '_') continue; - if($val === '' && $skipempty) continue; + if($val === '' && $skipEmptyStrings) continue; if($white) $url .= ' '; $url .= $key.'="'; diff --git a/inc/lang/nl/lang.php b/inc/lang/nl/lang.php index 2cd368639..f799318c3 100644 --- a/inc/lang/nl/lang.php +++ b/inc/lang/nl/lang.php @@ -3,6 +3,7 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * + * @author PBU <pbu@xs4all.nl> * @author Gerrit Uitslag <klapinklapin@gmail.com> * @author Andy <astolker@icloud.com> * @author Harriet Neitz <harrietneitz@gmail.com> diff --git a/inc/lang/sr/admin.txt b/inc/lang/sr/admin.txt index 8798fd4a6..284410b4b 100644 --- a/inc/lang/sr/admin.txt +++ b/inc/lang/sr/admin.txt @@ -1,3 +1,3 @@ ====== Администрација ====== -Изпод се налази листа доступних администраторских опција у DokuWiki-ју. +Испод се налази листа доступних администраторских опција у DokuWiki-ју. diff --git a/inc/parser/parser.php b/inc/parser/parser.php index d9fc5fb8f..aee82f01d 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -1,5 +1,7 @@ <?php +use dokuwiki\Debug\PropertyDeprecationHelper; + /** * Define various types of modes used by the parser - they are used to * populate the list of modes another mode accepts @@ -48,10 +50,50 @@ $PARSER_MODES = array( * @deprecated 2018-05-04 */ class Doku_Parser extends \dokuwiki\Parsing\Parser { + use PropertyDeprecationHelper { + __set as protected deprecationHelperMagicSet; + __get as protected deprecationHelperMagicGet; + } /** @inheritdoc */ - public function __construct(Doku_Handler $handler) { + public function __construct(Doku_Handler $handler = null) { dbg_deprecated(\dokuwiki\Parsing\Parser::class); + $this->deprecatePublicProperty('modes', __CLASS__); + $this->deprecatePublicProperty('connected', __CLASS__); + + if ($handler === null) { + $handler = new Doku_Handler(); + } + parent::__construct($handler); } + + public function __set($name, $value) + { + + if ($name === 'Handler') { + $this->handler = $value; + return; + } + + if ($name === 'Lexer') { + $this->lexer = $value; + return; + } + + $this->deprecationHelperMagicSet($name, $value); + } + + public function __get($name) + { + if ($name === 'Handler') { + return $this->handler; + } + + if ($name === 'Lexer') { + return $this->lexer; + } + + return $this->deprecationHelperMagicGet($name); + } } diff --git a/inc/template.php b/inc/template.php index c4658229a..011df63fe 100644 --- a/inc/template.php +++ b/inc/template.php @@ -348,15 +348,18 @@ function tpl_metaheaders($alt = true) { $jquery = getCdnUrls(); foreach($jquery as $src) { $head['script'][] = array( - 'type' => 'text/javascript', 'charset' => 'utf-8', '_data' => '', 'src' => $src - ); + 'type' => 'text/javascript', + 'charset' => 'utf-8', + '_data' => '', + 'src' => $src, + ) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []); } // load our javascript dispatcher $head['script'][] = array( 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '', - 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed - ); + 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed, + ) + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []); // trigger event here Event::createAndTrigger('TPL_METAHEADER_OUTPUT', $head, '_tpl_metaheaders_action', true); diff --git a/lib/plugins/authldap/lang/nl/settings.php b/lib/plugins/authldap/lang/nl/settings.php index 1f80b0251..1a3120291 100644 --- a/lib/plugins/authldap/lang/nl/settings.php +++ b/lib/plugins/authldap/lang/nl/settings.php @@ -3,6 +3,7 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * + * @author PBU <pbu@xs4all.nl> * @author Gerrit Uitslag <klapinklapin@gmail.com> * @author Remon <no@email.local> * @author Johan Wijnker <johan@wijnker.eu> @@ -19,6 +20,7 @@ $lang['referrals'] = 'Moeten verwijzingen worden gevolgd?'; $lang['deref'] = 'Hoe moeten de verwijzing van aliases worden bepaald?'; $lang['binddn'] = 'DN van een optionele bind gebruiker als anonieme bind niet genoeg is. Bijv. <code>cn=beheer, dc=mijn, dc=thuis</code>'; $lang['bindpw'] = 'Wachtwoord van bovenstaande gebruiker'; +$lang['attributes'] = 'Welke onderdelen moeten in LDAP gezocht worden'; $lang['userscope'] = 'Beperken scope van zoekfuncties voor gebruikers'; $lang['groupscope'] = 'Beperken scope van zoekfuncties voor groepen'; $lang['userkey'] = 'Attribuut aanduiding van de gebruikersnaam; moet consistent zijn met userfilter.'; diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php index 2ee8df707..3a408e0e3 100644 --- a/lib/plugins/config/lang/en/lang.php +++ b/lib/plugins/config/lang/en/lang.php @@ -187,6 +187,9 @@ $lang['search_fragment_o_ends_with'] = 'ends with'; $lang['search_fragment_o_contains'] = 'contains'; $lang['trustedproxy'] = 'Trust forwarding proxies matching this regular expression about the true client IP they report. The default matches local networks. Leave empty to trust no proxy.'; +$lang['_feature_flags'] = 'Feature Flags'; +$lang['defer_js'] = 'Defer javascript to be execute after the page\'s HTML has been parsed. Improves perceived page speed but could break a small number of plugins.'; + /* Network Options */ $lang['dnslookups'] = 'DokuWiki will lookup hostnames for remote IP addresses of users editing pages. If you have a slow or non working DNS server or don\'t want this feature, disable this option'; $lang['jquerycdn'] = 'Should the jQuery and jQuery UI script files be loaded from a CDN? This adds additional HTTP requests, but files may load faster and users may have them cached already.'; diff --git a/lib/plugins/config/lang/nl/lang.php b/lib/plugins/config/lang/nl/lang.php index d7c799026..6346143b6 100644 --- a/lib/plugins/config/lang/nl/lang.php +++ b/lib/plugins/config/lang/nl/lang.php @@ -3,6 +3,7 @@ /** * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * + * @author PBU <pbu@xs4all.nl> * @author Gerrit Uitslag <klapinklapin@gmail.com> * @author Harriet Neitz <harrietneitz@gmail.com> * @author mark prins <mprins@users.sf.net> @@ -43,6 +44,7 @@ $lang['_advanced'] = 'Geavanceerde instellingen'; $lang['_network'] = 'Netwerkinstellingen'; $lang['_msg_setting_undefined'] = 'Geen metadata voor deze instelling.'; $lang['_msg_setting_no_class'] = 'Geen class voor deze instelling.'; +$lang['_msg_setting_no_known_class'] = 'Setting class niet beschikbaar'; $lang['_msg_setting_no_default'] = 'Geen standaard waarde.'; $lang['title'] = 'Titel van de wiki'; $lang['start'] = 'Naam startpagina'; @@ -158,6 +160,7 @@ $lang['search_fragment_o_exact'] = 'exact'; $lang['search_fragment_o_starts_with'] = 'begint met'; $lang['search_fragment_o_ends_with'] = 'eindigt op'; $lang['search_fragment_o_contains'] = 'bevat'; +$lang['trustedproxy'] = 'Vertrouw op doorstuurproxy\'s die overeenkomen met deze reguliere expressie over het echte client-IP dat ze rapporteren. De standaard komt overeen met lokale netwerken. Laat leeg om geen proxy te vertrouwen.'; $lang['dnslookups'] = 'DokuWiki zoekt de hostnamen van IP-adressen van gebruikers die pagina wijzigen op. Schakel deze optie uit als je geen of een langzame DNS server hebt.'; $lang['jquerycdn'] = 'Moet er een CDN gebruikt worden om de jQuery en jQuery UI bestanden te laden. Dit zorgt voor extra HTTP verzoeken, maar bestanden laden mogelijk sneller en zitten misschien al in de cache van de gebruiker.'; $lang['jquerycdn_o_0'] = 'Geen CDN gebruiken'; diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php index 6cb9267f7..cd818cb88 100644 --- a/lib/plugins/config/settings/config.metadata.php +++ b/lib/plugins/config/settings/config.metadata.php @@ -230,6 +230,9 @@ $meta['search_nslimit'] = array('numeric', '_min' => 0); $meta['search_fragment'] = array('multichoice','_choices' => array('exact', 'starts_with', 'ends_with', 'contains'),); $meta['trustedproxy'] = array('regex'); +$meta['_feature_flags'] = ['fieldset']; +$meta['defer_js'] = ['onoff']; + $meta['_network'] = array('fieldset'); $meta['dnslookups'] = array('onoff'); $meta['jquerycdn'] = array('multichoice', '_choices' => array(0,'jquery', 'cdnjs')); 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 = '&', $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&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&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); } } diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 18308d68a..da8eec7e7 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -120,7 +120,7 @@ var dw_behaviour = { * @author Michael Klier <chi@chimeric.de> */ checkWindowsShares: function() { - if(!LANG.nosmblinks || navigator.userAgent.match(/(Trident|MSIE)/)) { + if(!LANG.nosmblinks || navigator.userAgent.match(/(Trident|MSIE|Edge)/)) { // No warning requested or none necessary return; } |