/** * Do we know that this title definitely exists, or should we otherwise * consider that it exists? * * @return bool */ public function isAlwaysKnown() { // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes // the full l10n of that language to be loaded. That takes much memory and // isn't needed. So we strip the language part away. // Also, extension messages which are not loaded, are shown as red, because // we don't call MessageCache::loadAllMessages. list($basename, ) = explode('/', $this->mDbkeyform, 2); return $this->isExternal() || $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' || $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey($basename); }
/** * Info about this page * Called for ?action=info when $wgAllowPageInfo is on. */ public function info() { global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser; if (!$wgAllowPageInfo) { $wgOut->showErrorPage('nosuchaction', 'nosuchactiontext'); return; } $page = $this->mTitle->getSubjectPage(); $wgOut->setPagetitle($page->getPrefixedText()); $wgOut->setPageTitleActionText(wfMsg('info_short')); $wgOut->setSubtitle(wfMsgHtml('infosubtitle')); if (!$this->mTitle->exists()) { $wgOut->addHTML('<div class="noarticletext">'); if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { // This doesn't quite make sense; the user is asking for // information about the _page_, not the message... -- RC $wgOut->addHTML(htmlspecialchars(wfMsgWeirdKey($this->mTitle->getText()))); } else { $msg = $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon'; $wgOut->addHTML(wfMsgExt($msg, 'parse')); } $wgOut->addHTML('</div>'); } else { $dbr = wfGetDB(DB_SLAVE); $wl_clause = array('wl_title' => $page->getDBkey(), 'wl_namespace' => $page->getNamespace()); $numwatchers = $dbr->selectField('watchlist', 'COUNT(*)', $wl_clause, __METHOD__, $this->getSelectOptions()); $pageInfo = $this->pageCountInfo($page); $talkInfo = $this->pageCountInfo($page->getTalkPage()); //FIXME: unescaped messages $wgOut->addHTML("<ul><li>" . wfMsg("numwatchers", $wgLang->formatNum($numwatchers)) . '</li>'); $wgOut->addHTML("<li>" . wfMsg('numedits', $wgLang->formatNum($pageInfo['edits'])) . '</li>'); if ($talkInfo) { $wgOut->addHTML('<li>' . wfMsg("numtalkedits", $wgLang->formatNum($talkInfo['edits'])) . '</li>'); } $wgOut->addHTML('<li>' . wfMsg("numauthors", $wgLang->formatNum($pageInfo['authors'])) . '</li>'); if ($talkInfo) { $wgOut->addHTML('<li>' . wfMsg('numtalkauthors', $wgLang->formatNum($talkInfo['authors'])) . '</li>'); } $wgOut->addHTML('</ul>'); } }
/** * Info about this page * Called for ?action=info when $wgAllowPageInfo is on. * * @public */ function info() { global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser; if (!$wgAllowPageInfo) { $wgOut->showErrorPage('nosuchaction', 'nosuchactiontext'); return; } $page = $this->mTitle->getSubjectPage(); $wgOut->setPagetitle($page->getPrefixedText()); $wgOut->setSubtitle(wfMsg('infosubtitle')); # first, see if the page exists at all. $exists = $page->getArticleId() != 0; if (!$exists) { if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { $wgOut->addHTML(wfMsgWeirdKey($this->mTitle->getText())); } else { $wgOut->addHTML(wfMsg($wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon')); } } else { $dbr =& wfGetDB(DB_SLAVE); $wl_clause = array('wl_title' => $page->getDBkey(), 'wl_namespace' => $page->getNamespace()); $numwatchers = $dbr->selectField('watchlist', 'COUNT(*)', $wl_clause, __METHOD__, $this->getSelectOptions()); $pageInfo = $this->pageCountInfo($page); $talkInfo = $this->pageCountInfo($page->getTalkPage()); $wgOut->addHTML("<ul><li>" . wfMsg("numwatchers", $wgLang->formatNum($numwatchers)) . '</li>'); $wgOut->addHTML("<li>" . wfMsg('numedits', $wgLang->formatNum($pageInfo['edits'])) . '</li>'); if ($talkInfo) { $wgOut->addHTML('<li>' . wfMsg("numtalkedits", $wgLang->formatNum($talkInfo['edits'])) . '</li>'); } $wgOut->addHTML('<li>' . wfMsg("numauthors", $wgLang->formatNum($pageInfo['authors'])) . '</li>'); if ($talkInfo) { $wgOut->addHTML('<li>' . wfMsg('numtalkauthors', $wgLang->formatNum($talkInfo['authors'])) . '</li>'); } $wgOut->addHTML('</ul>'); } }
/** * Initialise form fields in the object * Called on the first invocation, e.g. when a user clicks an edit link */ function initialiseForm() { $this->edittime = $this->mArticle->getTimestamp(); $this->textbox1 = $this->getContent(); $this->summary = ''; if (!$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI) { $this->textbox1 = wfMsgWeirdKey($this->mArticle->mTitle->getText()); } wfProxyCheck(); }
/** * Does this page have source text? * * @return Boolean */ public function hasSourceText() { if ($this->exists()) { return true; } if ($this->mNamespace == NS_MEDIAWIKI) { // If the page doesn't exist but is a known system message, default // message content will be displayed, same for language subpages // Also, if the page is form Mediawiki:message/lang, calling wfMsgWeirdKey // causes the full l10n of that language to be loaded. That takes much // memory and isn't needed. So we strip the language part away. list($basename, ) = explode('/', $this->mDbkeyform, 2); return (bool) wfMsgWeirdKey($basename); } return false; }
public function execute() { global $IP, $wgDefaultExternalStore, $wgNoDBParam; $wgNoDBParam = true; $lang = $this->getArg(0); $site = $this->getArg(1); $dbName = $this->getArg(2); $domain = $this->getArg(3); $languageNames = Language::getLanguageNames(); if (!isset($languageNames[$lang])) { $this->error("Language {$lang} not found in \$wgLanguageNames", true); } $name = $languageNames[$lang]; $dbw = wfGetDB(DB_MASTER); $common = "/home/wikipedia/common"; $this->output("Creating database {$dbName} for {$lang}.{$site} ({$name})\n"); # Set up the database $dbw->query("SET table_type=Innodb"); $dbw->query("CREATE DATABASE {$dbName}"); $dbw->selectDB($dbName); $this->output("Initialising tables\n"); $dbw->sourceFile($this->getDir() . '/tables.sql'); $dbw->sourceFile("{$IP}/extensions/OAI/update_table.sql"); $dbw->sourceFile("{$IP}/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql"); $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_changes.sql"); $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_log.sql"); $dbw->sourceFile("{$IP}/extensions/TitleKey/titlekey.sql"); $dbw->sourceFile("{$IP}/extensions/Oversight/hidden.sql"); $dbw->sourceFile("{$IP}/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql"); $dbw->sourceFile("{$IP}/extensions/AbuseFilter/abusefilter.tables.sql"); $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/PrefStats/PrefStats.sql"); $dbw->sourceFile("{$IP}/extensions/ProofreadPage/ProofreadPage.sql"); $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql"); $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql"); $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql"); $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/OptIn/OptIn.sql"); $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)"); # Initialise external storage if (is_array($wgDefaultExternalStore)) { $stores = $wgDefaultExternalStore; } elseif ($wgDefaultExternalStore) { $stores = array($wgDefaultExternalStore); } else { $stores = array(); } if (count($stores)) { global $wgDBuser, $wgDBpassword, $wgExternalServers; foreach ($stores as $storeURL) { $m = array(); if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) { continue; } $cluster = $m[1]; $this->output("Initialising external storage {$cluster}...\n"); # Hack $wgExternalServers[$cluster][0]['user'] = $wgDBuser; $wgExternalServers[$cluster][0]['password'] = $wgDBpassword; $store = new ExternalStoreDB(); $extdb = $store->getMaster($cluster); $extdb->query("SET table_type=InnoDB"); $extdb->query("CREATE DATABASE {$dbName}"); $extdb->selectDB($dbName); # Hack x2 $blobsTable = $store->getTable($extdb); $sedCmd = "sed s/blobs\\\\\\>/{$blobsTable}/ " . $this->getDir() . "/storage/blobs.sql"; $blobsFile = popen($sedCmd, 'r'); $extdb->sourceStream($blobsFile); pclose($blobsFile); $extdb->commit(); } } global $wgTitle, $wgArticle; $wgTitle = Title::newFromText(wfMsgWeirdKey("mainpage/{$lang}")); $this->output("Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n"); $wgArticle = new Article($wgTitle); $ucsite = ucfirst($site); $wgArticle->insertNewArticle($this->getFirstArticle($ucsite, $name), '', false, false); $this->output("Adding to dblists\n"); # Add to dblist $file = fopen("{$common}/all.dblist", "a"); fwrite($file, "{$dbName}\n"); fclose($file); # Update the sublists shell_exec("cd {$common} && ./refresh-dblist"); # print "Constructing interwiki SQL\n"; # Rebuild interwiki tables # passthru( '/home/wikipedia/conf/interwiki/update' ); $time = wfTimestamp(TS_RFC2822); // These arguments need to be escaped twice: once for echo and once for at $escDbName = wfEscapeShellArg(wfEscapeShellArg($dbName)); $escTime = wfEscapeShellArg(wfEscapeShellArg($time)); $escUcsite = wfEscapeShellArg(wfEscapeShellArg($ucsite)); $escName = wfEscapeShellArg(wfEscapeShellArg($name)); $escLang = wfEscapeShellArg(wfEscapeShellArg($lang)); $escDomain = wfEscapeShellArg(wfEscapeShellArg($domain)); shell_exec("echo notifyNewProjects {$escDbName} {$escTime} {$escUcsite} {$escName} {$escLang} {$escDomain} | at now + 15 minutes"); $this->output("Script ended. You still have to:\n\t* Add any required settings in InitialiseSettings.php\n\t* Run sync-common-all\n\t* Run /home/wikipedia/conf/interwiki/update\n\t"); }
function readOnlyPage($source = null, $protected = false) { global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle; $this->setRobotpolicy('noindex,nofollow'); $this->setArticleRelated(false); if ($protected) { $skin = $wgUser->getSkin(); $this->setPageTitle(wfMsg('viewsource')); $this->setSubtitle(wfMsg('viewsourcefor', $skin->makeKnownLinkObj($wgTitle))); # Determine if protection is due to the page being a system message # and show an appropriate explanation if ($wgTitle->getNamespace() == NS_MEDIAWIKI && !$wgUser->isAllowed('editinterface')) { $this->addWikiText(wfMsg('protectedinterface')); } else { $this->addWikiText(wfMsg('protectedtext')); } } else { $this->setPageTitle(wfMsg('readonly')); if ($wgReadOnly) { $reason = $wgReadOnly; } else { $reason = file_get_contents($wgReadOnlyFile); } $this->addWikiText(wfMsg('readonlytext', $reason)); } if (is_string($source)) { if (strcmp($source, '') == 0) { global $wgTitle; if ($wgTitle->getNamespace() == NS_MEDIAWIKI) { $source = wfMsgWeirdKey($wgTitle->getText()); } else { $source = ''; } } $rows = $wgUser->getIntOption('rows'); $cols = $wgUser->getIntOption('cols'); $text = "\n<textarea name='wpTextbox1' id='wpTextbox1' cols='{$cols}' rows='{$rows}' readonly='readonly'>" . htmlspecialchars($source) . "\n</textarea>"; $this->addHTML($text); } $this->returnToMain(false); }
/** * Should links to this title be shown as potentially viewable (i.e. as * "bluelinks"), even if there's no record by this title in the page * table? * * This function is semi-deprecated for public use, as well as somewhat * misleadingly named. You probably just want to call isKnown(), which * calls this function internally. * * (ISSUE: Most of these checks are cheap, but the file existence check * can potentially be quite expensive. Including it here fixes a lot of * existing code, but we might want to add an optional parameter to skip * it and any other expensive checks.) * * @return \type{\bool} TRUE or FALSE */ public function isAlwaysKnown() { if ($this->mInterwiki != '') { return true; // any interwiki link might be viewable, for all we know } switch ($this->mNamespace) { case NS_MEDIA: case NS_FILE: return wfFindFile($this); // file exists, possibly in a foreign repo // file exists, possibly in a foreign repo case NS_SPECIAL: return SpecialPage::exists($this->getDBKey()); // valid special page // valid special page case NS_MAIN: return $this->mDbkeyform == ''; // selflink, possibly with fragment // selflink, possibly with fragment case NS_MEDIAWIKI: // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes // the full l10n of that language to be loaded. That takes much memory and // isn't needed. So we strip the language part away. // Also, extension messages which are not loaded, are shown as red, because // we don't call MessageCache::loadAllMessages. list($basename, ) = explode('/', $this->mDbkeyform, 2); return wfMsgWeirdKey($basename); // known system message // known system message default: return false; } }
function addWiki($lang, $site, $dbName) { global $IP, $wgLanguageNames, $wgDefaultExternalStore; if (!isset($wgLanguageNames[$lang])) { print "Language {$lang} not found in \$wgLanguageNames\n"; return; } $name = $wgLanguageNames[$lang]; $dbw = wfGetDB(DB_MASTER); $common = "/home/wikipedia/common"; $maintenance = "{$IP}/maintenance"; print "Creating database {$dbName} for {$lang}.{$site} ({$name})\n"; # Set up the database $dbw->query("SET table_type=Innodb"); $dbw->query("CREATE DATABASE {$dbName}"); $dbw->selectDB($dbName); print "Initialising tables\n"; dbsource("{$maintenance}/tables.sql", $dbw); dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw); dbsource("{$IP}/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw); dbsource("{$IP}/extensions/CheckUser/cu_changes.sql", $dbw); dbsource("{$IP}/extensions/CheckUser/cu_log.sql", $dbw); dbsource("{$IP}/extensions/TitleKey/titlekey.sql", $dbw); dbsource("{$IP}/extensions/Oversight/hidden.sql", $dbw); dbsource("{$IP}/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql", $dbw); $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)"); # Initialise external storage if (is_array($wgDefaultExternalStore)) { $stores = $wgDefaultExternalStore; } elseif ($stores) { $stores = array($wgDefaultExternalStore); } else { $stores = array(); } if (count($stores)) { require_once 'ExternalStoreDB.php'; print "Initialising external storage {$store}...\n"; global $wgDBuser, $wgDBpassword, $wgExternalServers; foreach ($stores as $storeURL) { $m = array(); if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) { continue; } $cluster = $m[1]; # Hack $wgExternalServers[$cluster][0]['user'] = $wgDBuser; $wgExternalServers[$cluster][0]['password'] = $wgDBpassword; $store = new ExternalStoreDB(); $extdb =& $store->getMaster($cluster); $extdb->query("SET table_type=InnoDB"); $extdb->query("CREATE DATABASE {$dbName}"); $extdb->selectDB($dbName); dbsource("{$maintenance}/storage/blobs.sql", $extdb); $extdb->immediateCommit(); } } global $wgTitle, $wgArticle; $wgTitle = Title::newFromText(wfMsgWeirdKey("mainpage/{$lang}")); print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n"; $wgArticle = new Article($wgTitle); $ucsite = ucfirst($site); $wgArticle->insertNewArticle(<<<EOT ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|{$ucsite}]] in '''[[w:en:{$name}|{$name}]]''' language== * Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here. * If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]]. * For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]]. == Sister projects == <span class="plainlinks"> [http://www.wikipedia.org Wikipedia] | [http://www.wiktionary.org Wiktonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource] [http://www.wikiversity.org Wikiversity] </span> See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects. [[aa:]] [[af:]] [[als:]] [[ar:]] [[de:]] [[en:]] [[as:]] [[ast:]] [[ay:]] [[az:]] [[bcl:]] [[be:]] [[bg:]] [[bn:]] [[bo:]] [[bs:]] [[cs:]] [[co:]] [[cs:]] [[cy:]] [[da:]] [[el:]] [[eo:]] [[es:]] [[et:]] [[eu:]] [[fa:]] [[fi:]] [[fr:]] [[fy:]] [[ga:]] [[gl:]] [[gn:]] [[gu:]] [[he:]] [[hi:]] [[hr:]] [[hsb:]] [[hy:]] [[ia:]] [[id:]] [[is:]] [[it:]] [[ja:]] [[ka:]] [[kk:]] [[km:]] [[kn:]] [[ko:]] [[ks:]] [[ku:]] [[ky:]] [[la:]] [[ln:]] [[lo:]] [[lt:]] [[lv:]] [[hu:]] [[mi:]] [[mk:]] [[ml:]] [[mn:]] [[mr:]] [[ms:]] [[mt:]] [[my:]] [[na:]] [[nah:]] [[nds:]] [[ne:]] [[nl:]] [[no:]] [[oc:]] [[om:]] [[pa:]] [[pl:]] [[ps:]] [[pt:]] [[qu:]] [[ro:]] [[ru:]] [[sa:]] [[si:]] [[sk:]] [[sl:]] [[sq:]] [[sr:]] [[sv:]] [[sw:]] [[ta:]] [[te:]] [[tg:]] [[th:]] [[tk:]] [[tl:]] [[tr:]] [[tt:]] [[ug:]] [[uk:]] [[ur:]] [[uz:]] [[vi:]] [[vo:]] [[xh:]] [[yo:]] [[za:]] [[zh:]] [[zu:]] EOT , '', false, false); print "Adding to dblists\n"; # Add to dblist $file = fopen("{$common}/all.dblist", "a"); fwrite($file, "{$dbName}\n"); fclose($file); # Update the sublists shell_exec("cd {$common} && ./refresh-dblist"); #print "Constructing interwiki SQL\n"; # Rebuild interwiki tables #passthru( '/home/wikipedia/conf/interwiki/update' ); print "Script ended. You still have to:\n* Add any required settings in InitialiseSettings.php\n* Run sync-common-all\n* Run /home/wikipedia/conf/interwiki/update\n"; }