devel:releases:refactor2020
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devel:releases:refactor2020 [2020-09-14 23:07] – [Refactoring 2020] Klap-in | devel:releases:refactor2020 [2023-11-05 14:47] (current) – add old javascript functions and DOKU_TPL* constants Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <= [[devel: | ||
+ | |||
====== Refactoring 2020====== | ====== Refactoring 2020====== | ||
- | For the release of 2020 big parts of DokuWiki are refactored. | + | For the " |
- | ^Please share all remarks and possible improvements. See [[https:// | + | ^Please share all remarks and possible improvements. See [[https:// |
===== How to find deprecated code ===== | ===== How to find deprecated code ===== | ||
Line 8: | Line 10: | ||
Plugin/ | Plugin/ | ||
+ | |||
+ | Since the Igor 2022 release: | ||
+ | * logging of // | ||
+ | * use the plugin | ||
+ | * check [[plugin: | ||
+ | |||
+ | Up to the Hogfather 2020 release: | ||
* enable the [[config: | * enable the [[config: | ||
* use the plugin | * use the plugin | ||
- | * check '' | + | * Check logs for any information about deprecated calls caused by the plugin in '' |
+ | ===== Removed code ===== | ||
+ | ==== mail_send() ==== | ||
+ | |||
+ | Pull request [[pr> | ||
+ | |||
+ | [[codesearch> | ||
+ | |||
+ | Example | ||
+ | <code diff> | ||
+ | $text = rawLocale(' | ||
+ | - $text = str_replace(' | ||
+ | - $text = str_replace(' | ||
+ | - $text = str_replace(' | ||
+ | - $text = str_replace(' | ||
+ | - $text = str_replace(' | ||
+ | - | ||
+ | - return mail_send($userinfo[' | ||
+ | - | ||
+ | - | ||
+ | - | ||
+ | + $trep = array( | ||
+ | + ' | ||
+ | + ' | ||
+ | + ' | ||
+ | + ); | ||
+ | + | ||
+ | + $mail = new Mailer(); | ||
+ | + $mail-> | ||
+ | + $mail-> | ||
+ | + $mail-> | ||
+ | + return $mail-> | ||
+ | </ | ||
===== Deprecated and changed code ===== | ===== Deprecated and changed code ===== | ||
- | Below, you find lists with renamed, changed and moved parts of DokuWiki. Some examples are provided for easier update of plugins and templates. References to codesearch.dokuwiki.org can help locate | + | Below, you find lists with renamed, changed and moved parts of DokuWiki. Some examples are provided for easier update of plugins and templates. References to codesearch.dokuwiki.org can help locate |
Most of the changes documented here are merged with pull request [[pr> | Most of the changes documented here are merged with pull request [[pr> | ||
+ | |||
+ | |||
==== JSON class is deprecated ==== | ==== JSON class is deprecated ==== | ||
Line 198: | Line 241: | ||
|[[codesearch> | |[[codesearch> | ||
- | Renamed and moved function: | + | Renamed and moved functions: |
- | [[codesearch> | + | |
+ | * [[codesearch> | ||
<code diff> | <code diff> | ||
Line 206: | Line 250: | ||
- trigger_event(' | - trigger_event(' | ||
+ Event:: | + Event:: | ||
+ | </ | ||
+ | <code diff> | ||
+ | global $pluginController; | ||
+ | - $isDisabled = $pluginController-> | ||
+ | + $isDisabled = !$pluginController-> | ||
</ | </ | ||
Line 211: | Line 260: | ||
|global $[[codesearch> | |global $[[codesearch> | ||
+ | |||
+ | ==== ACL admin class admin_plugin_acl==== | ||
+ | [[https:// | ||
+ | |||
+ | Renamed public functions: | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |||
+ | |||
+ | Renamed and changed to protected functions: | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |[[codesearch> | ||
+ | |||
Line 303: | Line 378: | ||
Renamed and moved classes: | Renamed and moved classes: | ||
- | ^Old ^New^ | + | ^ Old |
- | |[[codesearch> | + | | [[codesearch> |
- | |CM_KEYMARKER DOKU_PLUGIN_IMAGES PLUGIN_METADATA|Configuration:: | + | | CM_KEYMARKER DOKU_PLUGIN_IMAGES PLUGIN_METADATA |
- | |[[codesearch> | + | | [[codesearch> |
Line 326: | Line 401: | ||
===== Deprecated 2016 ===== | ===== Deprecated 2016 ===== | ||
+ | ==== Changed signatures hooks, handle() and render() ==== | ||
There are some old signatures that need still some attention in some plugins. | There are some old signatures that need still some attention in some plugins. | ||
Line 344: | Line 420: | ||
+ public function render($mode, | + public function render($mode, | ||
</ | </ | ||
+ | |||
+ | ==== Replace DOKU_TPL* constants by tpl_* functions ==== | ||
+ | In 2012, [[github> | ||
+ | |||
+ | <code diff> | ||
+ | - if (file_exists(DOKU_TPLINC . ' | ||
+ | - // | ||
+ | - echo '< | ||
+ | + if (file_exists(tpl_incdir() . ' | ||
+ | + // | ||
+ | + echo '< | ||
+ | </ | ||
+ | |||
+ | ==== Old Javascript functions ==== | ||
+ | The introduction of jQuery in 2011, replaced a set of helpful functions. See also [[devel: | ||
+ | |||
+ | ==== $(' | ||
+ | '' | ||
+ | <code diff> | ||
+ | - var obj = $(' | ||
+ | - // obj now is a DOM object | ||
+ | |||
+ | + let $obj = jQuery('# | ||
+ | + // $obj is a jQuery object - if you really need the DOM object use [0] e.g.: | ||
+ | + let obj = $obj[0]; | ||
+ | </ | ||
+ | |||
+ | ==== getElementsByClass() ==== | ||
+ | |||
+ | use jQuery' | ||
+ | |||
+ | <code diff> | ||
+ | - var htmlelements = getElementsByClass( ' | ||
+ | - // htmlelements now is an array of DOM elements | ||
+ | - for(var n in htmlelements ) { | ||
+ | - | ||
+ | - } | ||
+ | |||
+ | /* New code */ | ||
+ | + jQuery(' | ||
+ | + | ||
+ | + }); | ||
+ | |||
+ | /* Or, this new code */ | ||
+ | + let $jqueryelements = jQuery(' | ||
+ | + // $jqueryelements is a jquery thing: an array plus some other stuff. | ||
+ | + $jqueryelements.each(function(){ | ||
+ | + | ||
+ | + }); | ||
+ | |||
+ | /* or, if you prefer (it shows some part of the internals) */ | ||
+ | + for (let n = 0; n < $jqueryelements.length; | ||
+ | + | ||
+ | + } | ||
+ | </ | ||
+ | |||
+ | * It is common to start the variable which contain a jQuery object with a '' | ||
+ | |||
+ | ==== addInitEvent() ==== | ||
+ | |||
+ | registering callbacks to be run when the DOM is ready to be used - use jQuery' | ||
+ | |||
+ | <code diff> | ||
+ | - addInitEvent(function(){ | ||
+ | - | ||
+ | - }); | ||
+ | |||
+ | + jQuery(function(){ | ||
+ | + | ||
+ | + }); | ||
+ | </ | ||
+ | |||
+ | ==== addEvent() ==== | ||
+ | |||
+ | Registering event handlers - use jQuery' | ||
+ | |||
+ | <code diff> | ||
+ | /* Old code */ | ||
+ | - addEvent(obj, | ||
+ | - | ||
+ | - }); | ||
+ | |||
+ | /* Recenter old code */ | ||
+ | - jQuery(obj).click(function(){ | ||
+ | - | ||
+ | - }); | ||
+ | |||
+ | /* New code */ | ||
+ | + jQuery(obj).on(" | ||
+ | + | ||
+ | + }); | ||
+ | </ | ||
+ | |||
+ | * replace " | ||
+ | |||
+ | ==== tw_sack ==== | ||
+ | |||
+ | executing AJAX requests - use jQuery' | ||
+ | |||
+ | <code diff> | ||
+ | /* Old code */ | ||
+ | - sack = new sack(DOKU_BASE + ' | ||
+ | - sack.AjaxFailedAlert = ''; | ||
+ | - sack.encodeURIString = false; | ||
+ | - sack.runAJAX(' | ||
+ | |||
+ | /* New code */ | ||
+ | + jQuery.post( | ||
+ | + | ||
+ | + { call: ' | ||
+ | + ); | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
===== General cleanup suggestions ===== | ===== General cleanup suggestions ===== | ||
Line 354: | Line 546: | ||
</ | </ | ||
- | Code beautification. The defines are already in core, so can be deleted. Further these code beautifications are not needed anymore with current tools. | + | Code beautification. The defines are already in core, so can be deleted. Further these code beautifications are not needed anymore with current |
<code diff> | <code diff> | ||
- // Some whitespace to help View > Source | - // Some whitespace to help View > Source | ||
Line 375: | Line 567: | ||
<code diff> | <code diff> | ||
- | - require_once(DOKU_PLUGIN.' | + | - require_once(DOKU_PLUGIN . ' |
- | - require_once(DOKU_PLUGIN.' | + | - require_once(DOKU_PLUGIN . ' |
- | - require_once(DOKU_PLUGIN.' | + | - require_once(DOKU_PLUGIN . ' |
- | - etc | + | etc |
- require_once DOKU_INC . ' | - require_once DOKU_INC . ' | ||
- require_once DOKU_INC . ' | - require_once DOKU_INC . ' | ||
+ | etc | ||
+ | </ | ||
+ | |||
+ | The historical '' | ||
+ | |||
+ | |||
+ | <code diff> | ||
+ | - public function getInfo() { | ||
+ | - ... | ||
+ | - } | ||
+ | </ | ||
+ | |||
+ | ===== Code improvements ===== | ||
+ | |||
+ | Do not use public properties, but setter/ | ||
+ | |||
+ | Example for the renderer: | ||
+ | <code diff> | ||
+ | - $renderer-> | ||
+ | + $renderer-> | ||
</ | </ |
devel/releases/refactor2020.1600117664.txt.gz · Last modified: 2020-09-14 23:07 by Klap-in