Add missing validation that media provider requires html or class name
authorMatthias Schmidt <gravatronics@live.com>
Wed, 17 Oct 2018 17:05:55 +0000 (19:05 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 17 Oct 2018 17:05:55 +0000 (19:05 +0200)
See #2545

wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php
wcfsetup/install/lang/en.xml

index 46ee6dbf1c3976ebe13a4441f32b1601650a48a1..584e23aae958c63a8d081ced6a906342d76e51e4 100644 (file)
@@ -161,7 +161,7 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat
                        MultilineTextFormField::create('html')
                                ->label('wcf.acp.pip.mediaProvider.html')
                                ->description('wcf.acp.pip.mediaProvider.html.description')
-                               ->addValidator(new FormFieldValidator('noClassName', function(MultilineTextFormField $formField) {
+                               ->addValidator(new FormFieldValidator('className', function(MultilineTextFormField $formField) {
                                        /** @var ClassNameFormField $className */
                                        $className = $formField->getDocument()->getNodeById('className');
                                        
@@ -174,6 +174,19 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat
                                                );
                                        }
                                }))
+                               ->addValidator(new FormFieldValidator('noClassName', function(MultilineTextFormField $formField) {
+                                       /** @var ClassNameFormField $className */
+                                       $className = $formField->getDocument()->getNodeById('className');
+                                       
+                                       if ($formField->getSaveValue() === '' && $className->getSaveValue() === '') {
+                                               $formField->addValidationError(
+                                                       new FormFieldValidationError(
+                                                               'noClassName',
+                                                               'wcf.acp.pip.mediaProvider.html.error.noClassName'
+                                                       )
+                                               );
+                                       }
+                               }))
                ]);
        }
        
index fa67d4a02814bdf8ddfb609b8d5b4715506c663e..727ca31f13d7ba862a9d277dcafbfef1dfca4022 100644 (file)
@@ -1947,7 +1947,8 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
                <item name="wcf.acp.pip.mediaProvider.regex.description"><![CDATA[The entered regular expressions (without delimiters) are used to check if this media provider is responsible for a given link. Each line is treated as its own regular expression.]]></item>
                <item name="wcf.acp.pip.mediaProvider.html"><![CDATA[HTML Code]]></item>
                <item name="wcf.acp.pip.mediaProvider.html.description"><![CDATA[The html code is used to produce the rendered output of the linked media content. Every named group of the regular expression is accessible as <code>{literal}{$name}{/literal}</code> where <code>name</code> is the name of the group.]]></item>
-               <item name="wcf.acp.pip.mediaProvider.html.error.className"><![CDATA[You cannot enter HTML code if you are already using a class that handles the output.]]></item>
+               <item name="wcf.acp.pip.mediaProvider.html.error.className"><![CDATA[You cannot enter HTML code if you have already provided a class that handles the output.]]></item>
+               <item name="wcf.acp.pip.mediaProvider.html.error.noClassName"><![CDATA[You have to provide either HTML code or a class that handles the output.]]></item>
                <item name="wcf.acp.pip.aclOption.categories.name"><![CDATA[Category Name]]></item>
                <item name="wcf.acp.pip.aclOption.categories.name.description"><![CDATA[The name of an ACL option category consists of least two segments separated by dots. Each segment must not be empty and may only contain letters, numbers, underscores, and dashes.]]></item>
                <item name="wcf.acp.pip.aclOption.categories.name.error.invalidSegments"><![CDATA[The following segments are invalid: {implode from=$invalidSegments key=segmentNumber item=segment}{if $segment !== ''}<code>{$segment}</code>{else}(empty){/if} (segment {#$segmentNumber + 1}){/implode}.]]></item>