From: Alexander Ebert Date: Tue, 8 Nov 2011 14:15:10 +0000 (+0100) Subject: Added support for user options X-Git-Tag: 2.0.0_Beta_1~1616^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c44dc3ce03b31a49e8d2d1f6cc6564b3e3d54d04;p=GitHub%2FWoltLab%2FWCF.git Added support for user options --- diff --git a/wcfsetup/install/files/lib/data/user/option/UserOption.class.php b/wcfsetup/install/files/lib/data/user/option/UserOption.class.php index 06f97db1c7..4802f4a36a 100644 --- a/wcfsetup/install/files/lib/data/user/option/UserOption.class.php +++ b/wcfsetup/install/files/lib/data/user/option/UserOption.class.php @@ -22,4 +22,16 @@ class UserOption extends Option { * @see wcf\data\DatabaseObject::$databaseTableIndexName */ protected static $databaseTableIndexName = 'optionID'; + + /** + * option value + * @var string + */ + public $optionValue = ''; + + /** + * output data + * @var array + */ + public $outputData = array(); } diff --git a/wcfsetup/install/files/lib/util/OptionUtil.class.php b/wcfsetup/install/files/lib/util/OptionUtil.class.php new file mode 100644 index 0000000000..0c312555c0 --- /dev/null +++ b/wcfsetup/install/files/lib/util/OptionUtil.class.php @@ -0,0 +1,66 @@ + + * @package com.woltlab.wcf + * @subpackage util + * @category Community Framework + */ +class OptionUtil { + /** + * Returns a list of the available options. + * + * @param string $selectOptions + * @return array + */ + public static function parseSelectOptions($selectOptions) { + $result = array(); + $options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($selectOptions))); + foreach ($options as $option) { + $key = $value = $option; + if (StringUtil::indexOf($option, ':') !== false) { + $optionData = explode(':', $option); + $key = array_shift($optionData); + $value = implode(':', $optionData); + } + + $result[$key] = $value; + } + + return $result; + } + + /** + * Returns a list of the enable options. + * + * @param string $enableOptions + * @return array + */ + public static function parseMultipleEnableOptions($enableOptions) { + $result = array(); + if (!empty($enableOptions)) { + $options = explode("\n", StringUtil::trim(StringUtil::unifyNewlines($enableOptions))); + $key = -1; + foreach ($options as $option) { + if (StringUtil::indexOf($option, ':') !== false) { + $optionData = explode(':', $option); + $key = array_shift($optionData); + $value = implode(':', $optionData); + } + else { + $key++; + $value = $option; + } + + $result[$key] = $value; + } + } + + return $result; + } +}