-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpecialMajorChangesLog.php
256 lines (219 loc) · 6.34 KB
/
SpecialMajorChangesLog.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
class SpecialMajorChangesLog extends SpecialPage {
/**
* @var User
*/
protected $mUserFilter;
/**
* @var Title
*/
protected $mTitleFilter;
protected $mRevTagFilter;
protected $mModeFilter;
protected $mStartDateFilter;
protected $mEndDateFilter;
protected $mAllowedModes = [
'all',
'onlymajor',
'onlyminor'
];
protected $mStatusFilter;
protected $mAllowedStatus = [
'all',
'done',
'queue'
];
public function __construct() {
parent::__construct( 'MajorChangesLog', 'majorchanges-log' );
}
protected function getGroupName() {
return 'changes';
}
public function execute( $parameter ) {
$this->setHeaders();
$this->outputHeader();
$this->getOutput()->addModules( 'mediawiki.special.majorchanges' );
$opts = new FormOptions();
$opts->add( 'page', '' );
$opts->add( 'user', '' );
$opts->add( 'mode', '' );
$opts->add( 'status', '' );
$opts->add( 'start', '' );
$opts->add( 'end', '' );
$opts->fetchValuesFromRequest( $this->getRequest() );
// Show the search form.
$this->searchForm();
// Show the log itself.
$this->showList( $opts );
}
private function getActionButtons( $formcontents ) {
if ( !ChangeTags::showTagEditingUI( $this->getUser() ) ) {
# If the user doesn't have the ability to edit tags, don't bother showing them the button(s).
return $formcontents;
}
$s = Html::openElement(
'form',
[ 'method' => 'post', 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' ]
) . "\n";
$s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
$s .= Html::hidden( 'type', 'logging' ) . "\n";
$s .= Html::hidden( 'wpTagList[]', 'שינוי מהותי טופל' ) . "\n";
$s .= Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() );
$s .= Html::hidden( 'wpSubmit', '1' ) . "\n";
$buttons = Html::element(
'button',
[
'type' => 'submit',
'name' => 'editchangetags',
'value' => '1',
'class' => "editchangetags-log-submit mw-log-editchangetags-button"
],
$this->msg( 'majorchanges-log-edit-tags' )->text()
) . "\n";
$buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML();
$legend = Html::element( 'legend', null, $this->msg( 'majorchanges-log-markdone' )->text() );
$buttons = Xml::tags( 'fieldset', null, $legend . $buttons );
$s .= $buttons . $formcontents . $buttons;
$s .= Html::closeElement( 'form' );
return $s;
}
function searchForm() {
$formDescriptor = [
'user' => [
'type' => 'user',
'name' => 'user',
'label-message' => 'majorchanges-log-user-filter',
],
'page' => [
'type' => 'title',
'name' => 'page',
'label-message' => 'majorchanges-log-title-filter',
],
'mode' => [
'type' => 'select',
'name' => 'mode',
'options-messages' => $this->getModeFilterOptions(),
'label-message' => 'majorchanges-log-mode-filter'
],
'status' => [
'type' => 'select',
'name' => 'status',
'options-messages' => $this->getStatusFilterOptions(),
'label-message' => 'majorchanges-log-status-filter'
],
'start' => [
'type' => 'date',
'name' => 'start',
'label-message' => 'majorchanges-start-date-filter'
],
'end' => [
'type' => 'date',
'name' => 'end',
'label-message' => 'majorchanges-end-date-filter'
]
];
HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
->setWrapperLegendMsg( 'majorchanges-log-filter' )
->setSubmitTextMsg( 'htmlform-submit' )
->setAction( $this->getPageTitle()->getLocalURL() )
->setMethod( 'get' )
->prepareForm()
->displayForm( false );
}
protected function getModeFilterOptions() {
$options = [];
foreach ( $this->mAllowedModes as $mode ) {
// majorchanges-log-mode-all, majorchanges-log-mode-onlymajor, majorchanges-log-mode-onlyminor
$msgName = "majorchanges-log-mode-{$mode}";
$options[ $msgName ] = $mode;
}
return $options;
}
protected function getStatusFilterOptions() {
$options = [];
foreach ( $this->mAllowedStatus as $status ) {
// majorchanges-log-status-all, majorchanges-log-status-done, majorchanges-log-status-queue
$msgName = "majorchanges-log-status-{$status}";
$options[ $msgName ] = $status;
}
return $options;
}
/**
* Creates the <select> for which tags to show
* @return string Formatted HTML
*/
protected function getModeFilter() {
$options = [];
foreach ( $this->mAllowedModes as $mode ) {
// majorchanges-log-mode-all, majorchanges-log-mode-onlymajor, majorchanges-log-mode-onlyminor
$text = $this->msg( "majorchanges-log-mode-{$mode}" )->escaped();
$options[] = Html::element(
'option', [
'value' => $mode,
'selected' => ( $mode === $this->mModeFilter ),
],
$text
);
}
$ret = '';
// Wrap options in a <select>
$ret .= Html::rawElement(
'select',
[ 'id' => 'wpModeFilter', 'name' => 'wpModeFilter' ],
implode( "\n", $options )
);
return $ret;
}
protected function getStatusFilter() {
$options = [];
foreach ( $this->mAllowedStatus as $status ) {
// majorchanges-log-status-all, majorchanges-log-status-done, majorchanges-log-status-queue
$text = $this->msg( "majorchanges-log-status-{$status}" )->escaped();
$options[] = Html::element(
'option', [
'value' => $status,
'selected' => ( $status === $this->mStatusFilter ),
],
$text
);
}
$ret = '';
// Wrap options in a <select>
$ret .= Html::rawElement(
'select',
[ 'id' => 'wpStatusFilter', 'name' => 'wpStatusFilter' ],
implode( "\n", $options )
);
return $ret;
}
private function showList( FormOptions $opts ) {
$out = $this->getOutput();
# Create a LogPager item to get the results and a LogEventsList item to format them...
$loglist = new LogEventsList(
$this->getContext(),
null,
LogEventsList::USE_CHECKBOXES
);
$pager = new MajorChangesLogPager(
$loglist, $opts
);
$pager->doQuery();
$logBody = $pager->getBody();
if ( $logBody ) {
$numRecordsMsg = $this->msg( 'majorchanges-log-filter-num-records' )
->numParams( $pager->getTotalNumRows() );
$out->addHTML(
$pager->getNavigationBar() .
$this->getActionButtons(
$numRecordsMsg->text() .
$loglist->beginLogEventsList() .
$logBody .
$loglist->endLogEventsList()
) .
$pager->getNavigationBar()
);
} else {
$out->addWikiMsg( 'majorchanges-log-noresults' );
}
}
}