From: Matthias Schmidt Date: Sun, 28 Oct 2018 10:20:21 +0000 (+0100) Subject: Set initial description of definition and classname fields in PHP code X-Git-Tag: 5.2.0_Alpha_1~575 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=78dc4b360454113438fa8965e64e1f1216d6012d;p=GitHub%2FWoltLab%2FWCF.git Set initial description of definition and classname fields in PHP code … instead of using JavaScript. See #2545 --- 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; + } }