From: Matthias Schmidt Date: Fri, 12 Aug 2011 21:03:12 +0000 (+0200) Subject: Renamed group option types X-Git-Tag: 2.0.0_Beta_1~1858^2~8 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=906d90dfaf4d8600959e76c53fdd03f816d20f4a;p=GitHub%2FWoltLab%2FWCF.git Renamed group option types --- diff --git a/wcfsetup/install/files/lib/system/option/group/BooleanGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/BooleanGroupOptionType.class.php new file mode 100644 index 0000000000..44b122f413 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/BooleanGroupOptionType.class.php @@ -0,0 +1,27 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class BooleanGroupOptionType extends BooleanOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + foreach ($values as $value) { + if ($value) return true; + } + + return false; + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeBoolean.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeBoolean.class.php deleted file mode 100644 index 09bcbfad03..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeBoolean.class.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeBoolean extends OptionTypeBoolean implements IGroupOptionType { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - foreach ($values as $value) { - if ($value) return true; - } - - return false; - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeGroups.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeGroups.class.php deleted file mode 100644 index 0203fc9da2..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeGroups.class.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeGroups extends AbstractOptionType implements IGroupOptionType { - /** - * @see wcf\system\option\IOptionType::getFormElement() - */ - public function getFormElement(Option $option, $value) { - // get selected group - $selectedGroups = explode(',', $value); - - // get all groups - $groups = UserGroup::getGroupsByType(); - - // generate html - $html = ''; - foreach ($groups as $group) { - $html .= ''; - } - - return $html; - } - - /** - * @see wcf\system\option\IOptionType::validate() - */ - public function validate(Option $option, $newValue) { - // get all groups - $groups = UserGroup::getGroupsByType(); - - // get new value - if (!is_array($newValue)) $newValue = array(); - $selectedGroups = ArrayUtil::toIntegerArray($newValue); - - // check groups - foreach ($selectedGroups as $groupID) { - if (!isset($groups[$groupID])) { - throw new UserInputException($option->optionName, 'validationFailed'); - } - } - } - - /** - * @see wcf\system\option\IOptionType::getData() - */ - public function getData(Option $option, $newValue) { - if (!is_array($newValue)) $newValue = array(); - $newValue = ArrayUtil::toIntegerArray($newValue); - sort($newValue, SORT_NUMERIC); - return implode(',', $newValue); - } - - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - $result = array(); - foreach ($values as $value) { - $value = explode(',', $value); - $result = array_merge($result, $value); - } - - $result = array_unique($result); - - return implode(',', $result); - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInteger.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInteger.class.php deleted file mode 100644 index 6b093c0c76..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInteger.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeInfiniteInteger extends GroupOptionTypeInteger { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - if (in_array(-1, $values)) return -1; - return parent::merge($values); - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInverseInteger.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInverseInteger.class.php deleted file mode 100644 index cc2cd22054..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInfiniteInverseInteger.class.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeInfiniteInverseInteger extends GroupOptionTypeInverseinteger { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - foreach ($values as $key => $value) { - if ($value == -1) unset($values[$key]); - } - - if (count($values) == 0) return -1; - return min($values); - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInteger.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInteger.class.php deleted file mode 100644 index b70913e119..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInteger.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeInteger extends OptionTypeInteger implements IGroupOptionType { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - return max($values); - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInverseInteger.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInverseInteger.class.php deleted file mode 100644 index 8169a75534..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeInverseInteger.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeInverseInteger extends OptionTypeInteger implements IGroupOptionType { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - return min($values); - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeText.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeText.class.php deleted file mode 100644 index 826b9746ad..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeText.class.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeText extends OptionTypeText implements IGroupOptionType { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - $result = ''; - - foreach ($values as $value) { - if (!empty($result)) $result .= "\n"; - $result .= $value; - } - - return $result; - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeTextarea.class.php b/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeTextarea.class.php deleted file mode 100644 index 5685a19d9e..0000000000 --- a/wcfsetup/install/files/lib/system/option/group/GroupOptionTypeTextarea.class.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.option.group - * @category Community Framework - */ -class GroupOptionTypeTextarea extends OptionTypeTextarea implements IGroupOptionType { - /** - * @see wcf\system\option\group\IGroupOptionType::merge() - */ - public function merge(array $values) { - $result = ''; - - foreach ($values as $value) { - if (!empty($result)) $result .= "\n"; - $result .= $value; - } - - return $result; - } -} diff --git a/wcfsetup/install/files/lib/system/option/group/GroupsGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/GroupsGroupOptionType.class.php new file mode 100644 index 0000000000..ffae580206 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/GroupsGroupOptionType.class.php @@ -0,0 +1,82 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class GroupsGroupOptionType extends AbstractOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\IOptionType::getFormElement() + */ + public function getFormElement(Option $option, $value) { + // get selected group + $selectedGroups = explode(',', $value); + + // get all groups + $groups = UserGroup::getGroupsByType(); + + // generate html + $html = ''; + foreach ($groups as $group) { + $html .= ''; + } + + return $html; + } + + /** + * @see wcf\system\option\IOptionType::validate() + */ + public function validate(Option $option, $newValue) { + // get all groups + $groups = UserGroup::getGroupsByType(); + + // get new value + if (!is_array($newValue)) $newValue = array(); + $selectedGroups = ArrayUtil::toIntegerArray($newValue); + + // check groups + foreach ($selectedGroups as $groupID) { + if (!isset($groups[$groupID])) { + throw new UserInputException($option->optionName, 'validationFailed'); + } + } + } + + /** + * @see wcf\system\option\IOptionType::getData() + */ + public function getData(Option $option, $newValue) { + if (!is_array($newValue)) $newValue = array(); + $newValue = ArrayUtil::toIntegerArray($newValue); + sort($newValue, SORT_NUMERIC); + return implode(',', $newValue); + } + + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + $result = array(); + foreach ($values as $value) { + $value = explode(',', $value); + $result = array_merge($result, $value); + } + + $result = array_unique($result); + + return implode(',', $result); + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/IGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/IGroupOptionType.class.php index 8dc31f76dd..77a64cb6c6 100644 --- a/wcfsetup/install/files/lib/system/option/group/IGroupOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/group/IGroupOptionType.class.php @@ -17,7 +17,7 @@ interface IGroupOptionType extends IOptionType { * Merges the different values of an option to a single value. * * @param array $values - * @return mixed $value + * @return mixed */ public function merge(array $values); } diff --git a/wcfsetup/install/files/lib/system/option/group/InfiniteIntegerGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/InfiniteIntegerGroupOptionType.class.php new file mode 100644 index 0000000000..c88b2b2eee --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/InfiniteIntegerGroupOptionType.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class InfiniteIntegerGroupOptionType extends IntegerGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + if (in_array(-1, $values)) return -1; + return parent::merge($values); + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/InfiniteInverseIntegerGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/InfiniteInverseIntegerGroupOptionType.class.php new file mode 100644 index 0000000000..18d24fbff6 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/InfiniteInverseIntegerGroupOptionType.class.php @@ -0,0 +1,27 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class InfiniteInverseIntegerGroupOptionType extends InverseIntegerGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + foreach ($values as $key => $value) { + if ($value == -1) unset($values[$key]); + } + + if (count($values) == 0) return -1; + return min($values); + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/IntegerGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/IntegerGroupOptionType.class.php new file mode 100644 index 0000000000..c618038225 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/IntegerGroupOptionType.class.php @@ -0,0 +1,23 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class IntegerGroupOptionType extends IntegerOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + return max($values); + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/InverseIntegerGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/InverseIntegerGroupOptionType.class.php new file mode 100644 index 0000000000..5f0192ad5f --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/InverseIntegerGroupOptionType.class.php @@ -0,0 +1,23 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class InverseIntegerGroupOptionType extends IntegerOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + return min($values); + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/TextGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/TextGroupOptionType.class.php new file mode 100644 index 0000000000..c33c385e78 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/TextGroupOptionType.class.php @@ -0,0 +1,30 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class TextGroupOptionType extends TextOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + $result = ''; + + foreach ($values as $value) { + if (!empty($result)) $result .= "\n"; + $result .= $value; + } + + return $result; + } +} diff --git a/wcfsetup/install/files/lib/system/option/group/TextareaGroupOptionType.class.php b/wcfsetup/install/files/lib/system/option/group/TextareaGroupOptionType.class.php new file mode 100644 index 0000000000..5c35a90370 --- /dev/null +++ b/wcfsetup/install/files/lib/system/option/group/TextareaGroupOptionType.class.php @@ -0,0 +1,30 @@ + + * @package com.woltlab.wcf + * @subpackage system.option.group + * @category Community Framework + */ +class TextareaGroupOptionType extends TextareaOptionType implements IGroupOptionType { + /** + * @see wcf\system\option\group\IGroupOptionType::merge() + */ + public function merge(array $values) { + $result = ''; + + foreach ($values as $value) { + if (!empty($result)) $result .= "\n"; + $result .= $value; + } + + return $result; + } +}