3 # This script is included from update.php and install.php. Do not run it
6 function initialiseMessages( $overwrite = false) {
7 global $wgLang, $wgScript, $wgServer, $wgAllMessagesEn;
8 global $wgOut, $wgArticle, $wgUser;
10 $fname = "initialiseMessages";
13 $timestamp = wfTimestampNow();
14 $invTimestamp = wfInvertTimestamp( $timestamp );
15 $navText = wfMsgNoDB( "allmessagestext" );
18 <table border=1 width=100%><tr><td>
26 print "Initialising \"MediaWiki\" namespace...\n";
27 $sql = "SELECT cur_title FROM cur WHERE cur_namespace=$ns AND cur_title IN(";
30 $sortedArray = ksort( $wgAllMessagesEn );
32 foreach ( $sortedArray as $key => $enMsg ) {
39 $message = wfMsgNoDB( $key );
40 $titleObj = Title::newFromText( $key );
41 $enctitle = wfStrencode($titleObj->getDBkey());
42 $sql .= "'$enctitle'";
46 $res = wfQuery( $sql, DB_READ );
48 $row = wfFetchObject( $res );
51 print "Setting up...";
54 $exists[$row->cur_title] = 1;
55 $row = wfFetchObject( $res );
58 $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
59 cur_user_text, cur_timestamp, cur_restrictions,
60 cur_is_new, inverse_timestamp, cur_touched) VALUES ";
62 $mwObj =& MagicWord::get( MAG_MSGNW );
63 $msgnw = $mwObj->getSynonym( 0 );
66 print "Processing...";
68 foreach ( $sortedArray as $key => $enMsg ) {
69 $message = wfMsgNoDB( $key );
70 $titleObj = Title::newFromText( $key );
71 $title = $titleObj->getDBkey();
72 $dbencMsg = wfStrencode( $message );
76 $sql = "DELETE FROM cur WHERE cur_namespace=$ns AND cur_title='$title'";
77 wfQuery( $sql, DB_WRITE, $fname );
79 if (array_key_exists($title, $exists)) {
100 $mw = str_replace( "$1", $key, $msgnw );
102 $message = wfEscapeWikiText( $message );
105 [$wgServer$wgScript?title=MediaWiki:$title&action=edit $key]
114 wfQuery( $sql, DB_WRITE, $fname );
117 $navText .= "</table>";
119 $title = wfMsgNoDB( "allmessages" );
120 $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title );
121 $wgArticle = new Article( $titleObj );
123 $wgUser = User::newFromName( 'MediaWiki default' );
124 print "Writing to " . $titleObj->getPrefixedDBkey() . "\n";
125 if ( $titleObj->getArticleID() ) {
126 $wgArticle->updateArticle( $navText, '', 0, 0 );
128 $wgArticle->insertNewArticle( $navText, '', 0, 0 );