From 58aea1e499061b21f068769af1fac8a9b5f29ce6 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 9 Aug 2011 20:08:57 +0200 Subject: [PATCH] Added function to give option type form elements a special CSS class --- .../files/acp/templates/optionFieldList.tpl | 2 +- .../acp/form/AbstractOptionListForm.class.php | 3 +- .../option/AbstractOptionType.class.php | 34 +++++++++++++++++++ .../lib/system/option/IOptionType.class.php | 7 ++++ .../system/option/OptionTypeBoolean.class.php | 14 ++++---- .../system/option/OptionTypeDate.class.php | 2 +- .../option/OptionTypeRadiobuttons.class.php | 9 +---- .../system/option/OptionTypeText.class.php | 14 +------- .../option/OptionTypeTimezone.class.php | 9 +---- 9 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/option/AbstractOptionType.class.php 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; - } } -- 2.20.1