From: Mark A. Hershberger Date: Thu, 27 Oct 2011 23:55:29 +0000 (+0000) Subject: Fixes Bug #6793 — “New Variable __NEWSECTIONS__ like __TOC__” by X-Git-Tag: 1.31.0-rc.0~26859 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=8e65a9e093c8c72649144669564ba324a8aa0227;p=lhc%2Fweb%2Fwiklou.git Fixes Bug #6793 — “New Variable __NEWSECTIONS__ like __TOC__” by adding Nx.devnull's patch that adds a hook needed by Extension:PlaceNewSection. --- diff --git a/CREDITS b/CREDITS index c2ee35bba2..dd96bc172a 100644 --- a/CREDITS +++ b/CREDITS @@ -139,6 +139,7 @@ following names for their contribution to the product. * Nathan Larson * nephele * Nik +* Nx.devnull * Nikolaos S. Karastathis * Olaf Lenz * Paul Copperman diff --git a/docs/hooks.txt b/docs/hooks.txt index 7a363814dd..5b5234fb3e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1475,6 +1475,13 @@ $action : Action being performed Change $result and return false to give a definitive answer, otherwise the built-in rate limiting checks are used, if enabled. +'PlaceNewSection': Override placement of new sections. +$wikipage : WikiPage object +$oldtext : the text of the article before editing +$subject : subject of the new section +&$text : text of the new section +Return false and put the merged text into $text to override the default behavior. + 'PrefixSearchBackend': Override the title prefix search used for OpenSearch and AJAX search suggestions. Put results into &$results outparam and return false. $ns : array of int namespace keys to search in diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 8d6d3ebf57..c52e0c7452 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -977,9 +977,11 @@ class WikiPage extends Page { if ( $section == 'new' ) { # Inserting a new section $subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : ''; - $text = strlen( trim( $oldtext ) ) > 0 + if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) { + $text = strlen( trim( $oldtext ) ) > 0 ? "{$oldtext}\n\n{$subject}{$text}" : "{$subject}{$text}"; + } } else { # Replacing an existing section; roll out the big guns global $wgParser;