--- /dev/null
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\util\FileUtil;
+use wcf\util\StringUtil;
+
+/**
+ * FileSizeOptionType is an implementation of IOptionType for file sizes.
+ *
+ * @author Tim Düsterhus
+ * @copyright 2011 Tim Düsterhus
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option
+ * @category Community Framework
+ */
+class FileSizeOptionType extends IntegerOptionType {
+ /**
+ * @see wcf\system\option\IOptionType::getData()
+ */
+ public function getData(Option $option, $newValue) {
+ $number = intval($newValue);
+ if (preg_match('/[kmgt]i?b$/i', $newValue, $multiplier)) {
+ switch (StringUtil::toLowerCase($multiplier[0])) {
+ case 'tb':
+ $number *= 1000;
+ case 'gb':
+ $number *= 1000;
+ case 'mb':
+ $number *= 1000;
+ case 'kb':
+ $number *= 1000;
+ break;
+ case 'tib':
+ $number *= 1024;
+ case 'gib':
+ $number *= 1024;
+ case 'mib':
+ $number *= 1024;
+ case 'kib':
+ $number *= 1024;
+ break;
+ }
+ }
+
+ return $number;
+ }
+
+ /**
+ * @see wcf\system\option\IOptionType::getFormElement()
+ */
+ public function getFormElement(Option $option, $value) {
+ // TODO: Maybe show more digits after the comma?
+ $value = FileUtil::formatFileSize($value);
+ return parent::getFormElement($option, $value);
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\option\user\group;
+use wcf\system\option\FileSizeOptionType;
+
+/**
+ * FileSizeUserGroupOptionType is an implementation of IUserGroupOptionType for file sizes.
+ * The merge of option values returns the highest value.
+ *
+ * @author Tim Düsterhus
+ * @copyright 2011 Tim Düsterhus
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.option.user.group
+ * @category Community Framework
+ */
+class FileSizeUserGroupOptionType extends FileSizeOptionType implements IUserGroupOptionType {
+ /**
+ * @see wcf\system\option\user.group\IUserGroupOptionType::merge()
+ */
+ public function merge(array $values) {
+ return max($values);
+ }
+}