Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created December 31, 2011 15:34
Show Gist options
  • Select an option

  • Save aaronpk/1544351 to your computer and use it in GitHub Desktop.

Select an option

Save aaronpk/1544351 to your computer and use it in GitHub Desktop.
Lowercase MediaWiki Hack

From http://jeffmcneill.com/2007/09/30/lowercase-usernames-namespaces-mediawiki-installation/

http://web.archive.org/web/20071210165719/http://jeffmcneill.com/2007/09/30/lowercase-usernames-namespaces-mediawiki-installation/

Ah, between this article on custom namespaces and a wonderful set of hacks over here and going into the languages.php file, here is what needs to be changed (beyond renaming special files and templates) in order to get an all-lower-case mediawiki installation:

LocalSettings.php

# DO NOT CAPITALIZE
$wgCapitalLinks = false;

# Added namespace
$wgExtraNamespaces[100] = “school”; #note, this is where you can add extra namespaces
$wgExtraNamespaces[101] = “school-talk”;
$wgNamespacesWithSubpages[school] = true; #note, add all namespaces with subpages here

languages/Language.php

/* private */ $wgNamespaceNamesEn = array(
NS_MEDIA => ‘media’,
NS_SPECIAL => ’special’,
NS_MAIN => ”,
NS_TALK => ‘talk’,
NS_USER => ‘user’,
NS_USER_TALK => ‘user-talk’,
NS_PROJECT => $wgMetaNamespace,
NS_PROJECT_TALK => $wgMetaNamespace . ‘-talk’,
NS_IMAGE => ‘image’,
NS_IMAGE_TALK => ‘image-talk’,
NS_MEDIAWIKI => ‘mediaWiki’,
NS_MEDIAWIKI_TALK => ‘mediaWiki-talk’,
NS_TEMPLATE => ‘template’,
NS_TEMPLATE_TALK => ‘template-talk’,
NS_HELP => ‘help’,
NS_HELP_TALK => ‘help-talk’,
NS_CATEGORY => ‘category’,
NS_CATEGORY_TALK => ‘category-talk’,
);

includes/User.php

function newFromName( $name, $validate = true ) {
## ADDITIONAL COMMENTING HERE FOR LOWERCASE SUPPORT
# Force usernames to capital
global $wgContLang;
## $name = $wgContLang->ucfirst( $name );

# Clean up name according to title rules
$t = Title::newFromText( $name );
## if( is_null( $t ) ) {
## return null;
## }
## ADDITIONAL COMMENTING HERE FOR LOWERCASE SUPPORT
## if( is_null( $nt ) ) {
  # Illegal name
  ## return null;
## }

## ADDITIONAL COMMENT HERE FOR LOWERCASE SUPPORT
function isValidUserName( $name ) {
  global $wgContLang, $wgMaxNameChars;

  if ( $name == ”
  || User::isIP( $name )
  || strpos( $name, ‘/’ ) !== false
  || strlen( $name ) > $wgMaxNameChars ) ## added right parens here
  ## || $name != $wgContLang->ucfirst( $name ) )
    return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment