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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<?php
class CCFilters {
/**
* Hook: ChangesListSpecialPageQuery
* @param string $name
* @param array &$tables
* @param array &$fields
* @param array &$conds
* @param array &$query_options
* @param array &$join_conds
* @param FormOptions $opts
*/
public static function user(
$name,
&$tables,
&$fields,
&$conds,
&$query_options,
&$join_conds,
FormOptions $opts
) {
global $wgRequest, $wgCCUserFilter;
if ( !$wgCCUserFilter ) {
return;
}
$opts->add( 'users', '' );
$users = $wgRequest->getVal( 'users' );
if ( $users === null ) {
return;
}
$userArr = UserArray::newFromNames( explode( '|', $users ) );
if ( $userArr->count() ) {
$dbr = wfGetDB( DB_REPLICA );
if ( class_exists( 'ActorMigration' ) ) {
$conds[] = ActorMigration::newMigration()
->getWhere( $dbr, 'rc_user', iterator_to_array( $userArr ) )['conds'];
} else {
$ids = [];
foreach ( $userArr as $user ) {
$ids[] = $user->getId();
}
$conds['rc_user'] = $ids;
}
$opts->setValue( 'users', $users );
}
}
/**
* Hook: SpecialRecentChangesPanel
* @param array &$items
* @param FormOptions $opts
*/
public static function userForm( &$items, FormOptions $opts ) {
global $wgRequest, $wgCCUserFilter;
if ( !$wgCCUserFilter ) {
return;
}
$opts->consumeValue( 'users' );
$default = $wgRequest->getVal( 'users', '' );
$items['users'] = Xml::inputLabelSep(
wfMessage( 'cleanchanges-users' )->text(),
'users',
'mw-users',
40,
$default
);
}
/**
* Hook: ChangesListSpecialPageQuery
* @param string $name
* @param array &$tables
* @param array &$fields
* @param array &$conds
* @param array &$query_options
* @param array &$join_conds
* @param FormOptions $opts
*/
public static function trailer(
$name,
&$tables,
&$fields,
&$conds,
&$query_options,
&$join_conds,
FormOptions $opts
) {
global $wgRequest, $wgCCTrailerFilter;
if ( !$wgCCTrailerFilter ) {
return;
}
$opts->add( 'trailer', '' );
$trailer = $wgRequest->getVal( 'trailer' );
if ( $trailer === null ) {
return;
}
$dbr = wfGetDB( DB_REPLICA );
$conds[] = 'rc_title ' . $dbr->buildLike( $dbr->anyString(), $trailer );
$opts->setValue( 'trailer', $trailer );
}
/**
* Hook: SpecialRecentChangesPanel
* @param array &$items
* @param FormOptions $opts
*/
public static function trailerForm( &$items, FormOptions $opts ) {
/**
* @var Language $wgLang
*/
global $wgLang, $wgRequest, $wgCCTrailerFilter;
if ( !$wgCCTrailerFilter ) {
return;
}
$opts->consumeValue( 'trailer' );
$default = $wgRequest->getVal( 'trailer', '' );
if ( is_callable( [ 'LanguageNames', 'getNames' ] ) ) {
$languages = LanguageNames::getNames( $wgLang->getCode(),
LanguageNames::FALLBACK_NORMAL,
LanguageNames::LIST_MW
);
} else {
$languages = Language::fetchLanguageNames( null, 'mw' );
}
ksort( $languages );
$options = Xml::option( wfMessage( 'cleanchanges-language-na' )->text(), '', $default === '' );
foreach ( $languages as $code => $name ) {
$selected = ( "/$code" === $default );
$options .= Xml::option( "$code - $name", "/$code", $selected ) . "\n";
}
$str =
Xml::openElement( 'select', [
'name' => 'trailer',
'class' => 'mw-language-selector',
'id' => 'sp-rc-language',
] ) .
$options .
Xml::closeElement( 'select' );
$items['tailer'] = [ wfMessage( 'cleanchanges-language' )->escaped(), $str ];
}
/**
* Hook: FetchChangesList
* @param User $user
* @param Skin $skin
*/
public static function hook( User $user, Skin $skin ): void {
global $wgCCTrailerFilter;
if ( $wgCCTrailerFilter && defined( 'ULS_VERSION' ) ) {
$skin->getOutput()->addModules( 'ext.cleanchanges.uls' );
}
}
}
|