Revert "Use set default values function"
authorCyperghost <olaf_schmitz_1@t-online.de>
Thu, 1 Feb 2024 13:02:50 +0000 (14:02 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Thu, 1 Feb 2024 13:02:50 +0000 (14:02 +0100)
This reverts commit f8cfff86e407013baafe8f126390e116795ff855.

wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php
wcfsetup/install/files/lib/acp/form/ArticleEditForm.class.php

index c32daf2d7bfd88f6bb097cde443bee98b9901a28..1814830e26bfb1f74e2ad6bd3920ab0446072847 100644 (file)
@@ -617,22 +617,6 @@ class ArticleAddForm extends AbstractForm
                 }
             }
         }
-
-        if (!$this->isMultilingual) {
-            if (isset($this->content[0])) {
-                $upcastProcessor = new HtmlUpcastProcessor();
-                $upcastProcessor->process($this->content[0], 'com.woltlab.wcf.article.content');
-                $this->content[0] = $upcastProcessor->getHtml();
-            }
-        } else {
-            foreach ($this->availableLanguages as $language) {
-                if (isset($this->content[$language->languageID])) {
-                    $upcastProcessor = new HtmlUpcastProcessor();
-                    $upcastProcessor->process($this->content[$language->languageID], 'com.woltlab.wcf.article.content');
-                    $this->content[$language->languageID] = $upcastProcessor->getHtml();
-                }
-            }
-        }
     }
 
     /**
@@ -662,6 +646,23 @@ class ArticleAddForm extends AbstractForm
 
         SmileyCache::getInstance()->assignVariables();
 
+        // readData not work in edit form
+        if (!$this->isMultilingual) {
+            if (isset($this->content[0])) {
+                $upcastProcessor = new HtmlUpcastProcessor();
+                $upcastProcessor->process($this->content[0], 'com.woltlab.wcf.article.content');
+                $this->content[0] = $upcastProcessor->getHtml();
+            }
+        } else {
+            foreach ($this->availableLanguages as $language) {
+                if (isset($this->content[$language->languageID])) {
+                    $upcastProcessor = new HtmlUpcastProcessor();
+                    $upcastProcessor->process($this->content[$language->languageID], 'com.woltlab.wcf.article.content');
+                    $this->content[$language->languageID] = $upcastProcessor->getHtml();
+                }
+            }
+        }
+
         WCF::getTPL()->assign([
             'action' => 'add',
             'isMultilingual' => $this->isMultilingual,
index 7bf4ce4583544f09f7805f1360a4d50f8fcf3459..636f9a7644bf6f33f5339a93036f18c9aa9d29e3 100644 (file)
@@ -173,54 +173,51 @@ class ArticleEditForm extends ArticleAddForm
         }
 
         parent::readData();
-    }
 
-    #[\Override]
-    protected function setDefaultValues()
-    {
-        parent::setDefaultValues();
-        $this->categoryID = $this->article->categoryID;
-        $this->publicationStatus = $this->article->publicationStatus;
-        $this->enableComments = $this->article->enableComments;
-        $this->username = $this->article->username;
-        $dateTime = DateUtil::getDateTimeByTimestamp($this->article->time);
-        $dateTime->setTimezone(WCF::getUser()->getTimeZone());
-        $this->time = $dateTime->format('c');
-        if ($this->article->publicationDate) {
-            $dateTime = DateUtil::getDateTimeByTimestamp($this->article->publicationDate);
+        if (empty($_POST)) {
+            $this->categoryID = $this->article->categoryID;
+            $this->publicationStatus = $this->article->publicationStatus;
+            $this->enableComments = $this->article->enableComments;
+            $this->username = $this->article->username;
+            $dateTime = DateUtil::getDateTimeByTimestamp($this->article->time);
             $dateTime->setTimezone(WCF::getUser()->getTimeZone());
-            $this->publicationDate = $dateTime->format('c');
-        }
+            $this->time = $dateTime->format('c');
+            if ($this->article->publicationDate) {
+                $dateTime = DateUtil::getDateTimeByTimestamp($this->article->publicationDate);
+                $dateTime->setTimezone(WCF::getUser()->getTimeZone());
+                $this->publicationDate = $dateTime->format('c');
+            }
 
-        foreach ($this->article->getArticleContents() as $languageID => $content) {
-            $this->title[$languageID] = $content->title;
-            $this->teaser[$languageID] = $content->teaser;
-            $this->content[$languageID] = $content->content;
-            $this->imageID[$languageID] = $content->imageID;
-            $this->teaserImageID[$languageID] = $content->teaserImageID;
-            $this->metaTitle[$languageID] = $content->metaTitle;
-            $this->metaDescription[$languageID] = $content->metaDescription;
-
-            // get tags
-            if (MODULE_TAGGING) {
-                $this->tags[$languageID] = TagEngine::getInstance()->getObjectTags(
-                    'com.woltlab.wcf.article',
-                    $content->articleContentID,
-                    [$languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID()]
-                );
+            foreach ($this->article->getArticleContents() as $languageID => $content) {
+                $this->title[$languageID] = $content->title;
+                $this->teaser[$languageID] = $content->teaser;
+                $this->content[$languageID] = $content->content;
+                $this->imageID[$languageID] = $content->imageID;
+                $this->teaserImageID[$languageID] = $content->teaserImageID;
+                $this->metaTitle[$languageID] = $content->metaTitle;
+                $this->metaDescription[$languageID] = $content->metaDescription;
+
+                // get tags
+                if (MODULE_TAGGING) {
+                    $this->tags[$languageID] = TagEngine::getInstance()->getObjectTags(
+                        'com.woltlab.wcf.article',
+                        $content->articleContentID,
+                        [$languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID()]
+                    );
+                }
             }
-        }
 
-        $this->readImages();
+            $this->readImages();
 
-        // labels
-        $assignedLabels = ArticleLabelObjectHandler::getInstance()->getAssignedLabels(
-            [$this->article->articleID],
-            true
-        );
-        if (isset($assignedLabels[$this->article->articleID])) {
-            foreach ($assignedLabels[$this->article->articleID] as $label) {
-                $this->labelIDs[$label->groupID] = $label->labelID;
+            // labels
+            $assignedLabels = ArticleLabelObjectHandler::getInstance()->getAssignedLabels(
+                [$this->article->articleID],
+                true
+            );
+            if (isset($assignedLabels[$this->article->articleID])) {
+                foreach ($assignedLabels[$this->article->articleID] as $label) {
+                    $this->labelIDs[$label->groupID] = $label->labelID;
+                }
             }
         }
     }