Ejemplo n.º 1
0
 /**
  * Get language names, indexed by code.
  * If $customisedOnly is true, only returns codes with a messages file
  *
  * @param $customisedOnly bool
  *
  * @return array
  */
 public static function getLanguageNames($customisedOnly = false)
 {
     global $wgExtraLanguageNames;
     static $coreLanguageNames;
     if ($coreLanguageNames === null) {
         include MWInit::compiledPath('languages/Names.php');
     }
     $allNames = $wgExtraLanguageNames + $coreLanguageNames;
     if (!$customisedOnly) {
         return $allNames;
     }
     global $IP;
     $names = array();
     $dir = opendir("{$IP}/languages/messages");
     while (false !== ($file = readdir($dir))) {
         $code = self::getCodeFromFileName($file, 'Messages');
         if ($code && isset($allNames[$code])) {
             $names[$code] = $allNames[$code];
         }
     }
     closedir($dir);
     return $names;
 }
Ejemplo n.º 2
0
 /**
  * Get an array of language names, indexed by code.
  * @param $inLanguage null|string: Code of language in which to return the names
  *		Use null for autonyms (native names)
  * @param $include string:
  *		'all' all available languages
  *		'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames (default)
  *		'mwfile' only if the language is in 'mw' *and* has a message file
  * @return array: language code => language name
  * @since 1.20
  */
 public static function fetchLanguageNames($inLanguage = null, $include = 'mw')
 {
     global $wgExtraLanguageNames;
     static $coreLanguageNames;
     if ($coreLanguageNames === null) {
         include MWInit::compiledPath('languages/Names.php');
     }
     $names = array();
     if ($inLanguage) {
         # TODO: also include when $inLanguage is null, when this code is more efficient
         wfRunHooks('LanguageGetTranslatedLanguageNames', array(&$names, $inLanguage));
     }
     $mwNames = $wgExtraLanguageNames + $coreLanguageNames;
     foreach ($mwNames as $mwCode => $mwName) {
         # - Prefer own MediaWiki native name when not using the hook
         # - For other names just add if not added through the hook
         if ($mwCode === $inLanguage || !isset($names[$mwCode])) {
             $names[$mwCode] = $mwName;
         }
     }
     if ($include === 'all') {
         return $names;
     }
     $returnMw = array();
     $coreCodes = array_keys($mwNames);
     foreach ($coreCodes as $coreCode) {
         $returnMw[$coreCode] = $names[$coreCode];
     }
     if ($include === 'mwfile') {
         $namesMwFile = array();
         # We do this using a foreach over the codes instead of a directory
         # loop so that messages files in extensions will work correctly.
         foreach ($returnMw as $code => $value) {
             if (is_readable(self::getMessagesFileName($code))) {
                 $namesMwFile[$code] = $names[$code];
             }
         }
         return $namesMwFile;
     }
     # 'mw' option; default if it's not one of the other two options (all/mwfile)
     return $returnMw;
 }
Ejemplo n.º 3
0
 /**
  * Get native language names, indexed by code.
  * Only those defined in MediaWiki, no other data like CLDR.
  * If $customisedOnly is true, only returns codes with a messages file
  *
  * @param $customisedOnly bool
  *
  * @return array
  */
 public static function getLanguageNames($customisedOnly = false)
 {
     global $wgExtraLanguageNames;
     static $coreLanguageNames;
     if ($coreLanguageNames === null) {
         include MWInit::compiledPath('languages/Names.php');
     }
     $allNames = $wgExtraLanguageNames + $coreLanguageNames;
     if (!$customisedOnly) {
         return $allNames;
     }
     $names = array();
     // We do this using a foreach over the codes instead of a directory
     // loop so that messages files in extensions will work correctly.
     foreach ($allNames as $code => $value) {
         if (is_readable(self::getMessagesFileName($code))) {
             $names[$code] = $allNames[$code];
         }
     }
     return $names;
 }
Ejemplo n.º 4
0
    MWFunction::call(MW_CONFIG_CALLBACK);
} elseif (file_exists("{$IP}/../wmf-config/wikimedia-mode")) {
    // Load settings, using wikimedia-mode if needed
    // @todo FIXME: Replace this hack with general farm-friendly code
    # @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
    # Maybe a hook?
    global $cluster;
    $cluster = 'pmtpa';
    require MWInit::interpretedPath('../wmf-config/wgConf.php');
    $maintenance->loadWikimediaSettings();
    require MWInit::interpretedPath('../wmf-config/CommonSettings.php');
} else {
    require_once $maintenance->loadSettings();
}
if ($maintenance->getDbType() === Maintenance::DB_ADMIN && is_readable("{$IP}/AdminSettings.php")) {
    require MWInit::interpretedPath('AdminSettings.php');
}
$maintenance->finalSetup();
// Some last includes
require_once MWInit::compiledPath('includes/Setup.php');
// Much much faster startup than creating a title object
$wgTitle = null;
// Do the work
try {
    $maintenance->execute();
    // Potentially debug globals
    $maintenance->globals();
} catch (MWException $mwe) {
    echo $mwe->getText();
    exit(1);
}
Ejemplo n.º 5
0
# Check that there is no previous output or previously set up buffers, because
# that would cause us to potentially mix gzip and non-gzip output, creating a
# big mess.
if (!defined('MW_NO_OUTPUT_BUFFER') && ob_get_level() == 0) {
    if (!defined('MW_COMPILED')) {
        require_once "{$IP}/includes/OutputHandler.php";
    }
    ob_start('wfOutputHandler');
}
// Wikia change - begin - @author: wladek
// Catch all output
echo $initialOutput;
// Wikia change - end
wfProfileOut('WebStart.php-ob_start');
if (!defined('MW_NO_SETUP')) {
    require_once MWInit::compiledPath("includes/Setup.php");
}
if (is_object($wgRequest) && $wgRequest->wasPosted() && wfReadOnly()) {
    if (strpos(strtolower($_SERVER['SCRIPT_URL']), 'datacenter') === false && strpos(strtolower($_SERVER['SCRIPT_URL']), 'api.php') === false) {
        $js = <<<EOD
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-288915-41");
pageTracker._trackEvent("error", "PostInReadOnly");
} catch(err) {}</script>
EOD;
        echo "<html><head>{$js}</head><body>{$wgReadOnly}</body></html>";