Index: trunk/extensions/HelpCommons/HelpCommons.i18n.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | * @author SVG |
19 | 19 | */ |
20 | 20 | $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', |
22 | 22 | ); |
23 | 23 | |
24 | 24 | /** Message documentation (Message documentation) |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | * @author SVG |
33 | 33 | */ |
34 | 34 | $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', |
36 | 36 | ); |
37 | 37 | |
38 | 38 | /** Galician (Galego) |
Index: trunk/extensions/HelpCommons/HelpCommons.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * |
9 | 9 | * @author: Tim 'SVG' Weyer <SVG@Wikiunity.com> |
10 | 10 | * |
11 | | -* @copyright Copyright (C) 2011 Tim 'SVG' Weyer, Wikiunity |
| 11 | +* @copyright Copyright (C) 2011 Tim Weyer, Wikiunity |
12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 13 | * |
14 | 14 | */ |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | 'author' => array( 'Tim Weyer' ), |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:HelpCommons', |
25 | 25 | 'descriptionmsg' => 'helpcommons-desc', |
26 | | - 'version' => '1.0', |
| 26 | + 'version' => '1.0.1', |
27 | 27 | ); |
28 | 28 | |
29 | 29 | // Internationalization |
— | — | @@ -31,6 +31,10 @@ |
32 | 32 | |
33 | 33 | // Help wiki(s) where the help namespace is fetched from |
34 | 34 | $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; |
35 | 39 | |
36 | 40 | // Hooks |
37 | 41 | $wgHooks['ShowMissingArticle'][] = 'wfHelpCommonsLoad'; |
— | — | @@ -150,8 +154,8 @@ |
151 | 155 | return true; |
152 | 156 | } |
153 | 157 | |
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() ) { |
156 | 160 | return true; |
157 | 161 | } |
158 | 162 | |
— | — | @@ -182,9 +186,10 @@ |
183 | 187 | if ( $wgTitle->getNamespace() != NS_HELP ) { |
184 | 188 | return false; |
185 | 189 | } |
| 190 | + |
186 | 191 | foreach ( $wgHelpCommonsFetchingWikis as $language => $urls ) { |
187 | 192 | foreach ( $urls as $url => $helpwiki ) { |
188 | | - if ( $wgLanguageCode == $language && $wgDBname != $helpwiki ) { |
| 193 | + if ( $wgLanguageCode == $language && $wgDBname != $helpwiki && !$wgTitle->exists() ) { |
189 | 194 | // FIXME: $result is unused |
190 | 195 | $result = '<span class="editsection">[<a href="' . $url . '/index.php?title=' . |
191 | 196 | str_replace( ' ', '_', $title ) . '&action=edit&section=' . $section . |
— | — | @@ -203,14 +208,18 @@ |
204 | 209 | * @return bool |
205 | 210 | */ |
206 | 211 | function fnProtectHelpCommons( &$title, &$user, $action, &$result ) { |
207 | | - global $wgHelpCommonsFetchingWikis, $wgLanguageCode, $wgDBname; |
| 212 | + global $wgHelpCommonsProtect, $wgHelpCommonsProtectAll, $wgHelpCommonsFetchingWikis, $wgLanguageCode, $wgDBname; |
208 | 213 | |
| 214 | + if ( !$wgHelpCommonsProtect && !$wgHelpCommonsProtectAll ) { |
| 215 | + return false; |
| 216 | + } |
| 217 | + |
209 | 218 | foreach ( $wgHelpCommonsFetchingWikis as $language => $urls ) { |
210 | 219 | 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' ) { |
215 | 224 | return true; |
216 | 225 | } |
217 | 226 | |
— | — | @@ -222,7 +231,7 @@ |
223 | 232 | __METHOD__ |
224 | 233 | ); |
225 | 234 | |
226 | | - if ( $dbr->numRows( $res ) < 1 ) { |
| 235 | + if ( $dbr->numRows( $res ) < 1 && $wgHelpCommonsProtect && !$wgHelpCommonsProtectAll ) { |
227 | 236 | return true; |
228 | 237 | } |
229 | 238 | |
— | — | @@ -232,7 +241,6 @@ |
233 | 242 | if( $ns == NS_HELP || $ns == NS_HELP_TALK ) { |
234 | 243 | // error message if action is blocked |
235 | 244 | $result = array( 'protectedpagetext' ); |
236 | | - |
237 | 245 | // bail, and stop the request |
238 | 246 | return false; |
239 | 247 | } |
— | — | @@ -241,3 +249,4 @@ |
242 | 250 | } |
243 | 251 | return true; |
244 | 252 | } |
| 253 | + |