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-22 22:54] – [Extension and Event] Klap-in | devel:releases:refactor2020 [2023-11-05 14:47] (current) – add old javascript functions and DOKU_TPL* constants Klap-in | ||
---|---|---|---|
Line 3: | Line 3: | ||
====== 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:// | ||
Line 10: | 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 ===== | ||
Line 19: | Line 58: | ||
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 219: | 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 334: | 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 352: | 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 383: | 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() { | ||
+ | - ... | ||
+ | - } | ||
</ | </ | ||
devel/releases/refactor2020.1600808086.txt.gz · Last modified: 2020-09-22 22:54 by Klap-in