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 [2022-07-02 20:09] – [Removed code] 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. This page lists changes upto August 2020. For more recent changes see [[devel: | + | For the " |
^Please share all remarks and possible improvements. See [[https:// | ^Please share all remarks and possible improvements. See [[https:// | ||
Line 11: | Line 11: | ||
Plugin/ | Plugin/ | ||
- | | + | Since the Igor 2022 release: |
+ | | ||
* use the plugin | * use the plugin | ||
- | * check '' | + | * check [[plugin: |
+ | Up to the Hogfather 2020 release: | ||
+ | |||
+ | * enable the [[config: | ||
+ | * use the plugin | ||
+ | * Check logs for any information about deprecated calls caused by the plugin in '' | ||
===== Removed code ===== | ===== Removed code ===== | ||
+ | ==== mail_send() ==== | ||
+ | |||
Pull request [[pr> | Pull request [[pr> | ||
Line 254: | Line 262: | ||
==== ACL admin class admin_plugin_acl==== | ==== ACL admin class admin_plugin_acl==== | ||
- | [[https:// | + | [[https:// |
Renamed public functions: | Renamed public functions: | ||
Line 393: | 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 411: | 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 442: | 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.1656785368.txt.gz · Last modified: 2022-07-02 20:09 by Klap-in