function execute($par) { global $wgRequest, $wgOut, $wgUser, $wgLanguageCode, $wgLocalisationCacheConf, $wgExtraNamespaces, $wgLocalDatabases, $wgInterwikiIntegrationPrefix, $wgMetaNamespace, $wgMetaNamespaceTalk, $wgSitename, $wgInterwikiIntegrationPWD; if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); return; } $dbr = wfGetDB(DB_SLAVE); $dbw = wfGetDB(DB_MASTER); $localDBname = $dbr->getProperty('mDBname'); $dbw->delete('integration_prefix', '*'); if (isset($wgInterwikiIntegrationPrefix)) { foreach ($wgInterwikiIntegrationPrefix as $thisPrefix => $thisDatabase) { $thisPWD = 0; if (isset($wgInterwikiIntegrationPWD[$thisDatabase]) && $wgInterwikiIntegrationPWD[$thisDatabase] == true) { $thisPWD = '1'; } $newDatabaseRow = array('integration_dbname' => $thisDatabase, 'integration_prefix' => $thisPrefix, 'integration_pwd' => $thisPWD); $dbw->insert('integration_prefix', $newDatabaseRow); foreach ($wgLocalDatabases as $thisDB) { $foreignDbr = wfGetDB(DB_SLAVE, array(), $thisDB); $foreignDbw = wfGetDB(DB_MASTER, array(), $thisDB); if ($thisDB != $localDBname && $thisDatabase == $localDBname) { $foreignResult = $foreignDbr->selectRow('interwiki', 'iw_prefix', array("iw_prefix" => $thisPrefix)); if (!$foreignResult) { $localTitle = Title::newFromText('Foobarfoobar'); $localURL = $localTitle->getFullURL(); $localURL = str_replace('Foobarfoobar', '$1', $localURL); $newInterwikiRow = array('iw_prefix' => $thisPrefix, 'iw_url' => $localURL, 'iw_local' => '1', 'iw_trans' => '0'); $foreignDbw->insert('interwiki', $newInterwikiRow); } } } } } $myCache = new LocalisationCache($wgLocalisationCacheConf); $namespaceNames = $myCache->getItem($wgLanguageCode, 'namespaceNames'); $namespaceNames[NS_PROJECT] = $wgMetaNamespace; $namespaceNames[NS_PROJECT_TALK] = $wgMetaNamespace . "_talk"; $dbw->delete('integration_namespace', array('integration_dbname' => $localDBname)); foreach ($namespaceNames as $key => $thisName) { $newNamespaceRow = array('integration_dbname' => $localDBname, 'integration_namespace_index' => $key, 'integration_namespace_title' => $thisName); $dbw->insert('integration_namespace', $newNamespaceRow); } foreach ($wgExtraNamespaces as $key => $thisName) { $newNamespaceRow = array('integration_dbname' => $localDBname, 'integration_namespace_index' => $key, 'integration_namespace_title' => $thisName); $dbw->insert('integration_namespace', $newNamespaceRow); } $newNamespaceRow = array('integration_dbname' => $localDBname, 'integration_namespace_index' => NS_SPECIAL, 'integration_namespace_title' => 'DisregardSpecial'); $dbw->insert('integration_namespace', $newNamespaceRow); $newNamespaceRow = array('integration_dbname' => $localDBname, 'integration_namespace_index' => NS_MEDIA, 'integration_namespace_title' => 'DisregardForPWD'); $dbw->insert('integration_namespace', $newNamespaceRow); $newNamespaceRow = array('integration_dbname' => $localDBname, 'integration_namespace_index' => NS_FILE, 'integration_namespace_title' => 'DisregardForPWD'); $dbw->insert('integration_namespace', $newNamespaceRow); $wgOut->setPagetitle(wfMsg('actioncomplete')); $wgOut->addWikiMsg('integration-setuptext', $wgSitename); return; }
public function testRecacheFallbacksWithHooks() { global $wgHooks; // Use hook to provide updates for messages. This is what the // LocalisationUpdate extension does. See bug 68781. $wgHooks['LocalisationCacheRecacheFallback'][] = function (LocalisationCache $lc, $code, array &$cache) { if ($code === 'ru') { $cache['messages']['present-uk'] = 'ru-override'; $cache['messages']['present-ru'] = 'ru-override'; $cache['messages']['present-en'] = 'ru-override'; } }; $lc = new LocalisationCache(array('store' => 'detect')); $lc->recache('uk'); $this->assertEquals(array('present-uk' => 'uk', 'present-ru' => 'ru-override', 'present-en' => 'ru-override'), $lc->getItem('uk', 'messages'), 'Updates provided by hooks follow the normal fallback order.'); }
/** * Get the plural rule types for the language * @since 1.22 * @return array Associative array with plural form number and plural rule type as key-value pairs */ public function getPluralRuleTypes() { $pluralRuleTypes = self::$dataCache->getItem(strtolower($this->mCode), 'pluralRuleTypes'); $fallbacks = Language::getFallbacksFor($this->mCode); if (!$pluralRuleTypes) { foreach ($fallbacks as $fallbackCode) { $pluralRuleTypes = self::$dataCache->getItem(strtolower($fallbackCode), 'pluralRuleTypes'); if ($pluralRuleTypes) { break; } } } return $pluralRuleTypes; }
/** * @param $code */ public function unload($code) { unset($this->mruLangs[$code]); parent::unload($code); }
/** * A regular expression to match legal word-trailing characters * which should be merged onto a link of the form [[foo]]bar. * * @return string */ function linkTrail() { return self::$dataCache->getItem($this->mCode, 'linkTrail'); }
/** * Helper function to rebuild list of languages codes. Prints the code * for each language which is rebuilt. * @param array $codes List of language codes to rebuild. * @param LocalisationCache $lc Instance of LocalisationCacheBulkLoad (?) * @param bool $force Rebuild up-to-date languages * @return int Number of rebuilt languages */ private function doRebuild($codes, $lc, $force) { $numRebuilt = 0; foreach ($codes as $code) { if ($force || $lc->isExpired($code)) { $this->output("Rebuilding {$code}...\n"); $lc->recache($code); $numRebuilt++; } } return $numRebuilt; }