You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
734 B
PHP
26 lines
734 B
PHP
<?php
|
|
namespace Isekai\OffcanvasToc;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
class Hooks {
|
|
public static function onLoad(\OutputPage $outputPage) {
|
|
$service = MediaWikiServices::getInstance();
|
|
if (
|
|
$outputPage->getTitle()->isContentPage() &&
|
|
$service->getUserOptionsLookup()->getOption($outputPage->getUser(), 'offcanvas-toc-enabled')
|
|
) {
|
|
$outputPage->addModules(['ext.isekai.offcanvas-toc']);
|
|
}
|
|
}
|
|
|
|
public static function onGetPreferences(\User $user, array &$preferences) {
|
|
$preferences['offcanvas-toc-enabled'] = [
|
|
'type' => 'toggle',
|
|
'label-message' => 'offcanvas-toc-enabled',
|
|
'section' => 'rendering/offcanvas-toc'
|
|
];
|
|
|
|
return true;
|
|
}
|
|
} |