From 78dc4b360454113438fa8965e64e1f1216d6012d Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 28 Oct 2018 11:20:21 +0100 Subject: [PATCH] Set initial description of definition and classname fields in PHP code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … instead of using JavaScript. See #2545 --- .../acp/templates/__objectTypePipGui.tpl | 2 -- ...ectTypePackageInstallationPlugin.class.php | 36 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl b/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl index 79e6e5cbfb..8630716113 100644 --- a/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl +++ b/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl @@ -30,7 +30,5 @@ } definitionID.addEventListener('change', update); - - update(); }); \ No newline at end of file diff --git a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php index f2672033f5..bd23597beb 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php @@ -46,7 +46,9 @@ use wcf\util\DirectoryUtil; * @package WoltLabSuite\Core\Acp\Package\Plugin */ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin implements IGuiPackageInstallationPlugin { - use TXmlGuiPackageInstallationPlugin; + use TXmlGuiPackageInstallationPlugin { + setEntryData as defaultSetEntryData; + } /** * @inheritDoc @@ -1056,4 +1058,36 @@ XML; } })); } + + /** + * @inheritDoc + * @since 3.2 + */ + public function setEntryData($identifier, IFormDocument $document) { + $returnValue = $this->defaultSetEntryData($identifier, $document); + + // set dynamic descriptions here instead of relying on the JavaScript + // code to avoid delayed appearance of the descriptions + + /** @var SingleSelectionFormField $definitionID */ + $definitionID = $document->getNodeById('definitionID'); + $objectTypeDefinition = ObjectTypeCache::getInstance()->getDefinition($definitionID->getSaveValue()); + + $definitionID->description( + 'wcf.acp.pip.objectType.definitionName.' . + $objectTypeDefinition->definitionName . + '.description' + ); + + /** @var ClassNameFormField $className */ + $className = $document->getNodeById('className'); + if ($objectTypeDefinition->interfaceName) { + $className->description( + 'wcf.form.field.className.description.interface', + ['interface' => $objectTypeDefinition->interfaceName] + ); + } + + return $returnValue; + } } -- 2.20.1