From 23af949da5192c3ff43d0bc192cdbfb4aadf5956 Mon Sep 17 00:00:00 2001 From: Jean-Marc Licht Date: Sat, 24 Mar 2012 19:44:07 +0100 Subject: [PATCH] Added language export function --- .../data/language/LanguageEditor.class.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php index 0979bfcfcb..a87b94a1cb 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageEditor.class.php @@ -144,6 +144,74 @@ class LanguageEditor extends DatabaseObjectEditor { } } + /** + * Exports this language. + */ + public function export($packageIDArray = array(), $exportCustomValues = false) { + $conditions = new PreparedStatementConditionBuilder(); + + // bom + echo "\xEF\xBB\xBF"; + + // header + echo "\nlanguageCode."\">\n"; + + // get items + $items = array(); + if (count($packageIDArray)) { + // sql conditions + $conditions->add("language_item.packageID IN (?)", array($packageIDArray)); + $conditions->add("language_item.languageID = ?", array($this->languageID)); + + $sql = "SELECT languageItem, " . ($exportCustomValues ? "CASE WHEN languageUseCustomValue > 0 THEN languageCustomItemValue ELSE languageItemValue END AS languageItemValue" : "languageItemValue") . ", languageCategory + FROM wcf".WCF_N."_language_item language_item + LEFT JOIN wcf".WCF_N."_language_category language_category + ON (language_category.languageCategoryID = language_item.languageCategoryID) + ".$conditions; + } + else { + // sql conditions + $conditions->add("language_item.packageID = package_dependency.dependency"); + $conditions->add("package_dependency.packageID = ?", array(PACKAGE_ID)); + $conditions->add("language_item.languageID = ?", array($this->languageID)); + + $sql = "SELECT languageItem, " . ($exportCustomValues ? "CASE WHEN languageUseCustomValue > 0 THEN languageCustomItemValue ELSE languageItemValue END AS languageItemValue" : "languageItemValue") . ", languageCategory + FROM wcf".WCF_N."_package_dependency package_dependency, + wcf".WCF_N."_language_item language_item + LEFT JOIN wcf".WCF_N."_language_category language_category + ON (language_category.languageCategoryID = language_item.languageCategoryID) + ".$conditions." + ORDER BY package_dependency.priority ASC"; + } + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $items[$row['languageCategory']][$row['languageItem']] = $row['languageItemValue']; + } + + // sort categories + ksort($items); + + foreach ($items as $category => $categoryItems) { + // sort items + ksort($categoryItems); + + // category header + echo "\t\n"; + + // items + foreach ($categoryItems as $item => $value) { + echo "\t\t\n"; + } + + // category footer + echo "\t\n"; + } + + // footer + echo ""; + } + /** * Imports language items from an XML file into this language. * Updates the relevant language files automatically. -- 2.20.1