*/
public $maxResults = 0;
- /**
- * list of option values
- * @var array
- */
- public $values = array();
-
/**
* @see wcf\form\IForm::readFormParameters()
*/
if (isset($_POST['sortField'])) $this->sortField = $_POST['sortField'];
if (isset($_POST['sortOrder'])) $this->sortOrder = $_POST['sortOrder'];
if (isset($_POST['columns']) && is_array($_POST['columns'])) $this->columns = $_POST['columns'];
-
- if (isset($_POST['values']) && is_array($_POST['values'])) $this->values = $_POST['values'];
+ }
+
+ /**
+ * @see wcf\acp\form\AbstractOptionListForm::initOptionHandler()
+ */
+ protected function initOptionHandler() {
+ $this->optionHandler->enableSearchMode();
+ $this->optionHandler->init();
}
/**
* @see wcf\page\IPage::readData()
*/
public function readData() {
- $this->readOptionTree();
-
parent::readData();
+
+ $this->readOptionTree();
}
/**
foreach ($this->optionHandler->getCategoryOptions('profile') as $option) {
$option = $option['object'];
- $value = isset($this->values[$option->optionName]) ? $this->values[$option->optionName] : null;
- $this->optionHandler->getTypeObject($option->optionType)->getCondition($this->conditions, $option->getDecoratedObject(), $value);
+ $value = isset($this->optionHandler->optionValues[$option->optionName]) ? $this->optionHandler->optionValues[$option->optionName] : null;
+ $this->optionHandler->getTypeObject($option->optionType)->getCondition($this->conditions, $option, $value);
}
}
}
*/
public $editMode = true;
+ /**
+ * true, if within search mode
+ * @var boolean
+ */
+ public $searchMode = false;
+
/**
* true, if empty options should be removed
* @var boolean
$this->editMode = $enable;
}
+ /**
+ * Enables search mode.
+ *
+ * @param boolean $enable
+ */
+ public function enableSearchMode($enable = true) {
+ $this->searchMode = $enable;
+ if ($enable) $this->enableEditMode(false);
+ }
+
/**
* Sets option values for a certain user.
*
public function getOption($optionName) {
$optionData = parent::getOption($optionName);
- $optionData['object'] = new ViewableUserOption($optionData['object']);
- if ($this->user !== null) {
- $optionData['object']->setOptionValue($this->user);
- }
-
- if ($this->removeEmptyOptions && empty($optionData['object']->optionValue)) {
- return null;
+ if (!$this->editMode && !$this->searchMode) {
+ $optionData['object'] = new ViewableUserOption($optionData['object']);
+ if ($this->user !== null) {
+ $optionData['object']->setOptionValue($this->user);
+ }
+
+ if ($this->removeEmptyOptions && empty($optionData['object']->optionValue)) {
+ return null;
+ }
}
return $optionData;
}
+ /**
+ * @see wcf\system\option\IOptionType::getFormElement()
+ */
+ protected function getFormElement($type, Option $option) {
+ if ($this->searchMode) return $this->getTypeObject($type)->getSearchFormElement($option, (isset($this->optionValues[$option->optionName]) ? $this->optionValues[$option->optionName] : null));
+
+ return parent::getFormElement($type, $option);
+ }
+
/**
* @see wcf\system\option\OptionHandler::validateOption()
*/
* @see wcf\system\option\OptionHandler::checkVisibility()
*/
protected function checkVisibility(Option $option) {
+ if ($option->disabled) {
+ return false;
+ }
+
+ // in registration
if ($this->inRegistration && !$option->askDuringRegistration && !$option->required) {
return false;
}
- if ($option->disabled) {
+ // search mode
+ if ($this->searchMode && !$option->searchable) {
return false;
}
if (!isset($this->optionValues[$option->optionName])) $this->optionValues[$option->optionName] = $option->defaultValue;
}
}
+
+ /**
+ * @see wcf\system\option\IOptionHandler::readUserInput()
+ */
+ public function readUserInput(array &$source) {
+ parent::readUserInput($source);
+
+ if ($this->searchMode) {
+ $this->optionValues = $this->rawValues;
+ }
+ }
}