Fixes Bug #6793 — “New Variable __NEWSECTIONS__ like __TOC__” by
authorMark A. Hershberger <mah@users.mediawiki.org>
Thu, 27 Oct 2011 23:55:29 +0000 (23:55 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Thu, 27 Oct 2011 23:55:29 +0000 (23:55 +0000)
adding Nx.devnull's patch that adds a hook needed by
Extension:PlaceNewSection.

CREDITS
docs/hooks.txt
includes/WikiPage.php

diff --git a/CREDITS b/CREDITS
index c2ee35b..dd96bc1 100644 (file)
--- 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
index 7a36381..5b5234f 100644 (file)
@@ -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
index 8d6d3eb..c52e0c7 100644 (file)
@@ -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;