-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.php
69 lines (64 loc) · 1.93 KB
/
function.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
<?php
function parsewikitext($text) {
$text = html_entity_decode($text);
$text = htmlspecialchars($text);
$text = preg_replace("/\[\[([^\|\]]+?)]]/", '<a href="https://zh.wikipedia.org/wiki/$1">$1</a>', $text);
$text = preg_replace("/\[\[([^\|\]]+?)\|([^]]+?)]]/", '<a href="https://zh.wikipedia.org/wiki/$1">$2</a>', $text);
return $text;
}
function blockflags(&$item, $key) {
$f = [
'anononly' => '僅限匿名使用者',
'noautoblock' => '停用自動封鎖',
'nocreate' => '停用帳號建立',
'noemail' => '停用電子郵件',
'nousertalk' => '無法編輯自己的對話頁面'
];
if (isset($f[$item])) {
$item = $f[$item];
}
}
function protectparams($text) {
return str_replace(
["[edit=", "[move=", "[create=", "=autoconfirmed]", "=sysop]"],
["[編輯=", "[移動=", "[建立=", "=僅允許已自動確認的使用者]", "=僅限管理員]"], $text);
}
function rightparams($group) {
$name = [
'accountcreator' => '帳號建立員',
'autoreviewer' => '巡查豁免者',
'bot' => '機器人',
'bureaucrat' => '行政員',
'confirmed' => '已確認的使用者',
'eventparticipant' => '活動參與者',
'filemover' => '檔案移動員',
'flood' => '機器使用者',
'interface-admin' => '介面管理員',
'ipblock-exempt' => 'IP 封鎖例外',
'massmessage-sender' => '大量訊息傳送者',
'oversight' => '監督員',
'patroller' => '巡查員',
'rollbacker' => '回退員',
'sysop' => '管理員'
];
return $name[$group];
}
function parserights($groups, $metadata) {
$res = [];
foreach ($groups as $key => $_) {
$expiry = $metadata[$key]["expiry"];
if ($expiry == "infinity") {
$res []= rightparams($groups[$key]);
} else {
$res []= sprintf("%s(%s/%s/%s %s:%s)",
rightparams($groups[$key]),
substr($expiry, 0, 4),
substr($expiry, 5, 2),
substr($expiry, 8, 2),
substr($expiry, 11, 2),
substr($expiry, 14, 2)
);
}
}
return implode("、", $res);
}