From d3478df7e26f3f82c0fe65c31bf41ee1965f8fc1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 3 Jan 2013 21:45:34 +0100 Subject: [PATCH] Fixed handling of style descriptions --- com.woltlab.wcf/template/styleChooser.tpl | 2 +- .../lib/data/style/StyleEditor.class.php | 27 ++++++++++--------- wcfsetup/setup/db/install.sql | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/com.woltlab.wcf/template/styleChooser.tpl b/com.woltlab.wcf/template/styleChooser.tpl index 7cc02c2d5c..eaaac6c7ff 100644 --- a/com.woltlab.wcf/template/styleChooser.tpl +++ b/com.woltlab.wcf/template/styleChooser.tpl @@ -10,7 +10,7 @@

{$style->styleName}

- {if $style->styleDescription}{$style->styleDescription}{/if} + {if $style->styleDescription}{lang}{@$style->styleDescription}{/lang}{/if} diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index e96a1810bf..f883e52a46 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -520,23 +520,16 @@ 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']); - } + } + + // handle descriptions + if (!empty($data['description'])) { + self::saveLocalizedDescriptions($style, $data['description']); } if ($data['default']) { @@ -546,6 +539,12 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject return $style; } + /** + * Saves localized style descriptions. + * + * @param wcf\data\style\StyleEditor $styleEditor + * @param array $descriptions + */ protected static function saveLocalizedDescriptions(StyleEditor $styleEditor, array $descriptions) { // localize package information $sql = "INSERT INTO wcf".WCF_N."_language_item @@ -582,6 +581,10 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject )); } } + + $styleEditor->update(array( + 'styleDescription' => 'wcf.style.styleDescription'.$styleEditor->styleID + )); } /** diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 3c36af65c1..4316a89e54 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -568,7 +568,7 @@ CREATE TABLE wcf1_style ( templateGroupID INT(10) NOT NULL DEFAULT 0, isDefault TINYINT(1) NOT NULL DEFAULT 0, isDisabled TINYINT(1) NOT NULL DEFAULT 0, - styleDescription TEXT, + styleDescription VARCHAR(30) NOT NULL DEFAULT '', styleVersion VARCHAR(255) NOT NULL DEFAULT '', styleDate CHAR(10) NOT NULL DEFAULT '0000-00-00', image VARCHAR(255) NOT NULL DEFAULT '', -- 2.20.1