From 0533ede6ff42655f7935edbfb9ce9d473a00e5c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Mon, 6 Aug 2018 12:24:23 +0200 Subject: [PATCH] Fix I18n values for reaction types See #2508 --- .../type/ReactionTypeAction.class.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php index 4be7cece21..02a5a73d64 100644 --- a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php +++ b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php @@ -4,6 +4,7 @@ use wcf\data\AbstractDatabaseObjectAction; use wcf\data\ISortableAction; use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\UserInputException; +use wcf\system\language\I18nHandler; use wcf\system\WCF; /** @@ -34,6 +35,57 @@ class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortab */ protected $requireACP = ['delete', 'update', 'updatePosition']; + /** + * @inheritDoc + */ + public function create() { + /** @var ReactionType $reactionType */ + $reactionType = parent::create(); + $reactionTypeEditor = new ReactionTypeEditor($reactionType); + + // i18n + $updateData = []; + if (isset($this->parameters['title_i18n'])) { + I18nHandler::getInstance()->save( + $this->parameters['title_i18n'], + 'wcf.reactionType.title' . $reactionType->reactionTypeID, + 'wcf.reactionType', + 1 + ); + + $updateData['title'] = 'wcf.reactionType.title' . $reactionType->reactionTypeID; + } + + if (!empty($updateData)) { + $reactionTypeEditor->update($updateData); + } + + return $reactionType; + } + + /** + * @inheritDoc + */ + public function update() { + parent::update(); + + // i18n + foreach ($this->getObjects() as $object) { + if (isset($this->parameters['title_i18n'])) { + I18nHandler::getInstance()->save( + $this->parameters['title_i18n'], + 'wcf.reactionType.title' . $object->reactionTypeID, + 'wcf.reactionType', + 1 + ); + + $object->update([ + 'title' => 'wcf.reactionType.title' . $object->reactionTypeID + ]); + } + } + } + /** * @inheritDoc */ -- 2.20.1