use wcf\data\language\item\LanguageItemList;
use wcf\form\AbstractFormBuilderForm;
use wcf\system\form\builder\container\FormContainer;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
-use wcf\system\form\builder\field\data\VoidFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\VoidFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\form\builder\field\RadioButtonFormField;
use wcf\data\IStorableObject;
use wcf\system\form\builder\data\FormDataHandler;
use wcf\system\form\builder\data\IFormDataHandler;
-use wcf\system\form\builder\field\data\DefaultFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\DefaultFormFieldDataProcessor;
use wcf\system\form\builder\field\IFileFormField;
use wcf\system\form\builder\field\IFormField;
use wcf\system\WCF;
<?php
namespace wcf\system\form\builder\data;
-use wcf\system\form\builder\field\data\IFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\IFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
/**
<?php
namespace wcf\system\form\builder\data;
-use wcf\system\form\builder\field\data\IFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\IFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
/**
<?php
namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\IFormDocument;
use wcf\util\ArrayUtil;
namespace wcf\system\form\builder\field;
use wcf\data\language\item\LanguageItemList;
use wcf\data\IStorableObject;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\IFormDocument;
use wcf\system\form\builder\IFormNode;
<?php
namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
/**
<?php
namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\IFormDocument;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\data\IStorableObject;
use wcf\system\acl\ACLHandler;
use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\IObjectTypeFormField;
use wcf\system\form\builder\field\TObjectTypeFormField;
use wcf\system\form\builder\IFormDocument;
namespace wcf\system\form\builder\field\acl\simple;
use wcf\system\acl\simple\SimpleAclHandler;
use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
/**
+++ /dev/null
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Field data processor implementation that supports a custom processor callable.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2018 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since 3.2
- */
-class CustomFormFieldDataProcessor implements IFormFieldDataProcessor {
- /**
- * processor id primarily used for error messages
- * @var string
- */
- protected $id;
-
- /**
- * callable processing the data
- * @var callable
- */
- protected $processor;
-
- /**
- * Initializes a new CustomFormFieldDataProcessor object.
- *
- * @param string $id processor id primarily used for error messages, does not have to be unique
- * @param callable $processor processor callable
- *
- * @throws \InvalidArgumentException if either id or processor callable are invalid
- */
- public function __construct($id, callable $processor) {
- if (preg_match('~^[a-z][A-z0-9-]*$~', $id) !== 1) {
- throw new \InvalidArgumentException("Invalid id '{$id}' given.");
- }
-
- $this->id = $id;
-
- // validate processor function
- $parameters = (new \ReflectionFunction($processor))->getParameters();
- if (count($parameters) !== 2) {
- throw new \InvalidArgumentException(
- "The processor function must expect two parameters, instead " . count($parameters) .
- " parameter" . (count($parameters) !== 1 ? 's' : '') . " are expected."
- );
- }
-
- /** @var \ReflectionClass $parameterClass */
- $parameterClass = $parameters[0]->getClass();
- if ($parameterClass === null || ($parameterClass->getName() !== IFormDocument::class && !is_subclass_of($parameterClass->getName(), IFormDocument::class))) {
- throw new \InvalidArgumentException(
- "The processor function's first parameter must be an instance of '" . IFormDocument::class . "', instead " .
- ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected."
- );
- }
- if (!$parameters[1]->isArray()) {
- throw new \InvalidArgumentException("The processor function's second parameter must be an array.");
- }
-
- $this->processor = $processor;
- }
-
- /**
- * @inheritDoc
- */
- public function __invoke(IFormDocument $document, array $parameters) {
- $parameters = call_user_func($this->processor, $document, $parameters);
-
- if (!is_array($parameters)) {
- throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array.");
- }
-
- return $parameters;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\field\IFormField;
-use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
-use wcf\system\form\builder\IFormParentNode;
-
-/**
- * Default field data processor that maps the form fields to entries in
- * the `data` sub-array with the field ids as array keys and field values
- * as array values.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2018 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since 3.2
- */
-class DefaultFormFieldDataProcessor implements IFormFieldDataProcessor {
- /**
- * @inheritDoc
- */
- public function __invoke(IFormDocument $document, array $parameters) {
- $parameters['data'] = [];
-
- $this->getData($document, $parameters['data']);
-
- return $parameters;
- }
-
- /**
- * Fetches all data from the given node and stores it in the given array.
- *
- * @param IFormNode $node node whose data will be fetched
- * @param array $data data storage
- */
- protected function getData(IFormNode $node, array &$data) {
- if ($node->checkDependencies()) {
- if ($node instanceof IFormParentNode) {
- foreach ($node as $childNode) {
- $this->getData($childNode, $data);
- }
- }
- else if ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) {
- $data[$node->getObjectProperty()] = $node->getSaveValue();
- }
- }
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Represents a data processor for form fields that populates or manipulates the
- * parameters array passed to the constructor of a database object action.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2018 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since 3.2
- */
-interface IFormFieldDataProcessor {
- /**
- * Processes the given parameters array and returns the processed version of it.
- *
- * @param IFormDocument $document documents whose field data is processed
- * @param array $parameters parameters before processing
- * @return array parameters after processing
- */
- public function __invoke(IFormDocument $document, array $parameters);
-}
+++ /dev/null
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Field data processor implementation that voids a certain data property.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2018 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since 3.2
- */
-class VoidFormFieldDataProcessor implements IFormFieldDataProcessor {
- /**
- * is `true` if the property is stored in the `data` array
- * @var bool
- */
- protected $isDataProperty;
-
- /**
- * name of the voided property
- * @var string
- */
- protected $property;
-
- /**
- * Initializes a new CustomFormFieldDataProcessor object.
- *
- * @param string $property name of the voided property
- * @param bool $isDataProperty is `true` if the property is stored in the `data` array
- */
- public function __construct($property, $isDataProperty = true) {
- $this->property = $property;
- $this->isDataProperty = $isDataProperty;
- }
-
- /**
- * @inheritDoc
- */
- public function __invoke(IFormDocument $document, array $parameters) {
- if ($this->isDataProperty) {
- if (isset($parameters['data'][$this->property])) {
- unset($parameters['data'][$this->property]);
- }
- }
- else if (isset($parameters[$this->property])) {
- unset($parameters[$this->property]);
- }
-
- return $parameters;
- }
-}
--- /dev/null
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Field data processor implementation that supports a custom processor callable.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since 3.2
+ */
+class CustomFormFieldDataProcessor implements IFormFieldDataProcessor {
+ /**
+ * processor id primarily used for error messages
+ * @var string
+ */
+ protected $id;
+
+ /**
+ * callable processing the data
+ * @var callable
+ */
+ protected $processor;
+
+ /**
+ * Initializes a new CustomFormFieldDataProcessor object.
+ *
+ * @param string $id processor id primarily used for error messages, does not have to be unique
+ * @param callable $processor processor callable
+ *
+ * @throws \InvalidArgumentException if either id or processor callable are invalid
+ */
+ public function __construct($id, callable $processor) {
+ if (preg_match('~^[a-z][A-z0-9-]*$~', $id) !== 1) {
+ throw new \InvalidArgumentException("Invalid id '{$id}' given.");
+ }
+
+ $this->id = $id;
+
+ // validate processor function
+ $parameters = (new \ReflectionFunction($processor))->getParameters();
+ if (count($parameters) !== 2) {
+ throw new \InvalidArgumentException(
+ "The processor function must expect two parameters, instead " . count($parameters) .
+ " parameter" . (count($parameters) !== 1 ? 's' : '') . " are expected."
+ );
+ }
+
+ /** @var \ReflectionClass $parameterClass */
+ $parameterClass = $parameters[0]->getClass();
+ if ($parameterClass === null || ($parameterClass->getName() !== IFormDocument::class && !is_subclass_of($parameterClass->getName(), IFormDocument::class))) {
+ throw new \InvalidArgumentException(
+ "The processor function's first parameter must be an instance of '" . IFormDocument::class . "', instead " .
+ ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected."
+ );
+ }
+ if (!$parameters[1]->isArray()) {
+ throw new \InvalidArgumentException("The processor function's second parameter must be an array.");
+ }
+
+ $this->processor = $processor;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function __invoke(IFormDocument $document, array $parameters) {
+ $parameters = call_user_func($this->processor, $document, $parameters);
+
+ if (!is_array($parameters)) {
+ throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array.");
+ }
+
+ return $parameters;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\field\IFormField;
+use wcf\system\form\builder\IFormDocument;
+use wcf\system\form\builder\IFormNode;
+use wcf\system\form\builder\IFormParentNode;
+
+/**
+ * Default field data processor that maps the form fields to entries in
+ * the `data` sub-array with the field ids as array keys and field values
+ * as array values.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since 3.2
+ */
+class DefaultFormFieldDataProcessor implements IFormFieldDataProcessor {
+ /**
+ * @inheritDoc
+ */
+ public function __invoke(IFormDocument $document, array $parameters) {
+ $parameters['data'] = [];
+
+ $this->getData($document, $parameters['data']);
+
+ return $parameters;
+ }
+
+ /**
+ * Fetches all data from the given node and stores it in the given array.
+ *
+ * @param IFormNode $node node whose data will be fetched
+ * @param array $data data storage
+ */
+ protected function getData(IFormNode $node, array &$data) {
+ if ($node->checkDependencies()) {
+ if ($node instanceof IFormParentNode) {
+ foreach ($node as $childNode) {
+ $this->getData($childNode, $data);
+ }
+ }
+ else if ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) {
+ $data[$node->getObjectProperty()] = $node->getSaveValue();
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Represents a data processor for form fields that populates or manipulates the
+ * parameters array passed to the constructor of a database object action.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since 3.2
+ */
+interface IFormFieldDataProcessor {
+ /**
+ * Processes the given parameters array and returns the processed version of it.
+ *
+ * @param IFormDocument $document documents whose field data is processed
+ * @param array $parameters parameters before processing
+ * @return array parameters after processing
+ */
+ public function __invoke(IFormDocument $document, array $parameters);
+}
--- /dev/null
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Field data processor implementation that voids a certain data property.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since 3.2
+ */
+class VoidFormFieldDataProcessor implements IFormFieldDataProcessor {
+ /**
+ * is `true` if the property is stored in the `data` array
+ * @var bool
+ */
+ protected $isDataProperty;
+
+ /**
+ * name of the voided property
+ * @var string
+ */
+ protected $property;
+
+ /**
+ * Initializes a new CustomFormFieldDataProcessor object.
+ *
+ * @param string $property name of the voided property
+ * @param bool $isDataProperty is `true` if the property is stored in the `data` array
+ */
+ public function __construct($property, $isDataProperty = true) {
+ $this->property = $property;
+ $this->isDataProperty = $isDataProperty;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function __invoke(IFormDocument $document, array $parameters) {
+ if ($this->isDataProperty) {
+ if (isset($parameters['data'][$this->property])) {
+ unset($parameters['data'][$this->property]);
+ }
+ }
+ else if (isset($parameters[$this->property])) {
+ unset($parameters[$this->property]);
+ }
+
+ return $parameters;
+ }
+}
use wcf\data\tag\Tag;
use wcf\data\IStorableObject;
use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\IObjectTypeFormField;
use wcf\system\form\builder\field\TObjectTypeFormField;
use wcf\system\form\builder\IFormDocument;
use wcf\system\exception\SystemException;
use wcf\system\form\builder\container\IFormContainer;
use wcf\system\form\builder\field\BooleanFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\IntegerFormField;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\form\builder\field\bbcode\BBCodeAttributesFormField;
use wcf\system\form\builder\field\BooleanFormField;
use wcf\system\form\builder\field\ClassNameFormField;
-use wcf\system\form\builder\field\data\VoidFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\VoidFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\IconFormField;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\ClassNameFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\form\builder\field\TextFormField;
use wcf\system\form\builder\field\TitleFormField;
use wcf\system\exception\SystemException;
use wcf\system\form\builder\container\IFormContainer;
use wcf\system\form\builder\field\BooleanFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\form\builder\container\FormContainer;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\IntegerFormField;
use wcf\system\form\builder\field\ItemListFormField;
use wcf\system\form\builder\field\TextFormField;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
use wcf\system\form\builder\container\FormContainer;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\IntegerFormField;
use wcf\system\form\builder\field\option\OptionFormField;
use wcf\system\form\builder\container\IFormContainer;
use wcf\system\form\builder\field\BooleanFormField;
use wcf\system\form\builder\field\ClassNameFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
use wcf\system\form\builder\field\MultilineTextFormField;
use wcf\system\form\builder\field\SingleSelectionFormField;