From: Marcel Werk Date: Tue, 9 Aug 2011 18:08:57 +0000 (+0200) Subject: Added function to give option type form elements a special CSS class X-Git-Tag: 2.0.0_Beta_1~1895 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=58aea1e499061b21f068769af1fac8a9b5f29ce6;p=GitHub%2FWoltLab%2FWCF.git Added function to give option type form elements a special CSS class --- diff --git a/wcfsetup/install/files/acp/templates/optionFieldList.tpl b/wcfsetup/install/files/acp/templates/optionFieldList.tpl index 68f865b3c9..babdc0eca4 100644 --- a/wcfsetup/install/files/acp/templates/optionFieldList.tpl +++ b/wcfsetup/install/files/acp/templates/optionFieldList.tpl @@ -6,7 +6,7 @@ {assign var=error value=''} {/if}
-
+
{@$optionData[html]} {if $error} diff --git a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php index af830cf6d7..ded1777342 100755 --- a/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractOptionListForm.class.php @@ -367,7 +367,8 @@ abstract class AbstractOptionListForm extends AbstractForm { // add option to list $children[] = array( 'object' => $option, - 'html' => $html + 'html' => $html, + 'cssClassName' => $this->getTypeObject($option->optionType)->getCSSClassName() ); $i++; diff --git a/wcfsetup/install/files/lib/system/option/AbstractOptionType.class.php b/wcfsetup/install/files/lib/system/option/AbstractOptionType.class.php new file mode 100644 index 0000000000..ce2eb93277 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/AbstractOptionType.class.php @@ -0,0 +1,34 @@ + + * @package com.woltlab.wcf + * @subpackage system.option + * @category Community Framework + */ +abstract class AbstractOptionType implements IOptionType { + /** + * @see wcf\system\option\IOptionType::validate() + */ + public function validate(Option $option, $newValue) {} + + /** + * @see wcf\system\option\IOptionType::getData() + */ + public function getData(Option $option, $newValue) { + return $newValue; + } + + /** + * @see wcf\system\option\IOptionType::getCSSClassName() + */ + public function getCSSClassName() { + return ''; + } +} diff --git a/wcfsetup/install/files/lib/system/option/IOptionType.class.php b/wcfsetup/install/files/lib/system/option/IOptionType.class.php index 9ec93a3923..a2064f2c29 100644 --- a/wcfsetup/install/files/lib/system/option/IOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/IOptionType.class.php @@ -39,4 +39,11 @@ interface IOptionType { * @return string */ public function getData(Option $option, $newValue); + + /** + * Returns css class name for this form element. + * + * @return string + */ + public function getCSSClassName(); } diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php index 09266fcc9f..0c755add3b 100644 --- a/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php @@ -15,7 +15,7 @@ use wcf\util\StringUtil; * @subpackage system.option * @category Community Framework */ -class OptionTypeBoolean implements IOptionType, ISearchableUserOption { +class OptionTypeBoolean extends AbstractOptionType implements ISearchableUserOption { /** * @see wcf\system\option\IOptionType::getFormElement() */ @@ -31,11 +31,6 @@ class OptionTypeBoolean implements IOptionType, ISearchableUserOption { return WCF::getTPL()->fetch('optionTypeBoolean'); } - /** - * @see wcf\system\option\IOptionType::validate() - */ - public function validate(Option $option, $newValue) {} - /** * @see wcf\system\option\IOptionType::getData() */ @@ -44,6 +39,13 @@ class OptionTypeBoolean implements IOptionType, ISearchableUserOption { return 0; } + /** + * @see wcf\system\option\IOptionType::getCSSClassName() + */ + public function getCSSClassName() { + return 'reversed'; + } + /** * @see wcf\system\option\ISearchableUserOption::getSearchFormElement() */ diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php index 2569a94b78..b313b8dc6a 100644 --- a/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php @@ -18,7 +18,7 @@ use wcf\util\DateUtil; * @subpackage system.option * @category Community Framework */ -class OptionTypeDate implements IOptionType, ISearchableUserOption { +class OptionTypeDate extends AbstractOptionType implements ISearchableUserOption { protected $yearRequired = true; /** diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php index ed8d524bc8..257e8a21cd 100644 --- a/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php @@ -18,7 +18,7 @@ use wcf\util\StringUtil; * @subpackage system.option * @category Community Framework */ -class OptionTypeRadiobuttons implements IOptionType, ISearchableUserOption { +class OptionTypeRadiobuttons extends AbstractOptionType implements ISearchableUserOption { public $templateName = 'optionTypeRadiobuttons'; /** @@ -63,13 +63,6 @@ class OptionTypeRadiobuttons implements IOptionType, ISearchableUserOption { } } - /** - * @see wcf\system\option\IOptionType::getData() - */ - public function getData(Option $option, $newValue) { - return $newValue; - } - /** * @see wcf\system\option\ISearchableUserOption::getSearchFormElement() */ diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php index c555aaf7f0..381c7d6ede 100644 --- a/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php @@ -17,7 +17,7 @@ use wcf\util\StringUtil; * @subpackage system.option * @category Community Framework */ -class OptionTypeText implements IOptionType, ISearchableUserOption { +class OptionTypeText extends AbstractOptionType implements ISearchableUserOption { /** * input type * @var string @@ -36,18 +36,6 @@ class OptionTypeText implements IOptionType, ISearchableUserOption { return WCF::getTPL()->fetch('optionTypeText'); } - /** - * @see wcf\system\option\IOptionType::validate() - */ - public function validate(Option $option, $newValue) {} - - /** - * @see wcf\system\option\IOptionType::getData() - */ - public function getData(Option $option, $newValue) { - return $newValue; - } - /** * @see wcf\system\option\ISearchableUserOption::getSearchFormElement() */ diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php index 2b3f521d78..cde2c56688 100644 --- a/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php +++ b/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php @@ -16,7 +16,7 @@ use wcf\util\DateUtil; * @subpackage system.option * @category Community Framework */ -class OptionTypeTimezone implements IOptionType { +class OptionTypeTimezone extends AbstractOptionType { /** * @see wcf\system\option\IOptionType::getFormElement() */ @@ -42,11 +42,4 @@ class OptionTypeTimezone implements IOptionType { throw new UserInputException($option->optionName, 'validationFailed'); } } - - /** - * @see wcf\system\option\IOptionType::getData() - */ - public function getData(Option $option, $newValue) { - return $newValue; - } }