From 50d9bbfef8b4814b7f230101a1a70777faebe74d Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 5 Jun 2007 01:50:33 +0000 Subject: [PATCH] (bug 10139) Introduce 'EditSectionLink' and 'EditSectionLinkForOther' hooks; see docs/hooks.txt for details [patch from Jack D. Pond, with small modifications] --- RELEASE-NOTES | 2 ++ docs/hooks.txt | 14 ++++++++++++++ includes/Linker.php | 17 ++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3d16fe0140..e16b89ed50 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/docs/hooks.txt b/docs/hooks.txt index cb39e2f7d6..9ea390dc8d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/Linker.php b/includes/Linker.php index 6abcaa3e8c..09695661e8 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1058,13 +1058,14 @@ class Linker { /** @todo document */ public function editSectionLinkForOther( $title, $section ) { global $wgContLang; - $title = Title::newFromText( $title ); $editurl = '§ion='.$section; $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); - - return "[".$url."]"; - + $result = null; + wfRunHooks( 'EditSectionLinkForOther', array( &$this, $title, $section, $url, &$result ) ); + return is_null( $result ) + ? "" + : "[{$result}]"; } /** @@ -1074,12 +1075,14 @@ class Linker { */ public function editSectionLink( $nt, $section, $hint='' ) { global $wgContLang; - $editurl = '§ion='.$section; $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"'; $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint ); - - return "[".$url."]"; + $result = null; + wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $url, &$result ) ); + return is_null( $result ) + ? "[{$url}]" + : "[{$result}]"; } /** -- 2.20.1