Set initial description of definition and classname fields in PHP code
authorMatthias Schmidt <gravatronics@live.com>
Sun, 28 Oct 2018 10:20:21 +0000 (11:20 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 28 Oct 2018 10:20:21 +0000 (11:20 +0100)
… instead of using JavaScript.

See #2545

wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl
wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php

index 79e6e5cbfb870546bc072ea0f9879d4c0e321c02..8630716113d7983d9ec2ffb5836ab8ab4269ca5b 100644 (file)
@@ -30,7 +30,5 @@
                }
                
                definitionID.addEventListener('change', update);
-               
-               update();
        });
 </script>
\ No newline at end of file
index f2672033f55ef727f22ca02f23f8e981524b9dc1..bd23597bebdb78392798ffc3ddab088c9f6483e5 100644 (file)
@@ -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;
+       }
 }