From: Alexander Ebert Date: Sat, 14 Jul 2012 16:37:25 +0000 (+0200) Subject: Added 'countrycode' attribute for languages X-Git-Tag: 2.0.0_Beta_1~993 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6675b34054b3f2b89f7e1f37c399d78b85776ac5;p=GitHub%2FWoltLab%2FWCF.git Added 'countrycode' attribute for languages --- diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index a87b94a1cb..f109015773 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -418,6 +418,24 @@ class LanguageEditor extends DatabaseObjectEditor { throw new SystemException("missing attribute 'languagename' in language file"); } + /** + * Takes an XML object and returns the specific country code. + * + * @param wcf\util\XML $xml + * @return string country code + */ + public static function readCountryCodeFromXML(XML $xml) { + $rootNode = $xml->xpath()->query('/ns:language')->item(0); + $attributes = $xml->xpath()->query('attribute::*', $rootNode); + foreach ($attributes as $attribute) { + if ($attribute->name == 'countrycode') { + return $attribute->value; + } + } + + throw new SystemException("missing attribute 'countrycode' in language file"); + } + /** * Imports language items from an XML file into a new or a current language. * Updates the relevant language files automatically. @@ -434,8 +452,10 @@ class LanguageEditor extends DatabaseObjectEditor { // create new language if ($language === null) { + $countryCode = self::readCountryCodeFromXML($xml); $languageName = self::readLanguageNameFromXML($xml); $language = self::create(array( + 'countryCode' => $countryCode, 'languageCode' => $languageCode, 'languageName' => $languageName )); diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php index 22044f981d..92412c4ff1 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -22,6 +22,7 @@ class LanguageCacheBuilder implements ICacheBuilder { public function getData(array $cacheResource) { $data = array( 'codes' => array(), + 'countryCodes' => array(), 'languages' => array(), 'packages' => array(), 'default' => 0, @@ -58,6 +59,9 @@ class LanguageCacheBuilder implements ICacheBuilder { // language code to language id $data['codes'][$language->languageCode] = $language->languageID; + + // country code to language id + $data['countryCode'][$language->languageID] = $language->countryCode; } // get language categories diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 714518ba73..4a4acdfa47 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1,5 +1,5 @@ - + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 22d31dd27e..fba2be3d1e 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1,5 +1,5 @@ - + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 82b04cfec9..689b6ffa0e 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -197,6 +197,7 @@ CREATE TABLE wcf1_language ( languageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, languageCode VARCHAR(20) NOT NULL DEFAULT '', languageName VARCHAR(255) NOT NULL DEFAULT '', + countryCode VARCHAR(10) NOT NULL DEFAULT '', isDefault TINYINT(1) NOT NULL DEFAULT 0, hasContent TINYINT(1) NOT NULL DEFAULT 0, UNIQUE KEY languageCode (languageCode)