forked from kolzchut/mediawiki-extensions-ArticleRanking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHooks.php
57 lines (49 loc) · 1.59 KB
/
Hooks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace MediaWiki\Extension\ArticleRanking;
use MediaWiki\MediaWikiServices;
use OutputPage;
use Skin;
class Hooks {
/**
* @param OutputPage &$out
* @param Skin &$skin
*
* @return bool
* @throws \ConfigException
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
$conf = MediaWikiServices::getInstance()->getMainConfig();
$wgArticleRankingAddChangeRequest = $conf->get( 'ArticleRankingAddChangeRequest' );
if ( $wgArticleRankingAddChangeRequest ) {
$out->addModules( [ 'ext.articleRanking.changeRequest' ] );
}
$out->addModules( [ 'ext.articleRanking' ] );
if ( $conf->get( 'ArticleRankingAddAfterVote' ) ) {
$out->addModules( [ 'ext.articleRanking-after-vote' ] );
}
// $out->showErrorPage( 'ranking-invalid-captcha-title', 'ranking-invalid-captcha-keys-message' );
if ( ArticleRanking::isCaptchaEnabled() ) {
$out->addHeadItem(
'recaptcha',
'<script async defer src="https://www.google.com/recaptcha/api.js"></script>'
);
}
return true;
}
/**
* Hook: ResourceLoaderGetConfigVars called right before
* ResourceLoaderStartUpModule::getConfig returns
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
*
* @param array &$vars variables to be added into the output of the startup module.
*
* @return true
*/
public static function onResourceLoaderGetConfigVars( &$vars ) {
global $wgArticleRankingConfig;
$vars['wgArticleRankingConfig'] = $wgArticleRankingConfig;
$vars['wgArticleRankingConfig']['isCaptchaEnabled'] = ArticleRanking::isCaptchaEnabled();
return true;
}
}