From 8e65a9e093c8c72649144669564ba324a8aa0227 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Thu, 27 Oct 2011 23:55:29 +0000 Subject: [PATCH] =?utf8?q?Fixes=20Bug=20#6793=20=E2=80=94=20=E2=80=9CNew?= =?utf8?q?=20Variable=20=5F=5FNEWSECTIONS=5F=5F=20like=20=5F=5FTOC=5F=5F?= =?utf8?q?=E2=80=9D=20by=20adding=20Nx.devnull's=20patch=20that=20adds=20a?= =?utf8?q?=20hook=20needed=20by=20Extension:PlaceNewSection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CREDITS | 1 + docs/hooks.txt | 7 +++++++ includes/WikiPage.php | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) 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; -- 2.20.1