Added "real" language name
authorMarcel Werk <burntime@woltlab.com>
Thu, 22 Sep 2011 14:31:24 +0000 (16:31 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 22 Sep 2011 14:31:24 +0000 (16:31 +0200)
wcfsetup/install/files/lib/acp/form/UserAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserOptionListForm.class.php
wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php
wcfsetup/install/files/lib/acp/form/UsersMassProcessingForm.class.php
wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php
wcfsetup/install/files/lib/data/language/LanguageEditor.class.php
wcfsetup/install/files/lib/system/language/LanguageFactory.class.php
wcfsetup/install/lang/de-informal.xml
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index 3ec1fa8f79591fe7f74322817290858b214c7f1f..758199587b25fd90ae7d915646de510acb0a7216 100644 (file)
@@ -304,10 +304,10 @@ class UserAddForm extends UserOptionListForm {
                        'groupIDs' => $this->groupIDs,
                        'optionTree' => $this->optionTree,
                        'availableGroups' => $this->getAvailableGroups(),
-                       'availableLanguages' => $this->getAvailableLanguages(),
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'languageID' => $this->languageID,
                        'visibleLanguages' => $this->visibleLanguages,
-                       'availableContentLanguages' => $this->getAvailableContentLanguages(),
+                       'availableContentLanguages' => LanguageFactory::getInstance()->getContentLanguages(),
                        'action' => 'add'
                ));
        }
index c6dfe357040a86af0850de8666d361c2456f9a9d..8685a4b3a94656133600755ae34fd25014979036 100644 (file)
@@ -32,40 +32,6 @@ abstract class UserOptionListForm extends AbstractOptionListForm {
                return UserGroup::getAccessibleGroups(array(), array(UserGroup::GUESTS, UserGroup::EVERYONE, UserGroup::USERS));
        }
        
-       /**
-        * Returns a list of all available languages.
-        * 
-        * @return      array
-        */
-       protected function getAvailableLanguages() {
-               $availableLanguages = array();
-               foreach (LanguageFactory::getInstance()->getAvailableLanguages(PACKAGE_ID) as $language) {
-                       $availableLanguages[$language['languageID']] = WCF::getLanguage()->get('wcf.global.language.'.$language['languageCode']);       
-               }
-               
-               // sort languages
-               StringUtil::sort($availableLanguages);
-               
-               return $availableLanguages;
-       }
-       
-       /**
-        * Returns a list of all available content languages.
-        * 
-        * @return      array
-        */
-       public static function getAvailableContentLanguages() {
-               $availableLanguages = array();
-               foreach (LanguageFactory::getInstance()->getAvailableContentLanguages(PACKAGE_ID) as $language) {
-                       $availableLanguages[$language['languageID']] = WCF::getLanguage()->get('wcf.global.language.'.$language['languageCode']);       
-               }
-               
-               // sort languages
-               StringUtil::sort($availableLanguages);
-               
-               return $availableLanguages;
-       }
-       
        /**
         * Returns the default-form language id    
         * 
index 14a421a406bca82a527caf101754401ba8445c65..f9f18b19c8bcf3c2846d0c41c280d0faa9129eec 100755 (executable)
@@ -7,6 +7,7 @@ use wcf\form\AbstractForm;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\UserInputException;
+use wcf\system\language\LanguageFactory;
 use wcf\system\wcf;
 use wcf\util\ArrayUtil;
 use wcf\util\HeaderUtil;
@@ -165,7 +166,7 @@ class UserSearchForm extends UserOptionListForm {
                        'languageIDs' => $this->languageIDs,
                        'optionTree' => $this->optionTree,
                        'availableGroups' => $this->getAvailableGroups(),
-                       'availableLanguages' => $this->getAvailablelanguages(),
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'invertGroupIDs' => $this->invertGroupIDs,
                        'sortField' => $this->sortField,
                        'sortOrder' => $this->sortOrder,
index 40296f7f07cb978c7ecfa65fb7ead1b30353fb64..157cb6ec51f8fba71e9c665d39ff02df39cd4506 100644 (file)
@@ -11,6 +11,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
+use wcf\system\language\LanguageFactory;
 use wcf\util\ArrayUtil;
 use wcf\util\StringUtil;
                
@@ -52,7 +53,6 @@ class UsersMassProcessingForm extends UserOptionListForm {
        
        // data
        public $availableGroups = array();
-       public $availableLanguages = array();
        public $options = array();
        public $availableActions = array('sendMail', 'exportMailAddress', 'assignToGroup', 'delete');
        public $affectedUsers = 0;
@@ -335,7 +335,6 @@ class UsersMassProcessingForm extends UserOptionListForm {
                }
                
                $this->availableGroups = $this->getAvailableGroups();
-               $this->availableLanguages = $this->getAvailableLanguages();
                
                foreach ($this->activeOptions as $name => $option) {
                        if (isset($this->values[$name])) {
@@ -359,7 +358,7 @@ class UsersMassProcessingForm extends UserOptionListForm {
                        'languageIDArray' => $this->languageIDArray,
                        'invertGroupIDs' => $this->invertGroupIDs,
                        'availableGroups' => $this->availableGroups,
-                       'availableLanguages' => $this->availableLanguages,
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'options' => $this->options,
                        'availableActions' => $this->availableActions,
                        // assign to group
index 7b14a8d50fe462edbb059501a974497ff0e19b60..e99f7dd9554d260b8e0c63973a5ca0958663916e 100755 (executable)
@@ -38,7 +38,7 @@ class CronjobListPage extends SortablePage {
        
        /**
         * @see wcf\page\MultipleLinkPage::$objectListClassName
-        */     
+        */
        public $objectListClassName = 'wcf\data\cronjob\CronjobList';
        
        /**
index 60d2c4ff0faec1c32f471117cf81f22c586e5dd6..0c487c7a8ed527205bd2cc41527c6b3cda11d8e9 100644 (file)
@@ -328,6 +328,24 @@ class LanguageEditor extends DatabaseObjectEditor {
                throw new SystemException("missing attribute 'languagecode' in language file");
        }
        
+       /**
+        * Takes an XML object and returns the specific language name.
+        *
+        * @param       wcf\util\XML    $xml
+        * @return      string          language name
+        */
+       public static function readLanguageNameFromXML(XML $xml) {
+               $rootNode = $xml->xpath()->query('/ns:language')->item(0);
+               $attributes = $xml->xpath()->query('attribute::*', $rootNode);
+               foreach ($attributes as $attribute) {
+                       if ($attribute->name == 'languagename') {
+                               return $attribute->value;
+                       }
+               }
+               
+               throw new SystemException("missing attribute 'languagename' in language file");
+       }
+       
        /**
         * Imports language items from an XML file into a new or a current language.
         * Updates the relevant language files automatically.
@@ -344,8 +362,10 @@ class LanguageEditor extends DatabaseObjectEditor {
                
                // create new language
                if ($language === null) {
+                       $languageName = self::readLanguageNameFromXML($xml);
                        $language = self::create(array(
-                               'languageCode' => $languageCode
+                               'languageCode' => $languageCode,
+                               'languageName' => $languageName
                        ));
                }
                
index 37a1d9fb2162ab3d479305e0799e02c73ab2e364..1beae1e20f153c9c6b3db3178b2d969b7d3324a8 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\language;
 use wcf\data\language\Language;
+use wcf\data\DatabaseObject;
 use wcf\system\cache\CacheHandler;
 use wcf\system\template\TemplateScriptingCompiler;
 use wcf\system\SingletonFactory;
@@ -65,6 +66,30 @@ class LanguageFactory extends SingletonFactory {
                return $this->languages[$languageID];
        }
        
+       /**
+        * Returns an instance of Language or NULL for a given language code.
+        *
+        * @param       string          $languageCode
+        * @return      wcf\data\language\Language
+        */
+       public function getLanguageByCode($languageCode) {
+               // called within WCFSetup
+               if ($this->cache === false || !count($this->cache['codes'])) {
+                       $sql = "SELECT  languageID
+                               FROM    wcf".WCF_N."_language
+                               WHERE   languageCode = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array($languageCode));
+                       $row = $statement->fetchArray();
+                       if (isset($row['languageID'])) return new Language($row['languageID']);
+               }
+               else if (isset($this->cache['codes'][$languageCode])) {
+                       return $this->getLanguage($this->cache['codes'][$languageCode]);
+               }
+               
+               return null;
+       }
+       
        /**
         * Returns true if the language category with the given name exists.
         *
@@ -104,8 +129,8 @@ class LanguageFactory extends SingletonFactory {
        protected function findPreferredLanguage() {
                // get available language codes
                $availableLanguageCodes = array();
-               foreach ($this->getAvailableLanguages(PACKAGE_ID) as $language) {
-                       $availableLanguageCodes[] = $language['languageCode'];
+               foreach ($this->getLanguages(PACKAGE_ID) as $language) {
+                       $availableLanguageCodes[] = $language->languageCode;
                }
                
                // get default language
@@ -146,48 +171,6 @@ class LanguageFactory extends SingletonFactory {
                return $defaultLanguageCode;
        }
        
-       /**
-        * Returns infos (code, id, encoding, etc) about all available languages
-        * for package with the given id.
-        *
-        * @param       integer         $packageID
-        * @return      array
-        */
-       public function getAvailableLanguages($packageID = PACKAGE_ID) {
-               // get list of all available languages
-               $availableLanguages = array();
-               if (isset($this->cache['packages'][$packageID])) {
-                       foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
-                               $availableLanguages[] = $this->cache['languages'][$availableLanguageID];
-                       }
-               }
-               return $availableLanguages;
-       }
-       
-       /**
-        * Returns an instance of Language or NULL for a given language code.
-        *
-        * @param       string          $languageCode
-        * @return      wcf\data\language\Language
-        */
-       public function getLanguageByCode($languageCode) {
-               // called within WCFSetup
-               if ($this->cache === false || !count($this->cache['codes'])) {
-                       $sql = "SELECT  languageID
-                               FROM    wcf".WCF_N."_language
-                               WHERE   languageCode = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($languageCode));
-                       $row = $statement->fetchArray();
-                       if (isset($row['languageID'])) return new Language($row['languageID']);
-               }
-               else if (isset($this->cache['codes'][$languageCode])) {
-                       return $this->getLanguage($this->cache['codes'][$languageCode]);
-               }
-               
-               return null;
-       }
-       
        /**
         * Returns the active scripting compiler object.
         *
@@ -256,22 +239,42 @@ class LanguageFactory extends SingletonFactory {
                return $this->cache['default'];
        }
        
+       /**
+        * Returns all available languages for package with the given id.
+        *
+        * @param       integer         $packageID
+        * @return      array<wcf\data\language\Language>
+        */
+       public function getLanguages($packageID = PACKAGE_ID) {
+               // get list of all available languages
+               $availableLanguages = array();
+               if (isset($this->cache['packages'][$packageID])) {
+                       foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
+                               $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID);
+                       }
+               }
+               
+               DatabaseObject::sort($availableLanguages, 'languageName');
+               return $availableLanguages;
+       }
+       
        /**
         * Returns all available content languages for given package.
         *
         * @param       integer         $packageID
-        * @return      array           $availableLanguages     infos about each language (code, id, encoding, etc)
+        * @return      array<wcf\data\language\Language>
         */
-       public function getAvailableContentLanguages($packageID = PACKAGE_ID) {
+       public function getContentLanguages($packageID = PACKAGE_ID) {
                $availableLanguages = array();
                if (isset($this->cache['packages'][$packageID])) {
                        foreach ($this->cache['packages'][$packageID] as $availableLanguageID) {
                                if ($this->cache['languages'][$availableLanguageID]['hasContent']) {
-                                       $availableLanguages[$availableLanguageID] = $this->cache['languages'][$availableLanguageID];
+                                       $availableLanguages[$availableLanguageID] = $this->getLanguage($availableLanguageID);
                                }
                        }
                }
                
+               DatabaseObject::sort($availableLanguages, 'languageName');
                return $availableLanguages;
        }
        
@@ -298,35 +301,4 @@ class LanguageFactory extends SingletonFactory {
                // rebuild language cache
                $this->clearCache();
        }
-       
-       /**
-        * Returns an ordered list of the names of all installed languages in the
-        * active language.
-        * 
-        * @return      array<string>
-        */     
-       public function getLanguages() {
-               $languages = array();
-               foreach ($this->cache['codes'] as $languageCode => $languageID) {
-                       $languages[$languageID] = WCF::getLanguage()->getDynamicVariable('wcf.global.language.'.$languageCode);
-               }
-               
-               StringUtil::sort($languages);
-               return $languages;
-       }
-       
-       /**
-        * Returns an ordered list of all installed language codes.
-        * 
-        * @return      array<string>
-        */
-       public function getLanguageCodes() {
-               $languageCodes = array();
-               foreach ($this->cache['codes'] as $languageCode => $languageID) {
-                       $languageCodes[$languageID] = $languageCode;
-               }
-               
-               StringUtil::sort($languageCodes);
-               return $languageCodes;
-       }
 }
index d4cda1134dc54500b2c31e83d1051ef4f3f7e551..f734405fd8809c1044a2dc5e0416ed0afcdab668 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de-informal">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de-informal" languagename="Deutsch (Du)">
        <category name="wcf.acp">
                <item name="wcf.acp"><![CDATA[Administrationsoberfläche]]></item>
                <item name="wcf.acp.help"><![CDATA[Hilfe]]></item>
index 26d2fd6e5862512ad468cbd37ad953d16ed5f012..a5022e77214176e9d687f12d93fbea736065a51e 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de" languagename="Deutsch">
        <category name="wcf.acp.cronjob">
                <item name="wcf.acp.cronjob.list"><![CDATA[Zeitgesteuerte Aufgaben]]></item>
                <item name="wcf.acp.cronjob.add"><![CDATA[Zeitgesteuerte Aufgabe hinzufügen]]></item>
                <item name="wcf.global.form.edit.success"><![CDATA[Ihre Änderungen wurden erfolgreich gespeichert.]]></item>
                <item name="wcf.global.form.add.success"><![CDATA[Der Eintrag wurde erfolgreich gespeichert.]]></item>
                <item name="wcf.global.loading"><![CDATA[Lädt …]]></item>
+               <item name="wcf.global.button.next"><![CDATA[Weiter &raquo;]]></item>
+               <item name="wcf.global.sortOrder.ascending"><![CDATA[in aufsteigender Reihenfolge]]></item>
+               <item name="wcf.global.sortOrder.descending"><![CDATA[in absteigender Reihenfolge]]></item>
+               <item name="wcf.global.button.back"><![CDATA[&laquo; Zurück]]></item>
+               <item name="wcf.global.button.collapsible"><![CDATA[Auf- und Zuklappen]]></item>
+               <item name="wcf.global.page.next"><![CDATA[nächste Seite]]></item>
+               <item name="wcf.global.page.previous"><![CDATA[vorherige Seite]]></item>
        </category>
        
        <category name="wcf.user">
index 3a79090ae968e753a5d05407e7ce0acf5d6660a3..dc5939752b21b3102d51e5de02e75685caf37a19 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en">
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en" languagename="English">
        <category name="wcf.acp">
                <item name="wcf.acp"><![CDATA[Administration Control Panel]]></item>
                <item name="wcf.acp.help"><![CDATA[Help]]></item>
index 368053ce57f1ffa1b5d8ae04ed2befb5435cc663..ac23cc6bf7aaf0f38f79f2bf59f461210c2735ab 100644 (file)
@@ -192,6 +192,7 @@ DROP TABLE IF EXISTS wcf1_language;
 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 '',
        isDefault TINYINT(1) NOT NULL DEFAULT 0,
        hasContent TINYINT(1) NOT NULL DEFAULT 0,
        UNIQUE KEY languageCode (languageCode)