Add default description for class name form fields with required interface
authorMatthias Schmidt <gravatronics@live.com>
Tue, 8 May 2018 06:07:50 +0000 (08:07 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 8 May 2018 06:07:50 +0000 (08:07 +0200)
See #2509

wcfsetup/install/files/lib/system/form/builder/field/ClassNameFormField.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 4372cf608c77d23b68cc4d35812ec1bd0c4c8432..25f06a8b0efe70cee9a5dde982491ccb0be7d518 100644 (file)
@@ -103,7 +103,11 @@ class ClassNameFormField extends TextFormField {
        }
        
        /**
-        * Returns the name of the interface the entered class must implement.
+        * Sets the name of the interface the entered class must implement and returns
+        * this field.
+        * 
+        * If no description has been set yet, `wcf.form.field.className.description.interface`
+        * is automatically used for the description.
         * 
         * @param       string          $interface      name of the interface the entered class must implement
         * @return      static                          this field
@@ -117,6 +121,13 @@ class ClassNameFormField extends TextFormField {
                
                $this->__implementedInterface = $interface;
                
+               if ($this->getDescription() === null) {
+                       $this->description(
+                               'wcf.form.field.className.description.interface',
+                               ['interface' => $this->__implementedInterface]
+                       );
+               }
+               
                return $this;
        }
        
index de68659dc0aa2f6f1e4c16a74dc94c0d669ff5f7..d414f7aa9aeae73979d225c8fd80ecd4a7d24e9d 100644 (file)
@@ -3018,6 +3018,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *}
        
        <category name="wcf.form">
                <item name="wcf.form.field.className"><![CDATA[Klasse]]></item>
+               <item name="wcf.form.field.className.description.interface"><![CDATA[Die angegebene Klasse (ohne Backslash als erstes Zeichen) muss das Interface <code>{$interface}</code> implementieren.]]></item>
                <item name="wcf.form.field.className.error.interface"><![CDATA[Die angegebene Klasse{if $language|isset} ({$language}){/if} implementiert nicht das Interface <code>{$interface}</code>.]]></item>
                <item name="wcf.form.field.className.error.isInstantiable"><![CDATA[Die angegebene Klasse{if $language|isset} ({$language}){/if} ist nicht instanziierbar.]]></item>
                <item name="wcf.form.field.className.error.leadingBackslash"><![CDATA[Die angegebene Klasse{if $language|isset} ({$language}){/if} darf keinen führenden Backslash besitzen.]]></item>
index 0da26790d6144fe137d74b10f29e90ffe10c85b0..841a656415081f65847fb608a36e8dd3aad08cbc 100644 (file)
@@ -2964,6 +2964,7 @@ Email: {@$emailAddress} {* this line ends with a space *}
        
        <category name="wcf.form">
                <item name="wcf.form.field.className"><![CDATA[Class]]></item>
+               <item name="wcf.form.field.className.description.interface"><![CDATA[The entered class (without leading backslash) must implement the interface <code>{$interface}</code>.]]></item>
                <item name="wcf.form.field.className.error.interface"><![CDATA[The entered class{if $language|isset} ({$language}){/if} does not implement the interface <code>{$interface}</code>.]]></item>
                <item name="wcf.form.field.className.error.isInstantiable"><![CDATA[The entered class{if $language|isset} ({$language}){/if} is not instantiable.]]></item>
                <item name="wcf.form.field.className.error.leadingBackslash"><![CDATA[The entered class name{if $language|isset} ({$language}){/if} must not have a leading backslash.]]></item>