From 5d7bde5d24fa8fe2def9d187d782fb0503c7f2e6 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 20 Jun 2018 13:40:55 +0200 Subject: [PATCH] Edit buttons for most boxes See #2575 --- com.woltlab.wcf/templates/__box.tpl | 5 +++- .../install/files/lib/data/box/Box.class.php | 20 +++++++++++++++ wcfsetup/install/files/style/layout/box.scss | 25 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/__box.tpl b/com.woltlab.wcf/templates/__box.tpl index 6987ec4ddb..1369d39830 100644 --- a/com.woltlab.wcf/templates/__box.tpl +++ b/com.woltlab.wcf/templates/__box.tpl @@ -1,4 +1,7 @@ -<{if $box->showHeader}section{else}div{/if} class="box{if $box->getImage()} boxWithImage{/if}{if $box->cssClassName} {$box->cssClassName}{/if}" data-box-identifier="{@$box->identifier}"> +<{if $box->showHeader}section{else}div{/if} class="box{if $box->getImage()} boxWithImage{/if}{if $box->showEditButton()} boxWithEditButton{/if}{if $box->cssClassName} {$box->cssClassName}{/if}" data-box-identifier="{@$box->identifier}"> + {if $box->showEditButton()} + + {/if} {if $box->getImage()}
{if $box->hasLink()} diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 0750694d8d..87fda493e8 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -117,6 +117,12 @@ class Box extends DatabaseObject { */ public $virtualShowOrder = -1; + /** + * list of positions that support the edit button + * @var string[] + */ + public $editButtonPositions = ['headerBoxes', 'sidebarLeft', 'contentTop', 'sidebarRight', 'contentBottom', 'footerBoxes', 'footer']; + /** * @inheritDoc */ @@ -507,6 +513,20 @@ class Box extends DatabaseObject { $this->virtualShowOrder = $virtualShowOrder; } + /** + * Returns true if an edit button should be displayed for this box. + * + * @return boolean + * @since 3.2 + */ + public function showEditButton() { + if (WCF::getSession()->getPermission('admin.content.cms.canManageBox') && in_array($this->position, $this->editButtonPositions)) { + return true; + } + + return false; + } + /** * Returns the box with the given identifier. * diff --git a/wcfsetup/install/files/style/layout/box.scss b/wcfsetup/install/files/style/layout/box.scss index e961b16069..f15b0c5e81 100644 --- a/wcfsetup/install/files/style/layout/box.scss +++ b/wcfsetup/install/files/style/layout/box.scss @@ -950,3 +950,28 @@ } } } + +.boxWithEditButton { + position: relative; + + &:hover .boxEditButton { + opacity: 1; + } + + .boxEditButton { + color: inherit; + opacity: 0; + position: absolute; + top: 4px; + transition: opacity .12s ease-in-out; + right: 4px; + + &:hover { + color: inherit; + } + + > .icon { + color: inherit; + } + } +} -- 2.20.1