11<?php
2+ class HandleReportsPager extends ReverseChronologicalPager {
3+ private $ conds ;
4+
5+ function __construct ($ conds ) {
6+ $ this ->conds = $ conds ;
7+
8+ parent ::__construct ();
9+ }
10+
11+ function getQueryInfo () {
12+ return [
13+ 'tables ' => 'report_reports ' ,
14+ 'fields ' => [
15+ 'report_id ' ,
16+ 'report_reason ' ,
17+ 'report_user ' ,
18+ 'report_revid ' ,
19+ 'report_timestamp '
20+ ],
21+ 'conds ' => $ this ->conds
22+ ];
23+ }
24+
25+ function getIndexField () {
26+ return 'report_timestamp ' ;
27+ }
28+
29+ function formatRow ($ row ) {
30+ global $ wgScriptPath ;
31+
32+ $ out = Html::openElement ('tr ' );
33+ $ out .= Html::rawElement ('td ' , [],
34+ wfTimestamp ( TS_ISO_8601 , $ row ->report_timestamp )
35+ );
36+ $ out .= Html::rawElement ('td ' , [], Html::rawElement (
37+ 'textarea ' ,
38+ [ 'readonly ' => '' ,
39+ 'class ' => 'mw-report-handling-textarea ' ],
40+ htmlspecialchars ($ row ->report_reason )
41+ ));
42+ $ user = User::newFromId ($ row ->report_user );
43+ $ out .= Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
44+ [ 'href ' => $ user ->getUserPage ()->getLocalURL () ],
45+ htmlspecialchars ($ user ->getName ())
46+ ));
47+ $ out .= Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
48+ [ 'href ' => $ wgScriptPath . '/index.php?diff= ' . $ row ->report_revid ],
49+ htmlspecialchars ($ row ->report_revid )
50+ ));
51+ $ out .= Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
52+ [ 'href ' => SpecialPage::getTitleFor ( 'HandleReports ' , $ row ->report_id )->getLocalURL () ],
53+ wfMessage ( 'report-handling-view-report ' )->escaped ()
54+ ));
55+ $ out .= Html::closeElement ('tr ' );
56+
57+ return $ out ;
58+ }
59+ }
260
361class SpecialHandleReports extends SpecialPage {
462
@@ -20,6 +78,7 @@ public function execute( $par ) {
2078 }
2179 $ dbr = wfGetDB ( DB_REPLICA );
2280 if (!ctype_digit ( $ par )) {
81+ $ out ->addHtml (Html::openElement ('p ' ));
2382 if ( strtolower ( $ par ) !== strtolower ( wfMessage ( 'report-handled ' )->text () ) ) {
2483 $ out ->addHTML (Html::rawElement ('a ' ,
2584 [ 'href ' => SpecialPage::getTitleFor ( 'HandleReports ' , wfMessage ('report-handled ' )->text () )->getLocalURL () ],
@@ -31,70 +90,52 @@ public function execute( $par ) {
3190 wfMessage ( 'report-handling-view-nothandled ' )->escaped ()
3291 ));
3392 }
34- $ out ->addHTML (Html::openElement (
35- 'table ' ,
36- [ 'class ' => 'mw-report-handling-list ' , 'width ' => '100% ' ]
37- ));
38- $ out ->addHTML (Html::openElement ('tr ' ));
39- $ out ->addHTML (Html::rawElement (
40- 'th ' , [],
41- wfMessage ( 'report-handling-th-timestamp ' )->escaped ()
42- ));
43- $ out ->addHTML (Html::rawElement (
44- 'th ' , [],
45- wfMessage ( 'report-handling-th-reason ' )->escaped ()
46- ));
47- $ out ->addHTML (Html::rawElement (
48- 'th ' , [],
49- wfMessage ( 'report-handling-th-user ' )->escaped ()
50- ));
51- $ out ->addHTML (Html::rawElement (
52- 'th ' , [],
53- wfMessage ( 'report-handling-th-revid ' )->escaped ()
54- ));
55- $ out ->addHTML (Html::rawElement ('th ' , [],
56- wfMessage ( 'report-handling-view-report ' )->escaped ()
57- ));
58- $ out ->addHTML (Html::closeElement ('tr ' ));
93+ $ out ->addHtml (Html::closeElement ('p ' ));
94+
5995 if ( strtolower ( $ par ) === strtolower ( wfMessage ( 'report-handled ' )->text () ) ) {
6096 $ conds = [ 'report_handled ' => 1 ];
6197 } else {
6298 $ conds = [ 'report_handled != 1 ' ];
6399 }
64- foreach ($ dbr ->select ( 'report_reports ' , [
65- 'report_id ' ,
66- 'report_reason ' ,
67- 'report_user ' ,
68- 'report_revid ' ,
69- 'report_timestamp ' ,
70- ], $ conds , __METHOD__ )
71- as $ row ) {
100+ $ pager = new HandleReportsPager ($ conds );
101+
102+ if ($ pager ->getNumRows () > 0 ) {
103+ $ out ->addHtml (Html::rawElement ('div ' , [], $ pager ->getNavigationBar ()));
104+
105+ $ out ->addHTML (Html::openElement (
106+ 'table ' ,
107+ [ 'class ' => 'mw-report-handling-list ' , 'width ' => '100% ' ]
108+ ));
72109 $ out ->addHTML (Html::openElement ('tr ' ));
73- $ out ->addHTML (Html::rawElement ('td ' , [],
74- wfTimestamp ( TS_ISO_8601 , $ row ->report_timestamp )
110+ $ out ->addHTML (Html::rawElement (
111+ 'th ' , [],
112+ wfMessage ( 'report-handling-th-timestamp ' )->escaped ()
75113 ));
76- $ out ->addHTML (Html::rawElement ('td ' , [], Html::rawElement (
77- 'textarea ' ,
78- [ 'readonly ' => '' ,
79- 'class ' => 'mw-report-handling-textarea ' ],
80- htmlspecialchars ($ row ->report_reason )
81- )));
82- $ user = User::newFromId ($ row ->report_user );
83- $ out ->addHTML (Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
84- [ 'href ' => $ user ->getUserPage ()->getLocalURL () ],
85- htmlspecialchars ($ user ->getName ())
86- )));
87- $ out ->addHTML (Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
88- [ 'href ' => $ wgScriptPath . '/index.php?diff= ' . $ row ->report_revid ],
89- htmlspecialchars ($ row ->report_revid )
90- )));
91- $ out ->addHTML (Html::rawElement ('td ' , [], Html::rawElement ('a ' ,
92- [ 'href ' => SpecialPage::getTitleFor ( 'HandleReports ' , $ row ->report_id )->getLocalURL () ],
114+ $ out ->addHTML (Html::rawElement (
115+ 'th ' , [],
116+ wfMessage ( 'report-handling-th-reason ' )->escaped ()
117+ ));
118+ $ out ->addHTML (Html::rawElement (
119+ 'th ' , [],
120+ wfMessage ( 'report-handling-th-user ' )->escaped ()
121+ ));
122+ $ out ->addHTML (Html::rawElement (
123+ 'th ' , [],
124+ wfMessage ( 'report-handling-th-revid ' )->escaped ()
125+ ));
126+ $ out ->addHTML (Html::rawElement ('th ' , [],
93127 wfMessage ( 'report-handling-view-report ' )->escaped ()
94- ))) ;
128+ ));
95129 $ out ->addHTML (Html::closeElement ('tr ' ));
130+
131+ $ out ->addHTML ($ pager ->getBody ());
132+
133+ $ out ->addHTML (Html::closeElement ('table ' ));
134+
135+ $ out ->addHtml (Html::rawElement ('div ' , [], $ pager ->getNavigationBar ()));
136+ } else {
137+ $ out ->addHTML (Html::rawElement ('p ' , [], wfMessage ('report-handling-no-reports ' )->escaped ()));
96138 }
97- $ out ->addHTML (Html::closeElement ('table ' ));
98139 } else {
99140 if ($ this ->getRequest ()->wasPosted ()) {
100141 return $ this ->onPost ( $ par , $ out , $ user );
0 commit comments