* @param bool $cancelable determines if dialog from can be canceled
* @return static this document
*/
- public function cancelable(bool $cancelable = true): DialogFormDocument {
+ public function cancelable(bool $cancelable = true) {
$this->__isCancelable = $cancelable;
return $this;
/**
* @inheritDoc
*/
- public function getAction(): string {
+ public function getAction() {
// do not throw exception if no action has been set as a dialog
// form does not require an action to be set
if ($this->__action === null) {
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
return WCF::getTPL()->fetch(
'__dialogForm',
'wcf',
*
* @return bool
*/
- public function isCancelable(): bool {
+ public function isCancelable() {
return $this->__isCancelable;
}
}
/**
* @inheritDoc
*/
- public function add(IFormFieldDataProcessor $processor): IFormDataHandler {
+ public function add(IFormFieldDataProcessor $processor) {
$this->processors[] = $processor;
return $this;
/**
* @inheritDoc
*/
- public function getData(IFormDocument $document): array {
+ public function getData(IFormDocument $document) {
$parameters = [];
foreach ($this->processors as $processor) {
$parameters = $processor($document, $parameters);
/**
* @inheritDoc
*/
- public function action(string $action): IFormDocument {
+ public function action(string $action) {
$this->__action = $action;
return $this;
/**
* @inheritDoc
*/
- public function build(): IFormDocument {
+ public function build() {
if ($this->isBuilt) {
throw new \BadMethodCallException("Form document has already been built.");
}
/**
* @inheritDoc
*/
- public function formMode(string $formMode): IFormDocument {
+ public function formMode(string $formMode) {
if ($this->__formMode !== null) {
throw new \BadMethodCallException("Form mode has already been set");
}
/**
* @inheritDoc
*/
- public function getAction(): string {
+ public function getAction() {
if ($this->__action === null) {
throw new \BadMethodCallException("Action has not been set.");
}
/**
* @inheritDoc
*/
- public function getData(): array {
+ public function getData() {
return $this->getDataHandler()->getData($this);
}
/**
* @inheritDoc
*/
- public function getDataHandler(): IFormDataHandler {
+ public function getDataHandler() {
if ($this->dataHandler === null) {
$this->dataHandler = new FormDataHandler();
$this->dataHandler->add(new DefaultFormFieldDataProcessor());
/**
* @inheritDoc
*/
- public function getDocument(): IFormDocument {
+ public function getDocument() {
return $this;
}
/**
* @inheritDoc
*/
- public function getFormMode(): string {
+ public function getFormMode() {
if ($this->__formMode === null) {
$this->__formMode = self::FORM_MODE_CREATE;
}
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
return WCF::getTPL()->fetch(
'__form',
'wcf',
/**
* @inheritDoc
*/
- public function getMethod(): string {
+ public function getMethod() {
return $this->__method;
}
/**
* @inheritDoc
*/
- public function getPrefix(): string {
+ public function getPrefix() {
if ($this->__prefix === null) {
return '';
}
/**
* @inheritDoc
*/
- public function hasRequestData(string $index = null): bool {
+ public function hasRequestData(string $index = null) {
$requestData = $this->getRequestData();
if ($index !== null) {
/**
* @inheritDoc
*/
- public function loadValuesFromObject(IStorableObject $object): IFormDocument {
+ public function loadValuesFromObject(IStorableObject $object) {
if ($this->__formMode === null) {
$this->formMode(self::FORM_MODE_UPDATE);
}
/**
* @inheritDoc
*/
- public function method(string $method): IFormDocument {
+ public function method(string $method) {
if ($method !== 'get' && $method !== 'post') {
throw new \InvalidArgumentException("Invalid method '{$method}' given.");
}
/**
* @inheritDoc
*/
- public function prefix(string $prefix): IFormDocument {
+ public function prefix(string $prefix) {
static::validateId($prefix);
$this->__prefix = $prefix;
/**
* @inheritDoc
*/
- public function readValues(): IFormParentNode {
+ public function readValues() {
if ($this->__requestData === null) {
$this->__requestData = $_POST;
}
/**
* @inheritDoc
*/
- public function requestData(array $requestData): IFormDocument {
+ public function requestData(array $requestData) {
if ($this->__requestData !== null) {
throw new \BadMethodCallException('Request data has already been set.');
}
*
* @throws \BadMethodCallException if the parent node has not been set previously
*/
- public function getParent(): IFormParentNode;
+ public function getParent();
/**
* Sets the parent node of this node and returns this node.
*
* @throws \BadMethodCallException if the parent node has already been set
*/
- public function parent(IFormParentNode $parentNode): IFormChildNode;
+ public function parent(IFormParentNode $parentNode);
}
* @param IFormFieldDataProcessor $processor added field data processor
* @return static this data handler
*/
- public function add(IFormFieldDataProcessor $processor): IFormDataHandler;
+ public function add(IFormFieldDataProcessor $processor);
/**
* Returns the data from the given form that is passed as the parameters
* @param IFormDocument $document processed form document
* @return array data passed to database object action
*/
- public function getData(IFormDocument $document): array;
+ public function getData(IFormDocument $document);
}
*
* @throws \InvalidArgumentException if the given action is invalid
*/
- public function action(string $action): IFormDocument;
+ public function action(string $action);
/**
* Is called once after all nodes have been added to this document.
*
* @throws \BadMethodCallException if this document has already been built
*/
- public function build(): IFormDocument;
+ public function build();
/**
* Sets the form mode (see `self::FORM_MODE_*` constants).
* @throws \BadMethodCallException if the form mode has already been set
* @throws \InvalidArgumentException if the given form mode is invalid
*/
- public function formMode(string $formMode): IFormDocument;
+ public function formMode(string $formMode);
/**
* Returns the `action` property of the HTML `form` element.
*
* @throws \BadMethodCallException if no action has been set
*/
- public function getAction(): string;
+ public function getAction();
/**
* Returns the array passed as the `$parameters` argument of the constructor
*
* @return array data passed to database object action
*/
- public function getData(): array;
+ public function getData();
/**
* Returns the data handler for this document that is used to process the
*
* @return IFormDataHandler form data handler
*/
- public function getDataHandler(): IFormDataHandler;
+ public function getDataHandler();
/**
* Returns the encoding type of this form. If the form contains any
*
* @return string form mode
*/
- public function getFormMode(): string;
+ public function getFormMode();
/**
* Returns the `method` property of the HTML `form` element. If no method
*
* @return string form method
*/
- public function getMethod(): string;
+ public function getMethod();
/**
* Returns the global form prefix that is prepended to form elements' names and ids to
*
* @return string global form element prefix
*/
- public function getPrefix(): string;
+ public function getPrefix();
/**
* Returns the request data of the form's fields.
* @param null|string $index array index of the returned data
* @return bool `tu
*/
- public function hasRequestData(string $index = null): bool;
+ public function hasRequestData(string $index = null);
/**
* Loads the field values from the given object and returns this document.
* @param IStorableObject $object object used to load field values
* @return static this document
*/
- public function loadValuesFromObject(IStorableObject $object): IFormDocument;
+ public function loadValuesFromObject(IStorableObject $object);
/**
* Sets the `method` property of the HTML `form` element and returns this document.
*
* @throws \InvalidArgumentException if the given method is invalid
*/
- public function method(string $method): IFormDocument;
+ public function method(string $method);
/**
* Sets the global form prefix that is prepended to form elements' names and ids to
*
* @throws \InvalidArgumentException if the given prefix is invalid
*/
- public function prefix(string $prefix): IFormDocument;
+ public function prefix(string $prefix);
/**
* Sets the request data of the form's fields.
*
* @throws \BadMethodCallException if request data has already been set
*/
- public function requestData(array $requestData): IFormDocument;
+ public function requestData(array $requestData);
}
*
* @throws \InvalidArgumentException if the given description is invalid
*/
- public function description(string $languageItem = null, array $variables = []): IFormElement;
+ public function description(string $languageItem = null, array $variables = []);
/**
* Returns the description of this element or `null` if no description has been set.
*
* @throws \InvalidArgumentException if the given label is invalid
*/
- public function label(string $languageItem = null, array $variables = []): IFormElement;
+ public function label(string $languageItem = null, array $variables = []);
/**
* Returns `true` if this element requires a label to be set.
*
* @return bool
*/
- public function requiresLabel(): bool;
+ public function requiresLabel();
}
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function addClass(string $class): IFormNode;
+ public function addClass(string $class);
/**
* Adds a dependency on the value of a `IFormField` so that this node is
* @param IFormFieldDependency $dependency added node dependency
* @return static this node
*/
- public function addDependency(IFormFieldDependency $dependency): IFormNode;
+ public function addDependency(IFormFieldDependency $dependency);
/**
* Adds an additional attribute to this node and returns this node.
*
* @throws \InvalidArgumentException if an invalid name or value is given (some attribute names are invalid as there are specific methods for setting that attribute)
*/
- public function attribute(string $name, string $value = null): IFormNode;
+ public function attribute(string $name, string $value = null);
/**
* Sets if this node is available and returns this node.
* @param bool $available determines if node is available
* @return static this node
*/
- public function available(bool $available = true): IFormNode;
+ public function available(bool $available = true);
/**
* Returns `true` if the node's dependencies are met and returns `false` otherwise.
*
* @return bool
*/
- public function checkDependencies(): bool;
+ public function checkDependencies();
/**
* Returns the value of the additional attribute of this node with the given name.
*
* @return array additional node attributes
*/
- public function getAttributes(): array;
+ public function getAttributes();
/**
* Returns all CSS classes of this node.
*
* @return string[] CSS classes of node
*/
- public function getClasses(): array;
+ public function getClasses();
/**
* Returns all of the node's dependencies.
*
* @return IFormFieldDependency[] node's dependencies
*/
- public function getDependencies(): array;
+ public function getDependencies();
/**
* Returns the form document this node belongs to.
*
* @throws \BadMethodCallException if form document is inaccessible for this node
*/
- public function getDocument(): IFormDocument;
+ public function getDocument();
/**
* Returns the html representation of this node.
*
* @return string html representation of node
*/
- public function getHtml(): string;
+ public function getHtml();
/**
* Returns additional template variables used to generate the html representation
*
* @return array additional template variables
*/
- public function getHtmlVariables(): array;
+ public function getHtmlVariables();
/**
* Returns the id of the form node.
*
* @throws \BadMethodCallException if no id has been set
*/
- public function getId(): string;
+ public function getId();
/**
* Returns the prefixed id of this node that means a combination of the form
*
* @throws \BadMethodCallException if no id has been set or if form document is inaccessible for this node
*/
- public function getPrefixedId(): string;
+ public function getPrefixedId();
/**
* Returns `true` if an additional attribute with the given name exists and returns
*
* @throws \InvalidArgumentException if the given attribute name is invalid
*/
- public function hasAttribute(string $name): bool;
+ public function hasAttribute(string $name);
/**
* Returns `true` if a CSS class with the given name exists and returns `false` otherwise.
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function hasClass(string $class): bool;
+ public function hasClass(string $class);
/**
* Returns `true` if this node has a dependency with the given id and
*
* @throws \InvalidArgumentException if the given id is invalid
*/
- public function hasDependency(string $dependencyId): bool;
+ public function hasDependency(string $dependencyId);
/**
* Sets the id of the node.
* @throws \BadMethodCallException if id has already been set
* @throws \InvalidArgumentException if the given id is invalid
*/
- public function id(string $id): IFormNode;
+ public function id(string $id);
/**
* Returns `true` if this node is available and returns `false` otherwise.
*
* @see IFormNode::available()
*/
- public function isAvailable(): bool;
+ public function isAvailable();
/**
* Is called once after all nodes have been added to the document this node belongs to.
*
* @throws \BadMethodCallException if this node has already been populated
*/
- public function populate(): IFormNode;
+ public function populate();
/**
* Removes the given CSS class and returns this node.
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function removeClass(string $class): IFormNode;
+ public function removeClass(string $class);
/**
* Removes the dependency with the given id and returns this node.
*
* @throws \InvalidArgumentException if the given id is invalid or no such dependency exists
*/
- public function removeDependency(string $dependencyId): IFormNode;
+ public function removeDependency(string $dependencyId);
/**
* Validates the node.
*
* @throws \InvalidArgumentException if the given id is already used by another element or otherwise is invalid
*/
- public static function create(string $id): IFormNode;
+ public static function create(string $id);
/**
* Checks if the given attribute name class a string and a valid attribute name.
*
* @throws \InvalidArgumentException if the given child node cannot be appended
*/
- public function appendChild(IFormChildNode $child): IFormParentNode;
+ public function appendChild(IFormChildNode $child);
/**
* Appends the given children to this node and returns this node.
*
* @throws \InvalidArgumentException if any of the given child nodes is invalid or cannot be appended
*/
- public function appendChildren(array $children): IFormParentNode;
+ public function appendChildren(array $children);
/**
* Returns all child nodes of this node.
*
* @return IFormChildNode[] children of this node
*/
- public function children(): array;
+ public function children();
/**
* Returns `true` if this node (or any of the child nodes) contains the node
* @param string $nodeId id of searched node
* @return bool
*/
- public function contains(string $nodeId): bool;
+ public function contains(string $nodeId);
/**
* Returns a recursive iterator for this node.
*
* @return \RecursiveIteratorIterator recursive iterator for this node
*/
- public function getIterator(): \RecursiveIteratorIterator;
+ public function getIterator();
/**
* Returns the node with the given id or `null` if no such node exists.
*
* @return bool
*/
- public function hasValidationErrors(): bool;
+ public function hasValidationErrors();
/**
* Inserts the given node before the node with the given id and returns this node.
*
* @throws \InvalidArgumentException if given node cannot be inserted or reference node id is invalid
*/
- public function insertBefore(IFormChildNode $child, string $referenceNodeId): IFormParentNode;
+ public function insertBefore(IFormChildNode $child, string $referenceNodeId);
/**
* Reads the value of this node and its children from request data and
*
* @return static this node
*/
- public function readValues(): IFormParentNode;
+ public function readValues();
/**
* Checks if the given node can be added as a child to this node.
*
* @throws \BadMethodCallException if form document is inaccessible for this node
*/
- public function getDocument(): IFormDocument {
+ public function getDocument() {
$element = $this;
while ($element instanceof IFormChildNode) {
$element = $element->getParent();
*
* @throws \BadMethodCallException if the parent node has not been set previously
*/
- public function getParent(): IFormParentNode {
+ public function getParent() {
if ($this->__parent === null) {
throw new \BadMethodCallException("Before getting the parent node of '{$this->getId()}', it must be set.");
}
* @param IFormParentNode $parentNode new parent node of this node
* @return static this node
*/
- public function parent(IFormParentNode $parentNode): IFormChildNode {
+ public function parent(IFormParentNode $parentNode) {
if ($this->__parent !== null) {
throw new \BadMethodCallException("The parent node of '{$this->getId()}' has already been set.");
}
*
* @throws \InvalidArgumentException if the given description is no string or otherwise is invalid
*/
- public function description(string $languageItem = null, array $variables = []): IFormElement {
+ public function description(string $languageItem = null, array $variables = []) {
if ($languageItem === null) {
if (!empty($variables)) {
throw new \InvalidArgumentException("Cannot use variables when unsetting description of element '{$this->getId()}'");
*
* @throws \InvalidArgumentException if the given label is no string or otherwise is invalid
*/
- public function label(string $languageItem = null, array $variables = []): IFormElement {
+ public function label(string $languageItem = null, array $variables = []) {
if ($languageItem === null) {
if (!empty($variables)) {
throw new \InvalidArgumentException("Cannot use variables when unsetting label of element '{$this->getId()}'");
*
* @return bool
*/
- public function requiresLabel(): bool {
+ public function requiresLabel() {
// by default, form elements do not require a label
return false;
}
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function addClass(string $class): IFormNode {
+ public function addClass(string $class) {
static::validateClass($class);
if (!in_array($class, $this->__classes)) {
* to this node.
*
* @param IFormFieldDependency $dependency added node dependency
- * @return static this node
+ * @return static this node
*/
- public function addDependency(IFormFieldDependency $dependency): IFormNode {
+ public function addDependency(IFormFieldDependency $dependency) {
$this->dependencies[] = $dependency;
$dependency->dependentNode($this);
*
* @throws \InvalidArgumentException if an invalid name or value is given (some attribute names are invalid as there are specific methods for setting that attribute)
*/
- public function attribute(string $name, string $value = null): IFormNode {
+ public function attribute(string $name, string $value = null) {
static::validateAttribute($name);
if ($value !== null && !is_bool($value) && !is_numeric($value) && !is_string($value)) {
* @param bool $available determines if node is available
* @return static this node
*/
- public function available(bool $available = true): IFormNode {
+ public function available(bool $available = true) {
$this->__available = $available;
return $this;
*
* @return bool
*/
- public function checkDependencies(): bool {
+ public function checkDependencies() {
if (!empty($this->dependencies)) {
foreach ($this->dependencies as $dependency) {
if (!$dependency->checkDependency()) {
*
* @return array additional node attributes
*/
- public function getAttributes(): array {
+ public function getAttributes() {
return $this->__attributes;
}
*
* @return string[] CSS classes of node
*/
- public function getClasses(): array {
+ public function getClasses() {
return $this->__classes;
}
*
* @return IFormFieldDependency[] node's dependencies
*/
- public function getDependencies(): array {
+ public function getDependencies() {
return $this->dependencies;
}
*
* @throws \BadMethodCallException if form document is inaccessible for this node
*/
- abstract public function getDocument(): IFormDocument;
+ abstract public function getDocument();
/**
* Returns additional template variables used to generate the html representation
*
* @return array additional template variables
*/
- public function getHtmlVariables(): array {
+ public function getHtmlVariables() {
return [];
}
*
* @throws \BadMethodCallException if no id has been set
*/
- public function getId(): string {
+ public function getId() {
if ($this->__id === null) {
throw new \BadMethodCallException("Id has not been set.");
}
*
* @throws \BadMethodCallException if no id has been set or if form document is inaccessible for this node
*/
- public function getPrefixedId(): string {
+ public function getPrefixedId() {
return $this->getDocument()->getPrefix() . $this->getId();
}
*
* @throws \InvalidArgumentException if the given attribute name is invalid
*/
- public function hasAttribute(string $name): bool {
+ public function hasAttribute(string $name) {
static::validateAttribute($name);
return isset($this->__attributes[$name]);
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function hasClass(string $class): bool {
+ public function hasClass(string $class) {
static::validateClass($class);
return array_search($class, $this->__classes) !== false;
*
* @throws \InvalidArgumentException if the given id is invalid
*/
- public function hasDependency(string $dependencyId): bool {
+ public function hasDependency(string $dependencyId) {
foreach ($this->dependencies as $dependency) {
if ($dependency->getId() === $dependencyId) {
return true;
* @throws \BadMethodCallException if id has already been set
* @throws \InvalidArgumentException if the given id is invalid
*/
- public function id(string $id): IFormNode {
+ public function id(string $id) {
static::validateId($id);
if ($this->__id !== null) {
*
* @see IFormNode::available()
*/
- public function isAvailable(): bool {
+ public function isAvailable() {
if ($this->__available && $this instanceof IFormParentNode) {
/** @var IFormChildNode $child */
foreach ($this as $child) {
*
* @throws \BadMethodCallException if this node has already been populated
*/
- public function populate(): IFormNode {
+ public function populate() {
if ($this->isPopulated) {
throw new \BadMethodCallException('Node has already been populated');
}
*
* @throws \InvalidArgumentException if the given class is invalid
*/
- public function removeClass(string $class): IFormNode {
+ public function removeClass(string $class) {
static::validateClass($class);
$index = array_search($class, $this->__classes);
*
* @throws \InvalidArgumentException if the given id is invalid or no such dependency exists
*/
- public function removeDependency(string $dependencyId): IFormNode {
+ public function removeDependency(string $dependencyId) {
foreach ($this->dependencies as $key => $dependency) {
if ($dependency->getId() === $dependencyId) {
unset($this->dependencies[$key]);
*
* @throws \InvalidArgumentException if the given id is already used by another node, or otherwise is invalid
*/
- public static function create(string $id): IFormNode {
+ public static function create(string $id) {
return (new static)->id($id);
}
*
* @throws \InvalidArgumentException if the given child node cannot be appended
*/
- public function appendChild(IFormChildNode $child): IFormParentNode {
+ public function appendChild(IFormChildNode $child) {
$this->validateChild($child);
$this->__children[] = $child;
*
* @throws \InvalidArgumentException if any of the given child nodes is invalid or cannot be appended
*/
- public function appendChildren(array $children): IFormParentNode {
+ public function appendChildren(array $children) {
foreach ($children as $child) {
$this->appendChild($child);
}
* @param string $nodeId id of searched node
* @return bool
*/
- public function contains(string $nodeId): bool {
+ public function contains(string $nodeId) {
static::validateId($nodeId);
foreach ($this->children() as $child) {
*
* @return IFormChildNode[] children of this node
*/
- public function children(): array {
+ public function children() {
return $this->__children;
}
*
* @return int number of children
*/
- public function count(): int {
+ public function count() {
return count($this->__children);
}
*
* @return IFormChildNode current child node
*/
- public function current(): IFormChildNode {
+ public function current() {
return $this->__children[$this->index];
}
*
* @return \RecursiveIteratorIterator recursive iterator for this node
*/
- public function getIterator(): \RecursiveIteratorIterator {
+ public function getIterator() {
return new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST, \RecursiveIteratorIterator::CATCH_GET_CHILD);
}
*
* @return bool
*/
- public function hasChildren(): bool {
+ public function hasChildren() {
return !empty($this->__children);
}
*
* @return bool
*/
- public function hasValidationErrors(): bool {
+ public function hasValidationErrors() {
foreach ($this->children() as $child) {
if ($child instanceof IFormField) {
if (!empty($child->getValidationErrors())) {
*
* @throws \InvalidArgumentException if given node cannot be inserted or reference node id is invalid
*/
- public function insertBefore(IFormChildNode $child, string $referenceNodeId): IFormParentNode {
+ public function insertBefore(IFormChildNode $child, string $referenceNodeId) {
$didInsertNode = false;
foreach ($this->children() as $index => $existingChild) {
if ($existingChild->getId() === $referenceNodeId) {
*
* @return int element key during the iteration
*/
- public function key(): int {
+ public function key() {
return $this->index;
}
*
* @return IFormParentNode this node
*/
- public function readValues(): IFormParentNode {
+ public function readValues() {
if ($this->isAvailable()) {
foreach ($this->children() as $child) {
if ($child instanceof IFormParentNode) {
*
* @return bool
*/
- public function valid(): bool {
+ public function valid() {
return isset($this->__children[$this->index]);
}
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
return WCF::getTPL()->fetch($this->templateName, 'wcf', array_merge($this->getHtmlVariables(), [
'container' => $this
]), true);
/**
* @inheritDoc
*/
- public function addValidationError(IFormFieldValidationError $error): IFormField {
+ public function addValidationError(IFormFieldValidationError $error) {
if (empty($this->validationErrors)) {
$this->addClass('formError');
}
/**
* @inheritDoc
*/
- public function addValidator(IFormFieldValidator $validator): IFormField {
+ public function addValidator(IFormFieldValidator $validator) {
if ($this->hasValidator($validator->getId())) {
throw new \InvalidArgumentException("Validator with id '{$validator->getId()}' already exists.");
}
/**
* @inheritDoc
*/
- public function autoFocus(bool $autoFocus = true): IFormField {
+ public function autoFocus(bool $autoFocus = true) {
$this->__autoFocus = $autoFocus;
return $this;
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
if ($this->templateName === null) {
throw new \LogicException("\$templateName property has not been set.");
}
/**
* @inheritDoc
*/
- public function getObjectProperty(): string {
+ public function getObjectProperty() {
if ($this->__objectProperty !== null) {
return $this->__objectProperty;
}
/**
* @inheritDoc
*/
- public function getValidationErrors(): array {
+ public function getValidationErrors() {
return $this->validationErrors;
}
/**
* @inheritDoc
*/
- public function getValidators(): array {
+ public function getValidators() {
return $this->validators;
}
/**
* @inheritDoc
*/
- public function hasValidator(string $validatorId): bool {
+ public function hasValidator(string $validatorId) {
FormFieldValidator::validateId($validatorId);
return isset($this->validators[$validatorId]);
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return true;
}
/**
* @inheritDoc
*/
- public function immutable(bool $immutable = true): IFormField {
+ public function immutable(bool $immutable = true) {
$this->__immutable = $immutable;
return $this;
/**
* @inheritDoc
*/
- public function isAutoFocused(): bool {
+ public function isAutoFocused() {
return $this->__autoFocus;
}
/**
* @inheritDoc
*/
- public function isImmutable(): bool {
+ public function isImmutable() {
return $this->__immutable;
}
/**
* @inheritDoc
*/
- public function isRequired(): bool {
+ public function isRequired() {
return $this->__required;
}
/**
* @inheritDoc
*/
- public function loadValueFromObject(IStorableObject $object): IFormField {
+ public function loadValueFromObject(IStorableObject $object) {
if (isset($object->{$this->getObjectProperty()})) {
$this->value($object->{$this->getObjectProperty()});
}
* @inheritDoc
* @return static
*/
- public function objectProperty(string $objectProperty): IFormField {
+ public function objectProperty(string $objectProperty) {
if ($objectProperty === '') {
$this->__objectProperty = null;
}
/**
* @inheritDoc
*/
- public function removeValidator(string $validatorId): IFormField {
+ public function removeValidator(string $validatorId) {
if (!$this->hasValidator($validatorId)) {
throw new \InvalidArgumentException("Unknown validator with id '{$validatorId}'");
}
* @inheritDoc
* @return static
*/
- public function required(bool $required = true): IFormField {
+ public function required(bool $required = true) {
$this->__required = $required;
return $this;
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
$this->__value = $value;
return $this;
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
*
* @throws \InvalidArgumentException if the given step value is invalid
*/
- public function step($step = null): AbstractNumericFormField {
+ public function step($step = null) {
if ($step !== null) {
if ($this->integerValues) {
if (!is_int($step)) {
/**
* @inheritDoc
- * @return static this field
*/
- public function value($value): IFormField {
+ public function value($value) {
if ($value !== null) {
if (is_string($value) && is_numeric($value)) {
if (preg_match('~^\d+$~', $value)) {
use wcf\system\acl\ACLHandler;
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
/**
* Implementation of a form field for setting acl option values.
*
* @throws \InvalidArgumentException if given category name is invalid
*/
- public function categoryName(string $categoryName): AclFormField {
+ public function categoryName(string $categoryName) {
// TODO: validation
$this->__categoryName = $categoryName;
/**
* @inheritDoc
*/
- public function getHtmlVariables(): array {
+ public function getHtmlVariables() {
ACLHandler::getInstance()->assignVariables($this->getObjectType()->objectTypeID);
$includeAclJavaScript = !static::$includedAclJavaScript;
/**
* @inheritDoc
*/
- public function getObjectTypeDefinition(): string {
+ public function getObjectTypeDefinition() {
return 'com.woltlab.wcf.acl';
}
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return false;
}
/**
* @inheritDoc
*/
- public function loadValueFromObject(IStorableObject $object): IFormField {
+ public function loadValueFromObject(IStorableObject $object) {
$this->objectID = $object->{$object::getDatabaseTableIndexName()};
if ($this->objectID === null) {
/**
* @inheritDoc
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
$this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) {
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
ACLHandler::getInstance()->readValues($this->getObjectType()->objectTypeID);
return $this;
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$this->__value = $this->getDocument()->getRequestData($this->getPrefixedId()) === '1';
}
/**
* @inheritDoc
*/
- public function requiresLabel(): bool {
+ public function requiresLabel() {
return true;
}
/**
* @inheritDoc
- * @return static this field
*/
- public function value($value): IFormField {
+ public function value($value) {
if (is_string($value) && in_array($value, ['0', '1', 'true', 'false'])) {
$value = ($value === '1' || $value === 'true');
}
* @param bool $classExists determines if entered class must exist
* @return static this field
*/
- public function classExists(bool $classExists = true): ClassNameFormField {
+ public function classExists(bool $classExists = true) {
$this->__classExists = $classExists;
return $this;
*
* @return bool
*/
- public function getClassExists(): bool {
+ public function getClassExists() {
return $this->__classExists;
}
*
* @return string
*/
- public function getImplementedInterface(): string {
+ public function getImplementedInterface() {
return $this->__implementedInterface;
}
*
* @return string
*/
- public function getParentClass(): string {
+ public function getParentClass() {
return $this->__parentClass;
}
*
* @throws \InvalidArgumentException if the entered interface does not exists
*/
- public function implementedInterface(string $interface): ClassNameFormField {
+ public function implementedInterface(string $interface) {
if (!interface_exists($interface)) {
throw new \InvalidArgumentException("Interface '{$interface}' does not exist.");
}
* @param bool $instantiable determines if entered class must be instantiable
* @return static this field
*/
- public function instantiable(bool $instantiable = true): ClassNameFormField {
+ public function instantiable(bool $instantiable = true) {
$this->__instantiable = $instantiable;
return $this;
*
* @return bool
*/
- public function isInstantiable(): bool {
+ public function isInstantiable() {
return $this->__instantiable;
}
*
* @throws \InvalidArgumentException if the entered class does not exists
*/
- public function parentClass(string $parentClass): ClassNameFormField {
+ public function parentClass(string $parentClass) {
if (!class_exists($parentClass)) {
throw new \InvalidArgumentException("Class '{$parentClass}' does not exist.");
}
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'className';
}
}
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'description';
}
}
* @param IFormFieldValidationError $error validation error
* @return static this field
*/
- public function addValidationError(IFormFieldValidationError $error): IFormField;
+ public function addValidationError(IFormFieldValidationError $error);
/**
* Sets whether this field is auto-focused and returns this field.
* @param bool $autoFocus determines if field is auto-focused
* @return static this field
*/
- public function autoFocus(bool $autoFocus = true): IFormField;
+ public function autoFocus(bool $autoFocus = true);
/**
* Adds the given validation error to this field and returns this field.
* @param IFormFieldValidator $validator
* @return static this field
*/
- public function addValidator(IFormFieldValidator $validator): IFormField;
+ public function addValidator(IFormFieldValidator $validator);
/**
* Returns the name of the object property this field represents.
*
* @return string
*/
- public function getObjectProperty(): string;
+ public function getObjectProperty();
/**
* Returns the field value saved in the database.
*
* @return IFormFieldValidationError[] field validation errors
*/
- public function getValidationErrors(): array;
+ public function getValidationErrors();
/**
* Returns all field value validators of this field.
*
* @return IFormFieldValidator[] field value validators of this field
*/
- public function getValidators(): array;
+ public function getValidators();
/**
* Returns the value of this field or `null` if no value has been set.
*
* @throws \InvalidArgumentException if the given id is invalid
*/
- public function hasValidator(string $validatorId): bool;
+ public function hasValidator(string $validatorId);
/**
* Returns `true` if this field provides a value that can simply be stored
*
* @return bool
*/
- public function hasSaveValue(): bool;
+ public function hasSaveValue();
/**
* Sets whether the value of this field is immutable and returns this field.
* @param bool $immutable determines if field value is immutable
* @return static this field
*/
- public function immutable(bool $immutable = true): IFormField;
+ public function immutable(bool $immutable = true);
/**
* Returns `true` if this field is auto-focused and returns `false` otherwise.
*
* @return bool
*/
- public function isAutoFocused(): bool;
+ public function isAutoFocused();
/**
* Returns `true` if the value of this field is immutable and returns `false`
*
* @return bool
*/
- public function isImmutable(): bool;
+ public function isImmutable();
/**
* Returns `true` if this field has to be filled out and returns `false` otherwise.
*
* @return bool
*/
- public function isRequired(): bool;
+ public function isRequired();
/**
* Loads the field value from the given object and returns this field.
* @param IStorableObject $object object used to load field value
* @return static this field
*/
- public function loadValueFromObject(IStorableObject $object): IFormField;
+ public function loadValueFromObject(IStorableObject $object);
/**
* Sets the name of the object property this field represents. If an empty
*
* @throws \InvalidArgumentException if the passed object property is no valid id
*/
- public function objectProperty(string $objectProperty): IFormField;
+ public function objectProperty(string $objectProperty);
/**
* Reads the value of this field from request data and return this field.
*
* @return static this field
*/
- public function readValue(): IFormField;
+ public function readValue();
/**
* Removes the field value validator with the given id and returns this field.
*
* @throws \InvalidArgumentException if the given id is invalid or no such validator exists
*/
- public function removeValidator(string $validatorId): IFormField;
+ public function removeValidator(string $validatorId);
/**
* Sets whether it is required to fill out this field and returns this field.
* @param bool $required determines if field has to be filled out
* @return static this field
*/
- public function required(bool $required = true): IFormField;
+ public function required(bool $required = true);
/**
* Sets the value of this field and returns this field.
*
* @throws \InvalidArgumentException if the given value is of an invalid type or otherwise is invalid
*/
- public function value($value): IFormField;
+ public function value($value);
}
*
* @throws \BadMethodCallException if i18n is disabled for this field or no language item has been set
*/
- public function getLanguageItemPattern(): string;
+ public function getLanguageItemPattern();
/**
* Returns `true` if the current field value is a i18n value and returns `false`
*
* @return bool
*/
- public function hasI18nValues(): bool;
+ public function hasI18nValues();
/**
* Returns `true` if the current field value is a plain value and returns `false`
*
* @return bool
*/
- public function hasPlainValue(): bool;
+ public function hasPlainValue();
/**
* Sets whether this field is supports i18n input and returns this field.
* @param bool $i18n determines if field is supports i18n input
* @return static this field
*/
- public function i18n(bool $i18n = true): II18nFormField;
+ public function i18n(bool $i18n = true);
/**
* Sets whether this field's value must be i18n input and returns this field.
* @param bool $i18nRequired determines if field value must be i18n input
* @return static this field
*/
- public function i18nRequired(bool $i18nRequired = true): II18nFormField;
+ public function i18nRequired(bool $i18nRequired = true);
/**
* Returns `true` if this field supports i18n input and returns `false` otherwise.
*
* @return bool
*/
- public function isI18n(): bool;
+ public function isI18n();
/**
* Returns `true` if this field's value must be i18n input and returns `false` otherwise.
*
* @return bool
*/
- public function isI18nRequired(): bool;
+ public function isI18nRequired();
/**
* Sets the pattern for the language item used to save the i18n values
* @throws \BadMethodCallException if i18n is disabled for this field
* @throws \InvalidArgumentException if the given pattern is invalid
*/
- public function languageItemPattern(string $pattern): II18nFormField;
+ public function languageItemPattern(string $pattern);
}
*
* @throws \InvalidArgumentException if the given maximum is no number or otherwise invalid
*/
- public function maximum($maximum = null): IMaximumFormField;
+ public function maximum($maximum = null);
}
*
* @throws \InvalidArgumentException if the given maximum length is no integer or otherwise invalid
*/
- public function maximumLength(int $maximumLength = null): IMaximumLengthFormField;
+ public function maximumLength(int $maximumLength = null);
/**
* Validates the maximum length of the given text.
*
* @throws \InvalidArgumentException if the given minimum is no number or otherwise invalid
*/
- public function minimum($minimum = null): IMinimumFormField;
+ public function minimum($minimum = null);
}
*
* @throws \InvalidArgumentException if the given minimum length is no integer or otherwise invalid
*/
- public function minimumLength(int $minimumLength = null): IMinimumLengthFormField;
+ public function minimumLength(int $minimumLength = null);
/**
* Validates the minimum length of the given text.
*
* @return bool
*/
- public function allowsMultiple(): bool;
+ public function allowsMultiple();
/**
* Returns the maximum number of values that can be selected or set.
*
* @return int maximum number of values
*/
- public function getMaximumMultiples(): int;
+ public function getMaximumMultiples();
/**
* Returns the minimum number of values that can be selected or set.
*
* @return int minimum number of values
*/
- public function getMinimumMultiples(): int;
+ public function getMinimumMultiples();
/**
* Sets the maximum number of values that can be selected or set and returns
*
* @throws \InvalidArgumentException if the given maximum number of values is invalid
*/
- public function maximumMultiples(int $maximum): IMultipleFormField;
+ public function maximumMultiples(int $maximum);
/**
* Sets the minimum number of values that can be selected or set and returns
* this field.
*
- * @param int $maximum maximum number of values
+ * @param int $minimum maximum number of values
* @return static this field
*
* @throws \InvalidArgumentException if the given minimum number of values is invalid
*/
- public function minimumMultiples(int $minimum): IMultipleFormField;
+ public function minimumMultiples(int $minimum);
/**
* Sets whether multiple values can be selected or set and returns this field.
* @param bool $multiple determines if multiple values can be selected/set
* @return static this field
*/
- public function multiple(bool $multiple = true): IMultipleFormField;
+ public function multiple(bool $multiple = true);
}
*
* @return bool
*/
- public function isNullable(): bool;
+ public function isNullable();
/**
* Sets whether this field supports `null` as its value and returns this field.
* @param bool $nullable determines if field supports `null` as its value
* @return static this node
*/
- public function nullable(bool $nullable = true): INullableFormField;
+ public function nullable(bool $nullable = true);
}
*
* @throws \BadMethodCallException if object type has not been set
*/
- public function getObjectType(): ObjectType;
+ public function getObjectType();
/**
* Sets the name of the object type and returns this field.
* @throws \UnexpectedValueException if object type definition returned by `getObjectTypeDefinition()` is unknown
* @throws InvalidObjectTypeException if given object type name is invalid
*/
- public function objectType(string $objectType): IObjectTypeFormField;
+ public function objectType(string $objectType);
/**
* Returns the name of the object type definition the set object type must be of.
*
* @return string name of object type's definition
*/
- public function getObjectTypeDefinition(): string;
+ public function getObjectTypeDefinition();
}
*
* @throws \InvalidArgumentException if the given value is invalid
*/
- public function placeholder(string $languageItem = null, array $variables = []): IPlaceholderFormField;
+ public function placeholder(string $languageItem = null, array $variables = []);
}
* @return array
* @throws \BadMethodCallException if nested options are not supported
*/
- public function getNestedOptions(): array;
+ public function getNestedOptions();
/**
* Returns the possible options of this field.
*
* @throws \BadMethodCallException if no options have been set
*/
- public function getOptions(): array;
+ public function getOptions();
/**
* Sets the possible options of this field and returns this field.
* @throws \InvalidArgumentException if given options are no array or callable or otherwise invalid
* @throws \UnexpectedValueException if callable does not return an array
*/
- public function options($options, bool $nestedOptions = false): ISelectionFormField;
+ public function options($options, bool $nestedOptions = false);
/**
* Returns `true` if the field class supports nested options and `false` otherwise.
*
* @return bool
*/
- public function supportsNestedOptions(): bool;
+ public function supportsNestedOptions();
}
*
* @throws \InvalidArgumentException if the given language item is invalid
*/
- public function suffix(string $languageItem = null, array $variables = []): ISuffixedFormField;
+ public function suffix(string $languageItem = null, array $variables = []);
}
/**
* @inheritDoc
*/
- public function getHtmlVariables(): array {
+ public function getHtmlVariables() {
$value = static::$includeJavaScript;
if (static::$includeJavaScript) {
static::$includeJavaScript = false;
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$this->__value = $this->getDocument()->getRequestData($this->getPrefixedId());
}
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
$value = preg_replace('~^fa-~', '', $value);
return parent::value($value);
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'isDisabled';
}
}
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
use wcf\util\ArrayUtil;
/**
*
* @return string
*/
- public function getSaveValueType(): string {
+ public function getSaveValueType() {
if ($this->saveValueType === null) {
$this->saveValueType = self::SAVE_VALUE_TYPE_CSV;
}
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
// arrays cannot be returned as a simple save value
return $this->getSaveValueType() !== self::SAVE_VALUE_TYPE_ARRAY;
}
/**
* @inheritDoc
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
// an array should be passed as a parameter outside of the `data` array
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
* @throws \BadMethodCallException if save value type has already been set
* @throws \InvalidArgumentException if given save value type is invalid
*/
- public function saveValueType(string $saveValueType): ItemListFormField {
+ public function saveValueType(string $saveValueType) {
if ($this->saveValueType !== null) {
throw new \BadMethodCallException("Save value type has already been set.");
}
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
switch ($this->getSaveValueType()) {
case self::SAVE_VALUE_TYPE_ARRAY:
if (is_array($value)) {
*
* @return int number of textarea rows
*/
- public function getRows(): int {
+ public function getRows() {
return $this->__rows;
}
*
* @throws \InvalidArgumentException if given number of rows is invalid
*/
- public function rows(int $rows): MultilineTextFormField {
+ public function rows(int $rows) {
if ($rows <= 0) {
throw new \InvalidArgumentException("Given number of rows is not positive.");
}
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
// ignore `null` as value which can be passed either for nullable
// fields or as value if no options are available
if ($value === null) {
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function supportsNestedOptions(): bool {
+ public function supportsNestedOptions() {
return false;
}
}
* and using the language item `wcf.form.field.showOrder.firstPosition`
* as value to mark adding it at the first position.
*/
- public function options($options, bool $nestedOptions = false): ISelectionFormField {
+ public function options($options, bool $nestedOptions = false) {
parent::options($options, $nestedOptions);
$this->__options = [0 => WCF::getLanguage()->get('wcf.form.field.showOrder.firstPosition')] + $this->__options;
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
$keys = array_keys($this->getOptions());
// when editing an objects, the value has to be reduced by one to determine the
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'showOrder';
}
}
use wcf\system\acl\simple\SimpleAclHandler;
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
/**
* Implementation of a form field for setting simple acl.
/**
* @inheritDoc
*/
- public function getHtmlVariables(): array {
+ public function getHtmlVariables() {
return [
'__aclSimplePrefix' => $this->getPrefixedId(),
'__aclInputName' => $this->getPrefixedId(),
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return false;
}
/**
* @inheritDoc
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
$this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('i18n', function(IFormDocument $document, array $parameters) {
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function value($value): IFormField {
+ public function value($value) {
// ignore `null` as value which can be passed either for nullable
// fields or as value if no options are available
if ($value === null) {
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'sortOrder';
}
}
<?php
declare(strict_types=1);
namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\IFormNode;
/**
* Allows form fields to have a default id so that when creating form fields the
* @inheritDoc
* @return static
*/
- public static function create(string $id = null): IFormNode {
+ public static function create(string $id = null) {
if ($id === null) {
$id = static::getDefaultId();
}
*
* @return string default id of form fields using this trait
*/
- abstract protected static function getDefaultId(): string;
+ abstract protected static function getDefaultId();
}
*
* @return array additional template variables
*/
- public function getHtmlVariables(): array {
+ public function getHtmlVariables() {
if ($this->isI18n()) {
I18nHandler::getInstance()->assignVariables();
*
* @throws \BadMethodCallException if i18n is disabled for this field or no language item has been set
*/
- public function getLanguageItemPattern(): string {
+ public function getLanguageItemPattern() {
if (!$this->isI18n()) {
throw new \BadMethodCallException("You can only get the language item pattern for fields with i18n enabled.");
}
*
* @return bool
*/
- public function hasI18nValues(): bool {
+ public function hasI18nValues() {
return I18nHandler::getInstance()->hasI18nValues($this->getPrefixedId());
}
*
* @return bool
*/
- public function hasPlainValue(): bool {
+ public function hasPlainValue() {
return I18nHandler::getInstance()->isPlainValue($this->getPrefixedId());
}
*
* @return bool
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return !$this->isI18n() || $this->hasPlainValue();
}
* @param bool $i18n determines if field supports i18n input
* @return II18nFormField this field
*/
- public function i18n(bool $i18n = true): II18nFormField {
+ public function i18n(bool $i18n = true) {
$this->__i18n = $i18n;
return $this;
* @param bool $i18nRequired determines if field value must be i18n input
* @return static this field
*/
- public function i18nRequired(bool $i18nRequired = true): II18nFormField {
+ public function i18nRequired(bool $i18nRequired = true) {
$this->__i18nRequired = $i18nRequired;
$this->i18n();
*
* @return bool
*/
- public function isI18n(): bool {
+ public function isI18n() {
return $this->__i18n;
}
*
* @return bool
*/
- public function isI18nRequired(): bool {
+ public function isI18nRequired() {
return $this->__i18nRequired;
}
* @throws \BadMethodCallException if i18n is disabled for this field
* @throws \InvalidArgumentException if the given pattern is invalid
*/
- public function languageItemPattern(string $pattern): II18nFormField {
+ public function languageItemPattern(string $pattern) {
if (!$this->isI18n()) {
throw new \BadMethodCallException("The language item pattern can only be set for fields with i18n enabled.");
}
/**
* @inheritDoc
*/
- public function loadValueFromObject(IStorableObject $object): IFormField {
+ public function loadValueFromObject(IStorableObject $object) {
if (isset($object->{$this->getId()})) {
$value = $object->{$this->getId()};
*
* @throws \BadMethodCallException if this node has already been populated
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
if ($this->isI18n()) {
*
* @return IFormField this field
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->isI18n()) {
I18nHandler::getInstance()->readValues();
}
*
* @throws \InvalidArgumentException if the given value is of an invalid type or otherwise is invalid
*/
- public function value($value): IFormField {
+ public function value($value) {
if ($this->isI18n()) {
if (is_string($value)) {
$this->setStringValue($value);
*
* @throws \InvalidArgumentException if the given maximum is no number or otherwise invalid
*/
- public function maximum($maximum = null): IMaximumFormField {
+ public function maximum($maximum = null) {
if ($maximum !== null) {
if (!is_numeric($maximum)) {
throw new \InvalidArgumentException("Given maximum is no int, '" . gettype($maximum) . "' given.");
*
* @throws \InvalidArgumentException if the given maximum length is no integer or otherwise invalid
*/
- public function maximumLength(int $maximumLength = null): IMaximumLengthFormField {
+ public function maximumLength(int $maximumLength = null) {
if ($maximumLength !== null) {
if (!is_int($maximumLength)) {
throw new \InvalidArgumentException("Given maximum length is no int, '" . gettype($maximumLength) . "' given.");
*
* @throws \InvalidArgumentException if the given minimum is no number or otherwise invalid
*/
- public function minimum($minimum = null): IMinimumFormField {
+ public function minimum($minimum = null) {
if ($minimum !== null) {
if (!is_numeric($minimum)) {
throw new \InvalidArgumentException("Given minimum is no int, '" . gettype($minimum) . "' given.");
*
* @throws \InvalidArgumentException if the given minimum length is no integer or otherwise invalid
*/
- public function minimumLength(int $minimumLength = null): IMinimumLengthFormField {
+ public function minimumLength(int $minimumLength = null) {
if ($minimumLength !== null) {
if (!is_int($minimumLength)) {
throw new \InvalidArgumentException("Given minimum length is no int, '" . gettype($minimumLength) . "' given.");
namespace wcf\system\form\builder\field;
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
/**
* Provides default implementations of `IMultipleFormField` methods.
*
* @return bool
*/
- public function allowsMultiple(): bool {
+ public function allowsMultiple() {
return $this->__multiple;
}
*
* @return int maximum number of values
*/
- public function getMaximumMultiples(): int {
+ public function getMaximumMultiples() {
return $this->__maximumMultiples;
}
*
* @return int minimum number of values
*/
- public function getMinimumMultiples(): int {
+ public function getMinimumMultiples() {
return $this->__minimumMultiples;
}
*
* @return bool
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return !$this->allowsMultiple();
}
*
* @throws \InvalidArgumentException if the given maximum number of values is invalid
*/
- public function maximumMultiples(int $maximum): IMultipleFormField {
+ public function maximumMultiples(int $maximum) {
if ($maximum !== IMultipleFormField::NO_MAXIMUM_MULTIPLES) {
if ($maximum <= 0) {
throw new \InvalidArgumentException("The maximum number of values has to be positive, '{$maximum}' given.");
*
* @throws \InvalidArgumentException if the given minimum number of values is invalid
*/
- public function minimumMultiples(int $minimum): IMultipleFormField {
+ public function minimumMultiples(int $minimum) {
if ($minimum < 0) {
throw new \InvalidArgumentException("The minimum number of values has to be non-negative, '{$minimum}' given.");
}
* @param bool $multiple determines if multiple values can be selected/set
* @return static this field
*/
- public function multiple(bool $multiple = true): IMultipleFormField {
+ public function multiple(bool $multiple = true) {
$this->__multiple = $multiple;
return $this;
*
* @throws \BadMethodCallException if this node has already been populated
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
if ($this->allowsMultiple()) {
*
* @throws \InvalidArgumentException if the given value is of an invalid type or otherwise is invalid
*/
- public function value($value): IFormField {
+ public function value($value) {
// ensure array value for form fields that actually support multiple values;
// allows enabling support for multiple values for existing fields
if ($this->allowsMultiple() && !is_array($value)) {
*
* @return bool
*/
- public function isNullable(): bool {
+ public function isNullable() {
return $this->__nullable;
}
* @param bool $nullable determines if field supports `null` as its value
* @return static this node
*/
- public function nullable(bool $nullable = true): INullableFormField {
+ public function nullable(bool $nullable = true) {
$this->__nullable = $nullable;
return $this;
*
* @throws \BadMethodCallException if object type has not been set
*/
- public function getObjectType(): ObjectType {
+ public function getObjectType() {
if ($this->__objectType === null) {
throw new \BadMethodCallException("Object type has not been set.");
}
* @throws \UnexpectedValueException if object type definition returned by `getObjectTypeDefinition()` is unknown
* @throws InvalidObjectTypeException if given object type name is invalid
*/
- public function objectType(string $objectType): IObjectTypeFormField {
+ public function objectType(string $objectType) {
if ($this->__objectType !== null) {
throw new \BadMethodCallException("Object type has already been set.");
}
*
* @return string name of object type's definition
*/
- abstract public function getObjectTypeDefinition(): string;
+ abstract public function getObjectTypeDefinition();
}
*
* @throws \InvalidArgumentException if the given value is no string or otherwise invalid
*/
- public function placeholder(string $languageItem = null, array $variables = []): IPlaceholderFormField {
+ public function placeholder(string $languageItem = null, array $variables = []) {
if ($languageItem === null) {
if (!empty($variables)) {
throw new \InvalidArgumentException("Cannot use variables when unsetting placeholder of field '{$this->getId()}'");
* @param bool $filterable determines if field's options are filterable by user
* @return static this node
*/
- public function filterable($filterable = true): ISelectionFormField {
+ public function filterable($filterable = true) {
$this->__filterable = $filterable;
return $this;
* @return array
* @throws \BadMethodCallException if nested options are not supported
*/
- public function getNestedOptions(): array {
+ public function getNestedOptions() {
if (!$this->supportsNestedOptions()) {
throw new \BadMethodCallException("Nested options are not supported.");
}
*
* @throws \BadMethodCallException if no options have been set
*/
- public function getOptions(): array {
+ public function getOptions() {
return $this->__options;
}
*
* @see IFormNode::available()
*/
- public function isAvailable(): bool {
+ public function isAvailable() {
// selections without any possible values are not available
return !empty($this->__options) && parent::isAvailable();
}
*
* @return bool
*/
- public function isFilterable(): bool {
+ public function isFilterable() {
return $this->__filterable;
}
* @throws \InvalidArgumentException if given options are no array or callable or otherwise invalid
* @throws \UnexpectedValueException if callable does not return an array
*/
- public function options($options, bool $nestedOptions = false): ISelectionFormField {
+ public function options($options, bool $nestedOptions = false) {
if ($nestedOptions) {
if (!is_array($options) && !is_callable($options)) {
throw new \InvalidArgumentException("The given nested options are neither an array nor a callable, " . gettype($options) . " given.");
*
* @return bool
*/
- public function supportsNestedOptions(): bool {
+ public function supportsNestedOptions() {
return true;
}
}
*
* @throws \InvalidArgumentException if the given language item is no string or otherwise invalid
*/
- public function suffix(string $languageItem = null, array $variables = []): ISuffixedFormField {
+ public function suffix(string $languageItem = null, array $variables = []) {
if ($languageItem === null) {
if (!empty($variables)) {
throw new \InvalidArgumentException("Cannot use variables when unsetting suffix of field '{$this->getId()}'");
use wcf\data\IStorableObject;
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
use wcf\system\tagging\TagEngine;
use wcf\util\ArrayUtil;
/**
* @inheritDoc
*/
- public function getObjectTypeDefinition(): string {
+ public function getObjectTypeDefinition() {
return 'com.woltlab.wcf.tagging.taggableObject';
}
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return false;
}
/**
* @inheritDoc
*/
- public function loadValueFromObject(IStorableObject $object): IFormField {
+ public function loadValueFromObject(IStorableObject $object) {
$objectID = $object->{$object::getDatabaseTableIndexName()};
if ($objectID === null) {
/**
* @inheritDoc
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
$this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) {
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
- * @return static this field
*/
- public function value($value): IFormField {
+ public function value($value) {
if (!is_array($value)) {
throw new \InvalidArgumentException("Given value is no array, " . gettype($value) . " given.");
}
/**
* @inheritDoc
*/
- protected static function getDefaultId(): string {
+ protected static function getDefaultId() {
return 'title';
}
}
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\util\StringUtil;
* @param string $autosaveId identifier used to autosave field value
* @return WysiwygFormField this field
*/
- public function autosaveId(string $autosaveId): WysiwygFormField {
+ public function autosaveId(string $autosaveId) {
$this->__autosaveId = $autosaveId;
return $this;
*
* @return string
*/
- public function getAutosaveId(): string {
+ public function getAutosaveId() {
return $this->__autosaveId;
}
/**
* @inheritDoc
*/
- public function getObjectTypeDefinition(): string {
+ public function getObjectTypeDefinition() {
return 'com.woltlab.wcf.message';
}
*
* @return int
*/
- public function getLastEditTime(): int {
+ public function getLastEditTime() {
return $this->__lastEditTime;
}
/**
* @inheritDoc
*/
- public function hasSaveValue(): bool {
+ public function hasSaveValue() {
return false;
}
* @param int $lastEditTime last time field has been edited
* @return WysiwygFormField this field
*/
- public function lastEditTime(int $lastEditTime): WysiwygFormField {
+ public function lastEditTime(int $lastEditTime) {
$this->__lastEditTime = $lastEditTime;
return $this;
/**
* @inheritDoc
*/
- public function populate(): IFormNode {
+ public function populate() {
parent::populate();
$this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('wysiwyg', function(IFormDocument $document, array $parameters) {
/**
* @inheritDoc
*/
- public function readValue(): IFormField {
+ public function readValue() {
if ($this->getDocument()->hasRequestData($this->getPrefixedId())) {
$value = $this->getDocument()->getRequestData($this->getPrefixedId());
/**
* @inheritDoc
*/
- public function __invoke(IFormDocument $document, array $parameters): array {
+ public function __invoke(IFormDocument $document, array $parameters) {
$parameters = call_user_func($this->processor, $document, $parameters);
if (!is_array($parameters)) {
/**
* @inheritDoc
*/
- public function __invoke(IFormDocument $document, array $parameters): array {
+ public function __invoke(IFormDocument $document, array $parameters) {
$parameters['data'] = [];
$this->getData($document, $parameters['data']);
* @param array $parameters parameters before processing
* @return array parameters after processing
*/
- public function __invoke(IFormDocument $document, array $parameters): array;
+ public function __invoke(IFormDocument $document, array $parameters);
}
/**
* @inheritDoc
*/
- public function dependentNode(IFormNode $node): IFormFieldDependency {
+ public function dependentNode(IFormNode $node) {
$this->__dependentNode = $node;
return $this;
/**
* @inheritDoc
*/
- public function field(IFormField $field): IFormFieldDependency {
+ public function field(IFormField $field) {
$this->__field = $field;
return $this;
/**
* @inheritDoc
*/
- public function getDependentNode(): IFormNode {
+ public function getDependentNode() {
if ($this->__dependentNode === null) {
throw new \BadMethodCallException("Dependent node has not been set.");
}
/**
* @inheritDoc
*/
- public function getField(): IFormField {
+ public function getField() {
if ($this->__field === null) {
throw new \BadMethodCallException("Field has not been set.");
}
/**
* @inheritDoc
*/
- public function getId(): string {
+ public function getId() {
return $this->__id;
}
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
if ($this->templateName === null) {
throw new \LogicException("Template name is not set.");
}
*
* @throws \InvalidArgumentException if given id no string or otherwise invalid
*/
- protected function id(string $id): IFormFieldDependency {
+ protected function id(string $id) {
if (preg_match('~^[a-z][A-z0-9-]*$~', $id) !== 1) {
throw new \InvalidArgumentException("Invalid id '{$id}' given.");
}
* @inheritDoc
* @return static
*/
- public static function create(string $id): IFormFieldDependency {
+ public static function create(string $id) {
return (new static)->id($id);
}
}
*
* @return bool
*/
- public function checkDependency(): bool;
+ public function checkDependency();
/**
* Sets the node whose availability depends on the value of a field.
*
* @throws \BadMethodCallException if no dependent node has been set
*/
- public function dependentNode(IFormNode $node): IFormFieldDependency;
+ public function dependentNode(IFormNode $node);
/**
* Sets the field the availability of the node dependents on.
*
* @throws \BadMethodCallException if no field has been set
*/
- public function field(IFormField $field): IFormFieldDependency;
+ public function field(IFormField $field);
/**
* Returns the node whose availability depends on the value of a field.
*
* @return IFormNode dependent node
*/
- public function getDependentNode(): IFormNode;
+ public function getDependentNode();
/**
* Returns the field the availability of the element dependents on.
*
* @return IFormField field controlling element availability
*/
- public function getField(): IFormField;
+ public function getField();
/**
* Returns the JavaScript code required to ensure this dependency in the template.
*
* @return string dependency JavaScript code
*/
- public function getHtml(): string;
+ public function getHtml();
/**
* Returns the id of this dependency.
*
* @return string id of the dependency
*/
- public function getId(): string;
+ public function getId();
/**
* Creates a new dependency with the given id.
*
* @throws \InvalidArgumentException if the given id is invalid
*/
- public static function create(string $id): IFormFieldDependency;
+ public static function create(string $id);
}
/**
* @inheritDoc
*/
- public function checkDependency(): bool {
+ public function checkDependency() {
return !empty($this->getField()->getValue());
}
}
/**
* @inheritDoc
*/
- public function checkDependency(): bool {
+ public function checkDependency() {
$inArray = in_array($this->getField()->getValue(), $this->getValues());
if ($this->isNegated()) {
*
* @throws \BadMethodCallException if no values have been set
*/
- public function getValues(): array {
+ public function getValues() {
if ($this->__values === null) {
throw new \BadMethodCallException("Values have not been set for dependency '{$this->getId()}' on node '{$this->getDependentNode()->getId()}'.");
}
*
* @return bool
*/
- public function isNegated(): bool {
+ public function isNegated() {
return $this->__isNegated;
}
* @param bool $negate
* @return static $this this dependency
*/
- public function negate(bool $negate = true): ValueFormFieldDependency {
+ public function negate(bool $negate = true) {
$this->__isNegated = $negate;
return $this;
*
* @throws \InvalidArgumentException if given values are invalid
*/
- public function values(array $values): ValueFormFieldDependency {
+ public function values(array $values) {
if (empty($values)) {
throw new \InvalidArgumentException("Given values are empty.");
}
/**
* @inheritDoc
*/
- public function getHtml(): string {
+ public function getHtml() {
return WCF::getTPL()->fetch('__formFieldError', 'wcf', [
'error' => $this
]);
/**
* @inheritDoc
*/
- public function getInformation(): array {
+ public function getInformation() {
return $this->information;
}
/**
* @inheritDoc
*/
- public function getMessage(): string {
+ public function getMessage() {
return WCF::getLanguage()->getDynamicVariable($this->languageItem, $this->information);
}
/**
* @inheritDoc
*/
- public function getType(): string {
+ public function getType() {
return $this->type;
}
}
/**
* @inheritDoc
*/
- public function getId(): string {
+ public function getId() {
return $this->id;
}
*
* @throws \InvalidArgumentException if regular expression is invalid
*/
- public static function getRegularExpressionValidator(string $regularExpression, string $languageItemPrefix): IFormFieldValidator {
+ public static function getRegularExpressionValidator(string $regularExpression, string $languageItemPrefix) {
$regex = Regex::compile($regularExpression);
if (!$regex->isValid()) {
throw new \InvalidArgumentException("Invalid regular expression '{$regularExpression}' given.");
*
* @return string
*/
- public function getHtml(): string;
+ public function getHtml();
/**
* Returns additional information about the error.
*
* @return array additional error information
*/
- public function getInformation(): array;
+ public function getInformation();
/**
* Returns the message describing the validation error.
*
* @return string error message
*/
- public function getMessage(): string;
+ public function getMessage();
/**
* Returns the type of the validation error.
*
* @return string error type
*/
- public function getType(): string;
+ public function getType();
}
*
* @return string id of the dependency
*/
- public function getId(): string;
+ public function getId();
/**
* Checks if the given parameter is a string and a valid validator id.