Work-around for description in non-i18n environments
authorAlexander Ebert <ebert@woltlab.com>
Sat, 26 Sep 2015 13:25:25 +0000 (15:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 26 Sep 2015 13:25:25 +0000 (15:25 +0200)
If there is only a single language installed, the actual content is the
actual content and not a phrase. The `__optional` attribute will cause
`{lang}` to not yield any content at all.

This is pretty much an edge case because we want to suppress
non-existing descriptions to be displayed as a generic phrase.

wcfsetup/install/files/acp/templates/userOptionAdd.tpl

index 5f5d6489fbc4cbfeecda405bbb36eb639ebd4dd4..1aaba8b6168532ce7eabead2835c3f88495b85e0 100644 (file)
                                <dl{if $errorField == 'optionDescription'} class="formError"{/if}>
                                        <dt><label for="optionDescription">{lang}wcf.acp.user.option.description{/lang}</label></dt>
                                        <dd>
-                                               <textarea name="optionDescription" id="optionDescription" cols="40" rows="10">{lang __optional=true}{$i18nPlainValues['optionDescription']}{/lang}</textarea>
+                                               {* dirty work-around for non-i18n environments *}
+                                               {capture assign=__optionDescription}{lang __optional=true}{$i18nPlainValues['optionDescription']}{/lang}{/capture}
+                                               {if !$__optionDescription && !"~^[a-zA-Z0-9\-\_\.]+$~"|preg_match:$i18nPlainValues['optionDescription']}{assign var=__optionDescription value=$i18nPlainValues['optionDescription']}{/if}
+                                               
+                                               <textarea name="optionDescription" id="optionDescription" cols="40" rows="10">{$__optionDescription}</textarea>
                                                {if $errorField == 'optionDescription'}
                                                        <small class="innerError">
                                                                {if $errorType == 'empty'}