mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-28 18:21:50 +00:00
664b2890d7
This sets up the tags: * discussiontools * discussiontools-reply * discussiontools-edit (not yet implemented) * discussiontools-newsection (not yet implemented) The tags are flagged as user-addable, because otherwise they can't be passed through to the VE API (at least, not without editing it so that it explicitly knows about them, which seems like a strange interdependency). It's assumed that letting users who know about the tags add them to random changes via action=editchangetags would be (a) the pettiest and most inconsequential vandalism possible, and (b) unlikely to happen. This relies upon I2c1d0f8d69bc03e5c1877c790247e165f160e966 in VisualEditor to not also tag the edits with `visualeditor`. Bug: T242184 Change-Id: I4e5e26afdd52279df242e1912f073b415b812c3b
67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* DiscussionTools extension hooks
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license MIT
|
|
*/
|
|
|
|
class DiscussionToolsHooks {
|
|
|
|
public static function onRegistration() {
|
|
global $wgLocaltimezone;
|
|
// If $wgLocaltimezone isn't hard-coded, it is evaluated from the system
|
|
// timezone. On some systems this isn't guaranteed to be static, for example
|
|
// on Debian, GMT can get converted to UTC, instead of Europe/London.
|
|
//
|
|
// Timestamp parsing assumes that the timezone never changes.
|
|
//
|
|
// HACK: Do not run this test on CI as $wgLocaltimezone is not configured.
|
|
if ( !$wgLocaltimezone && !getenv( 'ZUUL_PROJECT' ) ) {
|
|
throw new \ConfigException( 'DiscussionTools requires $wgLocaltimezone to be set' );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds DiscussionTools JS to the output.
|
|
*
|
|
* This is attached to the MediaWiki 'BeforePageDisplay' hook.
|
|
*
|
|
* @param OutputPage $output The page view.
|
|
* @param Skin $skin The skin that's going to build the UI.
|
|
*/
|
|
public static function onBeforePageDisplay( OutputPage $output, Skin $skin ) {
|
|
$title = $output->getTitle();
|
|
$actionName = Action::getActionName( $output->getContext() );
|
|
if (
|
|
// Don't show on edit pages
|
|
$actionName !== 'edit' &&
|
|
$actionName !== 'submit' &&
|
|
// Only wikitext pages (e.g. not Flow boards)
|
|
$title->getContentModel() === CONTENT_MODEL_WIKITEXT &&
|
|
$title->isTalkPage()
|
|
// TODO: Allow non talk pages to be treated as talk pages
|
|
// using a magic word.
|
|
) {
|
|
$output->addModules( [
|
|
'ext.discussionTools.init'
|
|
] );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements the ListDefinedTags, ChangeTagsListActive, and
|
|
* ChangeTagsAllowedAdd hooks, to populate core Special:Tags with the change
|
|
* tags in use by VisualEditor.
|
|
*
|
|
* @param array &$tags Available change tags.
|
|
*/
|
|
public static function onListDefinedTags( &$tags ) {
|
|
$tags[] = 'discussiontools';
|
|
$tags[] = 'discussiontools-reply';
|
|
$tags[] = 'discussiontools-edit';
|
|
$tags[] = 'discussiontools-newsection';
|
|
}
|
|
}
|