r105304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105303‎ | r105304 | r105305 >
Date:15:38, 6 December 2011
Author:cervidae
Status:deferred
Tags:
Comment:
adding version 1.0.1
Modified paths:
  • /trunk/extensions/HelpCommons/HelpCommons.i18n.php (modified) (history)
  • /trunk/extensions/HelpCommons/HelpCommons.php (modified) (history)

Diff [purge]

Index: trunk/extensions/HelpCommons/HelpCommons.i18n.php
@@ -17,7 +17,7 @@
1818 * @author SVG
1919 */
2020 $messages['en'] = array(
21 - 'helpcommons-desc' => 'Fetches the help namespace from a help wiki and includes them into other wikis on the wiki family',
 21+ 'helpcommons-desc' => 'Fetches the help pages from a help wiki and includes them into other wikis on the wiki family',
2222 );
2323
2424 /** Message documentation (Message documentation)
@@ -31,7 +31,7 @@
3232 * @author SVG
3333 */
3434 $messages['de'] = array(
35 - 'helpcommons-desc' => 'Nimmt den Hilfe-Namensraum aus einem Hilfe Wiki und bindet ihn in andere Wikis der Wiki-Family ein',
 35+ 'helpcommons-desc' => 'Nimmt den Hilfe-Namensraum aus einem Hilfe Wiki und bindet ihn in andere Wikis der Wiki-Familie ein',
3636 );
3737
3838 /** Galician (Galego)
Index: trunk/extensions/HelpCommons/HelpCommons.php
@@ -7,7 +7,7 @@
88 *
99 * @author: Tim 'SVG' Weyer <SVG@Wikiunity.com>
1010 *
11 -* @copyright Copyright (C) 2011 Tim 'SVG' Weyer, Wikiunity
 11+* @copyright Copyright (C) 2011 Tim Weyer, Wikiunity
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 *
1414 */
@@ -22,7 +22,7 @@
2323 'author' => array( 'Tim Weyer' ),
2424 'url' => 'http://www.mediawiki.org/wiki/Extension:HelpCommons',
2525 'descriptionmsg' => 'helpcommons-desc',
26 - 'version' => '1.0',
 26+ 'version' => '1.0.1',
2727 );
2828
2929 // Internationalization
@@ -31,6 +31,10 @@
3232
3333 // Help wiki(s) where the help namespace is fetched from
3434 $wgHelpCommonsFetchingWikis = array();
 35+// If true, all non-existing help pages and talks which exist on help wiki will be protected on non-help wikis
 36+$wgHelpCommonsProtect = true;
 37+// If true, every non-existing help page will be protected on non-help wikis
 38+$wgHelpCommonsProtectAll = false;
3539
3640 // Hooks
3741 $wgHooks['ShowMissingArticle'][] = 'wfHelpCommonsLoad';
@@ -150,8 +154,8 @@
151155 return true;
152156 }
153157
154 - // only affects non-existing Help pages
155 - if ( $target->getNamespace() != NS_HELP || $target->exists() ) {
 158+ // only affects non-existing help pages and talks
 159+ if ( $target->getNamespace() != NS_HELP && $target->getNamespace() != NS_HELP_TALK || $target->exists() ) {
156160 return true;
157161 }
158162
@@ -182,9 +186,10 @@
183187 if ( $wgTitle->getNamespace() != NS_HELP ) {
184188 return false;
185189 }
 190+
186191 foreach ( $wgHelpCommonsFetchingWikis as $language => $urls ) {
187192 foreach ( $urls as $url => $helpwiki ) {
188 - if ( $wgLanguageCode == $language && $wgDBname != $helpwiki ) {
 193+ if ( $wgLanguageCode == $language && $wgDBname != $helpwiki && !$wgTitle->exists() ) {
189194 // FIXME: $result is unused
190195 $result = '<span class="editsection">[<a href="' . $url . '/index.php?title=' .
191196 str_replace( ' ', '_', $title ) . '&amp;action=edit&amp;section=' . $section .
@@ -203,14 +208,18 @@
204209 * @return bool
205210 */
206211 function fnProtectHelpCommons( &$title, &$user, $action, &$result ) {
207 - global $wgHelpCommonsFetchingWikis, $wgLanguageCode, $wgDBname;
 212+ global $wgHelpCommonsProtect, $wgHelpCommonsProtectAll, $wgHelpCommonsFetchingWikis, $wgLanguageCode, $wgDBname;
208213
 214+ if ( !$wgHelpCommonsProtect && !$wgHelpCommonsProtectAll ) {
 215+ return false;
 216+ }
 217+
209218 foreach ( $wgHelpCommonsFetchingWikis as $language => $urls ) {
210219 foreach ( $urls as $url => $helpwiki ) {
211 - // only protect Help pages on non-help-pages-fetching wikis
212 - if ( $wgLanguageCode == $language && $wgDBname != $helpwiki ) {
213 - // block actions 'edit' and 'create'
214 - if ( $action != 'edit' && $action != 'create' ) {
 220+ // only protect non-existing help pages on non-help-page-fetching wikis
 221+ if ( $wgLanguageCode == $language && $wgDBname != $helpwiki && !$title->exists() ) {
 222+ // block actions 'create', 'edit' and 'protect'
 223+ if ( $action != 'create' && $action != 'edit' && $action != 'protect' ) {
215224 return true;
216225 }
217226
@@ -222,7 +231,7 @@
223232 __METHOD__
224233 );
225234
226 - if ( $dbr->numRows( $res ) < 1 ) {
 235+ if ( $dbr->numRows( $res ) < 1 && $wgHelpCommonsProtect && !$wgHelpCommonsProtectAll ) {
227236 return true;
228237 }
229238
@@ -232,7 +241,6 @@
233242 if( $ns == NS_HELP || $ns == NS_HELP_TALK ) {
234243 // error message if action is blocked
235244 $result = array( 'protectedpagetext' );
236 -
237245 // bail, and stop the request
238246 return false;
239247 }
@@ -241,3 +249,4 @@
242250 }
243251 return true;
244252 }
 253+

Status & tagging log