jenkins-bot has submitted this change and it was merged.
Change subject: Change all linebreaks from Windows to Unix
......................................................................
Change all linebreaks from Windows to Unix
No other changes done at all
Change-Id: Iedda4cfab5e75925f3184b27f5042737ecc2338c
---
M api/includes/ApiCountries.php
M api/includes/CommonFunctions.php
M api/includes/DBException.php
M api/includes/Debug.php
M api/includes/Defaults.php
M api/includes/DynamicKml.php
M api/includes/Language.php
7 files changed, 377 insertions(+), 377 deletions(-)
Approvals:
Jean-Frédéric: Looks good to me, approved
jenkins-bot: Verified
diff --git a/api/includes/ApiCountries.php b/api/includes/ApiCountries.php
index 0bbae09..634c264 100644
--- a/api/includes/ApiCountries.php
+++ b/api/includes/ApiCountries.php
@@ -1,113 +1,113 @@
-<?php
-
-class ApiCountries extends ApiBase {
- public static $defaultLanguages = array(
- 'be' => 'nl',
- 'ch' => 'de',
- 'es' => 'es',
- 'fr' => 'fr',
- 'sk' => 'sk',
- 'it' => 'it',
- );
-
- public function __construct() {
- $this->setTopLevelNodeName( 'countries' );
- $this->setObjectNodeName( 'country' );
- }
-
- public function getAllowedParams() {
- return $this->getDefaultAllowedParams();
- }
-
- public function executeModule() {
- $countries = self::getInfo();
- $res = array();
- $formatter = $this->getFormatter();
- $isJson = stripos( 'json', get_class( $formatter ) ) !== false;
- foreach ( $countries as $code => $languages ) {
- $row = new stdClass;
- $row->code = $code;
- $row->languages = $isJson ? $languages : implode( ',',
$languages );
- if ( isset( self::$defaultLanguages[$code] ) ) {
- $row->default = self::$defaultLanguages[$code];
- }
- $res[] = $row;
- }
- $formatter->output( $res, 10000, null, array( 'code',
'languages', 'default' ), null );
- }
-
- public static function getDefaultLanguage( $country ) {
- if ( isset( self::$defaultLanguages[$country] ) ) {
- return self::$defaultLanguages[$country];
- } else {
- $languages = self::getInfo();
- if ( isset( $languages[$country] ) ) {
- return $languages[$country][0]; // Hope we have
defaults for all multilingual countries:P
- }
- }
- return false;
- }
-
- public static function getAllLanguages() {
- static $languages = null;
- if ( $languages !== null ) {
- return $languages;
- }
- $info = self::getInfo();
- $languages = array();
- foreach ( $info as $country ) {
- $languages = array_merge( $languages, $country );
- }
- $languages = array_unique( $languages );
- return $languages;
- }
-
- public static function getInfo() {
- static $cached = null;
- if ( $cached !== null ) {
- return $cached;
- }
- $cached = self::getCachedInfo();
- return $cached;
- }
-
- private static function getCachedInfo() {
- global $cacheDir;
-
- $fname = "$cacheDir/countries.ser";
- if ( file_exists( $fname ) ) {
- $data = unserialize( file_get_contents( $fname ) );
- } else {
- $data = self::getInfoFromDB();
- file_put_contents( $fname, serialize( $data ) );
- }
- return $data;
- }
-
- private static function getInfoFromDB() {
- $ret = array();
- $db = Database::getDb();
- $res = new ResultWrapper( $db, $db->query( 'SELECT country,
lang, adm0 FROM `monuments_all` GROUP BY country, lang' ) );
- foreach ( $res as $row ) {
- $country = $row->adm0;
- $lang = $row->lang;
- if ( !isset( $ret[$country] ) ) {
- $ret[$country] = array();
- }
- if ( !isset( $ret[$country][$lang] ) ) {
- $ret[$country][$lang] = count( $ret[$country] );
- }
- }
- return array_map( 'array_flip', $ret );
- }
-
- public static function pickCountryLanguage( $country, $useLang ) {
- $languages = self::getInfo();
-
- // Use default if the language is not used in this country
- if ( !isset( $languages[$country] ) || !in_array( $useLang,
$languages[$country] ) ) {
- $useLang = false;
- }
- return $useLang;
- }
-}
+<?php
+
+class ApiCountries extends ApiBase {
+ public static $defaultLanguages = array(
+ 'be' => 'nl',
+ 'ch' => 'de',
+ 'es' => 'es',
+ 'fr' => 'fr',
+ 'sk' => 'sk',
+ 'it' => 'it',
+ );
+
+ public function __construct() {
+ $this->setTopLevelNodeName( 'countries' );
+ $this->setObjectNodeName( 'country' );
+ }
+
+ public function getAllowedParams() {
+ return $this->getDefaultAllowedParams();
+ }
+
+ public function executeModule() {
+ $countries = self::getInfo();
+ $res = array();
+ $formatter = $this->getFormatter();
+ $isJson = stripos( 'json', get_class( $formatter ) ) !== false;
+ foreach ( $countries as $code => $languages ) {
+ $row = new stdClass;
+ $row->code = $code;
+ $row->languages = $isJson ? $languages : implode( ',',
$languages );
+ if ( isset( self::$defaultLanguages[$code] ) ) {
+ $row->default = self::$defaultLanguages[$code];
+ }
+ $res[] = $row;
+ }
+ $formatter->output( $res, 10000, null, array( 'code',
'languages', 'default' ), null );
+ }
+
+ public static function getDefaultLanguage( $country ) {
+ if ( isset( self::$defaultLanguages[$country] ) ) {
+ return self::$defaultLanguages[$country];
+ } else {
+ $languages = self::getInfo();
+ if ( isset( $languages[$country] ) ) {
+ return $languages[$country][0]; // Hope we have
defaults for all multilingual countries:P
+ }
+ }
+ return false;
+ }
+
+ public static function getAllLanguages() {
+ static $languages = null;
+ if ( $languages !== null ) {
+ return $languages;
+ }
+ $info = self::getInfo();
+ $languages = array();
+ foreach ( $info as $country ) {
+ $languages = array_merge( $languages, $country );
+ }
+ $languages = array_unique( $languages );
+ return $languages;
+ }
+
+ public static function getInfo() {
+ static $cached = null;
+ if ( $cached !== null ) {
+ return $cached;
+ }
+ $cached = self::getCachedInfo();
+ return $cached;
+ }
+
+ private static function getCachedInfo() {
+ global $cacheDir;
+
+ $fname = "$cacheDir/countries.ser";
+ if ( file_exists( $fname ) ) {
+ $data = unserialize( file_get_contents( $fname ) );
+ } else {
+ $data = self::getInfoFromDB();
+ file_put_contents( $fname, serialize( $data ) );
+ }
+ return $data;
+ }
+
+ private static function getInfoFromDB() {
+ $ret = array();
+ $db = Database::getDb();
+ $res = new ResultWrapper( $db, $db->query( 'SELECT country,
lang, adm0 FROM `monuments_all` GROUP BY country, lang' ) );
+ foreach ( $res as $row ) {
+ $country = $row->adm0;
+ $lang = $row->lang;
+ if ( !isset( $ret[$country] ) ) {
+ $ret[$country] = array();
+ }
+ if ( !isset( $ret[$country][$lang] ) ) {
+ $ret[$country][$lang] = count( $ret[$country] );
+ }
+ }
+ return array_map( 'array_flip', $ret );
+ }
+
+ public static function pickCountryLanguage( $country, $useLang ) {
+ $languages = self::getInfo();
+
+ // Use default if the language is not used in this country
+ if ( !isset( $languages[$country] ) || !in_array( $useLang,
$languages[$country] ) ) {
+ $useLang = false;
+ }
+ return $useLang;
+ }
+}
diff --git a/api/includes/CommonFunctions.php b/api/includes/CommonFunctions.php
index 0301106..c64f7fe 100644
--- a/api/includes/CommonFunctions.php
+++ b/api/includes/CommonFunctions.php
@@ -1,38 +1,38 @@
-<?php
-//FIXME: functions used in API should be moved to some(?) class
-
-function getImageFromCommons($filename, $size) {
- if ($filename and $size) {
- $filename = str_replace(' ', '_', $filename);
- $md5hash = md5($filename);
- //urlencode($filename);
- $url = "//upload.wikimedia.org/wikipedia/commons/thumb/" . $md5hash[0]
. "/" . $md5hash[0] . $md5hash[1] . "/" . $filename . "/" . $size . "px-" .
$filename;
- return $url;
- }
-}
-
-function processWikitext($wikilang, $text, $makelinks) {
- /* Process the wikitext.
- * If makelinks is true, make html links
- * If makelinks is false, remove wikitext to produce normal text without
links
- */
- $result = $text;
- $differentLinkRegex="/\[\[([^\|]*)\|([^\]]*)\]\]/";
- $simpleLinkRegex="/\[\[([^\]]*)\\]\]/";
- $wikiUrl = '//' . $wikilang . '.wikipedia.org/wiki/';
- $differentLinkReplace = "'<a href=\"" . $wikiUrl ."' . rawurlencode('$1')
. '\">$2</a>'";
- $simpleLinkReplace = "'<a href=\"". $wikiUrl ."' . rawurlencode('$1') .
'\">$1</a>'";
- if ( $makelinks ) {
- $result = preg_replace($differentLinkRegex . "e",
$differentLinkReplace, $result);
- $result = preg_replace($simpleLinkRegex . "e", $simpleLinkReplace,
$result);
- $result = $result;
- } else {
- $result = preg_replace($differentLinkRegex, "$2", $result);
- $result = preg_replace($simpleLinkRegex, "$1", $result);
- }
- return $result;
-}
-
-function replaceSpaces( $in_string ) {
- return str_replace(' ', '_', $in_string);
-}
+<?php
+//FIXME: functions used in API should be moved to some(?) class
+
+function getImageFromCommons($filename, $size) {
+ if ($filename and $size) {
+ $filename = str_replace(' ', '_', $filename);
+ $md5hash = md5($filename);
+ //urlencode($filename);
+ $url = "//upload.wikimedia.org/wikipedia/commons/thumb/" . $md5hash[0]
. "/" . $md5hash[0] . $md5hash[1] . "/" . $filename . "/" . $size . "px-" .
$filename;
+ return $url;
+ }
+}
+
+function processWikitext($wikilang, $text, $makelinks) {
+ /* Process the wikitext.
+ * If makelinks is true, make html links
+ * If makelinks is false, remove wikitext to produce normal text without
links
+ */
+ $result = $text;
+ $differentLinkRegex="/\[\[([^\|]*)\|([^\]]*)\]\]/";
+ $simpleLinkRegex="/\[\[([^\]]*)\\]\]/";
+ $wikiUrl = '//' . $wikilang . '.wikipedia.org/wiki/';
+ $differentLinkReplace = "'<a href=\"" . $wikiUrl ."' . rawurlencode('$1')
. '\">$2</a>'";
+ $simpleLinkReplace = "'<a href=\"". $wikiUrl ."' . rawurlencode('$1') .
'\">$1</a>'";
+ if ( $makelinks ) {
+ $result = preg_replace($differentLinkRegex . "e",
$differentLinkReplace, $result);
+ $result = preg_replace($simpleLinkRegex . "e", $simpleLinkReplace,
$result);
+ $result = $result;
+ } else {
+ $result = preg_replace($differentLinkRegex, "$2", $result);
+ $result = preg_replace($simpleLinkRegex, "$1", $result);
+ }
+ return $result;
+}
+
+function replaceSpaces( $in_string ) {
+ return str_replace(' ', '_', $in_string);
+}
diff --git a/api/includes/DBException.php b/api/includes/DBException.php
index 6fe818e..5150802 100644
--- a/api/includes/DBException.php
+++ b/api/includes/DBException.php
@@ -1,11 +1,11 @@
-<?php
-
-class DBException extends Exception {
- public function __construct( $message, $code = 0, $query = '' ) {
- $msg = "SQL error $code: $message";
- if ( $query ) {
- $msg .= "\nLast query was: $query";
- }
- parent::__construct( $msg );
- }
-}
+<?php
+
+class DBException extends Exception {
+ public function __construct( $message, $code = 0, $query = '' ) {
+ $msg = "SQL error $code: $message";
+ if ( $query ) {
+ $msg .= "\nLast query was: $query";
+ }
+ parent::__construct( $msg );
+ }
+}
diff --git a/api/includes/Debug.php b/api/includes/Debug.php
index 4f6794f..fd591e0 100644
--- a/api/includes/Debug.php
+++ b/api/includes/Debug.php
@@ -1,37 +1,37 @@
-<?php
-
-class Debug {
- private static $debugLog = false;
-
- /**
- * @param string $msg
- */
- public static function log( $msg ) {
- self::init();
- if ( self::$debugLog ) {
- self::$debugLog .= "\t$msg\n";
- }
- }
-
- public static function init() {
- if ( !defined( 'DEBUG_FILE' ) ) {
- return;
- }
- if ( !self::$debugLog ) {
- if ( isset( $_SERVER['REQUEST_URI'] ) ) {
- $time = gmdate( DATE_ISO8601 );
- self::$debugLog =
"$time\t{$_SERVER['REQUEST_URI']}";
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
- self::$debugLog .= "\t" .
$_SERVER['HTTP_USER_AGENT'];
- }
- self::$debugLog .= "\n";
- }
- }
- }
-
- public static function saveLog() {
- if ( self::$debugLog ) {
- file_put_contents( DEBUG_FILE, self::$debugLog,
FILE_APPEND );
- }
- }
-}
\ No newline at end of file
+<?php
+
+class Debug {
+ private static $debugLog = false;
+
+ /**
+ * @param string $msg
+ */
+ public static function log( $msg ) {
+ self::init();
+ if ( self::$debugLog ) {
+ self::$debugLog .= "\t$msg\n";
+ }
+ }
+
+ public static function init() {
+ if ( !defined( 'DEBUG_FILE' ) ) {
+ return;
+ }
+ if ( !self::$debugLog ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) ) {
+ $time = gmdate( DATE_ISO8601 );
+ self::$debugLog =
"$time\t{$_SERVER['REQUEST_URI']}";
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
+ self::$debugLog .= "\t" .
$_SERVER['HTTP_USER_AGENT'];
+ }
+ self::$debugLog .= "\n";
+ }
+ }
+ }
+
+ public static function saveLog() {
+ if ( self::$debugLog ) {
+ file_put_contents( DEBUG_FILE, self::$debugLog,
FILE_APPEND );
+ }
+ }
+}
diff --git a/api/includes/Defaults.php b/api/includes/Defaults.php
index 9cf1731..a266e72 100644
--- a/api/includes/Defaults.php
+++ b/api/includes/Defaults.php
@@ -1,11 +1,11 @@
-<?php
-
-$dbServer = 'tools-db';
-$dbUser = 's51138';
-$dbDatabase = 's51138__heritage_p';
-$dbPassword = '<set password in database.inc';
-$dbMiserMode = false;
-$tsI18nDir = '/data/project/intuition/src/Intuition';
-$cacheDir = '/data/project/heritage/temp';
-$cldrPath = false;
-$subdivisionsPath = false;
+<?php
+
+$dbServer = 'tools-db';
+$dbUser = 's51138';
+$dbDatabase = 's51138__heritage_p';
+$dbPassword = '<set password in database.inc';
+$dbMiserMode = false;
+$tsI18nDir = '/data/project/intuition/src/Intuition';
+$cacheDir = '/data/project/heritage/temp';
+$cldrPath = false;
+$subdivisionsPath = false;
diff --git a/api/includes/DynamicKml.php b/api/includes/DynamicKml.php
index 0480bee..ac411c3 100644
--- a/api/includes/DynamicKml.php
+++ b/api/includes/DynamicKml.php
@@ -1,46 +1,46 @@
-<?php
-
-/**
- * KML network link generation
- */
-
-
-class DynamicKml {
-
- function output($request_url) {
- header( "Content-Type: application/vnd.google-earth.kml+xml" );
- $replCount = 1;
- $kml_url = htmlspecialchars( str_replace('format=dynamickml',
'format=kml', $request_url, $replCount) );
- $desc = 'Cultural heritage monuments database for <a
-href="http://www.wikilovesmonuments.eu">www.wikilovesmonuments.eu</a>';
- $desc = htmlspecialchars( $desc );
- $folderName = 'Wiki Loves Monuments';
- $folderName = htmlspecialchars( $folderName );
- $linkName = 'Monuments';
- $linkName = htmlspecialchars( $linkName );
- echo '<?xml version="1.0" encoding="UTF-8"?>
-<kml xmlns="http://earth.google.com/kml/2.1">
- <Folder>
- <name>'. $folderName .'</name>
- <open>1</open>
- <Snippet></Snippet>
- <description>'. $desc .'</description>
- <NetworkLink>
- <name>'. $linkName .'</name>
- <visibility>1</visibility>
- <open>0</open>
- <Link>
- <href>' . $kml_url .'</href>
- <viewRefreshMode>onStop</viewRefreshMode>
- <viewRefreshTime>1</viewRefreshTime>
- <viewFormat>bbox=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</viewFormat>
- <viewBoundScale>0.9</viewBoundScale>
- </Link>
- </NetworkLink>
- </Folder>
-</kml>
-';
- } //func
-
-
-} //class
+<?php
+
+/**
+ * KML network link generation
+ */
+
+
+class DynamicKml {
+
+ function output($request_url) {
+ header( "Content-Type: application/vnd.google-earth.kml+xml" );
+ $replCount = 1;
+ $kml_url = htmlspecialchars( str_replace('format=dynamickml',
'format=kml', $request_url, $replCount) );
+ $desc = 'Cultural heritage monuments database for <a
+href="http://www.wikilovesmonuments.eu">www.wikilovesmonuments.eu</a>';
+ $desc = htmlspecialchars( $desc );
+ $folderName = 'Wiki Loves Monuments';
+ $folderName = htmlspecialchars( $folderName );
+ $linkName = 'Monuments';
+ $linkName = htmlspecialchars( $linkName );
+ echo '<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://earth.google.com/kml/2.1">
+ <Folder>
+ <name>'. $folderName .'</name>
+ <open>1</open>
+ <Snippet></Snippet>
+ <description>'. $desc .'</description>
+ <NetworkLink>
+ <name>'. $linkName .'</name>
+ <visibility>1</visibility>
+ <open>0</open>
+ <Link>
+ <href>' . $kml_url .'</href>
+ <viewRefreshMode>onStop</viewRefreshMode>
+ <viewRefreshTime>1</viewRefreshTime>
+ <viewFormat>bbox=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</viewFormat>
+ <viewBoundScale>0.9</viewBoundScale>
+ </Link>
+ </NetworkLink>
+ </Folder>
+</kml>
+';
+ } //func
+
+
+} //class
diff --git a/api/includes/Language.php b/api/includes/Language.php
index 229e8b1..4bccd22 100644
--- a/api/includes/Language.php
+++ b/api/includes/Language.php
@@ -1,121 +1,121 @@
-<?php
-class Language {
- private $data;
- private $code;
- private static $languageCache = array();
- private $fallback;
-
- private static $subdivisionOverrides = array(
- 'Be' => 'Be-x-old',
- );
-
- private static $cldrOverrides = array(
- 'No' => 'Nb',
- 'Sr' => 'Sr_ec',
- 'Be_x_old' => 'Be',
- );
-
- private function __construct( $code, array $data ) {
- $this->code = $code;
- $this->data = $data;
-
- $fallbacks = $this->getFallbacks();
- if ( $fallbacks ) {
- $this->fallback = self::newFromCode( $fallbacks[0] );
- }
- }
-
- public static function newFromCode( $code, $countryLang = false ) {
- if ( isset( self::$languageCache[$code] ) ) {
- return self::$languageCache[$code];
- }
- if ( !preg_match( '/^[-a-z0-9]+$/i', $code ) ) {
- throw new Exception( "Invalid language code '$code'!" );
- }
- $data = self::getRawData( $code );
- if ( !$data && $countryLang ) {
- $data = self::getRawData( $countryLang );
- }
-
- self::$languageCache[$code] = new Language( $code, $data );
- return self::$languageCache[$code];
- }
-
- private static function getRawData( $code ) {
- global $cldrPath, $subdivisionsPath;
- $data = array();
- if ( $cldrPath && $subdivisionsPath ) {
- $prettyCode = ucfirst( $code );
- $subCode = isset(
self::$subdivisionOverrides[$prettyCode] )
- ? self::$subdivisionOverrides[$prettyCode]
- : $prettyCode;
- $file =
"{$subdivisionsPath}/subdivisions/Subdivisions{$subCode}.php";
- if ( is_file( $file ) ) {
- $subdivisions = array();
- require_once( $file );
- $overrides_file =
"{$subdivisionsPath}/overrides/Overrides{$subCode}.php";
- if ( is_file( $overrides_file ) ) {
- require_once( $overrides_file );
- }
- $data['subdivisions'] = $subdivisions;
- }
- $prettyCode = str_replace( '-', '_', $prettyCode );
- $cldrCode = isset( self::$cldrOverrides[$prettyCode] )
- ? self::$cldrOverrides[$prettyCode]
- : $prettyCode;
- $file =
"{$cldrPath}/CldrNames/CldrNames{$cldrCode}.php";
- if ( is_file( $file ) ) {
- $countryNames = array();
- require_once( $file );
- $data['countryNames'] = $countryNames;
- }
- }
- return $data;
- }
-
- private function getFallbacks() {
- static $fallbacks = null;
- if ( $fallbacks === null ) {
- // Run tools/scrape-fallbacks.php to update this
information
- $fallbacks = unserialize( file_get_contents( dirname(
__DIR__ ) . '/data/LanguageFallbacks.ser' ) );
- // WLM-specific overrides due to the state of CLDR
- $fallbacks['pt'] = array( 'pt-br' );
- $fallbacks['pt-br'] = array( 'en' );
- }
-
- if ( isset( $fallbacks[$this->code] ) ) {
- return $fallbacks[$this->code];
- }
- return array();
- }
-
- public function hasData() {
- return !empty( $this->data );
- }
-
- public function getCode() {
- return $this->code;
- }
-
- public function getName( $code ) {
- if ( !$this->hasData() ) {
- return false;
- }
- $code = strtoupper( $code );
- $parts = explode( '-', $code, 2 );
-
- if ( count( $parts ) == 1 ) {
- if ( isset( $this->data['countryNames'][$code] ) ) {
- return $this->data['countryNames'][$code];
- } elseif ( isset(
$this->data['subdivisions']['GB'][$code] ) ) {
- // GB is only country that has subdivisions
that may not have two-letter prefixes
- return
$this->data['subdivisions']['GB'][$code]['name'];
- }
- } else {
- if ( isset( $this->data['subdivisions'][$parts[0]] ) &&
isset( $this->data['subdivisions'][$parts[0]][$code] ) ) {
- return
$this->data['subdivisions'][$parts[0]][$code]['name'];
- }
- }
- return $this->fallback ? $this->fallback->getName( $code ) :
false;
- }
-}
\ No newline at end of file
+<?php
+class Language {
+ private $data;
+ private $code;
+ private static $languageCache = array();
+ private $fallback;
+
+ private static $subdivisionOverrides = array(
+ 'Be' => 'Be-x-old',
+ );
+
+ private static $cldrOverrides = array(
+ 'No' => 'Nb',
+ 'Sr' => 'Sr_ec',
+ 'Be_x_old' => 'Be',
+ );
+
+ private function __construct( $code, array $data ) {
+ $this->code = $code;
+ $this->data = $data;
+
+ $fallbacks = $this->getFallbacks();
+ if ( $fallbacks ) {
+ $this->fallback = self::newFromCode( $fallbacks[0] );
+ }
+ }
+
+ public static function newFromCode( $code, $countryLang = false ) {
+ if ( isset( self::$languageCache[$code] ) ) {
+ return self::$languageCache[$code];
+ }
+ if ( !preg_match( '/^[-a-z0-9]+$/i', $code ) ) {
+ throw new Exception( "Invalid language code '$code'!" );
+ }
+ $data = self::getRawData( $code );
+ if ( !$data && $countryLang ) {
+ $data = self::getRawData( $countryLang );
+ }
+
+ self::$languageCache[$code] = new Language( $code, $data );
+ return self::$languageCache[$code];
+ }
+
+ private static function getRawData( $code ) {
+ global $cldrPath, $subdivisionsPath;
+ $data = array();
+ if ( $cldrPath && $subdivisionsPath ) {
+ $prettyCode = ucfirst( $code );
+ $subCode = isset(
self::$subdivisionOverrides[$prettyCode] )
+ ? self::$subdivisionOverrides[$prettyCode]
+ : $prettyCode;
+ $file =
"{$subdivisionsPath}/subdivisions/Subdivisions{$subCode}.php";
+ if ( is_file( $file ) ) {
+ $subdivisions = array();
+ require_once( $file );
+ $overrides_file =
"{$subdivisionsPath}/overrides/Overrides{$subCode}.php";
+ if ( is_file( $overrides_file ) ) {
+ require_once( $overrides_file );
+ }
+ $data['subdivisions'] = $subdivisions;
+ }
+ $prettyCode = str_replace( '-', '_', $prettyCode );
+ $cldrCode = isset( self::$cldrOverrides[$prettyCode] )
+ ? self::$cldrOverrides[$prettyCode]
+ : $prettyCode;
+ $file =
"{$cldrPath}/CldrNames/CldrNames{$cldrCode}.php";
+ if ( is_file( $file ) ) {
+ $countryNames = array();
+ require_once( $file );
+ $data['countryNames'] = $countryNames;
+ }
+ }
+ return $data;
+ }
+
+ private function getFallbacks() {
+ static $fallbacks = null;
+ if ( $fallbacks === null ) {
+ // Run tools/scrape-fallbacks.php to update this
information
+ $fallbacks = unserialize( file_get_contents( dirname(
__DIR__ ) . '/data/LanguageFallbacks.ser' ) );
+ // WLM-specific overrides due to the state of CLDR
+ $fallbacks['pt'] = array( 'pt-br' );
+ $fallbacks['pt-br'] = array( 'en' );
+ }
+
+ if ( isset( $fallbacks[$this->code] ) ) {
+ return $fallbacks[$this->code];
+ }
+ return array();
+ }
+
+ public function hasData() {
+ return !empty( $this->data );
+ }
+
+ public function getCode() {
+ return $this->code;
+ }
+
+ public function getName( $code ) {
+ if ( !$this->hasData() ) {
+ return false;
+ }
+ $code = strtoupper( $code );
+ $parts = explode( '-', $code, 2 );
+
+ if ( count( $parts ) == 1 ) {
+ if ( isset( $this->data['countryNames'][$code] ) ) {
+ return $this->data['countryNames'][$code];
+ } elseif ( isset(
$this->data['subdivisions']['GB'][$code] ) ) {
+ // GB is only country that has subdivisions
that may not have two-letter prefixes
+ return
$this->data['subdivisions']['GB'][$code]['name'];
+ }
+ } else {
+ if ( isset( $this->data['subdivisions'][$parts[0]] ) &&
isset( $this->data['subdivisions'][$parts[0]][$code] ) ) {
+ return
$this->data['subdivisions'][$parts[0]][$code]['name'];
+ }
+ }
+ return $this->fallback ? $this->fallback->getName( $code ) :
false;
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/282115
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iedda4cfab5e75925f3184b27f5042737ecc2338c
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/heritage
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Lokal Profil <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits