From: Matthias Schmidt Date: Sun, 24 Jun 2018 08:46:05 +0000 (+0200) Subject: Add missing changes for object type pip gui X-Git-Tag: 5.2.0_Alpha_1~711 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c281b1abceb6d0348541973528995b7f2d295dd5;p=GitHub%2FWoltLab%2FWCF.git Add missing changes for object type pip gui See 48e11cf5250e155c15f79c9998d872572c01df16 See #2545 --- diff --git a/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl b/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl index 7640dc3ca9..79e6e5cbfb 100644 --- a/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl +++ b/wcfsetup/install/files/acp/templates/__objectTypePipGui.tpl @@ -7,29 +7,29 @@ {/implode} }); - var definitionNamesWithInterface = { - {implode from=$definitionNamesWithInterface key=definitionName item=interfaceName} - '{@$definitionName}': '{@$interfaceName|encodeJS}' + var definitionInterfaces = { + {implode from=$definitionInterfaces key=definitionID item=interfaceName} + {@$definitionID}: '{@$interfaceName|encodeJS}' {/implode} }; var classNameDescription = elById('className').nextElementSibling; - var definitionName = elById('definitionName'); - var definitionNameDescription = definitionName.nextElementSibling; + var definitionID = elById('definitionID'); + var definitionIDDescription = definitionID.nextElementSibling; function update() { // update description of `definitionName` field - definitionNameDescription.innerHTML = Language.get('wcf.acp.pip.objectType.definitionName.' + definitionName.value + '.description'); + definitionIDDescription.innerHTML = Language.get('wcf.acp.pip.objectType.definitionName.' + definitionID.options.item(definitionID.selectedIndex).textContent + '.description'); // update description of `className` field with new interface - if (definitionNamesWithInterface[definitionName.value]) { + if (definitionInterfaces[definitionID.value]) { classNameDescription.innerHTML = Language.get('wcf.form.field.className.description.interface', { - interface: definitionNamesWithInterface[definitionName.value] + interface: definitionInterfaces[definitionID.value] }); } } - definitionName.addEventListener('change', update); + definitionID.addEventListener('change', update); update(); }); diff --git a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php index 18c9b4abb4..4af4710271 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php @@ -137,10 +137,11 @@ trait TXmlGuiPackageInstallationPlugin { /** * Extracts the PIP object data from the given XML element. * - * @param \DOMElement $element + * @param \DOMElement $element element whose data is returned + * @param bool $saveData is `true` if data is intended to be saved and otherwise `false` * @return array */ - abstract protected function getElementData(\DOMElement $element): array; + abstract protected function getElementData(\DOMElement $element, bool $saveData = false): array; /** * Returns the identifier of the given `import` element. @@ -274,13 +275,13 @@ XML; * @param \DOMElement|null $oldElement XML element with old data */ protected function saveObject(\DOMElement $newElement, \DOMElement $oldElement = null) { - $newElementData = $this->getElementData($newElement); + $newElementData = $this->getElementData($newElement, true); if ($oldElement === null) { call_user_func([$this->className, 'create'], $newElementData); } else { - $sqlData = $this->findExistingItem($this->getElementData($oldElement)); + $sqlData = $this->findExistingItem($this->getElementData($oldElement, true)); $statement = WCF::getDB()->prepareStatement($sqlData['sql']); $statement->execute($sqlData['parameters']); diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php index 567a4dbc24..1113d20b62 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php @@ -473,7 +473,7 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'name' => $element->getAttribute('name'), 'packageID' => $this->installation->getPackage()->packageID, diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php index cdfc2526d9..63ea0a9cda 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -130,7 +130,7 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = parent::getElementData($element); $icon = $element->getElementsByTagName('icon')->item(0); diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php index f51212d5c0..1ed2ff7d8a 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php @@ -114,7 +114,7 @@ class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInsta * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'className' => $element->getElementsByTagName('classname')->item(0)->nodeValue, 'packageID' => $this->installation->getPackage()->packageID, diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php index 7da7c0c57a..3674059014 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractMenuPackageInstallationPlugin.class.php @@ -264,7 +264,7 @@ abstract class AbstractMenuPackageInstallationPlugin extends AbstractXMLPackageI * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'menuItem' => $element->getAttribute('name'), 'packageID' => $this->installation->getPackage()->packageID diff --git a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php index 8df69bdb87..d13512128d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CoreObjectPackageInstallationPlugin.class.php @@ -128,7 +128,7 @@ class CoreObjectPackageInstallationPlugin extends AbstractXMLPackageInstallation * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { return [ 'objectName' => $element->getElementsByTagName('objectname')->item(0)->nodeValue, 'packageID' => $this->installation->getPackage()->packageID diff --git a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php index 957d44cfe0..48b959ffd5 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php @@ -250,7 +250,7 @@ class CronjobPackageInstallationPlugin extends AbstractXMLPackageInstallationPlu * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'className' => $element->getElementsByTagName('classname')->item(0)->nodeValue, 'cronjobName' => $element->getAttribute('name'), diff --git a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php index cd3cf9a30c..bb8ab37279 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php @@ -175,7 +175,7 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'name' => $element->getAttribute('name'), 'packageID' => $this->installation->getPackage()->packageID, diff --git a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php index df9c504a99..d8404f7d4c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypeDefinitionPackageInstallationPlugin.class.php @@ -169,7 +169,7 @@ class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageIn * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'definitionName' => $element->getElementsByTagName('name')->item(0)->nodeValue, 'packageID' => $this->installation->getPackage()->packageID 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 19463ffbf2..1e5970e401 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ObjectTypePackageInstallationPlugin.class.php @@ -70,7 +70,7 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation /** * @var string[] */ - public $definitionNamesWithInterface = []; + public $definitionInterfaces = []; /** * Returns the id of the object type definition with the given name. @@ -161,7 +161,7 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation public function getAdditionalTemplateCode(): string { return WCF::getTPL()->fetch('__objectTypePipGui', 'wcf', [ 'definitionNames' => $this->definitionNames, - 'definitionNamesWithInterface' => $this->definitionNamesWithInterface + 'definitionInterfaces' => $this->definitionInterfaces ], true); } @@ -169,7 +169,7 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'definitionID' => $this->getDefinitionID($element->getElementsByTagName('definitionname')->item(0)->nodeValue), 'objectType' => $element->getElementsByTagName('name')->item(0)->nodeValue, @@ -190,7 +190,12 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation } } - $data['additionalData'] = serialize($additionalData); + if ($saveData) { + $data['additionalData'] = serialize($additionalData); + } + else { + $data = array_merge($additionalData, $data); + } return $data; } @@ -209,7 +214,7 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation $this->definitionNames[$definition->definitionID] = $definition->definitionName; if ($definition->interfaceName) { - $this->definitionNamesWithInterface[$definition->definitionID] = $definition->interfaceName; + $this->definitionInterfaces[$definition->definitionID] = $definition->interfaceName; } } @@ -284,7 +289,7 @@ class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallation $form->getNodeById('className')->addDependency( ValueFormFieldDependency::create('definitionID') ->field($definitionID) - ->values(array_keys($this->definitionNamesWithInterface)) + ->values(array_keys($this->definitionInterfaces)) ); // add object type-specific fields @@ -656,7 +661,7 @@ XML; ->addDependency( ValueFormFieldDependency::create('definitionID') ->field($definitionIDField) - ->values([$definitionName]) + ->values([ObjectTypeCache::getInstance()->getDefinitionByName($definitionName)->definitionID]) ); $form->appendChild($formContainer); diff --git a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php index 45bdc07d6e..e9f53ff73c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php @@ -145,7 +145,7 @@ class PIPPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { return [ 'className' => $element->nodeValue, 'pluginName' => $element->getAttribute('name'), diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php index f37381b799..0b7ab8e977 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php @@ -309,7 +309,7 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { return [ 'environment' => $element->getElementsByTagName('environment')->item(0)->nodeValue, 'eventName' => $element->getElementsByTagName('eventname')->item(0)->nodeValue, diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php index 7a25cba247..e43a0ae0ab 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php @@ -126,7 +126,7 @@ class UserMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationP * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = parent::getElementData($element); $className = $element->getElementsByTagName('classname')->item(0); diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php index f2a05d622c..f9356f3de9 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php @@ -277,7 +277,7 @@ class UserNotificationEventPackageInstallationPlugin extends AbstractXMLPackageI * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'className' => $element->getElementsByTagName('classname')->item(0)->nodeValue, 'objectTypeID' => $this->getObjectTypeID($element->getElementsByTagName('objecttype')->item(0)->nodeValue), diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php index 28084cb983..891d9fc247 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserProfileMenuPackageInstallationPlugin.class.php @@ -175,7 +175,7 @@ class UserProfileMenuPackageInstallationPlugin extends AbstractXMLPackageInstall * @inheritDoc * @since 3.2 */ - protected function getElementData(\DOMElement $element): array { + protected function getElementData(\DOMElement $element, bool $saveData = false): array { $data = [ 'className' => $element->getElementsByTagName('classname')->item(0)->nodeValue, 'menuItem' => $element->getAttribute('name'),