--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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);
+ }
+}
--- /dev/null
+<?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);
+ }
+}
--- /dev/null
+<?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;
+ }
+}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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);
- }
-}
+++ /dev/null
-<?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);
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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
- );
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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');
- }
-}
+++ /dev/null
-<?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');
- }
- }
-}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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
+ );
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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');
+ }
+}
--- /dev/null
+<?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');
+ }
+ }
+}