--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\system\option\BooleanOptionType;
+
+/**
+ * BooleanGroupOptionType is an implementation of IGroupOptionType for boolean values.
+ * The merge of option values returns true, if at least one value is true. Otherwise false.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\OptionTypeBoolean;
-
-/**
- * GroupOptionTypeBoolean is an implementation of GroupOptionType for boolean values.
- * The merge of option values returns true, if at least one value is true. Otherwise false.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\data\option\Option;
-use wcf\data\user\group\UserGroup;
-use wcf\system\option\AbstractOptionType;
-use wcf\util\ArrayUtil;
-use wcf\util\StringUtil;
-
-/**
- * GroupOptionTypeGroups generates a select-list of all available user groups.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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 .= '<label><input type="checkbox" name="values['.StringUtil::encodeHTML($option->optionName).'][]" value="'.$group->groupID.'" '.(in_array($group->groupID, $selectedGroups) ? 'checked="checked" ' : '').'/> '.StringUtil::encodeHTML($group->groupName).'</label>';
- }
-
- 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);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-
-/**
- * GroupOptionTypeInfiniteinteger is an implementation of GroupOptionType for integer values with the infinite option.
- * The merge of option values returns true, if at least one value is -1. Otherwise it returns the highest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-
-/**
- * GroupOptionTypeInfiniteinverseinteger is an implementation of GroupOptionType for integer values.
- * The merge of option values returns -1 if all values are -1 otherwise the lowest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\OptionTypeInteger;
-
-/**
- * GroupOptionTypeInteger is an implementation of GroupOptionType for integer values.
- * The merge of option values returns the highest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\OptionTypeInteger;
-
-/**
- * GroupOptionTypeInverseInteger is an implementation of GroupOptionType for integer values.
- * The merge of option values returns the lowest value.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\OptionTypeText;
-
-/**
- * GroupOptionTypeText is an implementation of GroupOptionType for text values.
- * The merge of option values returns merge of all text values.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\option\group;
-use wcf\system\option\OptionTypeTextarea;
-
-/**
- * GroupOptionTypeTextarea is an implementation of GroupOptionType for text values.
- * The merge of option values returns merge of all text values.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\data\option\Option;
+use wcf\data\user\group\UserGroup;
+use wcf\system\option\AbstractOptionType;
+use wcf\util\ArrayUtil;
+use wcf\util\StringUtil;
+
+/**
+ * GroupsGroupOptionType generates a select-list of all available user groups.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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 .= '<label><input type="checkbox" name="values['.StringUtil::encodeHTML($option->optionName).'][]" value="'.$group->groupID.'" '.(in_array($group->groupID, $selectedGroups) ? 'checked="checked" ' : '').'/> '.StringUtil::encodeHTML($group->groupName).'</label>';
+ }
+
+ 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);
+ }
+}
* Merges the different values of an option to a single value.
*
* @param array $values
- * @return mixed $value
+ * @return mixed
*/
public function merge(array $values);
}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+
+/**
+ * InfiniteIntegerGroupOptionType is an implementation of IGroupOptionType for
+ * integer values with the infinite option.
+ * The merge of option values returns true, if at least one value is -1. Otherwise
+ * it returns the highest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+
+/**
+ * InfiniteInverseIntegerGroupOptionType is an implementation of IGroupOptionType for integer values.
+ * The merge of option values returns -1 if all values are -1 otherwise the lowest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\system\option\IntegerOptionType;
+
+/**
+ * IntegerGroupOptionType is an implementation of IGroupOptionType for integer values.
+ * The merge of option values returns the highest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\system\option\IntegerOptionType;
+
+/**
+ * InverseIntegerGroupOptionType is an implementation of IGroupOptionType for integer values.
+ * The merge of option values returns the lowest value.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\system\option\TextOptionType;
+
+/**
+ * TextGroupOptionType is an implementation of IGroupOptionType for text values.
+ * The merge of option values returns merge of all text values.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\group;
+use wcf\system\option\TextareaOptionType;
+
+/**
+ * TextareaGroupOptionType is an implementation of IGroupOptionType for text values.
+ * The merge of option values returns merge of all text values.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}