From: Cyperghost Date: Tue, 19 Nov 2024 09:27:39 +0000 (+0100) Subject: Add pages form field X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=797e0db0d7dae417ffbe7be8bb0d3720fa462571;p=GitHub%2FWoltLab%2FWCF.git Add pages form field --- diff --git a/com.woltlab.wcf/templates/shared_multiplePagesSelectionFormField.tpl b/com.woltlab.wcf/templates/shared_multiplePagesSelectionFormField.tpl new file mode 100644 index 0000000000..8d44f893b6 --- /dev/null +++ b/com.woltlab.wcf/templates/shared_multiplePagesSelectionFormField.tpl @@ -0,0 +1,19 @@ +{include file="shared_multipleSelectionFormField"} + +{if $field->getVisibleEverywhereFieldId() !== null} + +{/if} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/PagesFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/PagesFormField.class.php new file mode 100644 index 0000000000..601ced0106 --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/field/PagesFormField.class.php @@ -0,0 +1,64 @@ + + * @since 6.2 + */ +final class PagesFormField extends MultipleSelectionFormField +{ + use TDefaultIdFormField; + + /** + * @inheritDoc + */ + protected $templateName = 'shared_multiplePagesSelectionFormField'; + + private ?string $visibleEverywhereFieldId = null; + private string $invertedLabel = ''; + + public function __construct() + { + $this + ->options((new PageNodeTree())->getNodeList(), true) + ->filterable(); + } + + #[\Override] + protected static function getDefaultId() + { + return 'pageIDs'; + } + + public function getVisibleEverywhereFieldId(): ?string + { + return $this->visibleEverywhereFieldId; + } + + public function visibleEverywhereFieldId(?string $visibleEverywhereFieldId): self + { + $this->visibleEverywhereFieldId = $visibleEverywhereFieldId; + + return $this; + } + + public function getInvertedLabel(): string + { + return $this->invertedLabel; + } + + public function invertedLabel(string $languageItem, array $variables = []): self + { + $this->invertedLabel = WCF::getLanguage()->getDynamicVariable($languageItem, $variables); + + return $this; + } +}