From: Alexander Ebert Date: Sun, 13 Jan 2013 21:23:07 +0000 (+0100) Subject: Providing sane default values for style creation X-Git-Tag: 2.0.0_Beta_1~566^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4aae896107c9860f91733b8f749419003c2f2071;p=GitHub%2FWoltLab%2FWCF.git Providing sane default values for style creation Fixed issue with exporting a style as an installable package. --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index a4d9153921..cb9529ca3c 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2749,7 +2749,11 @@ WCF.MultipleLanguageInput = Class.extend({ var $form = $(this._element.parents('form')[0]); var $elementID = this._element.wcfIdentify(); - for (var $languageID in this._values) { + for (var $languageID in this._availableLanguages) { + if (this._values[$languageID] === undefined) { + this._values[$languageID] = ''; + } + $('').appendTo($form); } diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 9b188f295a..da508275f6 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -250,10 +250,6 @@ class StyleAddForm extends AbstractForm { throw new UserInputException('authorName'); } - if (empty($this->license)) { - throw new UserInputException('license'); - } - // validate date if (empty($this->styleDate)) { throw new UserInputException('styleDate'); @@ -280,7 +276,7 @@ class StyleAddForm extends AbstractForm { } // validate style description - if (!I18nHandler::getInstance()->validateValue('styleDescription', true)) { + if (!I18nHandler::getInstance()->validateValue('styleDescription', true, true)) { throw new UserInputException('styleDescription'); } @@ -402,7 +398,9 @@ class StyleAddForm extends AbstractForm { } if (empty($_POST)) { + $this->authorName = WCF::getUser()->username; $this->styleDate = date('Y-m-d', TIME_NOW); + $this->styleVersion = '1.0.0'; } } diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index f883e52a46..f2201ecc3c 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -630,6 +630,19 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $styleTar->add(WCF_DIR.'images/'.$this->image, '', FileUtil::addTrailingSlash(dirname(WCF_DIR.'images/'.$this->image))); } + // fetch style description + $sql = "SELECT language.languageCode, language_item.languageItemValue + FROM wcf".WCF_N."_language_item language_item + LEFT JOIN wcf".WCF_N."_language language + ON (language.languageID = language_item.languageID) + WHERE language_item.languageItem = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->styleDescription)); + $styleDescriptions = array(); + while ($row = $statement->fetchArray()) { + $styleDescriptions[$row['languageCode']] = $row['languageItemValue']; + } + // create style info file $xml = new XMLWriter(); $xml->beginDocument('style', 'http://www.woltlab.com', 'http://www.woltlab.com/XSD/maelstrom/style.xsd'); @@ -637,7 +650,12 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // general block $xml->startElement('general'); $xml->writeElement('stylename', $this->styleName); - if ($this->styleDescription) $xml->writeElement('description', $this->styleDescription); + + // style description + foreach ($styleDescriptions as $languageCode => $value) { + $xml->writeElement('description', $value, array('language' => $languageCode)); + } + $xml->writeElement('date', $this->styleDate); $xml->writeElement('version', $this->styleVersion); if ($this->image) $xml->writeElement('image', $this->image); @@ -775,14 +793,19 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // append style tar $styleTarName = FileUtil::unifyDirSeperator($styleTarName); - $packageTar->add($styleTarName, '', dirname($styleTarName)); + $packageTar->add($styleTarName, '', FileUtil::addTrailingSlash(dirname($styleTarName))); // create package.xml $xml->beginDocument('package', 'http://www.woltlab.com', 'http://www.woltlab.com/XSD/maelstrom/package.xsd', array('name' => $packageName)); $xml->startElement('packageinformation'); $xml->writeElement('packagename', $this->styleName); - $xml->writeElement('packagedescription', $this->styleDescription); + + // description + foreach ($styleDescriptions as $languageCode => $value) { + $xml->writeElement('packagedescription', $value, array('language' => $languageCode)); + } + $xml->writeElement('version', $this->styleVersion); $xml->writeElement('date', $this->styleDate); $xml->endElement(); @@ -792,7 +815,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject if ($this->authorURL) $xml->writeElement('authorurl', $this->authorURL); $xml->endElement(); - $xml->startElement('instructions', array('name' => 'install')); + $xml->startElement('instructions', array('type' => 'install')); $xml->writeElement('instruction', basename($styleTarName), array('type' => 'style')); $xml->endElement(); diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 6daa54a0b4..c9b52ab00a 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -239,7 +239,7 @@ class I18nHandler extends SingletonFactory { return false; } - if (empty($this->i18nValues[$elementID][$language->languageID])) { + if (!$permitEmptyValue && empty($this->i18nValues[$elementID][$language->languageID])) { return false; } }