r1697 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1696‎ | r1697 | r1698 >
Date:14:04, 21 September 2003
Author:timstarling
Status:old
Tags:
Comment:
MediaWiki namespace
Modified paths:
  • /trunk/phase3/maintenance/InitialiseMessages.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/InitialiseMessages.php
@@ -0,0 +1,94 @@
 2+<?
 3+
 4+# This script is included from update.php and install.php. Do not run it
 5+# by itself.
 6+
 7+function initialiseMessages() {
 8+ global $wgLang, $wgScript, $wgServer;
 9+
 10+ $fname = "initialiseMessages";
 11+ if ( !method_exists( $wgLang, "getAllMessages" ) ) {
 12+ print "
 13+Error, \$wgLang->getAllMessages() does not exist\n
 14+You need to insert this function into your language file. For example:
 15+
 16+function getAllMessages()
 17+{
 18+ global \$wgAllMessagesEn;
 19+ return \$wgAllMessagesEn;
 20+}
 21+ \n";
 22+ return;
 23+ }
 24+ $ns = NS_MEDIAWIKI;
 25+ $sql = "SELECT 1 FROM cur WHERE cur_namespace=$ns LIMIT 1";
 26+ $res = wfQuery( $sql, DB_READ, $fname );
 27+ if ( wfNumRows( $res ) ) {
 28+ print "MediaWiki: namespace already initialised\n";
 29+ return;
 30+ }
 31+
 32+ $messages = $wgLang->getAllMessages();
 33+ $timestamp = wfTimestampNow();
 34+ $invTimestamp = wfInvertTimestamp( $timestamp );
 35+ $navText = wfMsgNoDB( "allmessagestext" );
 36+ $navText .= "
 37+
 38+<table border=1 width=100%><tr><td>
 39+ '''Name'''
 40+</td><td>
 41+ '''Default text'''
 42+</td><td>
 43+ '''Current text'''
 44+</td></tr>";
 45+
 46+ print "Initialising \"MediaWiki\" namespace...";
 47+
 48+ foreach ( $messages as $key => $message ) {
 49+ $titleObj = Title::newFromText( $key );
 50+ $title = $titleObj->getDBkey();
 51+ $dbencMsg = wfStrencode( $message );
 52+ $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
 53+ cur_user_text, cur_timestamp, cur_restrictions,
 54+ cur_is_new, inverse_timestamp) VALUES (
 55+ $ns,
 56+ '$title',
 57+ '$dbencMsg',
 58+ 'MediaWiki default',
 59+ '$timestamp',
 60+ 'sysop',
 61+ 1,
 62+ '$invTimestamp')";
 63+ wfQuery( $sql, DB_WRITE, $fname );
 64+ $mwObj =& MagicWord::get( MAG_MSGNW );
 65+ $mw = $mwObj->getSynonym( 0 );
 66+ $mw = str_replace( "$1", $key, $mw );
 67+
 68+ $message = htmlspecialchars( $message );
 69+ $navText .=
 70+"<tr><td>
 71+ [$wgServer$wgScript?title=MediaWiki:$title&action=edit $key]
 72+</td><td>
 73+ $message
 74+</td><td>
 75+ $mw
 76+</td></tr>";
 77+ }
 78+ $navText .= "</table>";
 79+ $navText = wfStrencode( $navText );
 80+ $title = wfMsgNoDB( "allmessages" );
 81+ $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
 82+ cur_user_text, cur_timestamp, cur_restrictions,
 83+ cur_is_new, inverse_timestamp) VALUES (
 84+ $ns,
 85+ '$title',
 86+ '$navText',
 87+ 'MediaWiki default',
 88+ '$timestamp',
 89+ 'sysop',
 90+ 1,
 91+ '$invTimestamp')";
 92+ wfQuery( $sql, DB_WRITE, $fname );
 93+ print "done \n";
 94+}
 95+
Property changes on: trunk/phase3/maintenance/InitialiseMessages.php
___________________________________________________________________
Added: svn:eol-style
196 + native
Added: svn:keywords
297 + Author Date Id Revision

Status & tagging log