Fixed style description management
authorAlexander Ebert <ebert@woltlab.com>
Thu, 3 Jan 2013 21:05:27 +0000 (22:05 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 3 Jan 2013 21:05:27 +0000 (22:05 +0100)
Fixes #890

wcfsetup/install/files/acp/templates/styleAdd.tpl
wcfsetup/install/files/acp/templates/styleList.tpl
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php

index 914919ed58df97bb61251a65c6a9d775bced229f..1cab6f48d6b6b0179f8c9d50fce91aa49b1d5ba0 100644 (file)
                                                                {/if}
                                                        </small>
                                                {/if}
+                                               
+                                               {include file='multipleLanguageInputJavascript' elementIdentifier='styleDescription' forceSelection=true}
                                        </dd>
                                </dl>
                        </fieldset>
index f40c482dce4d6ef37dd4c81f0f82f8ce5ea72675..f6ebbe40a5c919917e707ad9b0d7af446412cbd2 100644 (file)
@@ -44,7 +44,7 @@
                                        <div class="details">
                                                <hgroup class="containerHeadline">
                                                        <h1><a href="{link controller='StyleEdit' id=$style->styleID}{/link}">{$style->styleName}</a></h1>
-                                                       {if $style->styleDescription}<h2>{$style->styleDescription}</h2>{/if}
+                                                       {if $style->styleDescription}<h2>{lang}{@$style->styleDescription}{/lang}</h2>{/if}
                                                </hgroup>
                                                <ul class="buttonList" data-style-id="{@$style->styleID}">
                                                        <li><a href="{link controller='StyleEdit' id=$style->styleID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><img src="{@$__wcf->getPath()}icon/edit.svg" class="icon16" alt="" /></a></li>
index 011503cc3952668cb00f47e9fe2d7ea52b7bf81d..1c1f608f7a621f2adb2cb5f6939002a46d8982c9 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\style\StyleEditor;
+
 use wcf\data\package\Package;
 use wcf\data\style\StyleAction;
 use wcf\data\template\group\TemplateGroupList;
@@ -7,6 +9,7 @@ use wcf\form\AbstractForm;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\SystemException;
 use wcf\system\exception\UserInputException;
+use wcf\system\language\I18nHandler;
 use wcf\system\Regex;
 use wcf\system\WCF;
 use wcf\util\DateUtil;
@@ -174,6 +177,8 @@ class StyleAddForm extends AbstractForm {
        public function readParameters() {
                parent::readParameters();
                
+               I18nHandler::getInstance()->register('styleDescription');
+               
                $this->setVariables();
                $this->readStyleVariables();
                
@@ -197,6 +202,8 @@ class StyleAddForm extends AbstractForm {
        public function readFormParameters() {
                parent::readFormParameters();
                
+               I18nHandler::getInstance()->readValues();
+               
                // ignore everything except well-formed rgba()
                $regEx = new Regex('rgba\(\d{1,3}, \d{1,3}, \d{1,3}, (1|1\.00?|0|0?\.[0-9]{1,2})\)');
                foreach ($this->colors as $variableName) {
@@ -273,6 +280,11 @@ class StyleAddForm extends AbstractForm {
                        throw new UserInputException('styleVersion', 'notValid');
                }
                
+               // validate style description
+               if (!I18nHandler::getInstance()->validateValue('styleDescription', true)) {
+                       throw new UserInputException('styleDescription');
+               }
+               
                // validate template group id
                if ($this->templateGroupID) {
                        if (!isset($this->availableTemplateGroups[$this->templateGroupID])) {
@@ -478,8 +490,8 @@ class StyleAddForm extends AbstractForm {
                        'data' => array(
                                'styleName' => $this->styleName,
                                'templateGroupID' => $this->templateGroupID,
-                               'disabled' => 1, // styles are disabled by default
-                               'styleDescription' => ($this->styleDescription ? $this->styleDescription : null),
+                               'isDisabled' => 1, // styles are disabled by default
+                               'styleDescription' => '',
                                'styleVersion' => $this->styleVersion,
                                'styleDate' => $this->styleDate,
                                'imagePath' => $this->imagePath,
@@ -492,7 +504,16 @@ class StyleAddForm extends AbstractForm {
                        'tmpHash' => $this->tmpHash,
                        'variables' => $this->variables
                ));
-               $this->objectAction->executeAction();
+               $returnValues = $this->objectAction->executeAction();
+               $style = $returnValues['returnValues'];
+               
+               // save style description
+               I18nHandler::getInstance()->save('styleDescription', 'wcf.style.styleDescription'.$style->styleID, 'wcf.style');
+               
+               $styleEditor = new StyleEditor($style);
+               $styleEditor->update(array(
+                       'styleDescription' => 'wcf.style.styleDescription'.$style->styleID
+               ));
                
                // call saved event
                $this->saved();
@@ -517,6 +538,8 @@ class StyleAddForm extends AbstractForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               I18nHandler::getInstance()->assignVariables();
+               
                WCF::getTPL()->assign(array(
                        'action' => 'add',
                        'authorName' => $this->authorName,
index d5d86a6690c14bf89d10aa0e7ed8a3124ade5d98..4d61392d12cff820a6987035c4ae70a66c75f0fd 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\style\Style;
 use wcf\data\style\StyleAction;
 use wcf\form\AbstractForm;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\language\I18nHandler;
 use wcf\system\WCF;
 
 /**
@@ -73,6 +74,8 @@ class StyleEditForm extends StyleAddForm {
        public function readData() {
                parent::readData();
                
+               I18nHandler::getInstance()->setOptions('styleDescription', PACKAGE_ID, $this->style->styleDescription, 'wcf.style.styleDescription\d+');
+               
                if (empty($_POST)) {
                        $this->authorName = $this->style->authorName;
                        $this->authorURL = $this->style->authorURL;
@@ -98,7 +101,6 @@ class StyleEditForm extends StyleAddForm {
                        'data' => array(
                                'styleName' => $this->styleName,
                                'templateGroupID' => $this->templateGroupID,
-                               'styleDescription' => ($this->styleDescription ? $this->styleDescription : null),
                                'styleVersion' => $this->styleVersion,
                                'styleDate' => $this->styleDate,
                                'imagePath' => $this->imagePath,
@@ -113,6 +115,9 @@ class StyleEditForm extends StyleAddForm {
                ));
                $this->objectAction->executeAction();
                
+               // save description
+               I18nHandler::getInstance()->save('styleDescription', $this->style->styleDescription, 'wcf.style');
+               
                // call saved event
                $this->saved();
                
@@ -128,6 +133,8 @@ class StyleEditForm extends StyleAddForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               I18nHandler::getInstance()->assignVariables(!empty($_POST));
+               
                WCF::getTPL()->assign(array(
                        'action' => 'edit',
                        'style' => $this->style,