mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
c6c7dd2fb0
Why: - We want to allow extensions to register interactive menu items in the overflow menu. What: - Create a PHP hook to allow extensions to provide menu items for rendering in the overflow menu - The hook allows for registering resource loader modules required by the menu item - The hook passes in some contextual information, like the thread item data, context source object, and if the page is editable - Create a JS hook that fires when a user selects one of the menu items - Example implementation: Ie9afbedb4f24cbd75eb48bb21dc9f6d8d732d853 Misc: - Remove b/c code that existed to handle a transitional period where JSON encoded overflow menu data did not necessarily exist in the parser cache - Rename code instances of ellipsis button / data / menu to refer to "overflow menu" - Some renames will have to wait until parser cache is updated; these are noted with TODOs Bug: T342251 Change-Id: I5f2a51791f8ba7619d1399a4b93111e9bb44e172
44 lines
1.8 KiB
PHP
44 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Hooks;
|
|
|
|
use IContextSource;
|
|
use MediaWiki\Extension\DiscussionTools\OverflowMenuItem;
|
|
|
|
/**
|
|
* This is a hook handler interface, see docs/Hooks.md in core.
|
|
* Use the hook name "DiscussionToolsAddOverflowMenuItems" to register handlers implementing this interface.
|
|
*
|
|
* @stable to implement
|
|
* @ingroup Hooks
|
|
*/
|
|
interface DiscussionToolsAddOverflowMenuItemsHook {
|
|
|
|
/**
|
|
* Register menu items to add to the DiscussionTools overflow menu.
|
|
*
|
|
* These menu items appear in an overflow menu that opens via a button with an ellipsis icon.
|
|
* The button can be displayed adjacent to:
|
|
* - topic headings
|
|
* - individual comments
|
|
*
|
|
* @param OverflowMenuItem[] &$overflowMenuItems Menu items to add to the DiscussionTools
|
|
* overflow/ellipsis menu adjacent to topic headings and individual comments.
|
|
* @param string[] &$resourceLoaderModules List of ResourceLoader modules that DiscussionTools
|
|
* will load when adding the menu item to the overflow menu. Implementations of this hook
|
|
* would typically add at least one item to the list. Make sure to include the relevant OOUI icon
|
|
* ResourceLoader module associated with the 'icon' property of the OverflowMenuItem.
|
|
* @param bool $isSectionEditable If the section is editable (only set of heading overflow menus)
|
|
* @param array $threadItemData The relevant thread item for the overflow menu.
|
|
* @param IContextSource $contextSource Use this to obtain Title, User, Skin, Config, etc objects as needed.
|
|
* @return bool|void True or no return value to continue or false to abort
|
|
*/
|
|
public function onDiscussionToolsAddOverflowMenuItems(
|
|
array &$overflowMenuItems,
|
|
array &$resourceLoaderModules,
|
|
bool $isSectionEditable,
|
|
array $threadItemData,
|
|
IContextSource $contextSource
|
|
);
|
|
}
|