r104344 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104343‎ | r104344 | r104345 >
Date:16:42, 27 November 2011
Author:cervidae
Status:deferred (Comments)
Tags:
Comment:
Confine DoEditSectionLink Hook to NS_HELP
Modified paths:
  • /trunk/extensions/SharedHelpNamespace/SharedHelpNamespace.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SharedHelpNamespace/SharedHelpNamespace.php
@@ -29,8 +29,10 @@
3030 $dir = dirname( __FILE__ ) . '/';
3131 $wgExtensionMessagesFiles['SharedHelpNamespace'] = $dir . 'SharedHelpNamespace.i18n.php';
3232
33 -// Help wikis where the help namespace is fetched from
34 -$wgSharedHelpNamespaceFetchingWikis = array();
 33+// Help wiki(s) where the help namespace is fetched from
 34+if( !isset($wgSharedHelpNamespaceFetchingWikis) ) {
 35+ $wgSharedHelpNamespaceFetchingWikis = array();
 36+}
3537
3638 // Hooks
3739 $wgHooks['ShowMissingArticle'][] = 'wfSharedHelpNamespaceLoad';
@@ -145,16 +147,21 @@
146148
147149
148150 function wfSharedHelpNamespaceChangeEditSectionLink( $skin, $title, $section, $tooltip, $result, $lang = false ) {
149 - global $wgSharedHelpNamespaceFetchingWikis, $wgLanguageCode, $wgDBname;
 151+ global $wgTitle, $wgSharedHelpNamespaceFetchingWikis, $wgLanguageCode, $wgDBname;
150152
151 - foreach ( $wgSharedHelpNamespaceFetchingWikis as $language => $urls ) {
152 - foreach ( $urls as $url => $wgSharedHelpNamespaceFetchingWiki ) {
153 - if ( $wgLanguageCode == "$language" && $wgDBname != $wgSharedHelpNamespaceFetchingWiki ) {
154 - $result = '<span class="editsection">[<a href="'.$url.'/index.php?title='.str_replace( ' ', '_', $title ).'&amp;action=edit&amp;section='.$section.'" title="'.wfMsg( 'editsectionhint', $tooltip ).'">'.wfMsg( 'editsection' ).'</a>]</span>';
 153+ if ( $wgTitle->getNamespace() == NS_HELP ) {
 154+ foreach ( $wgSharedHelpNamespaceFetchingWikis as $language => $urls ) {
 155+ foreach ( $urls as $url => $wgSharedHelpNamespaceFetchingWiki ) {
 156+ if ( $wgLanguageCode == "$language" && $wgDBname != $wgSharedHelpNamespaceFetchingWiki ) {
 157+ $result = '<span class="editsection">[<a href="'.$url.'/index.php?title='.str_replace( ' ', '_', $title ).'&amp;action=edit&amp;section='.$section.'" title="'.wfMsg( 'editsectionhint', $tooltip ).'">'.wfMsg( 'editsection' ).'</a>]</span>';
 158+ }
155159 }
156160 }
 161+ return true;
 162+ } else {
 163+ return false;
157164 }
158 - return true;
 165+
159166 }
160167
161168

Follow-up revisions

RevisionCommit summaryAuthorDate
r104444Merging with Reedy's several code changes. Thankscervidae15:37, 28 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:24, 29 November 2011

Configuration variables must be defined unconditionally. User should be able to override them in LocalSettings.php after including the extension.

#Comment by SVG (talk | contribs)   16:27, 29 November 2011

Fixed in r104444. Thanks.

Status & tagging log