DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:releases:refactor2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:releases:refactor2 [2020-09-28 11:39] – [Only new events with dokuwiki\Form\Form from DokuWiki] s-saharadevel:releases:refactor2 [2021-12-19 16:09] (current) – moved to [[devel:releases:refactor2021]] Klap-in
Line 1: Line 1:
-====== Refactoring ====== 
-Suggestions for development version (August 2020 and later) of Dokuwiki.  
- 
-[[devel:develonly]] 
- 
-===== Refactored UI elements using Form\Form class ===== 
- 
-Implemented by [[pr>3198|PR 3198]]  
- 
-==== Only new events with dokuwiki\Form\Form from DokuWiki ==== 
- 
-DokuWiki used before this release ''Doku_Form'' at a lot of places. The old ''Doku_Form'' triggered a [[codesearch>HTML_*FORM_OUTPUT]] event, when it was outputted by ''html_form()''. DokuWiki core code is updated to use the [[devel:form|new forms]], therefore the old events are **not triggered** anymore. The new style ''Form'' triggers [[codesearch>FORM_*_OUTPUT]] event when its HTML-representation is generated by ''toHTML()'' method.  
- 
-The old ''Doku_Form'' had been passed to handler of old [[codesearch>HTML_EDIT_FORMSELECTION]] event, that is **not triggered** anymore. Instead, DokuWiki core code has changed to triggers new [[codesearch>EDIT_FORM_ADDTEXTAREA]] event that provides a ''dokuwiki/Form/Form'' in the ''%%$data['form']%%'' and the event handler will complete the [[edit_window|editor]] form. 
- 
-:!: To enable your actions again, the new event handlers have to be implemented as well. The new events should pass the new ''dokuwiki\Form\Form'' object as the event data. The old event handlers can be kept temporary for backward compatibility. 
- 
-See for the description of the events: 
-| New  |[[devel:event:FORM_EDIT_OUTPUT]], [[devel:event:EDIT_FORM_ADDTEXTAREA]], [[devel:event:FORM_LOGIN_OUTPUT]], [[devel:event:FORM_CONFLICT_OUTPUT]], [[devel:event:FORM_DRAFT_OUTPUT]], [[devel:event:FORM_RECENT_OUTPUT]], [[devel:event:FORM_REVISIONS_OUTPUT]], [[devel:event:FORM_SEARCH_OUTPUT]], [[devel:event:FORM_SUBSCRIBE_OUTPUT]], [[devel:event:FORM_UPDATEPROFILE_OUTPUT]], [[devel:event:FORM_PROFILEDELETE_OUTPUT]], [[devel:event:FORM_REGISTER_OUTPUT]], [[devel:event:FORM_RESENDPWD_OUTPUT]], [[devel:event:FORM_UPLOAD_OUTPUT]], [[devel:event:FORM_SEARCHMEDIA_OUTPUT]], [[devel:event:FORM_QUICKSEARCH_OUTPUT]] | 
-| Old  |[[devel:event:HTML_EDITFORM_OUTPUT]], [[devel:event:HTML_EDIT_FORMSELECTION]], [[devel:event:HTML_LOGINFORM_OUTPUT]], [[devel:event:HTML_CONFLICTFORM_OUTPUT]], [[devel:event:HTML_DRAFTFORM_OUTPUT]], [[devel:event:HTML_RECENTFORM_OUTPUT]], [[devel:event:HTML_REVISIONSFORM_OUTPUT]], [[devel:event:HTML_SUBSCRIBEFORM_OUTPUT]], [[devel:event:HTML_UPDATEPROFILEFORM_OUTPUT]], [[devel:event:HTML_PROFILEDELETEFORM_OUTPUT]], [[devel:event:HTML_REGISTERFORM_OUTPUT]], [[devel:event:HTML_RESENDPWDFORM_OUTPUT]], [[devel:event:HTML_UPLOADFORM_OUTPUT]] |  
- 
-Changes to the ''dokuwiki\Form\Form'' class. An optional argument is added to ''toHTML()'' to make code simple without a separate event trigger. 
-<code diff> 
-- Event::createAndTrigger('FORM_SEARCH_OUTPUT', $searchForm); 
-- return $searchForm->toHTML(); 
-+ return $searchForm->toHTML('Search'); 
-</code> 
- 
- 
-==== UI elements implemented as class methods ==== 
- 
-[[devel:Action Router]] calls ''Action::tplContent()'', which calls ''Ui::show()'' that returns the actual HTML to output.  
- 
-**Deprecated** functions: [[codesearch>html_login]], [[codesearch>html_edit]], [[codesearch>html_edit_form]], [[codesearch>html_show]], [[codesearch>html_locked]], [[codesearch>html_index]],  [[codesearch>html_backlinks]], [[codesearch>html_diff]], [[codesearch>html_conflict]], [[codesearch>html_register]], [[codesearch>tpl_subscribe]] 
- 
-**Deprecated** and only used in DokuWiki: [[codesearch>html_denied]], [[codesearch>html_showrev]], [[codesearch>html_draft]], [[codesearch>html_revisions]], [[codesearch>html_recent]], [[codesearch>html_updateprofile]], [[codesearch>html_resendpwd]], [[codesearch>html_diff_head]], [[codesearch>html_diff_navigation]], [[codesearch>html_diff_navigationlink]] 
- 
-**Removed** functions: [[codesearch>html_minoredit]]. 
- 
-<code diff> 
-// inc/html.php 
-- html_login($svg) 
-+ (new dokuwiki\Ui\Login($svg))->show() 
- 
-- html_denied()  
-+ (new dokuwiki\Action\Denied())->showBanner() 
- 
-- html_edit() 
-+ (new dokuwiki\Ui\Editor)->show() 
- 
--    html_edit_form($data) 
-+    (new dokuwiki\Ui\Editor)->addTextarea($data) 
- 
--    html_minoredit() 
-+    // obsoleted: integrated into dokuwiki\Ui\Editor::show()   
- 
-- html_showrev() 
-+ (new dokuwiki\Ui\PageView)->showrev() 
- 
-- html_show($txt) 
-+ (new dokuwiki\Ui\PageView($txt))->show() 
- 
-- html_draft() 
-+ (new Ui\PageDraft)->show() 
- 
-- html_locked() 
-+ (new dokuwiki\Action\Locked())->showBanner() 
- 
-- html_revisions($first, $media_id) 
-+ (new dokuwiki\Ui\Revisions($first, $media_id))->show() 
- 
-- html_recent($first, $show_changes) 
-+ (new dokuwiki\Ui\Recent($first, $show_changes))->show() 
- 
-- html_index($ns) 
-+ (new dokuwiki\Ui\Index($ns))->show() 
- 
--    html_list_index($item) 
-+    (new dokuwiki\Ui\Index)->formatListItem($item) 
- 
--    html_li_index($item) 
-+    (new dokuwiki\Ui\Index)->tagListItem($item) 
- 
-- html_backlinks() { 
-+ (new dokuwiki\Ui\Backlinks)->show(); 
- 
-- html_diff($text, $intro, $type) 
-+ (new dokuwiki\Ui\Diff($text, $intro, $type))->show() 
- 
--    html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) 
-+    // changed to protected method; dokuwiki\Ui\Diff()::diffHead() 
- 
--    html_diff_navigation($pagelog, $type, $l_rev, $r_rev) 
-+    // changed to protected method; dokuwiki\Ui\Diff()::diffNavigation() 
- 
--    html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null) 
-+    // changed to protected method; dokuwiki\Ui\Diff()::diffViewlink() 
- 
--    html_insert_softbreaks($diffhtml) 
-+    (new dokuwiki\Ui\Diff())->insertSoftbreaks($diffhtml) 
- 
-- html_conflict($text, $summary) 
-+ (new dokuwiki\Ui\Conflict($text, $summary))->show() 
- 
-- html_register() 
-+ (new dokuwiki\Ui\UserRegister)->show() 
- 
-- html_updateprofile() 
-+ (new dokuwiki\Ui\UserProfile)->show() 
- 
-- html_resendpwd() 
-+ (new dokuwiki\Ui\UserResendPwd)->show() 
-</code> 
- 
-<code diff> 
-// inc/template.php 
-- tpl_subscribe() 
-+ (new \dokuwiki\Ui\Subscribe)->show() 
-</code> 
- 
-==== Small callbacks changed to annonymous functions ==== 
- 
-**Removed** functions: [[codesearch>html_hilight_callback]], which was used by [[codesearch>html_hilight]](). 
- 
-<code diff> 
-// html_hilight_callback() is integrated into html_hilight()  
-- $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 
-+ $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui", function ($match) { 
-+     $hlight = unslash($match[0]); 
-+     if (!isset($match[2])) { 
-+         $hlight = '<span class="search_hit">'.$hlight.'</span>'; 
-+     } 
-+     return $hlight; 
-+ }, $html); 
-</code> 
- 
-**Removed** function: [[codesearch>html_softbreak_callback]], which was used by [[codesearch>html_insert_softbreaks]](). 
-<code diff> 
-// html_softbreak_callback() is integrated into Ui\Diff::insertSoftbreaks() 
-- return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml); 
-+ return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/', function ($match) { 
-+   ... 
-+ }, $diffhtml); 
-</code> 
- 
-**Changed** usage of [[codesearch>html_buildlist]](), of which 4th argument callable [[codesearch>html_li_default]] has **deprecated**. 
- 
-<code diff> 
-- function html_buildlist($data, $class, $func, $lifunc = 'html_li_default', $forcewrapper = false){ 
-+ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = false) { 
-+   ... 
-+   // set callback function to build the <li> tag, formerly defined as html_li_default() 
-+   if (!is_callable($lifunc)) { 
-+      $lifunc = function ($item) { 
-+          return '<li class="level'.$item['level'].'">'; 
-+      }; 
-+   } 
-+   .... 
-+ } 
-  // Example if you want to use own 'html_li_default' function/method in your plugin ... 
-+     protected function myLiFunc($item) { ... } 
-+     $html = html_buildlist($data, $class, $func, [$this, 'myLiFunc']); 
- 
-  // if you want to use callbacks in Ui\Index class: 
-+     $idx = new dokuwiki\Ui\Index; 
-+     $html = html_buildlist($data, $class, [$idx,'formatListItem'], [$idx,'tagListItem']) 
-</code> 
- 
-==== Other changed functions ==== 
- 
- 
-Changed function: [[codesearch>html_sizechange]] 
-<code diff> 
-- html_sizechange($sizechange, $form) // where $form is the old Doku_Form 
-+ $html = html_sizechange($sizechange) 
-</code> 
-===== Sort with collator ===== 
- 
-[[pr>3115]] 
- 
-Improved sort in different languages. Not backward compatible. Maybe include library with exist check? 
- 
- 
-===== Refactor fulltext search functions and class Doku_Indexer ===== 
-  
- 
-[[pr>2943]] 
- 
-Following Functions will be Deprecated:   
- 
-Indexer: 
-[[codesearch>idx_get_version]],  
-[[codesearch>idx_addPage]],  
-[[codesearch>idx_getIndex]],  
-[[codesearch>idx_listIndexLengths]],  
-[[codesearch>idx_indexLengths]],  
-[[codesearch>idx_get_indexer]] 
- 
-MetadataIndex: 
-[[codesearch>ft_pageLookup]],  
-[[codesearch>ft_mediainuse]],  
-[[codesearch>ft_backlinks]], 
- 
-FulltextIndex: 
-[[codesearch>ft_pageSearch]],  
-[[codesearch>ft_snippet]],  
-[[codesearch>ft_snippet_re_preprocess]],  
-[[codesearch>ft_queryParser]],  
-[[codesearch>ft_queryUnparser_simple]] 
- 
  
devel/releases/refactor2.1601285951.txt.gz · Last modified: 2020-09-28 11:39 by s-sahara

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki