diff --git a/extension.json b/extension.json
index 5afe25b5a..4049476bf 100644
--- a/extension.json
+++ b/extension.json
@@ -417,13 +417,13 @@
]
},
"Hooks": {
- "UserGetDefaultOptions": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onUserGetDefaultOptions",
- "GetPreferences": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onGetPreferences",
- "BeforePageDisplay": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onBeforePageDisplay",
- "CategoryPageView": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onCategoryPageView",
- "ResourceLoaderGetConfigVars": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onResourceLoaderGetConfigVars",
+ "UserGetDefaultOptions": "main",
+ "GetPreferences": "main",
+ "BeforePageDisplay": "main",
+ "CategoryPageView": "main",
+ "ResourceLoaderGetConfigVars": "main",
"MakeGlobalVariablesScript": "main",
- "ThumbnailBeforeProduceHTML": "MediaWiki\\Extension\\MultimediaViewer\\Hooks::onThumbnailBeforeProduceHTML"
+ "ThumbnailBeforeProduceHTML": "main"
},
"HookHandlers": {
"main": {
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 5b2e68eda..fc00f577f 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -24,17 +24,32 @@
namespace MediaWiki\Extension\MultimediaViewer;
use CategoryPage;
+use Config;
use ExtensionRegistry;
use MediaWiki\Category\Category;
+use MediaWiki\Hook\BeforePageDisplayHook;
use MediaWiki\Hook\MakeGlobalVariablesScriptHook;
+use MediaWiki\Hook\ThumbnailBeforeProduceHTMLHook;
use MediaWiki\MediaWikiServices;
+use MediaWiki\Page\Hook\CategoryPageViewHook;
+use MediaWiki\Preferences\Hook\GetPreferencesHook;
+use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
+use MediaWiki\User\Hook\UserGetDefaultOptionsHook;
use MediaWiki\User\UserOptionsLookup;
use OutputPage;
use Skin;
use ThumbnailImage;
use User;
-class Hooks implements MakeGlobalVariablesScriptHook {
+class Hooks implements
+ MakeGlobalVariablesScriptHook,
+ UserGetDefaultOptionsHook,
+ GetPreferencesHook,
+ BeforePageDisplayHook,
+ CategoryPageViewHook,
+ ResourceLoaderGetConfigVarsHook,
+ ThumbnailBeforeProduceHTMLHook
+{
/** Link to more information about this module */
protected static $infoLink =
'https://mediawiki.org/wiki/Special:MyLanguage/Extension:Media_Viewer/About';
@@ -63,7 +78,7 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UserGetDefaultOptions
* @param array &$defaultOptions
*/
- public static function onUserGetDefaultOptions( array &$defaultOptions ) {
+ public function onUserGetDefaultOptions( &$defaultOptions ) {
global $wgMediaViewerEnableByDefault;
if ( $wgMediaViewerEnableByDefault ) {
@@ -111,7 +126,7 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* @param OutputPage $out
* @param Skin $skin
*/
- public static function onBeforePageDisplay( OutputPage $out, $skin ) {
+ public function onBeforePageDisplay( $out, $skin ): void {
$pageHasThumbnails = count( $out->getFileSearchOptions() ) > 0;
$pageIsFilePage = $out->getTitle()->inNamespace( NS_FILE );
// TODO: Have Flow work out if there are any images on the page
@@ -139,7 +154,7 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* Add JavaScript to the page if there are images in the category
* @param CategoryPage $catPage
*/
- public static function onCategoryPageView( CategoryPage $catPage ) {
+ public function onCategoryPageView( $catPage ) {
$title = $catPage->getTitle();
$cat = Category::newFromTitle( $title );
if ( $cat->getFileCount() > 0 ) {
@@ -154,7 +169,7 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* @param User $user
* @param array &$prefs
*/
- public static function onGetPreferences( $user, &$prefs ) {
+ public function onGetPreferences( $user, &$prefs ) {
$prefs['multimediaviewer-enable'] = [
'type' => 'toggle',
'label-message' => 'multimediaviewer-optin-pref',
@@ -166,8 +181,10 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
* Export variables used in both PHP and JS to keep DRY
* @param array &$vars
+ * @param string $skin
+ * @param Config $config
*/
- public static function onResourceLoaderGetConfigVars( array &$vars ) {
+ public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
global $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerExtensions,
$wgMediaViewerImageQueryParameter, $wgMediaViewerRecordVirtualViewBeaconURI;
@@ -206,9 +223,9 @@ class Hooks implements MakeGlobalVariablesScriptHook {
* @param array &$attribs Attributes of the element
* @param array|bool &$linkAttribs Attributes of the wrapping element
*/
- public static function onThumbnailBeforeProduceHTML(
- ThumbnailImage $thumbnail,
- array &$attribs,
+ public function onThumbnailBeforeProduceHTML(
+ $thumbnail,
+ &$attribs,
&$linkAttribs
) {
$file = $thumbnail->getFile();