Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4150636
DiscussionToolsHooks.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DiscussionToolsHooks.php
View Options
<?php
/**
* DiscussionTools hooks for listening to our own hooks
*
* @file
* @ingroup Extensions
* @license MIT
*/
namespace
MediaWiki\Extension\DiscussionTools\Hooks
;
use
MediaWiki\Config\Config
;
use
MediaWiki\Config\ConfigFactory
;
use
MediaWiki\Context\IContextSource
;
use
MediaWiki\Extension\DiscussionTools\OverflowMenuItem
;
use
MediaWiki\Registration\ExtensionRegistry
;
use
MediaWiki\User\UserNameUtils
;
class
DiscussionToolsHooks
implements
DiscussionToolsAddOverflowMenuItemsHook
{
private
Config
$config
;
private
UserNameUtils
$userNameUtils
;
public
function
__construct
(
ConfigFactory
$configFactory
,
UserNameUtils
$userNameUtils
)
{
$this
->
config
=
$configFactory
->
makeConfig
(
'discussiontools'
);
$this
->
userNameUtils
=
$userNameUtils
;
}
/**
* @param OverflowMenuItem[] &$overflowMenuItems
* @param string[] &$resourceLoaderModules
* @param array $threadItemData
* @param IContextSource $contextSource
* @return bool|void
*/
public
function
onDiscussionToolsAddOverflowMenuItems
(
array
&
$overflowMenuItems
,
array
&
$resourceLoaderModules
,
array
$threadItemData
,
IContextSource
$contextSource
)
{
if
(
(
$threadItemData
[
'type'
]
??
null
)
===
'heading'
&&
!(
$threadItemData
[
'uneditableSection'
]
??
false
)
&&
$contextSource
->
getSkin
()->
getSkinName
()
===
'minerva'
)
{
$overflowMenuItems
[]
=
new
OverflowMenuItem
(
'edit'
,
'edit'
,
$contextSource
->
msg
(
'skin-view-edit'
),
2
);
}
if
(
$this
->
config
->
get
(
'DiscussionToolsEnableThanks'
)
)
{
$user
=
$contextSource
->
getUser
();
$showThanks
=
ExtensionRegistry
::
getInstance
()->
isLoaded
(
'Thanks'
);
if
(
$showThanks
&&
(
$threadItemData
[
'type'
]
??
null
)
===
'comment'
&&
$user
->
isNamed
()
)
{
$recipient
=
$this
->
userNameUtils
->
getCanonical
(
$threadItemData
[
'author'
],
UserNameUtils
::
RIGOR_NONE
);
if
(
$recipient
!==
$user
->
getName
()
&&
!
$this
->
userNameUtils
->
isIP
(
$recipient
)
)
{
$overflowMenuItems
[]
=
new
OverflowMenuItem
(
'thank'
,
'heart'
,
$contextSource
->
msg
(
'thanks-button-thank'
),
);
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 19:39 (6 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
43/02/0f5b13a70cf819c0cf5d38446adc
Default Alt Text
DiscussionToolsHooks.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment