<?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;
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;
public function readParameters() {
parent::readParameters();
+ I18nHandler::getInstance()->register('styleDescription');
+
$this->setVariables();
$this->readStyleVariables();
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) {
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])) {
'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,
'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();
public function assignVariables() {
parent::assignVariables();
+ I18nHandler::getInstance()->assignVariables();
+
WCF::getTPL()->assign(array(
'action' => 'add',
'authorName' => $this->authorName,
use wcf\data\style\StyleAction;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\language\I18nHandler;
use wcf\system\WCF;
/**
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;
'data' => array(
'styleName' => $this->styleName,
'templateGroupID' => $this->templateGroupID,
- 'styleDescription' => ($this->styleDescription ? $this->styleDescription : null),
'styleVersion' => $this->styleVersion,
'styleDate' => $this->styleDate,
'imagePath' => $this->imagePath,
));
$this->objectAction->executeAction();
+ // save description
+ I18nHandler::getInstance()->save('styleDescription', $this->style->styleDescription, 'wcf.style');
+
// call saved event
$this->saved();
public function assignVariables() {
parent::assignVariables();
+ I18nHandler::getInstance()->assignVariables(!empty($_POST));
+
WCF::getTPL()->assign(array(
'action' => 'edit',
'style' => $this->style,