From d6ea6768c2a61002dd7c263811fce2ea59eec775 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 24 Feb 2019 14:41:22 +0100 Subject: [PATCH] Add option to remove tab menu container's link anchors See #2509 See #2852 --- .../templates/__tabMenuFormContainer.tpl | 2 +- .../templates/__tabTabMenuFormContainer.tpl | 2 +- .../acp/templates/__tabMenuFormContainer.tpl | 2 +- .../templates/__tabTabMenuFormContainer.tpl | 2 +- .../container/TabMenuFormContainer.class.php | 29 +++++++++++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/com.woltlab.wcf/templates/__tabMenuFormContainer.tpl b/com.woltlab.wcf/templates/__tabMenuFormContainer.tpl index 8b349ccee5..9e45658ac3 100644 --- a/com.woltlab.wcf/templates/__tabMenuFormContainer.tpl +++ b/com.woltlab.wcf/templates/__tabMenuFormContainer.tpl @@ -8,7 +8,7 @@ {foreach from=$container item='child'} {if $child->isAvailable()} {assign var='__tabMenuFormContainerChildId' value=$child->getPrefixedId()|concat:'Container'} - checkDependencies()} style="display: none;"{/if}>{@$child->getLabel()} + checkDependencies()} style="display: none;"{/if}>usesAnchors()} href="{@$__wcf->getAnchor($__tabMenuFormContainerChildId)}"{/if}>{@$child->getLabel()} {/if} {/foreach} diff --git a/com.woltlab.wcf/templates/__tabTabMenuFormContainer.tpl b/com.woltlab.wcf/templates/__tabTabMenuFormContainer.tpl index 2db5b317be..86db167713 100644 --- a/com.woltlab.wcf/templates/__tabTabMenuFormContainer.tpl +++ b/com.woltlab.wcf/templates/__tabTabMenuFormContainer.tpl @@ -7,7 +7,7 @@ {foreach from=$container item='child'} {if $child->isAvailable()} {assign var='__tabMenuFormContainerChildId' value=$child->getPrefixedId()|concat:'Container'} - checkDependencies()} style="display: none;"{/if}>{@$child->getLabel()} + checkDependencies()} style="display: none;"{/if}>usesAnchors()} href="{@$__wcf->getAnchor($__tabMenuFormContainerChildId)}"{/if}>{@$child->getLabel()} {/if} {/foreach} diff --git a/wcfsetup/install/files/acp/templates/__tabMenuFormContainer.tpl b/wcfsetup/install/files/acp/templates/__tabMenuFormContainer.tpl index 8b349ccee5..9e45658ac3 100644 --- a/wcfsetup/install/files/acp/templates/__tabMenuFormContainer.tpl +++ b/wcfsetup/install/files/acp/templates/__tabMenuFormContainer.tpl @@ -8,7 +8,7 @@ {foreach from=$container item='child'} {if $child->isAvailable()} {assign var='__tabMenuFormContainerChildId' value=$child->getPrefixedId()|concat:'Container'} - checkDependencies()} style="display: none;"{/if}>{@$child->getLabel()} + checkDependencies()} style="display: none;"{/if}>usesAnchors()} href="{@$__wcf->getAnchor($__tabMenuFormContainerChildId)}"{/if}>{@$child->getLabel()} {/if} {/foreach} diff --git a/wcfsetup/install/files/acp/templates/__tabTabMenuFormContainer.tpl b/wcfsetup/install/files/acp/templates/__tabTabMenuFormContainer.tpl index 2db5b317be..86db167713 100644 --- a/wcfsetup/install/files/acp/templates/__tabTabMenuFormContainer.tpl +++ b/wcfsetup/install/files/acp/templates/__tabTabMenuFormContainer.tpl @@ -7,7 +7,7 @@ {foreach from=$container item='child'} {if $child->isAvailable()} {assign var='__tabMenuFormContainerChildId' value=$child->getPrefixedId()|concat:'Container'} - checkDependencies()} style="display: none;"{/if}>{@$child->getLabel()} + checkDependencies()} style="display: none;"{/if}>usesAnchors()} href="{@$__wcf->getAnchor($__tabMenuFormContainerChildId)}"{/if}>{@$child->getLabel()} {/if} {/foreach} diff --git a/wcfsetup/install/files/lib/system/form/builder/container/TabMenuFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/TabMenuFormContainer.class.php index 29d506fbe4..2bfc906fe3 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/TabMenuFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/TabMenuFormContainer.class.php @@ -16,6 +16,12 @@ class TabMenuFormContainer extends FormContainer implements ITabMenuFormContaine */ protected $templateName = '__tabMenuFormContainer'; + /** + * is `true` if the links in the tab menu have anchors + * @var boolean + */ + protected $useAnchors = true; + /** * @inheritDoc */ @@ -23,4 +29,27 @@ class TabMenuFormContainer extends FormContainer implements ITabMenuFormContaine $this->addClass('section') ->addClass('tabMenuContainer'); } + + /** + * Sets if the links in the tab menu have anchors and returns this form container. + * + * @param boolean $useAnchors + * @return TabMenuFormContainer this form container + */ + public function useAnchors($useAnchors = true) { + $this->useAnchors = $useAnchors; + + return $this; + } + + /** + * Returns `true` if the links in the tab menu have anchors and `false` otherwise. + * + * By default, the links in the tab menu have anchors. + * + * @return boolean + */ + public function usesAnchors() { + return $this->useAnchors; + } } -- 2.20.1