-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMoegirlAD.hooks.php
75 lines (56 loc) · 1.75 KB
/
MoegirlAD.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/*
* Static class for hooks handle by MoegirlAD.
*
* @file MoegirlAD.hooks.php
*
* @license Apache-2.0+
* @author Fish Thirteen < [email protected] >
*
*/
final class MoegirlADHooks {
public static function onSkinAfterContent(&$data, $skin) {
global $wgMoegirlADBottomADCode;
if (MoegirlADHooks::shouldShowADs()) {
$data .= $wgMoegirlADBottomADCode;
}
return true;
}
public static function onSiteNoticeAfter(&$siteNotice, $skin) {
global $wgMoegirlADTopADCode;
if (MoegirlADHooks::shouldShowADs()) {
$siteNotice = $wgMoegirlADTopADCode . $siteNotice;
}
return true;
}
public static function onSkinAfterBottomScripts( $skin, &$text ) {
global $wgMoegirlADFooterEnabled, $wgMoegirlADFooterADCode;
if (MoegirlADHooks::shouldShowADs() && $wgMoegirlADFooterEnabled) {
$text .= $wgMoegirlADFooterADCode;
}
return true;
}
public static function onSkinBuildSidebar( Skin $skin, &$bar ) {
global $wgMoegirlADSideBarEnabled, $wgMoegirlADSideBarADName, $wgMoegirlADSideBarADCode;
if (MoegirlADHooks::shouldShowADs() && $wgMoegirlADSideBarEnabled) {
$bar[$wgMoegirlADSideBarADName] = $wgMoegirlADSideBarADCode;
}
return true;
}
/**
* Check if the advertice should be display
*
* @return boolean
*/
public static function shouldShowADs() {
global $wgMoegirlADEnabled;
if ($wgMoegirlADEnabled) {
$currentUser = RequestContext::getMain()->getUser();
//只对未登录用户和没有编辑过任何条目的用户显示广告
return !(is_object($currentUser) && $currentUser->isLoggedIn() && $currentUser->getEditCount() != null && $currentUser->getEditCount() > 0);
} else {
return false;
}
}
}
?>