* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package WoltLabSuite\Core\System\Devtools\Pip
* @since 3.2
+ *
+ * @property PackageInstallationDispatcher|DevtoolsPackageInstallationDispatcher $installation
*/
trait TXmlGuiPackageInstallationPlugin {
/**
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\exception\SystemException;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\SingleSelectionFormField;
use wcf\system\form\builder\field\TextFormField;
}
}));
- $form->getNodeById('data')->appendChildren([$nameFormField, $objectTypeFormField]);
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([$nameFormField, $objectTypeFormField]);
if ($this->entryType === 'options') {
$categoryList = new ACLOptionCategoryList();
->values([$objectType])
);
- $form->getNodeById('data')->appendChild($categoryNameField);
+ $dataContainer->appendChild($categoryNameField);
}
}
}
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
+ $data = $form->getData()['data'];
+
$acpSearchProvider = $document->createElement('acpsearchprovider');
- $acpSearchProvider->setAttribute('name', $form->getNodeById('providerName')->getSaveValue());
- $acpSearchProvider->appendChild($document->createElement('classname', $form->getNodeById('className')->getSaveValue()));
+ $acpSearchProvider->setAttribute('name', $data['providerName']);
+ $acpSearchProvider->appendChild($document->createElement('classname', $data['classname']));
/** @var IntegerFormField $showOrder */
- $showOrder = $form->getNodeById('showOrder');
- if ($showOrder->getSaveValue()) {
- $acpSearchProvider->appendChild($document->createElement('showorder', (string) $showOrder->getSaveValue()));
+ if (!empty($data['showOrder'])) {
+ $acpSearchProvider->appendChild($document->createElement('showorder', (string) $data['showorder']));
}
$document->getElementsByTagName('import')->item(0)->appendChild($acpSearchProvider);
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
+ $data = $form->getData()['data'];
+
$coreObject = $document->createElement($this->tagName);
- $coreObject->appendChild($document->createElement('objectname', $form->getNodeById('objectName')->getSaveValue()));
+ $coreObject->appendChild($document->createElement('objectname', $data['objectname']));
$document->getElementsByTagName('import')->item(0)->appendChild($coreObject);
use wcf\system\devtools\pip\IDevtoolsPipEntryList;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\ClassNameFormField;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\form\builder\field\TextFormField;
* @since 3.2
*/
public function addFormFields(IFormDocument $form) {
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('name')
->label('wcf.acp.pip.mediaProvider.name')
->description('wcf.acp.pip.mediaProvider.name.description')
->label('wcf.acp.pip.mediaProvider.html')
->description('wcf.acp.pip.mediaProvider.html.description')
->addValidator(new FormFieldValidator('noClassName', function(MultilineTextFormField $formField) {
- if ($formField->getSaveValue() && $formField->getDocument()->getNodeById('className')->getSaveValue()) {
+ /** @var ClassNameFormField $className */
+ $className = $formField->getDocument()->getNodeById('className');
+
+ if ($formField->getSaveValue() && $className->getSaveValue()) {
$formField->addValidationError(
new FormFieldValidationError(
'className',
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
+ $data = $form->getData()['data'];
+
$provider = $document->createElement($this->tagName);
- $provider->setAttribute('name', $form->getNodeById('name')->getSaveValue());
+ $provider->setAttribute('name', $data['name']);
- $provider->appendChild($document->createElement('title', $form->getNodeById('title')->getSaveValue()));
+ $provider->appendChild($document->createElement('title', $data['title']));
$regex = $document->createElement('regex');
$regex->appendChild($document->createCDATASection(
- StringUtil::escapeCDATA(StringUtil::unifyNewlines($form->getNodeById('regex')->getSaveValue()))
+ StringUtil::escapeCDATA(StringUtil::unifyNewlines($data['regex']))
));
$provider->appendChild($regex);
- $html = $form->getNodeById('html')->getSaveValue();
- if ($html) {
- $htmlElement = $document->createElement('regex');
- $htmlElement->appendChild($document->createCDATASection(StringUtil::escapeCDATA($html)));
+ if (!empty($data['html'])) {
+ $htmlElement = $document->createElement('html');
+ $htmlElement->appendChild($document->createCDATASection(StringUtil::escapeCDATA($data['html'])));
$provider->appendChild($htmlElement);
}
- $className = $form->getNodeById('className')->getSaveValue();
- if ($className) {
- $provider->appendChild($document->createElement('className', $className));
+ if (!empty($data['className'])) {
+ $provider->appendChild($document->createElement('className', $data['className']));
}
$document->getElementsByTagName('import')->item(0)->appendChild($provider);
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\exception\SystemException;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\BooleanFormField;
use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
* @since 3.2
*/
public function addFormFields(IFormDocument $form) {
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('identifier')
->label('wcf.acp.pip.menu.identifier')
->description('wcf.acp.pip.menu.identifier.description')
use wcf\system\devtools\pip\IDevtoolsPipEntryList;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
use wcf\system\form\builder\field\TextFormField;
* @since 3.2
*/
public function addFormFields(IFormDocument $form) {
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('name')
->label('wcf.acp.pip.objectTypeDefinition.definitionName')
->description('wcf.acp.pip.objectTypeDefinition.definitionName.description', ['project' => $this->installation->getProject()])
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
+ $data = $form->getData()['data'];
+
$definition = $document->createElement('definition');
- $definition->appendChild($document->createElement('name', $form->getNodeById('name')->getSaveValue()));
+ $definition->appendChild($document->createElement('name', $data['name']));
- /** @var TextFormField $interfaceName */
- $interfaceName = $form->getNodeById('interfaceName');
- if ($interfaceName->getSaveValue()) {
- $definition->appendChild($document->createElement('interfacename', $interfaceName->getSaveValue()));
+ if (!empty($data['interfacename'])) {
+ $definition->appendChild($document->createElement('interfacename', $data['interfacename']));
}
$import = $document->getElementsByTagName('import')->item(0);
}
// add default form fields
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
SingleSelectionFormField::create('definitionID')
->label('wcf.acp.pip.objectType.definitionName')
->description('<!-- will be replaced by JavaScript -->')
->required()
->addValidator(self::getObjectTypeAlikeValueValidator('wcf.acp.pip.objectType.objectType'))
->addValidator(new FormFieldValidator('uniqueness', function(TextFormField $formField) {
- $definitionID = $formField->getDocument()->getNodeById('definitionID')->getValue();
+ /** @var SingleSelectionFormField $definitionIDField */
+ $definitionIDField = $formField->getDocument()->getNodeById('definitionID');
+
+ $definitionID = $definitionIDField->getSaveValue();
if ($definitionID) {
$definition = ObjectTypeCache::getInstance()->getDefinition($definitionID);
->description('<!-- will be replaced by JavaScript -->')
->required()
->addValidator(new FormFieldValidator('implementsInterface', function(TextFormField $formField) {
- $definitionID = $formField->getDocument()->getNodeById('definitionID')->getValue();
+ /** @var SingleSelectionFormField $definitionIDField */
+ $definitionIDField = $formField->getDocument()->getNodeById('definitionID');
+
+ $definitionID = $definitionIDField->getSaveValue();
if ($definitionID) {
$definition = ObjectTypeCache::getInstance()->getDefinition($definitionID);
return $nestedOptions;
}, true)
->addValidator(new FormFieldValidator('selfParent', function(SingleSelectionFormField $formField) {
- if ($formField->getDocument()->getNodeById('identifier')->getValue() === $formField->getValue()) {
+ /** @var TextFormField $identifier */
+ $identifier = $formField->getDocument()->getNodeById('identifier');
+
+ if ($identifier->getSaveValue() === $formField->getValue()) {
$formField->addValidationError(
new FormFieldValidationError(
'selfParent',
'metaKeywords' => []
];
- /** @var \DOMElement $title */
+ /** @var \DOMElement $name */
foreach ($element->getElementsByTagName('name') as $name) {
$data['name'][LanguageFactory::getInstance()->getLanguageByCode($name->getAttribute('language'))->languageID] = $name->nodeValue;
}
use wcf\system\devtools\pip\IDevtoolsPipEntryList;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\field\validation\FormFieldValidator;
$acpTemplateEvents = $getEvents($acpTemplateList);
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('name')
->label('wcf.acp.pip.templateListener.name')
->description('wcf.acp.pip.templateListener.name.description')
]);
foreach ($templateEvents as $templateName => $events) {
- $form->getNodeById('data')->appendChild(
+ $dataContainer->appendChild(
SingleSelectionFormField::create($templateName . '_eventName')
->objectProperty('eventname')
->label('wcf.acp.pip.templateListener.eventName')
}
foreach ($acpTemplateEvents as $templateName => $events) {
- $form->getNodeById('data')->appendChild(
+ $dataContainer->appendChild(
SingleSelectionFormField::create('acp_' . $templateName . '_eventName')
->objectProperty('eventname')
->label('wcf.acp.pip.templateListener.eventName')
);
}
- $form->getNodeById('data')->appendChildren([
+ $dataContainer->appendChildren([
SingleSelectionFormField::create('environment')
->label('wcf.acp.pip.templateListener.environment')
->description('wcf.acp.pip.templateListener.environment.description')
])
->value('user')
->addValidator(new FormFieldValidator('uniqueness', function(SingleSelectionFormField $formField) {
+ /** @var TextFormField $nameField */
+ $nameField = $formField->getDocument()->getNodeById('name');
+
$listenerList = new TemplateListenerList();
$listenerList->getConditionBuilder()->add(
'name = ?',
- [$formField->getDocument()->getNodeById('name')->getSaveValue()]
+ [$nameField->getSaveValue()]
);
if ($formField->getSaveValue() === 'admin') {
- $templateName = $formField->getDocument()->getNodeById('acpTemplateName')->getSaveValue();
- $eventName = $formField->getDocument()->getNodeById('acp_' . $templateName . '_eventName')->getSaveValue();
+ /** @var SingleSelectionFormField $templateNameField */
+ $templateNameField = $formField->getDocument()->getNodeById('acpTemplateName');
+
+ /** @var SingleSelectionFormField $eventNameField */
+ $eventNameField = $formField->getDocument()->getNodeById('acp_' . $templateNameField->getSaveValue() . '_eventName');
}
else {
- $templateName = $formField->getDocument()->getNodeById('templateName')->getSaveValue();
- $eventName = $formField->getDocument()->getNodeById($templateName . '_eventName')->getSaveValue();
+ /** @var SingleSelectionFormField $templateNameField */
+ $templateNameField = $formField->getDocument()->getNodeById('templateName');
+
+ /** @var SingleSelectionFormField $eventNameField */
+ $eventNameField = $formField->getDocument()->getNodeById($templateNameField->getSaveValue() . '_eventName');
}
+ $templateName = $templateNameField->getSaveValue();
+ $eventName = $eventNameField->getSaveValue();
+
$listenerList->getConditionBuilder()->add('templateName = ?', [$templateName]);
$listenerList->getConditionBuilder()->add('eventName = ?', [$eventName]);
$listenerList->getConditionBuilder()->add('environment = ?', [$formField->getSaveValue()]);
if ($listenerList->countObjects() > 0) {
- $formField->getDocument()->getNodeById('name')->addValidationError(
+ $nameField->addValidationError(
new FormFieldValidationError(
'notUnique',
'wcf.acp.pip.templateListener.name.error.notUnique'
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
+ $data = $form->getData()['data'];
+
$listener = $document->createElement($this->tagName);
- $listener->setAttribute('name', $form->getNodeById('name')->getSaveValue());
+ $listener->setAttribute('name', $data['name']);
- $environment = $form->getNodeById('environment')->getSaveValue();
- if ($environment === 'user') {
- $templateName = $form->getNodeById('templateName')->getSaveValue();
+ if ($data['environment'] === 'user') {
+ $templateName = $data['templateName'];
$listener->appendChild($document->createElement('templatename', $templateName));
- $listener->appendChild($document->createElement('eventname', $form->getNodeById($templateName . '_eventName')->getSaveValue()));
+ $listener->appendChild($document->createElement('eventname', $data[$templateName . '_eventName']));
}
else {
- $templateName = $form->getNodeById('acpTemplateName')->getSaveValue();
+ $templateName = $data['acpTemplateName'];
$listener->appendChild($document->createElement('templatename', $templateName));
- $listener->appendChild($document->createElement('eventname', $form->getNodeById('acp_' . $templateName . '_eventName')->getSaveValue()));
+ $listener->appendChild($document->createElement('eventname', $data['acp_' . $templateName . '_eventName']));
}
- $listener->appendChild($document->createElement('templatecode', '<![CDATA[' . StringUtil::unifyNewlines(StringUtil::escapeCDATA($form->getNodeById('templateCode')->getSaveValue())) . ']]>'));
- $listener->appendChild($document->createElement('environment', $environment));
+ $listener->appendChild(
+ $document->createElement(
+ 'templatecode',
+ '<![CDATA[' . StringUtil::unifyNewlines(StringUtil::escapeCDATA($data['templatecode'])) . ']]>'
+ )
+ );
+ $listener->appendChild($document->createElement('environment', $data['environment']));
$document->getElementsByTagName('import')->item(0)->appendChild($listener);
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\exception\SystemException;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\OptionFormField;
use wcf\system\form\builder\field\UserGroupOptionFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
* @since 3.2
*/
public function addFormFields(IFormDocument $form) {
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('name')
->label('wcf.acp.pip.userNotificationEvent.name')
->description('wcf.acp.pip.userNotificationEvent.name.description')
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
- $event = $document->createElement($this->tagName);
-
- $event->appendChild($document->createElement('name', $form->getNodeById('name')->getSaveValue()));
- $event->appendChild($document->createElement('objecttype', $form->getNodeById('objectType')->getSaveValue()));
- $event->appendChild($document->createElement('classname', $form->getNodeById('className')->getSaveValue()));
-
- /** @var ItemListFormField $options */
- $options = $form->getNodeById('options');
- if ($options->getSaveValue()) {
- $event->appendChild($document->createElement('options', $options->getSaveValue()));
- }
+ $data = $form->getData()['data'];
- /** @var ItemListFormField $permissions */
- $permissions = $form->getNodeById('permissions');
- if ($permissions->getSaveValue()) {
- $event->appendChild($document->createElement('permissions', $permissions->getSaveValue()));
- }
+ $event = $document->createElement($this->tagName);
- /** @var BooleanFormField $permissions */
- $preset = $form->getNodeById('preset');
- if ($preset->getSaveValue()) {
- $event->appendChild($document->createElement('preset', '1'));
+ foreach (['name', 'objecttype', 'classname'] as $element) {
+ $event->appendChild(
+ $document->createElement(
+ $element,
+ (string)$data[$element]
+ )
+ );
}
- /** @var BooleanFormField $permissions */
- $presetMailNotificationType = $form->getNodeById('presetMailNotificationType');
- if ($presetMailNotificationType->getSaveValue()) {
- $event->appendChild($document->createElement('presetmailnotificationtype', $presetMailNotificationType->getSaveValue()));
+ foreach (['options', 'permissions', 'preset', 'presetmailnotificationtype'] as $optionalElement) {
+ if (!empty($data[$optionalElement])) {
+ $event->appendChild(
+ $document->createElement(
+ $optionalElement,
+ (string)$data[$optionalElement]
+ )
+ );
+ }
}
$document->getElementsByTagName('import')->item(0)->appendChild($event);
use wcf\system\devtools\pip\IDevtoolsPipEntryList;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
+use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\OptionFormField;
use wcf\system\form\builder\field\UserGroupOptionFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
* @since 3.2
*/
public function addFormFields(IFormDocument $form) {
- $form->getNodeById('data')->appendChildren([
+ /** @var FormContainer $dataContainer */
+ $dataContainer = $form->getNodeById('data');
+
+ $dataContainer->appendChildren([
TextFormField::create('name')
->label('wcf.acp.pip.userProfileMenu.name')
->description('wcf.acp.pip.userProfileMenu.name.description')
* @since 3.2
*/
protected function writeEntry(\DOMDocument $document, IFormDocument $form): \DOMElement {
- $userProfileMenuItem = $document->createElement('userprofilemenuitem');
- $userProfileMenuItem->setAttribute('name', $form->getNodeById('name')->getSaveValue());
- $userProfileMenuItem->appendChild($document->createElement('classname', $form->getNodeById('className')->getSaveValue()));
-
- /** @var ItemListFormField $options */
- $options = $form->getNodeById('options');
- if ($options->getSaveValue()) {
- $userProfileMenuItem->appendChild($document->createElement('options', $options->getSaveValue()));
- }
+ $data = $form->getData()['data'];
- /** @var ItemListFormField $permissions */
- $permissions = $form->getNodeById('permissions');
- if ($permissions->getSaveValue()) {
- $userProfileMenuItem->appendChild($document->createElement('permissions', $permissions->getSaveValue()));
- }
+ $userProfileMenuItem = $document->createElement('userprofilemenuitem');
+ $userProfileMenuItem->setAttribute('name', $data['name']);
+ $userProfileMenuItem->appendChild($document->createElement('classname', $data['className']));
- /** @var IntegerFormField $showOrder */
- $showOrder = $form->getNodeById('showOrder');
- if ($showOrder->getSaveValue()) {
- $userProfileMenuItem->appendChild($document->createElement('showorder', (string) $showOrder->getSaveValue()));
+ foreach (['options', 'permissions', 'showorder'] as $optionalElement) {
+ if (!empty($data[$optionalElement])) {
+ $userProfileMenuItem->appendChild(
+ $document->createElement(
+ $optionalElement,
+ (string)$data[$optionalElement]
+ )
+ );
+ }
}
$import = $document->getElementsByTagName('import')->item(0);