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 $mwMsg =& MagicWord::get( MAG_MSG );
16 $navText = str_replace( "$1", "allmessagestext", $mwMsg->getSynonym( 0 ) );
19 <table border=1 width=100%><tr><td>
27 print "Initialising \"MediaWiki\" namespace...\n";
28 $sql = "SELECT cur_title FROM cur WHERE cur_namespace=$ns AND cur_title IN(";
31 $sortedArray = $wgAllMessagesEn;
32 ksort( $sortedArray );
34 foreach ( $sortedArray as $key => $enMsg ) {
41 $message = wfMsgNoDB( $key );
42 $titleObj = Title::newFromText( $key );
43 $enctitle = wfStrencode($titleObj->getDBkey());
44 $sql .= "'$enctitle'";
47 $res = wfQuery( $sql, DB_READ );
48 $row = wfFetchObject( $res );
52 $exists[$row->cur_title] = 1;
53 $row = wfFetchObject( $res );
55 $sql = "INSERT INTO cur (cur_namespace, cur_title, cur_text,
56 cur_user_text, cur_timestamp, cur_restrictions,
57 cur_is_new, inverse_timestamp, cur_touched) VALUES ";
59 $mwObj =& MagicWord::get( MAG_MSGNW );
60 $msgnw = $mwObj->getSynonym( 0 );
61 $talk = $wgLang->getNsText( NS_TALK );
62 $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK );
64 foreach ( $sortedArray as $key => $enMsg ) {
65 $message = wfMsgNoDB( $key );
66 $titleObj = Title::newFromText( $key );
67 $title = $titleObj->getDBkey();
68 $dbencMsg = wfStrencode( $message );
72 wfQuery( "DELETE FROM cur WHERE cur_namespace=$ns AND cur_title='$title'", DB_WRITE, $fname );
74 if (array_key_exists($title, $exists)) {
95 $mw = str_replace( "$1", $key, $msgnw );
97 $message = wfEscapeWikiText( $message );
100 [$wgServer$wgScript?title=MediaWiki:$title&action=edit $key]<br>
101 [[$mwtalk:$title|$talk]]
110 wfQuery( $sql, DB_WRITE, $fname );
114 $navText .= "</table>";
116 $title = wfMsgNoDB( "allmessages" );
117 $titleObj = Title::makeTitle( NS_MEDIAWIKI, $title );
118 $wgArticle = new Article( $titleObj );
120 $wgUser = User::newFromName( 'MediaWiki default' );
121 if ( $titleObj->getArticleID() ) {
122 $wgArticle->updateArticle( $navText, '', 0, 0 );
124 $wgArticle->insertNewArticle( $navText, '', 0, 0 );