(bug 10139) Introduce 'EditSectionLink' and 'EditSectionLinkForOther' hooks; see...
authorRob Church <robchurch@users.mediawiki.org>
Tue, 5 Jun 2007 01:50:33 +0000 (01:50 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 5 Jun 2007 01:50:33 +0000 (01:50 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Linker.php

index 3d16fe0..e16b89e 100644 (file)
@@ -55,6 +55,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   a non-existent article or re-creating a previously-deleted article
 * Added variables 'wgRestrictionEdit' and 'wgRestrictionMove' for JS to header
 * (bug 9898) Allow viewing all namespaces in Special:Newpages
+* (bug 10139) Introduce 'EditSectionLink' and 'EditSectionLinkForOther' hooks;
+  see docs/hooks.txt for details
 
 == Bugfixes since 1.10 ==
 
index cb39e2f..9ea390d 100644 (file)
@@ -391,6 +391,20 @@ Alternatively, modifying $error and returning true will cause the contents of $e
 to be echoed at the top of the edit form as wikitext. Return true without altering
 $error to allow the edit to proceed.
 
+'EditSectionLink': Override the return value of Linker::editSectionLink()
+$skin: Skin rendering the UI
+$title: Title being linked to
+$section: Section to link to
+$link: Default link
+$result: Result (alter this to override the generated links)
+
+'EditSectionLinkForOther': Override the return value of Linker::editSectionLinkForOther()
+$skin: Skin rendering the UI
+$title: Title being linked to
+$section: Section to link to
+$link: Default link
+$result: Result (alter this to override the generated links)
+
 'EmailConfirmed': When checking that the user's email address is "confirmed"
 $user: User being checked
 $confirmed: Whether or not the email address is confirmed
index 6abcaa3..0969566 100644 (file)
@@ -1058,13 +1058,14 @@ class Linker {
        /** @todo document */
        public function editSectionLinkForOther( $title, $section ) {
                global $wgContLang;
-
                $title = Title::newFromText( $title );
                $editurl = '&section='.$section;
                $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl );
-
-               return "<span class=\"editsection\">[".$url."]</span>";
-
+               $result = null;
+               wfRunHooks( 'EditSectionLinkForOther', array( &$this, $title, $section, $url, &$result ) );
+               return is_null( $result )
+                       ? "<span class=\"editsection\"[{$url}]</span>"
+                       : "<span class=\"editsection\">[{$result}]</span>";
        }
 
        /**
@@ -1074,12 +1075,14 @@ class Linker {
         */
        public function editSectionLink( $nt, $section, $hint='' ) {
                global $wgContLang;
-
                $editurl = '&section='.$section;
                $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
                $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '',  $hint );
-
-               return "<span class=\"editsection\">[".$url."]</span>";
+               $result = null;
+               wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $url, &$result ) );
+               return is_null( $result )
+                       ? "<span class=\"editsection\">[{$url}]</span>"
+                       : "<span class=\"editsection\">[{$result}]</span>";
        }
 
        /**