Fixed handling of style descriptions
authorAlexander Ebert <ebert@woltlab.com>
Thu, 3 Jan 2013 20:45:34 +0000 (21:45 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 3 Jan 2013 20:45:34 +0000 (21:45 +0100)
com.woltlab.wcf/template/styleChooser.tpl
wcfsetup/install/files/lib/data/style/StyleEditor.class.php
wcfsetup/setup/db/install.sql

index 7cc02c2d5c12ea5b806ac40919595c0c020894bf..eaaac6c7ffb000b739d6798f1c6e775b05829b68 100644 (file)
@@ -10,7 +10,7 @@
                                                <hgroup class="containerHeadline">
                                                        <h1>{$style->styleName}</h1>
                                                </hgroup>
-                                               {if $style->styleDescription}<small>{$style->styleDescription}</small>{/if}
+                                               {if $style->styleDescription}<small>{lang}{@$style->styleDescription}{/lang}</small>{/if}
                                        </div>
                                </div>
                        </li>
index e96a1810bf03bd76424475d637d436d0f66c00cf..f883e52a4618d2f0dcd23c5df134825861d193fd 100644 (file)
@@ -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<string>                   $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
+               ));
        }
        
        /**
index 3c36af65c1aa38e3603a6331a65af8db95dad46b..4316a89e5481d7e0f4c8159e6dd362c16ce70e9f 100644 (file)
@@ -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 '',