Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions com.woltlab.wcf/templates/shared_standaloneInteractionButton.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<div class="dropdown" id="{$containerID}">
<button type="button" class="button dropdownToggle" aria-label="{lang}wcf.global.button.more{/lang}">
{icon name='ellipsis-vertical'}
<div class="dropdown {$cssClassName}" id="{$containerID}">
<button
type="button"
class="button dropdownToggle {$buttonCssClassName}"
{if !$label}aria-label="{lang}wcf.global.button.more{/lang}"{/if}
>
{icon name=$icon}
{if $label}
<span>{$label}</span>
{/if}
</button>

<ul class="dropdownMenu">
Expand Down
4 changes: 2 additions & 2 deletions wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use wcf\system\file\upload\UploadFile;
use wcf\system\file\upload\UploadHandler;
use wcf\system\interaction\admin\StyleInteractions;
use wcf\system\interaction\StandaloneInteractionContextMenuView;
use wcf\system\interaction\StandaloneInteractionContextMenuComponent;
use wcf\system\language\I18nHandler;
use wcf\system\request\LinkHandler;
use wcf\system\style\StyleCompiler;
Expand Down Expand Up @@ -453,7 +453,7 @@ public function assignVariables()
'style' => $this->style,
'styleID' => $this->styleID,
'isDarkMode' => $this->isDarkMode,
'interactionContextMenu' => new StandaloneInteractionContextMenuView(
'interactionContextMenu' => new StandaloneInteractionContextMenuComponent(
new StyleInteractions(),
$this->style,
LinkHandler::getInstance()->getControllerLink(StyleListPage::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use wcf\http\Helper;
use wcf\system\exception\IllegalLinkException;
use wcf\system\interaction\admin\UserRankInteractions;
use wcf\system\interaction\StandaloneInteractionContextMenuView;
use wcf\system\interaction\StandaloneInteractionContextMenuComponent;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;

Expand Down Expand Up @@ -66,7 +66,7 @@ public function assignVariables()
parent::assignVariables();

WCF::getTPL()->assign([
'interactionContextMenu' => new StandaloneInteractionContextMenuView(
'interactionContextMenu' => new StandaloneInteractionContextMenuComponent(
new UserRankInteractions(),
$this->formObject,
LinkHandler::getInstance()->getControllerLink(UserRankListPage::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use wcf\system\endpoint\IController;
use wcf\system\endpoint\PostRequest;
use wcf\system\exception\UserInputException;
use wcf\system\interaction\bulk\BulkInteractionContextMenuView;
use wcf\system\interaction\bulk\BulkInteractionContextMenuComponent;
use wcf\system\interaction\bulk\IBulkInteractionProvider;

/**
Expand Down Expand Up @@ -42,10 +42,10 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
$list->setObjectIDs($parameters->objectIDs);
$list->readObjects();

$view = new BulkInteractionContextMenuView($provider);
$component = new BulkInteractionContextMenuComponent($provider);

return new JsonResponse([
'template' => $view->renderContextMenuOptions($list->getObjects()),
'template' => $component->renderContextMenuOptions($list->getObjects()),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use wcf\system\endpoint\IController;
use wcf\system\exception\UserInputException;
use wcf\system\interaction\IInteractionProvider;
use wcf\system\interaction\InteractionContextMenuView;
use wcf\system\interaction\InteractionContextMenuComponent;

/**
* Retrieves the options for an interaction context menu.
Expand Down Expand Up @@ -40,10 +40,10 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
$object = new ($provider->getObjectClassName())($parameters->objectID);
\assert($object instanceof DatabaseObject);

$view = new InteractionContextMenuView($provider);
$contextMenu = new InteractionContextMenuComponent($provider);

return new JsonResponse([
'template' => $view->renderContextMenuOptions($object),
'template' => $contextMenu->renderContextMenuOptions($object),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use wcf\system\interaction\bulk\IBulkInteractionProvider;
use wcf\system\interaction\IInteraction;
use wcf\system\interaction\IInteractionProvider;
use wcf\system\interaction\InteractionContextMenuView;
use wcf\system\interaction\InteractionContextMenuComponent;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\StringUtil;
Expand Down Expand Up @@ -64,7 +64,7 @@ abstract class AbstractGridView
private string|int|null $objectIDFilter = null;
private ?IInteractionProvider $interactionProvider = null;
private ?IBulkInteractionProvider $bulkInteractionProvider = null;
private InteractionContextMenuView $interactionContextMenuView;
private InteractionContextMenuComponent $interactionContextMenuComponent;

/**
* Adds a new column to the grid view.
Expand Down Expand Up @@ -308,17 +308,17 @@ public function renderColumn(GridViewColumn $column, DatabaseObject $row): strin
/**
* Returns the view of the interaction context menu.
*/
public function getInteractionContextMenuView(): InteractionContextMenuView
public function getInteractionContextMenuComponent(): InteractionContextMenuComponent
{
if ($this->interactionProvider === null) {
throw new \BadMethodCallException("Missing interaction provider.");
}

if (!isset($this->interactionContextMenuView)) {
$this->interactionContextMenuView = new InteractionContextMenuView($this->interactionProvider);
if (!isset($this->interactionContextMenuComponent)) {
$this->interactionContextMenuComponent = new InteractionContextMenuComponent($this->interactionProvider);
}

return $this->interactionContextMenuView;
return $this->interactionContextMenuComponent;
}

/**
Expand All @@ -328,7 +328,7 @@ public function renderInteractionInitialization(): string
{
$code = '';
if ($this->interactionProvider !== null) {
$code = $this->getInteractionContextMenuView()->renderInitialization($this->getID() . '_table');
$code = $this->getInteractionContextMenuComponent()->renderInitialization($this->getID() . '_table');
}

if ($this->quickInteractions !== []) {
Expand Down Expand Up @@ -368,7 +368,7 @@ public function renderInteractionContextMenuButton(DatabaseObject $row): string
return '';
}

return $this->getInteractionContextMenuView()->renderButton($row);
return $this->getInteractionContextMenuComponent()->renderButton($row);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
use wcf\data\DatabaseObject;
use wcf\system\WCF;

class InteractionContextMenuView
/**
* Represents the component of an interaction content menu.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class InteractionContextMenuComponent
{
public function __construct(
protected readonly IInteractionProvider $provider
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace wcf\system\interaction;

use wcf\data\DatabaseObject;
use wcf\system\WCF;

/**
* Represents the component of a standalone button for an interaction content menu.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class StandaloneInteractionContextMenuComponent extends InteractionContextMenuComponent
{
public function __construct(
IInteractionProvider $provider,
protected readonly DatabaseObject $object,
protected readonly string $redirectUrl,
protected readonly string $label = '',
protected readonly string $icon = 'ellipsis-vertical',
protected readonly string $cssClassName = '',
protected readonly string $buttonCssClassName = ''
) {
parent::__construct($provider);
}

public function render(): string
{
$contextMenuOptions = $this->renderContextMenuOptions($this->object);
if (!$contextMenuOptions) {
return '';
}

return WCF::getTPL()->render(
'wcf',
'shared_standaloneInteractionButton',
[
'contextMenuOptions' => $contextMenuOptions,
'initializationCode' => $this->renderInitialization($this->getContainerID()),
'containerID' => $this->getContainerID(),
'providerClassName' => \get_class($this->provider),
'objectID' => $this->object->getObjectID(),
'redirectUrl' => $this->redirectUrl,
'label' => $this->label,
'icon' => $this->icon,
'cssClassName' => $this->cssClassName,
'buttonCssClassName' => $this->buttonCssClassName,
],
);
}

public function getContainerID(): string
{
$classNamePieces = \explode('\\', \get_class($this->object));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a more complicated version of \str_replace()?


return \implode('-', $classNamePieces) . '-' . $this->object->getObjectID();
}

public static function forContentHeaderButton(
IInteractionProvider $provider,
DatabaseObject $object,
string $redirectUrl,
): self {
return new self($provider, $object, $redirectUrl, icon: 'ellipsis-vertical');
}

public static function forContentInteractionButton(
IInteractionProvider $provider,
DatabaseObject $object,
string $redirectUrl,
string $label,
): self {
return new self($provider, $object, $redirectUrl, $label, 'pencil', 'contentInteractionButton', 'small');
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
use wcf\system\interaction\Divider;
use wcf\system\WCF;

class BulkInteractionContextMenuView
/**
* Represents the component of an bulk interaction content menu.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class BulkInteractionContextMenuComponent
{
public function __construct(
protected readonly IBulkInteractionProvider $provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use wcf\system\event\EventHandler;
use wcf\system\interaction\bulk\IBulkInteractionProvider;
use wcf\system\interaction\IInteractionProvider;
use wcf\system\interaction\InteractionContextMenuView;
use wcf\system\interaction\InteractionContextMenuComponent;
use wcf\system\listView\filter\IListViewFilter;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract class AbstractListView
private string|int|null $objectIDFilter = null;
private ?IInteractionProvider $interactionProvider = null;
private ?IBulkInteractionProvider $bulkInteractionProvider = null;
private InteractionContextMenuView $interactionContextMenuView;
private InteractionContextMenuComponent $interactionContextMenuComponent;

/**
* @var array<string, string>
Expand Down Expand Up @@ -461,7 +461,7 @@ public function renderInteractionInitialization(): string
return '';
}

return $this->getInteractionContextMenuView()->renderInitialization($this->getID() . '_items');
return $this->getInteractionContextMenuComponent()->renderInitialization($this->getID() . '_items');
}

/**
Expand All @@ -482,17 +482,17 @@ public function renderBulkInteractionInitialization(): string
/**
* Returns the view of the interaction context menu.
*/
public function getInteractionContextMenuView(): InteractionContextMenuView
public function getInteractionContextMenuComponent(): InteractionContextMenuComponent
{
if ($this->interactionProvider === null) {
throw new \BadMethodCallException("Missing interaction provider.");
}

if (!isset($this->interactionContextMenuView)) {
$this->interactionContextMenuView = new InteractionContextMenuView($this->interactionProvider);
if (!isset($this->interactionContextMenuComponent)) {
$this->interactionContextMenuComponent = new InteractionContextMenuComponent($this->interactionProvider);
}

return $this->interactionContextMenuView;
return $this->interactionContextMenuComponent;
}

/**
Expand All @@ -506,7 +506,7 @@ public function renderInteractionContextMenuButton(DatabaseObject $item): string
return '';
}

return $this->getInteractionContextMenuView()->renderButton($item);
return $this->getInteractionContextMenuComponent()->renderButton($item);
}

/**
Expand Down