Renamed option types
authorMatthias Schmidt <gravatronics@live.com>
Fri, 12 Aug 2011 20:56:25 +0000 (22:56 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 16 Aug 2011 11:34:05 +0000 (13:34 +0200)
24 files changed:
wcfsetup/install/files/lib/system/option/BooleanOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/CustomselectOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/DateOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/FloatOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/IntegerOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/MultiselectOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeCustomselect.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeFloat.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeInteger.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeMultiselect.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypePassword.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeSelect.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeText.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeTextarea.class.php [deleted file]
wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php [deleted file]
wcfsetup/install/files/lib/system/option/PasswordOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/RadiobuttonsOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/SelectOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/TextOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/TextareaOptionType.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/TimezoneOptionType.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/option/BooleanOptionType.class.php b/wcfsetup/install/files/lib/system/option/BooleanOptionType.class.php
new file mode 100644 (file)
index 0000000..39458dc
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * BooleanOptionType is an implementation of IOptionType for boolean 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
+ * @category   Community Framework
+ */
+class BooleanOptionType extends AbstractOptionType implements ISearchableUserOption {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               $options = Option::parseEnableOptions($option->enableOptions);
+               
+               WCF::getTPL()->assign(array(
+                       'disableOptions' => $options['disableOptions'],
+                       'enableOptions' => $options['enableOptions'],
+                       'option' => $option,
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('optionTypeBoolean');
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(Option $option, $newValue) {
+               if ($newValue !== null) return 1;
+               return 0;
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::getCSSClassName()
+        */
+       public function getCSSClassName() {
+               return 'reversed';
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(Option $option, $value) {
+               return $this->getFormElement($option, $value);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+               $value = intval($value);
+               if (!$value) return false;
+               
+               $conditions->add("option_value.userOption".$option->optionID." = ?", array(1));
+               return true;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/CustomselectOptionType.class.php b/wcfsetup/install/files/lib/system/option/CustomselectOptionType.class.php
new file mode 100644 (file)
index 0000000..1b56a94
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\WCF;
+
+/**
+ * OptionTypeSelect is an implementation of IOptionType for 'select' tags with a
+ * text field for custom inputs.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class CustomselectOptionType extends SelectOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               WCF::getTPL()->assign(array(
+                       'option' => $option,
+                       'selectOptions' => $option->parseSelectOptions(),
+                       'value' => $value,
+                       'customValue' => (!isset($options[$value]) ? $value : '')
+               ));
+               
+               return WCF::getTPL()->fetch('optionTypeCustomselect');
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::validate()
+        */
+       public function validate(Option $option, $newValue) {}
+       
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(Option $option, $newValue) {
+               if (empty($newValue) && isset($_POST['values'][$option->optionName.'_custom'])) {
+                       return $_POST['values'][$option->optionName.'_custom'];
+               }
+               return $newValue;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/DateOptionType.class.php b/wcfsetup/install/files/lib/system/option/DateOptionType.class.php
new file mode 100644 (file)
index 0000000..a03a057
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\DateUtil;
+
+/**
+ * DateOptionType is an implementation of IOptionType for date inputs.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class DateOptionType extends AbstractOptionType implements ISearchableUserOption {
+       protected $yearRequired = true;
+       
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(array &$optionData) {
+               if (!isset($optionData['optionValue'])) {
+                       if (isset($optionData['defaultValue'])) $optionData['optionValue'] = $optionData['defaultValue'];
+                       else $optionData['optionValue'] = '';
+               }
+               $optionData['isOptionGroup'] = true;
+               $optionData['divClass'] = 'formDate';
+               
+               $year = $month = $day = '';
+               $optionValue = explode('-', (is_array($optionData['optionValue']) ? implode('-', $optionData['optionValue']) : $optionData['optionValue']));
+               if (isset($optionValue[0])) $year = intval($optionValue[0]);
+               if (empty($year)) $year = '';
+               if (isset($optionValue[1])) $month = $optionValue[1];
+               if (isset($optionValue[2])) $day = $optionValue[2];
+               $dateInputOrder = explode('-', WCF::getLanguage()->get('wcf.global.dateInputOrder'));
+               
+               // generate days
+               $days = array();
+               $days[0] = '';
+               for ($i = 1; $i < 32; $i++) {
+                       $days[$i] = $i;         
+               }
+               
+               // generate months
+               $months = array();
+               $months[0] = '';
+               // TODO: $dateFormatLocalized is no longer available, fix this!
+               $monthFormat = (Language::$dateFormatLocalized ? '%B' : '%m');
+               for ($i = 1; $i < 13; $i++) {
+                       $months[$i] = DateUtil::formatDate($monthFormat, gmmktime(0, 0, 0, $i, 10, 2006), false, true);
+               }
+               
+               WCF::getTPL()->assign(array(
+                       'year' => $year,
+                       'month' => $month,
+                       'day' => $day,
+                       'days' => $days,
+                       'months' => $months,
+                       'optionData' => $optionData,
+                       'dateInputOrder' => $dateInputOrder,
+                       'yearRequired' => $this->yearRequired
+               ));
+               return WCF::getTPL()->fetch('optionTypeDate');
+       }
+       
+       /**
+        * Formats the user input.
+        * 
+        * @param       array           $newValue
+        */
+       protected function getValue(array &$newValue) {
+               if (isset($newValue['year'])) $newValue['year'] = intval($newValue['year']);
+               else $newValue['year'] = 0;
+               if (isset($newValue['month'])) $newValue['month'] = intval($newValue['month']);
+               else $newValue['month'] = 0;
+               if (isset($newValue['day'])) $newValue['day'] = intval($newValue['day']);
+               else $newValue['day'] = 0;
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::validate()
+        */
+       public function validate(array $optionData, $newValue) {
+               $this->getValue($newValue);
+               
+               if ($newValue['year'] || $newValue['month'] || $newValue['day']) {
+                       if (strlen($newValue['year']) == 2) {
+                               $newValue['year'] = '19'.$newValue['year'];
+                       }
+                       
+                       if (!checkdate(intval($newValue['month']), intval($newValue['day']), ((!$this->yearRequired && !$newValue['year']) ? 2000 : intval($newValue['year'])))) {
+                               throw new UserInputException($optionData['optionName'], 'validationFailed');
+                       }
+                       if (($newValue['year'] || $this->yearRequired) && ((strlen($newValue['year']) != 4 && strlen($newValue['year']) != 2) || $newValue['year'] < 1902)) {
+                               throw new UserInputException($optionData['optionName'], 'validationFailed');
+                       }
+               }
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(array $optionData, $newValue) {
+               $this->getValue($newValue);
+               
+               if ($newValue['year'] || $newValue['month'] || $newValue['day']) {
+                       if ($newValue['month'] < 10) $newValue['month'] = '0'.$newValue['month'];
+                       if ($newValue['day'] < 10) $newValue['day'] = '0'.$newValue['day'];
+                       if (strlen($newValue['year']) == 2) {
+                               $newValue['year'] = '19'.$newValue['year'];
+                       }
+                       if (!$this->yearRequired && strlen($newValue['year']) < 2) {
+                               $newValue['year'] = '0000';
+                       }
+                       return $newValue['year'].'-'.$newValue['month'].'-'.$newValue['day'];
+               }
+               
+               return '';
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(array &$optionData) {
+               return $this->getFormElement($optionData);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+               $value = $this->getData($optionData, $value);
+               if ($value == '') return false;
+               
+               $conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
+               return true;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/FloatOptionType.class.php b/wcfsetup/install/files/lib/system/option/FloatOptionType.class.php
new file mode 100644 (file)
index 0000000..503ca54
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\WCF;
+
+/**
+ * FloatOptionType is an implementation of IOptionType for float fields.
+ *
+ * @author     Tobias Friebel
+ * @copyright  2001-2011 Tobias Friebel
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.option
+ * @category   Community Framework
+ */
+class FloatOptionType extends TextOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               $value = str_replace('.', WCF::getLanguage()->get('wcf.global.decimalPoint'), $value);
+               
+               return parent::getFormElement($option, $value);
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(Option $option, $newValue) {
+               $newValue = str_replace(' ', '', $newValue);
+               $newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
+               $newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue);
+               return floatval($newValue);
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/IntegerOptionType.class.php b/wcfsetup/install/files/lib/system/option/IntegerOptionType.class.php
new file mode 100644 (file)
index 0000000..06ecd1f
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+
+/**
+ * IntegerOptionType is an implementation of IOptionType for integer fields.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class IntegerOptionType extends TextOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(Option $option, $newValue) {
+               return intval($newValue);
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/MultiselectOptionType.class.php b/wcfsetup/install/files/lib/system/option/MultiselectOptionType.class.php
new file mode 100644 (file)
index 0000000..1db2609
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\ArrayUtil;
+use wcf\util\OptionUtil;
+
+/**
+ * MultiselectOptionType is an implementation of IOptionType for multiple 'select' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class MultiselectOptionType extends SelectOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(array &$optionData) {
+               if (!isset($optionData['optionValue'])) {
+                       if (isset($optionData['defaultValue'])) $optionData['optionValue'] = explode("\n", $optionData['defaultValue']);
+                       else $optionData['optionValue'] = array();
+               }
+               else if (!is_array($optionData['optionValue'])) {
+                       $optionData['optionValue'] = explode("\n", $optionData['optionValue']);
+               }
+               
+               // get options
+               $options = OptionUtil::parseSelectOptions($optionData['selectOptions']);
+               
+               WCF::getTPL()->assign(array(
+                       'optionData' => $optionData,
+                       'options' => $options
+               ));
+               return WCF::getTPL()->fetch('optionTypeMultiselect');
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::validate()
+        */
+       public function validate(array $optionData, $newValue) {
+               if (!is_array($newValue)) $newValue = array();
+               $options = OptionUtil::parseSelectOptions($optionData['selectOptions']);
+               foreach ($newValue as $value) {
+                       if (!isset($options[$value])) throw new UserInputException($optionData['optionName'], 'validationFailed');
+               }
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::getData()
+        */
+       public function getData(array $optionData, $newValue) {
+               if (!is_array($newValue)) $newValue = array();
+               return implode("\n", $newValue);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(array &$optionData) {
+               return $this->getFormElement($optionData);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $options, $value) {
+               if (!is_array($value) || !count($value)) return false;
+               $value = ArrayUtil::trim($value);
+               if (!count($value)) return false;
+               
+               $conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
+               return true;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeBoolean.class.php
deleted file mode 100644 (file)
index 0c755ad..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * OptionTypeBoolean is an implementation of OptionType for boolean 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
- * @category   Community Framework
- */
-class OptionTypeBoolean extends AbstractOptionType implements ISearchableUserOption {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               $options = Option::parseEnableOptions($option->enableOptions);
-               
-               WCF::getTPL()->assign(array(
-                       'disableOptions' => $options['disableOptions'],
-                       'enableOptions' => $options['enableOptions'],
-                       'option' => $option,
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch('optionTypeBoolean');
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(Option $option, $newValue) {
-               if ($newValue !== null) return 1;
-               return 0;
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::getCSSClassName()
-        */
-       public function getCSSClassName() {
-               return 'reversed';
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(Option $option, $value) {
-               return $this->getFormElement($option, $value);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
-               $value = intval($value);
-               if (!$value) return false;
-               
-               $conditions->add("option_value.userOption".$option->optionID." = ?", array(1));
-               return true;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeCustomselect.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeCustomselect.class.php
deleted file mode 100644 (file)
index f7549ea..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionTypeSelect;
-use wcf\system\WCF;
-
-/**
- * OptionTypeSelect is an implementation of OptionType for 'select' tags with a text field for custom inputs.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeCustomselect extends OptionTypeSelect {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               WCF::getTPL()->assign(array(
-                       'option' => $option,
-                       'selectOptions' => $option->parseSelectOptions(),
-                       'value' => $value,
-                       'customValue' => (!isset($options[$value]) ? $value : '')
-               ));
-               
-               return WCF::getTPL()->fetch('optionTypeCustomselect');
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::validate()
-        */
-       public function validate(Option $option, $newValue) {}
-       
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(Option $option, $newValue) {
-               if (empty($newValue) && isset($_POST['values'][$option->optionName.'_custom'])) {
-                       return $_POST['values'][$option->optionName.'_custom'];
-               }
-               return $newValue;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeDate.class.php
deleted file mode 100644 (file)
index b313b8d..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\exception\UserInputException;
-use wcf\system\option\OptionType;
-use wcf\system\option\SearchableUserOption;
-use wcf\system\WCF;
-use wcf\util\DateUtil;
-
-/**
- * OptionTypeDate is an implementation of OptionType for date inputs.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeDate extends AbstractOptionType implements ISearchableUserOption {
-       protected $yearRequired = true;
-       
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(array &$optionData) {
-               if (!isset($optionData['optionValue'])) {
-                       if (isset($optionData['defaultValue'])) $optionData['optionValue'] = $optionData['defaultValue'];
-                       else $optionData['optionValue'] = '';
-               }
-               $optionData['isOptionGroup'] = true;
-               $optionData['divClass'] = 'formDate';
-               
-               $year = $month = $day = '';
-               $optionValue = explode('-', (is_array($optionData['optionValue']) ? implode('-', $optionData['optionValue']) : $optionData['optionValue']));
-               if (isset($optionValue[0])) $year = intval($optionValue[0]);
-               if (empty($year)) $year = '';
-               if (isset($optionValue[1])) $month = $optionValue[1];
-               if (isset($optionValue[2])) $day = $optionValue[2];
-               $dateInputOrder = explode('-', WCF::getLanguage()->get('wcf.global.dateInputOrder'));
-               
-               // generate days
-               $days = array();
-               $days[0] = '';
-               for ($i = 1; $i < 32; $i++) {
-                       $days[$i] = $i;         
-               }
-               
-               // generate months
-               $months = array();
-               $months[0] = '';
-               // TODO: $dateFormatLocalized is no longer available, fix this!
-               $monthFormat = (Language::$dateFormatLocalized ? '%B' : '%m');
-               for ($i = 1; $i < 13; $i++) {
-                       $months[$i] = DateUtil::formatDate($monthFormat, gmmktime(0, 0, 0, $i, 10, 2006), false, true);
-               }
-               
-               WCF::getTPL()->assign(array(
-                       'year' => $year,
-                       'month' => $month,
-                       'day' => $day,
-                       'days' => $days,
-                       'months' => $months,
-                       'optionData' => $optionData,
-                       'dateInputOrder' => $dateInputOrder,
-                       'yearRequired' => $this->yearRequired
-               ));
-               return WCF::getTPL()->fetch('optionTypeDate');
-       }
-       
-       /**
-        * Formats the user input.
-        * 
-        * @param       array           $newValue
-        */
-       protected function getValue(array &$newValue) {
-               if (isset($newValue['year'])) $newValue['year'] = intval($newValue['year']);
-               else $newValue['year'] = 0;
-               if (isset($newValue['month'])) $newValue['month'] = intval($newValue['month']);
-               else $newValue['month'] = 0;
-               if (isset($newValue['day'])) $newValue['day'] = intval($newValue['day']);
-               else $newValue['day'] = 0;
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::validate()
-        */
-       public function validate(array $optionData, $newValue) {
-               $this->getValue($newValue);
-               
-               if ($newValue['year'] || $newValue['month'] || $newValue['day']) {
-                       if (strlen($newValue['year']) == 2) {
-                               $newValue['year'] = '19'.$newValue['year'];
-                       }
-                       
-                       if (!checkdate(intval($newValue['month']), intval($newValue['day']), ((!$this->yearRequired && !$newValue['year']) ? 2000 : intval($newValue['year'])))) {
-                               throw new UserInputException($optionData['optionName'], 'validationFailed');
-                       }
-                       if (($newValue['year'] || $this->yearRequired) && ((strlen($newValue['year']) != 4 && strlen($newValue['year']) != 2) || $newValue['year'] < 1902)) {
-                               throw new UserInputException($optionData['optionName'], 'validationFailed');
-                       }
-               }
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(array $optionData, $newValue) {
-               $this->getValue($newValue);
-               
-               if ($newValue['year'] || $newValue['month'] || $newValue['day']) {
-                       if ($newValue['month'] < 10) $newValue['month'] = '0'.$newValue['month'];
-                       if ($newValue['day'] < 10) $newValue['day'] = '0'.$newValue['day'];
-                       if (strlen($newValue['year']) == 2) {
-                               $newValue['year'] = '19'.$newValue['year'];
-                       }
-                       if (!$this->yearRequired && strlen($newValue['year']) < 2) {
-                               $newValue['year'] = '0000';
-                       }
-                       return $newValue['year'].'-'.$newValue['month'].'-'.$newValue['day'];
-               }
-               
-               return '';
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(array &$optionData) {
-               return $this->getFormElement($optionData);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
-               $value = $this->getData($optionData, $value);
-               if ($value == '') return false;
-               
-               $conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
-               return true;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeFloat.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeFloat.class.php
deleted file mode 100644 (file)
index a7a7896..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionTypeText;
-use wcf\system\WCF;
-
-/**
- * OptionTypeFloat is an implementation of OptionType for float fields.
- *
- * @author     Tobias Friebel
- * @copyright  2001-2011 Tobias Friebel
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.option
- * @category   Community Framework
- */
-class OptionTypeFloat extends OptionTypeText {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               $value = str_replace('.', WCF::getLanguage()->get('wcf.global.decimalPoint'), $value);
-               
-               return parent::getFormElement($option, $value);
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(Option $option, $newValue) {
-               $newValue = str_replace(' ', '', $newValue);
-               $newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
-               $newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue);
-               return floatval($newValue);
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeInteger.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeInteger.class.php
deleted file mode 100644 (file)
index 26be493..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionTypeText;
-
-/**
- * OptionTypeText is an implementation of OptionType for integer fields.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeInteger extends OptionTypeText {
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(Option $option, $newValue) {
-               return intval($newValue);
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeMultiselect.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeMultiselect.class.php
deleted file mode 100644 (file)
index 4bd0fe8..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\option\OptionTypeSelect;
-use wcf\system\option\SearchableUserOption;
-use wcf\system\WCF;
-use wcf\system\exception\UserInputException;
-use wcf\util\ArrayUtil;
-use wcf\util\OptionUtil;
-
-/**
- * OptionTypeSelect is an implementation of OptionType for multiple 'select' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeMultiselect extends OptionTypeSelect {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(array &$optionData) {
-               if (!isset($optionData['optionValue'])) {
-                       if (isset($optionData['defaultValue'])) $optionData['optionValue'] = explode("\n", $optionData['defaultValue']);
-                       else $optionData['optionValue'] = array();
-               }
-               else if (!is_array($optionData['optionValue'])) {
-                       $optionData['optionValue'] = explode("\n", $optionData['optionValue']);
-               }
-               
-               // get options
-               $options = OptionUtil::parseSelectOptions($optionData['selectOptions']);
-               
-               WCF::getTPL()->assign(array(
-                       'optionData' => $optionData,
-                       'options' => $options
-               ));
-               return WCF::getTPL()->fetch('optionTypeMultiselect');
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::validate()
-        */
-       public function validate(array $optionData, $newValue) {
-               if (!is_array($newValue)) $newValue = array();
-               $options = OptionUtil::parseSelectOptions($optionData['selectOptions']);
-               foreach ($newValue as $value) {
-                       if (!isset($options[$value])) throw new UserInputException($optionData['optionName'], 'validationFailed');
-               }
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::getData()
-        */
-       public function getData(array $optionData, $newValue) {
-               if (!is_array($newValue)) $newValue = array();
-               return implode("\n", $newValue);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(array &$optionData) {
-               return $this->getFormElement($optionData);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $options, $value) {
-               if (!is_array($value) || !count($value)) return false;
-               $value = ArrayUtil::trim($value);
-               if (!count($value)) return false;
-               
-               $conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
-               return true;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypePassword.class.php b/wcfsetup/install/files/lib/system/option/OptionTypePassword.class.php
deleted file mode 100644 (file)
index ac14a67..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\option\OptionTypeText;
-
-/**
- * OptionTypeText is an implementation of OptionType for 'input type="password"' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypePassword extends OptionTypeText {
-       /**
-        * @see wcf\system\option\OptionTypeText::$inputType
-        */
-       protected $inputType = 'password';
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
-               return false;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeRadiobuttons.class.php
deleted file mode 100644 (file)
index 257e8a2..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\option\OptionType;
-use wcf\system\option\SearchableUserOption;
-use wcf\system\WCF;
-use wcf\system\UserInputException;
-use wcf\util\StringUtil;
-
-/**
- * OptionTypeRadiobuttons is an implementation of OptionType for 'input type="radio"' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeRadiobuttons extends AbstractOptionType implements ISearchableUserOption {
-       public $templateName = 'optionTypeRadiobuttons';
-
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               // get options
-               $selectOptions = $option->parseSelectOptions();
-
-               $availableOptions = $option->parseMultipleEnableOptions();
-               $options = array(
-                       'disableOptions' => array(),
-                       'enableOptions' => array()
-               );
-               
-               foreach ($availableOptions as $key => $enableOptions) {
-                       $optionData = Option::parseEnableOptions($enableOptions);
-                       
-                       $options['disableOptions'][$key] = $optionData['disableOptions'];
-                       $options['enableOptions'][$key] = $optionData['enableOptions'];
-               }
-               
-               WCF::getTPL()->assign(array(
-                       'disableOptions' => $options['disableOptions'],
-                       'enableOptions' => $options['enableOptions'],
-                       'option' => $option,
-                       'selectOptions' => $selectOptions,
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch($this->templateName);
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::validate()
-        */
-       public function validate(Option $option, $newValue) {
-               if (!empty($newValue)) {
-                       $options = $option->parseSelectOptions();
-                       if (!isset($options[$newValue])) {
-                               throw new UserInputException($option->optionName, 'validationFailed');
-                       }
-               }
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(Option $option, $value) {
-               return $this->getFormElement($optionData, $value);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
-               $value = StringUtil::trim($value);
-               if (!$value) return false;
-               
-               $conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
-               return true;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeSelect.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeSelect.class.php
deleted file mode 100644 (file)
index a6377e3..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionTypeRadiobuttons;
-use wcf\system\WCF;
-
-/**
- * OptionTypeSelect is an implementation of OptionType for 'select' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeSelect extends OptionTypeRadiobuttons {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               // get options
-               $options = $this->parseEnableOptions($option);
-               
-               WCF::getTPL()->assign(array(
-                       'disableOptions' => $options['disableOptions'],
-                       'enableOptions' => $options['enableOptions'],
-                       'option' => $option,
-                       'selectOptions' => $option->parseSelectOptions(),
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch('optionTypeSelect');
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(Option $option, $value) {
-               return $this->getFormElement($optionData, $value);
-       }
-       
-       /**
-        * @todo        This is not really tested yet!
-        * @param       Option          $option
-        * @return      array
-        */
-       protected function parseEnableOptions(Option $option) {
-               $disableOptions = $enableOptions = '';
-               
-               if (!empty($option->enableOptions)) {
-                       $options = $option->parseMultipleEnableOptions();
-                       
-                       foreach ($options as $key => $optionData) {
-                               $tmp = explode(',', $optionData);
-                               
-                               foreach ($optionData as $item) {
-                                       if ($item{0} == '!') {
-                                               if (!empty($disableOptions)) $disableOptions .= ',';
-                                               $disableOptions .= "{ value: '".$key."', option: '".StringUtil::substring($item, 1)."' }";
-                                       }
-                                       else {
-                                               if (!empty($enableOptions)) $enableOptions .= ',';
-                                               $enableOptions .= "{ value: '".$key."', option: '".$item."' }";
-                                       }
-                               }
-                       }
-               }
-               
-               return array(
-                       'disableOptions' => $disableOptions,
-                       'enableOptions' => $enableOptions
-               );
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeText.class.php
deleted file mode 100644 (file)
index 381c7d6..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\option\OptionType;
-use wcf\system\option\SearchableUserOption;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * OptionTypeText is an implementation of OptionType for 'input type="text"' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeText extends AbstractOptionType implements ISearchableUserOption {
-       /**
-        * input type
-        * @var string
-        */
-       protected $inputType = 'text';
-       
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               WCF::getTPL()->assign(array(
-                       'option' => $option,
-                       'inputType' => $this->inputType,
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch('optionTypeText');
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
-        */
-       public function getSearchFormElement(Option $option, $value) {
-               return $this->getFormElement($optionData, $value);
-       }
-       
-       /**
-        * @see wcf\system\option\ISearchableUserOption::getCondition()
-        */
-       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
-               $value = StringUtil::trim($value);
-               if (empty($value)) return false;
-               
-               $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
-               return true;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeTextarea.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeTextarea.class.php
deleted file mode 100644 (file)
index 87a39ba..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionTypeText;
-use wcf\system\WCF;
-
-/**
- * OptionTypeTextarea is an implementation of OptionType for 'textarea' tags.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeTextarea extends OptionTypeText {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               WCF::getTPL()->assign(array(
-                       'option' => $option,
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch('optionTypeTextarea');
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php b/wcfsetup/install/files/lib/system/option/OptionTypeTimezone.class.php
deleted file mode 100644 (file)
index cde2c56..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-namespace wcf\system\option;
-use wcf\data\option\Option;
-use wcf\system\option\OptionType;
-use wcf\system\exception\UserInputException;
-use wcf\system\WCF;
-use wcf\util\DateUtil;
-
-/**
- * OptionTypeTimezone is an implementation of OptionType for a select box, which list the available time zones.
- *
- * @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
- * @category   Community Framework
- */
-class OptionTypeTimezone extends AbstractOptionType {
-       /**
-        * @see wcf\system\option\IOptionType::getFormElement()
-        */
-       public function getFormElement(Option $option, $value) {
-               $timezoneOptions = array();
-               foreach (DateUtil::getAvailableTimezones() as $timezone) {
-                       $timezoneOptions[$timezone] = WCF::getLanguage()->get('wcf.global.date.timezone.'.str_replace('/', '.', strtolower($timezone)));
-               }
-               
-               WCF::getTPL()->assign(array(
-                       'option' => $option,
-                       'selectOptions' => $timezoneOptions,
-                       'value' => $value
-               ));
-               return WCF::getTPL()->fetch('optionTypeSelect');
-       }
-       
-       /**
-        * @see wcf\system\option\IOptionType::validate()
-        */
-       public function validate(Option $option, $newValue) {
-               if (!in_array($newValue, DateUtil::getAvailableTimezones())) {
-                       throw new UserInputException($option->optionName, 'validationFailed');
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/option/PasswordOptionType.class.php b/wcfsetup/install/files/lib/system/option/PasswordOptionType.class.php
new file mode 100644 (file)
index 0000000..a8aa040
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+
+/**
+ * OptionTypeText is an implementation of IOptionType for 'input type="password"' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class PasswordOptionType extends TextOptionType {
+       /**
+        * @see wcf\system\option\TextOptionType::$inputType
+        */
+       protected $inputType = 'password';
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+               return false;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/RadiobuttonsOptionType.class.php b/wcfsetup/install/files/lib/system/option/RadiobuttonsOptionType.class.php
new file mode 100644 (file)
index 0000000..5677dae
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+use wcf\system\UserInputException;
+use wcf\util\StringUtil;
+
+/**
+ * RadiobuttonsOptionType is an implementation of IOptionType for 'input type="radio"' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class RadiobuttonsOptionType extends AbstractOptionType implements ISearchableUserOption {
+       /**
+        * name of the template that contains the form element of this option type
+        * @var string
+        */
+       public $templateName = 'optionTypeRadiobuttons';
+
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               // get options
+               $selectOptions = $option->parseSelectOptions();
+
+               $availableOptions = $option->parseMultipleEnableOptions();
+               $options = array(
+                       'disableOptions' => array(),
+                       'enableOptions' => array()
+               );
+               
+               foreach ($availableOptions as $key => $enableOptions) {
+                       $optionData = Option::parseEnableOptions($enableOptions);
+                       
+                       $options['disableOptions'][$key] = $optionData['disableOptions'];
+                       $options['enableOptions'][$key] = $optionData['enableOptions'];
+               }
+               
+               WCF::getTPL()->assign(array(
+                       'disableOptions' => $options['disableOptions'],
+                       'enableOptions' => $options['enableOptions'],
+                       'option' => $option,
+                       'selectOptions' => $selectOptions,
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch($this->templateName);
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::validate()
+        */
+       public function validate(Option $option, $newValue) {
+               if (!empty($newValue)) {
+                       $options = $option->parseSelectOptions();
+                       if (!isset($options[$newValue])) {
+                               throw new UserInputException($option->optionName, 'validationFailed');
+                       }
+               }
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(Option $option, $value) {
+               return $this->getFormElement($optionData, $value);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+               $value = StringUtil::trim($value);
+               if (!$value) return false;
+               
+               $conditions->add("option_value.userOption".$option->optionID." = ?", array($value));
+               return true;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php b/wcfsetup/install/files/lib/system/option/SelectOptionType.class.php
new file mode 100644 (file)
index 0000000..00229c4
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\WCF;
+
+/**
+ * SelectOptionType is an implementation of IOptionType for 'select' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class SelectOptionType extends RadiobuttonsOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               // get options
+               $options = $this->parseEnableOptions($option);
+               
+               WCF::getTPL()->assign(array(
+                       'disableOptions' => $options['disableOptions'],
+                       'enableOptions' => $options['enableOptions'],
+                       'option' => $option,
+                       'selectOptions' => $option->parseSelectOptions(),
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('optionTypeSelect');
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(Option $option, $value) {
+               return $this->getFormElement($optionData, $value);
+       }
+       
+       /**
+        * @todo        This is not really tested yet!
+        * @param       Option          $option
+        * @return      array
+        */
+       protected function parseEnableOptions(Option $option) {
+               $disableOptions = $enableOptions = '';
+               
+               if (!empty($option->enableOptions)) {
+                       $options = $option->parseMultipleEnableOptions();
+                       
+                       foreach ($options as $key => $optionData) {
+                               $tmp = explode(',', $optionData);
+                               
+                               foreach ($optionData as $item) {
+                                       if ($item{0} == '!') {
+                                               if (!empty($disableOptions)) $disableOptions .= ',';
+                                               $disableOptions .= "{ value: '".$key."', option: '".StringUtil::substring($item, 1)."' }";
+                                       }
+                                       else {
+                                               if (!empty($enableOptions)) $enableOptions .= ',';
+                                               $enableOptions .= "{ value: '".$key."', option: '".$item."' }";
+                                       }
+                               }
+                       }
+               }
+               
+               return array(
+                       'disableOptions' => $disableOptions,
+                       'enableOptions' => $enableOptions
+               );
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/TextOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextOptionType.class.php
new file mode 100644 (file)
index 0000000..c0ce5b9
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\option\OptionType;
+use wcf\system\option\SearchableUserOption;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * TextOptionType is an implementation of IOptionType for 'input type="text"' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class TextOptionType extends AbstractOptionType implements ISearchableUserOption {
+       /**
+        * input type
+        * @var string
+        */
+       protected $inputType = 'text';
+       
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               WCF::getTPL()->assign(array(
+                       'option' => $option,
+                       'inputType' => $this->inputType,
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('optionTypeText');
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(Option $option, $value) {
+               return $this->getFormElement($option, $value);
+       }
+       
+       /**
+        * @see wcf\system\option\ISearchableUserOption::getCondition()
+        */
+       public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
+               $value = StringUtil::trim($value);
+               if (empty($value)) return false;
+               
+               $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%'));
+               return true;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/TextareaOptionType.class.php b/wcfsetup/install/files/lib/system/option/TextareaOptionType.class.php
new file mode 100644 (file)
index 0000000..082b0f1
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\WCF;
+
+/**
+ * TextareaOptionType is an implementation of IOptionType for 'textarea' tags.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class TextareaOptionType extends TextOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               WCF::getTPL()->assign(array(
+                       'option' => $option,
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('optionTypeTextarea');
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/option/TimezoneOptionType.class.php b/wcfsetup/install/files/lib/system/option/TimezoneOptionType.class.php
new file mode 100644 (file)
index 0000000..c8a1ea1
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace wcf\system\option;
+use wcf\data\option\Option;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\DateUtil;
+
+/**
+ * TimezoneOptionType is an implementation of IOptionType for a select box, which
+ * list the available time zones.
+ *
+ * @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
+ * @category   Community Framework
+ */
+class TimezoneOptionType extends AbstractOptionType {
+       /**
+        * @see wcf\system\option\IOptionType::getFormElement()
+        */
+       public function getFormElement(Option $option, $value) {
+               $timezoneOptions = array();
+               foreach (DateUtil::getAvailableTimezones() as $timezone) {
+                       $timezoneOptions[$timezone] = WCF::getLanguage()->get('wcf.global.date.timezone.'.str_replace('/', '.', strtolower($timezone)));
+               }
+               
+               WCF::getTPL()->assign(array(
+                       'option' => $option,
+                       'selectOptions' => $timezoneOptions,
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('optionTypeSelect');
+       }
+       
+       /**
+        * @see wcf\system\option\IOptionType::validate()
+        */
+       public function validate(Option $option, $newValue) {
+               if (!in_array($newValue, DateUtil::getAvailableTimezones())) {
+                       throw new UserInputException($option->optionName, 'validationFailed');
+               }
+       }
+}