From 12445303f7c7f0d9e564d14baf76e4b671c6a41e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 29 Sep 2011 21:25:23 +0200 Subject: [PATCH] i18n now working for textareas Changes some more fields to support i18n. Meanwhile textareas with enabled i18n support may look a bit weird, @Luzifr will be fixing this within time. --- com.woltlab.wcf/option.xml | 6 ++- .../acp/templates/optionTypeTextareaI18n.tpl | 10 +++++ .../option/TextI18nOptionType.class.php | 10 +++++ .../option/TextareaI18nOptionType.class.php | 45 +++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 wcfsetup/install/files/acp/templates/optionTypeTextareaI18n.tpl create mode 100644 wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php diff --git a/com.woltlab.wcf/option.xml b/com.woltlab.wcf/option.xml index 17fcb33fe1..b1e5d6a5c4 100644 --- a/com.woltlab.wcf/option.xml +++ b/com.woltlab.wcf/option.xml @@ -117,7 +117,8 @@ diff --git a/wcfsetup/install/files/acp/templates/optionTypeTextareaI18n.tpl b/wcfsetup/install/files/acp/templates/optionTypeTextareaI18n.tpl new file mode 100644 index 0000000000..ecc8981bc2 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/optionTypeTextareaI18n.tpl @@ -0,0 +1,10 @@ + + diff --git a/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php index 05a2bf2c8a..5283210001 100644 --- a/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/TextI18nOptionType.class.php @@ -4,6 +4,16 @@ use wcf\data\option\Option; use wcf\system\language\I18nHandler; use wcf\system\WCF; +/** + * TextI18nOptionType is an implementation of IOptionType for 'input type="text"' tags with i18n support. + * + * @author Alexander Ebert + * @copyright 2001-2011 WoltLab GmbH + * @license GNU Lesser General Public License + * @package com.woltlab.wcf + * @subpackage system.option + * @category Community Framework + */ class TextI18nOptionType extends TextOptionType { /** * @see wcf\system\option\AbstractOptionType::$supportI18n diff --git a/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php new file mode 100644 index 0000000000..b63366f03e --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/TextareaI18nOptionType.class.php @@ -0,0 +1,45 @@ + + * @package com.woltlab.wcf + * @subpackage system.option + * @category Community Framework + */ +class TextareaI18nOptionType extends TextareaOptionType { + /** + * @see wcf\system\option\AbstractOptionType::$supportI18n + */ + protected $supportI18n = true; + + /** + * @see wcf\system\option\IOptionType::getFormElement() + */ + public function getFormElement(Option $option, $value) { + $useRequestData = (count($_POST)) ? true : false; + I18nHandler::getInstance()->assignVariables($useRequestData); + + WCF::getTPL()->assign(array( + 'option' => $option, + 'value' => $value + )); + return WCF::getTPL()->fetch('optionTypeTextareaI18n'); + } + + /** + * @see wcf\system\option\IOptionType::validate() + */ + public function validate(Option $option, $newValue) { + if (!I18nHandler::getInstance()->validateValue($option->optionName)) { + throw new UserInputException($option->optionName, 'validationFailed'); + } + } +} -- 2.20.1