From: Alexander Ebert Date: Thu, 3 Jan 2013 20:22:28 +0000 (+0100) Subject: Added support for i18n style descriptions (ACP missing) X-Git-Tag: 2.0.0_Beta_1~584^2~1^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6981d6288d32904548457eb3f900df607a31d2b;p=GitHub%2FWoltLab%2FWCF.git Added support for i18n style descriptions (ACP missing) See #890 --- diff --git a/com.woltlab.wcf/woltlab-basic-style.tgz b/com.woltlab.wcf/woltlab-basic-style.tgz index fdcc511c7d..93f2ff84d7 100644 Binary files a/com.woltlab.wcf/woltlab-basic-style.tgz and b/com.woltlab.wcf/woltlab-basic-style.tgz differ diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index e1509d6e78..dd3a12bb2f 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -1,5 +1,6 @@ xpath(); $data = array( - 'name' => '', 'description' => '', 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, + 'name' => '', 'description' => array(), 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, 'license' => '', 'authorName' => '', 'authorURL' => '', 'templates' => '', 'images' => '', 'variables' => '', 'date' => '0000-00-00', 'icons' => '', 'iconsPath' => '', 'imagesPath' => '' ); @@ -175,6 +177,12 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $data['default'] = true; break; + case 'description': + if ($element->hasAttribute('language')) { + $data['description'][$element->getAttribute('language')] = $element->nodeValue; + } + break; + case 'stylename': $data['name'] = $element->nodeValue; break; @@ -188,7 +196,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject break; case 'copyright': - case 'description': case 'image': case 'license': $data[$element->tagName] = $element->nodeValue; @@ -286,7 +293,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $styleData = array( 'styleName' => $data['name'], 'variables' => $data['variables'], - 'styleDescription' => $data['description'], 'styleVersion' => $data['version'], 'styleDate' => $data['date'], 'copyright' => $data['copyright'], @@ -514,11 +520,23 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // save style if ($style !== null) { + // handle descriptions + if (!empty($data['description'])) { + $styleData['styleDescription'] = 'wcf.style.styleDescription'.$style->styleID; + self::saveLocalizedDescriptions($style, $data['description']); + } + $style->update($styleData); } else { $styleData['packageID'] = $packageID; $style = new StyleEditor(self::create($styleData)); + + // handle descriptions + if (!empty($data['description'])) { + $styleData['styleDescription'] = 'wcf.style.styleDescription'.$style->styleID; + self::saveLocalizedDescriptions($style, $data['description']); + } } if ($data['default']) { @@ -528,6 +546,44 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject return $style; } + protected static function saveLocalizedDescriptions(StyleEditor $styleEditor, array $descriptions) { + // localize package information + $sql = "INSERT INTO wcf".WCF_N."_language_item + (languageID, languageItem, languageItemValue, languageCategoryID, packageID) + VALUES (?, ?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + // get language list + $languageList = new LanguageList(); + $languageList->sqlLimit = 0; + $languageList->readObjects(); + + // workaround for WCFSetup + if (!PACKAGE_ID) { + $sql = "SELECT * + FROM wcf".WCF_N."_language_category + WHERE languageCategory = ?"; + $statement2 = WCF::getDB()->prepareStatement($sql); + $statement2->execute(array('wcf.style')); + $languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory'); + } + else { + $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.style'); + } + + foreach ($languageList as $language) { + if (isset($descriptions[$language->landugeCode])) { + $statement->execute(array( + $language->languageID, + 'wcf.style.styleDescription'.$styleEditor->styleID, + $descriptions[$language->languageCode], + $languageCategory->languageCategoryID, + $styleEditor->packageID + )); + } + } + } + /** * Returns available location path. *