diff --git a/files/lib/acp/form/FaqQuestionAddForm.class.php b/files/lib/acp/form/FaqQuestionAddForm.class.php index 613932a..d59f1e7 100644 --- a/files/lib/acp/form/FaqQuestionAddForm.class.php +++ b/files/lib/acp/form/FaqQuestionAddForm.class.php @@ -19,6 +19,7 @@ use wcf\system\form\builder\field\SingleSelectionFormField; use wcf\system\form\builder\field\TextFormField; use wcf\system\form\builder\IFormDocument; +use wcf\system\html\input\HtmlInputProcessor; use wcf\system\language\LanguageFactory; use wcf\system\request\IRouteController; use wcf\system\request\LinkHandler; @@ -59,8 +60,6 @@ class FaqQuestionAddForm extends AbstractFormBuilderForm protected $isMultilingual = 0; - protected $multiLingualAnswers = []; - /** * @inheritDoc */ @@ -185,20 +184,21 @@ public function buildForm() static function (IFormDocument $document, array $parameters) { foreach ($parameters['data'] as $key => $val) { if (\str_starts_with($key, 'answer_i18n_')) { - $languageID = (int)\substr($key, 12); - $parameters['answer_i18n'][$languageID] = $val; unset($parameters['data'][$key]); } } - - return $parameters; - }, - function (IFormDocument $document, array $data, IStorableObject $object) { - foreach ($this->multiLingualAnswers as $languageID => $answer) { - $data['answer_i18n_' . $languageID] = $answer; + foreach ($parameters as $key => $val) { + if ( + \str_starts_with($key, 'answer_i18n') + && \str_ends_with($key, 'htmlInputProcessor') + && $val instanceof HtmlInputProcessor + ) { + $parts = \explode('_', $key); + $parameters['answer_i18n'][(int)$parts[2]] = $val->getHtml(); + } } - return $data; + return $parameters; } )); } diff --git a/files/lib/data/faq/QuestionAction.class.php b/files/lib/data/faq/QuestionAction.class.php index 0951145..fef5009 100644 --- a/files/lib/data/faq/QuestionAction.class.php +++ b/files/lib/data/faq/QuestionAction.class.php @@ -50,20 +50,7 @@ public function create() { //prepare answer if (isset($this->parameters['answer_i18n'])) { - $answers = ''; - foreach ($this->parameters['answer_i18n'] as $languageID => $answer) { - $processor = new HtmlInputProcessor(); - $processor->process($answer, 'dev.tkirch.wsc.faq.question', 0); - $this->parameters['answer_i18n'][$languageID] = $processor->getHtml(); - $answers .= $answer; - } - $inputProcessor = new HtmlInputProcessor(); - $inputProcessor->process($answers, 'dev.tkirch.wsc.faq.question', 0); $this->parameters['data']['isMultilingual'] = 1; - } else { - $inputProcessor = new HtmlInputProcessor(); - $inputProcessor->process($this->parameters['data']['answer'], 'dev.tkirch.wsc.faq.question', 0); - $this->parameters['data']['answer'] = $inputProcessor->getHtml(); } //get question @@ -91,20 +78,17 @@ public function create() $this->updateSearchIndex($question); foreach ($this->parameters as $parameter) { - if (!($parameter instanceof AttachmentHandler)) { - continue; - } - $parameter->updateObjectID($question->questionID); - } - - if (!empty($inputProcessor)) { - $inputProcessor->setObjectID($question->questionID); - if ( - MessageEmbeddedObjectManager::getInstance()->registerObjects( - $inputProcessor - ) - ) { - $updateData['hasEmbeddedObjects'] = 1; + if ($parameter instanceof AttachmentHandler) { + $parameter->updateObjectID($question->questionID); + } elseif ($parameter instanceof HtmlInputProcessor) { + $parameter->setObjectID($question->questionID); + if ( + MessageEmbeddedObjectManager::getInstance()->registerObjects( + $parameter + ) + ) { + $updateData['hasEmbeddedObjects'] = 1; + } } } @@ -132,20 +116,7 @@ public function update() //prepare answer if (isset($this->parameters['answer_i18n'])) { - $answers = ''; - foreach ($this->parameters['answer_i18n'] as $languageID => $answer) { - $processor = new HtmlInputProcessor(); - $processor->process($answer, 'dev.tkirch.wsc.faq.question', 0); - $this->parameters['answer_i18n'][$languageID] = $processor->getHtml(); - $answers .= $answer; - } - $inputProcessor = new HtmlInputProcessor(); - $inputProcessor->process($answers, 'dev.tkirch.wsc.faq.question', 0); $this->parameters['data']['isMultilingual'] = 1; - } else { - $inputProcessor = new HtmlInputProcessor(); - $inputProcessor->process($this->parameters['data']['answer'], 'dev.tkirch.wsc.faq.question', 0); - $this->parameters['data']['answer'] = $inputProcessor->getHtml(); } parent::update(); @@ -202,20 +173,18 @@ public function update() } foreach ($this->parameters as $parameter) { - if (!($parameter instanceof AttachmentHandler)) { - continue; + if ($parameter instanceof AttachmentHandler) { + $parameter->updateObjectID($object->questionID); + } elseif ($parameter instanceof HtmlInputProcessor) { + $parameter->setObjectID($object->questionID); + if ( + $object->hasEmbeddedObjects != MessageEmbeddedObjectManager::getInstance()->registerObjects( + $parameter + ) + ) { + $updateData['hasEmbeddedObjects'] = $object->hasEmbeddedObjects ? 0 : 1; + } } - $parameter->updateObjectID($object->questionID); - } - - $inputProcessor->setObjectID($object->questionID); - - if ( - $object->hasEmbeddedObjects != MessageEmbeddedObjectManager::getInstance()->registerObjects( - $inputProcessor - ) - ) { - $updateData['hasEmbeddedObjects'] = $object->hasEmbeddedObjects ? 0 : 1; } if (!empty($updateData)) { diff --git a/package.xml b/package.xml index 50c0b58..dd809ea 100644 --- a/package.xml +++ b/package.xml @@ -7,14 +7,14 @@ A simple and powerful FAQ for your WSC. Ein simples und leistungsstarkes FAQ für Ihr WSC. 2.1.2 - 2024-04-15 + 2024-08-09 Hanashi Development, Titus Kirch https://hanashi.dev - com.woltlab.wcf + com.woltlab.wcf com.woltlab.wcf