forked from MoeMoeFish/MoegirlRating
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoegirlRating.hooks.php
68 lines (55 loc) · 2.05 KB
/
MoegirlRating.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
<?php
final class MoegirlRatingHooks {
public static function onSkinAfterContent( &$data, $skin ) {
$pageTitle = $skin->getTitle();
$output = $skin->getOutput();
$request = $skin->getRequest();
MRLogging::logging( MRLogging::$INFO, __FILE__, __LINE__, 'Namespace: '. $pageTitle->getNamespace() );
if ( $pageTitle->isSpecialPage()
|| $pageTitle->getArticleID() == 0
|| !$pageTitle->canTalk()
|| $pageTitle->isTalkPage()
|| method_exists( $pageTitle, 'isMainPage' ) && $pageTitle->isMainPage() // 主页
|| in_array( $pageTitle->getNamespace(), array( NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE, NS_USER ))
|| $output->isPrintable()
|| $request->getVal( 'action', 'view' ) != 'view'
) {
return true;
}
$articleId = $skin->getTitle()->getArticleID();
MRLogging::logging( MRLogging::$INFO, __FILE__, __LINE__, 'Moegirl rating show in wiki: ' . $articleId );
global $wgScriptPath;
$data .=<<<EOF
<div id="rating-main">
<div class="moegirl_rating clearfix">
<div class="rating_title">为本页面评分:</div>
<div class="rating_body_disabled rating_main" >
<ul class="mr-rating-ul">
<li><a class="r-1" >1</a></li>
<li><a class="r-2" >2</a></li>
<li><a class="r-3" >3</a></li>
<li><a class="r-4" >4</a></li>
<li><a class="r-5" >5</a></li>
</ul>
<div class="rating_body_result" ></div>
<div class="moegirl-rating-error-tip"></div>
</div>
<div class="rating_result" ><div class="result_icon loading" ></div><div class="result_text" ></div></div>
</div>
</div>
<script type="text/javascript" >
window.RLQ = window.RLQ || [];
window.RLQ.push(function(){
mw.loader.using( 'ext.MoegirlRating', function() {
new MoegirlRatingControl( '#rating-main', $articleId, '$wgScriptPath' ).init();
});
});
</script>
EOF;
return true;
}
public static function addDatabases( DatabaseUpdater $updater ) {
$updater->addExtensionUpdate( array( 'addTable', SqlSentences::$ratingRecordTable, __DIR__ . '/sql/create-rating-history-table.sql', true ) );
return true;
}
}