3 # This script is included from update.php and install.php. Do not run it
6 function initialiseMessages() {
7 global $wgLang, $wgScript, $wgServer;
9 $fname = "initialiseMessages";
10 if ( !method_exists( $wgLang, "getAllMessages" ) ) {
12 Error, \$wgLang->getAllMessages() does not exist\n
13 You need to insert this function into your language file. For example:
15 function getAllMessages()
17 global \$wgAllMessagesEn;
18 return \$wgAllMessagesEn;
24 $sql = "SELECT 1 FROM cur WHERE cur_namespace=$ns LIMIT 1";
25 $res = wfQuery( $sql, DB_READ
, $fname );
26 if ( wfNumRows( $res ) ) {
27 print "MediaWiki: namespace already initialised\n";
31 $messages = $wgLang->getAllMessages();
32 $timestamp = wfTimestampNow();
33 $invTimestamp = wfInvertTimestamp( $timestamp );
34 $navText = wfMsgNoDB( "allmessagestext" );
37 <table border=1 width=100%><tr><td>
45 print "Initialising \"MediaWiki\" namespace...";
47 foreach ( $messages as $key => $message ) {
48 $titleObj = Title
::newFromText( $key );
49 $title = $titleObj->getDBkey();
50 $dbencMsg = wfStrencode( $message );
51 $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
52 cur_user_text, cur_timestamp, cur_restrictions,
53 cur_is_new, inverse_timestamp) VALUES (
62 wfQuery( $sql, DB_WRITE
, $fname );
63 $mwObj =& MagicWord
::get( MAG_MSGNW
);
64 $mw = $mwObj->getSynonym( 0 );
65 $mw = str_replace( "$1", $key, $mw );
67 $message = htmlspecialchars( $message );
70 [$wgServer$wgScript?title=MediaWiki:$title&action=edit $key]
77 $navText .= "</table>";
78 $navText = wfStrencode( $navText );
79 $title = wfMsgNoDB( "allmessages" );
80 $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
81 cur_user_text, cur_timestamp, cur_restrictions,
82 cur_is_new, inverse_timestamp) VALUES (
91 wfQuery( $sql, DB_WRITE
, $fname );