Index: trunk/extensions/FlaggedRevs/specialpages/PendingChanges_body.php |
— | — | @@ -6,6 +6,8 @@ |
7 | 7 | |
8 | 8 | class PendingChanges extends SpecialPage |
9 | 9 | { |
| 10 | + protected $pager = null; |
| 11 | + |
10 | 12 | public function __construct() { |
11 | 13 | parent::__construct( 'PendingChanges' ); |
12 | 14 | $this->includable( true ); |
— | — | @@ -13,28 +15,38 @@ |
14 | 16 | |
15 | 17 | public function execute( $par ) { |
16 | 18 | global $wgRequest, $wgUser; |
| 19 | + |
17 | 20 | $this->setHeaders(); |
18 | 21 | $this->skin = $wgUser->getSkin(); |
19 | 22 | $this->currentUnixTS = wfTimestamp( TS_UNIX ); // now |
20 | | - # Read params |
| 23 | + |
21 | 24 | $this->namespace = $wgRequest->getIntOrNull( 'namespace' ); |
22 | 25 | $this->level = $wgRequest->getInt( 'level', - 1 ); |
23 | | - $this->category = trim( $wgRequest->getVal( 'category' ) ); |
24 | | - $catTitle = Title::makeTitleSafe( NS_CATEGORY, $this->category ); |
| 26 | + $category = trim( $wgRequest->getVal( 'category' ) ); |
| 27 | + $catTitle = Title::makeTitleSafe( NS_CATEGORY, $category ); |
25 | 28 | $this->category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
26 | 29 | $this->size = $wgRequest->getIntOrNull( 'size' ); |
27 | 30 | $this->watched = $wgRequest->getCheck( 'watched' ); |
28 | 31 | $this->stable = $wgRequest->getCheck( 'stable' ); |
29 | 32 | $feedType = $wgRequest->getVal( 'feed' ); |
| 33 | + if ( $this->including() ) { |
| 34 | + $incLimit = $this->parseParams( $par ); // apply non-URL params |
| 35 | + } |
| 36 | + |
| 37 | + $this->pager = new PendingChangesPager( $this, $this->namespace, |
| 38 | + $this->level, $this->category, $this->size, $this->watched, $this->stable ); |
| 39 | + |
30 | 40 | # Output appropriate format... |
31 | 41 | if ( $feedType != null ) { |
32 | 42 | $this->feed( $feedType ); |
33 | 43 | } else { |
34 | | - if ( !$this->including() ) { |
| 44 | + if ( $this->including() ) { |
| 45 | + $this->pager->setLimit( $incLimit ); // apply non-URL limit |
| 46 | + } else { |
35 | 47 | $this->setSyndicated(); |
36 | 48 | $this->showForm(); |
37 | 49 | } |
38 | | - $this->showList( $par ); |
| 50 | + $this->showPageList(); |
39 | 51 | } |
40 | 52 | } |
41 | 53 | |
— | — | @@ -51,14 +63,14 @@ |
52 | 64 | |
53 | 65 | public function showForm() { |
54 | 66 | global $wgUser, $wgOut, $wgScript; |
55 | | - $action = htmlspecialchars( $wgScript ); |
56 | | - # Explanation text... |
57 | | - $wgOut->addWikiMsg( 'pendingchanges-list' ); |
58 | | - $form = |
59 | | - "<form action=\"$action\" method=\"get\">\n" . |
60 | | - '<fieldset><legend>' . wfMsg( 'pendingchanges-legend' ) . '</legend>' . |
61 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
| 67 | + # Explanatory text |
| 68 | + $wgOut->addWikiMsg( 'pendingchanges-list', $this->pager->getNumRows() ); |
62 | 69 | |
| 70 | + $form = Html::openElement( 'form', array( 'name' => 'pendingchanges', |
| 71 | + 'action' => $wgScript, 'method' => 'get' ) ) . "\n"; |
| 72 | + $form .= "<fieldset><legend>" . wfMsgHtml( 'pendingchanges-legend' ) . "</legend>\n"; |
| 73 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n"; |
| 74 | + |
63 | 75 | $items = array(); |
64 | 76 | if ( count( FlaggedRevs::getReviewNamespaces() ) > 1 ) { |
65 | 77 | $items[] = "<span style='white-space: nowrap;'>" . |
— | — | @@ -77,6 +89,7 @@ |
78 | 90 | if ( $items ) { |
79 | 91 | $form .= implode( ' ', $items ) . '<br />'; |
80 | 92 | } |
| 93 | + |
81 | 94 | $items = array(); |
82 | 95 | $items[] = |
83 | 96 | Xml::label( wfMsg( "pendingchanges-category" ), 'wpCategory' ) . ' ' . |
— | — | @@ -89,42 +102,35 @@ |
90 | 103 | $form .= |
91 | 104 | Xml::label( wfMsg( 'pendingchanges-size' ), 'wpSize' ) . |
92 | 105 | Xml::input( 'size', 4, $this->size, array( 'id' => 'wpSize' ) ) . ' ' . |
93 | | - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
94 | | - "</fieldset></form>"; |
| 106 | + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n"; |
| 107 | + $form .= "</fieldset>"; |
| 108 | + $form .= Html::closeElement( 'form' ) . "\n"; |
| 109 | + |
95 | 110 | $wgOut->addHTML( $form ); |
96 | 111 | } |
97 | 112 | |
98 | | - public function showList( $par ) { |
| 113 | + public function showPageList() { |
99 | 114 | global $wgOut; |
100 | | - $limit = false; // defer to Pager |
101 | | - if ( $this->including() ) { |
102 | | - $limit = $this->parseParams( $par ); |
103 | | - } |
104 | | - $pager = new PendingChangesPager( $this, $this->namespace, $this->level, |
105 | | - $this->category, $this->size, $this->watched, $this->stable ); |
106 | | - // Apply limit if transcluded |
107 | | - if ( $limit ) $pager->mLimit = $limit; |
108 | 115 | // Viewing the list normally... |
109 | 116 | if ( !$this->including() ) { |
110 | | - if ( $pager->getNumRows() ) { |
111 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
112 | | - $wgOut->addHTML( $pager->getBody() ); |
113 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 117 | + if ( $this->pager->getNumRows() ) { |
| 118 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 119 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 120 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
114 | 121 | } else { |
115 | 122 | $wgOut->addWikiMsg( 'pendingchanges-none' ); |
116 | 123 | } |
117 | 124 | // If this list is transcluded... |
118 | 125 | } else { |
119 | | - if ( $pager->getNumRows() ) { |
120 | | - $wgOut->addHTML( $pager->getBody() ); |
| 126 | + if ( $this->pager->getNumRows() ) { |
| 127 | + $wgOut->addHTML( $this->pager->getBody() ); |
121 | 128 | } else { |
122 | 129 | $wgOut->addWikiMsg( 'pendingchanges-none' ); |
123 | 130 | } |
124 | 131 | } |
125 | 132 | } |
126 | 133 | |
127 | | - // set namespace and category fields of $this |
128 | | - // @returns int paging limit |
| 134 | + // set pager parameters from $par, return pager limit |
129 | 135 | protected function parseParams( $par ) { |
130 | 136 | global $wgLang; |
131 | 137 | $bits = preg_split( '/\s*,\s*/', trim( $par ) ); |
— | — | @@ -155,7 +161,7 @@ |
156 | 162 | * @param string $type |
157 | 163 | */ |
158 | 164 | protected function feed( $type ) { |
159 | | - global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut, $wgRequest; |
| 165 | + global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut; |
160 | 166 | if ( !$wgFeed ) { |
161 | 167 | $wgOut->addWikiMsg( 'feed-unavailable' ); |
162 | 168 | return; |
— | — | @@ -169,13 +175,11 @@ |
170 | 176 | wfMsg( 'tagline' ), |
171 | 177 | $this->getTitle()->getFullUrl() |
172 | 178 | ); |
173 | | - $pager = new PendingChangesPager( $this, $this->namespace, $this->category ); |
174 | | - $limit = $wgRequest->getInt( 'limit', 50 ); |
175 | | - $pager->mLimit = min( $wgFeedLimit, $limit ); |
| 179 | + $this->pager->mLimit = min( $wgFeedLimit, $this->pager->mLimit ); |
176 | 180 | |
177 | 181 | $feed->outHeader(); |
178 | | - if ( $pager->getNumRows() > 0 ) { |
179 | | - foreach ( $pager->mResult as $row ) { |
| 182 | + if ( $this->pager->getNumRows() > 0 ) { |
| 183 | + foreach ( $this->pager->mResult as $row ) { |
180 | 184 | $feed->outItem( $this->feedItem( $row ) ); |
181 | 185 | } |
182 | 186 | } |
— | — | @@ -211,14 +215,15 @@ |
212 | 216 | public function formatRow( $row ) { |
213 | 217 | global $wgLang, $wgUser; |
214 | 218 | $css = $quality = $underReview = ''; |
215 | | - |
216 | 219 | $title = Title::newFromRow( $row ); |
217 | | - $link = $this->skin->makeKnownLinkObj( $title ); |
218 | | - $hist = $this->skin->makeKnownLinkObj( $title, |
219 | | - wfMsgHtml( 'hist' ), 'action=history' ); |
220 | 220 | $stxt = ChangesList::showCharacterDifference( $row->rev_len, $row->page_len ); |
221 | | - $review = $this->skin->makeKnownLinkObj( $title, |
| 221 | + # Page links... |
| 222 | + $link = $this->skin->link( $title ); |
| 223 | + $hist = $this->skin->linkKnown( $title, |
| 224 | + wfMsgHtml( 'hist' ), array(), 'action=history' ); |
| 225 | + $review = $this->skin->linkKnown( $title, |
222 | 226 | wfMsg( 'pendingchanges-diff' ), |
| 227 | + array(), |
223 | 228 | 'diff=cur&oldid='.intval($row->stable).'&diffonly=0' ); |
224 | 229 | # Show quality level if there are several |
225 | 230 | if ( FlaggedRevs::qualityVersions() ) { |
— | — | @@ -283,9 +288,11 @@ |
284 | 289 | * Query to list out outdated reviewed pages |
285 | 290 | */ |
286 | 291 | class PendingChangesPager extends AlphabeticPager { |
287 | | - public $mForm, $mConds; |
288 | | - private $category, $namespace; |
| 292 | + public $mForm; |
| 293 | + protected $category, $namespace; |
289 | 294 | |
| 295 | + const PAGE_LIMIT = 100; // Don't get too expensive |
| 296 | + |
290 | 297 | function __construct( $form, $namespace, $level = - 1, $category = '', |
291 | 298 | $size = null, $watched = false, $stable = false ) |
292 | 299 | { |
— | — | @@ -309,12 +316,17 @@ |
310 | 317 | $this->watched = (bool)$watched; |
311 | 318 | $this->stable = $stable && !FlaggedRevs::isStableShownByDefault() |
312 | 319 | && !FlaggedRevs::useOnlyIfProtected(); |
| 320 | + |
313 | 321 | parent::__construct(); |
314 | | - // Don't get too expensive |
| 322 | + # Don't get too expensive |
315 | 323 | $this->mLimitsShown = array( 20, 50, 100 ); |
316 | | - $this->mLimit = min( $this->mLimit, 100 ); |
| 324 | + $this->setLimit( $this->mLimit ); // apply max limit |
317 | 325 | } |
318 | 326 | |
| 327 | + function setLimit( $limit ) { |
| 328 | + $this->mLimit = min( $limit, self::PAGE_LIMIT ); |
| 329 | + } |
| 330 | + |
319 | 331 | function formatRow( $row ) { |
320 | 332 | return $this->mForm->formatRow( $row ); |
321 | 333 | } |
— | — | @@ -331,7 +343,6 @@ |
332 | 344 | |
333 | 345 | function getQueryInfo() { |
334 | 346 | global $wgUser; |
335 | | - $conds = $this->mConds; |
336 | 347 | $tables = array( 'page', 'revision' ); |
337 | 348 | $fields = array( 'page_namespace', 'page_title', 'page_len', 'rev_len', 'page_latest' ); |
338 | 349 | # Show outdated "stable" versions |
— | — | @@ -411,6 +422,14 @@ |
412 | 423 | } |
413 | 424 | |
414 | 425 | function getStartBody() { |
| 426 | + wfProfileIn( __METHOD__ ); |
| 427 | + # Do a link batch query |
| 428 | + $lb = new LinkBatch(); |
| 429 | + foreach ( $this->mResult as $row ) { |
| 430 | + $lb->add( $row->page_namespace, $row->page_title ); |
| 431 | + } |
| 432 | + $lb->execute(); |
| 433 | + wfProfileOut( __METHOD__ ); |
415 | 434 | return '<ul>'; |
416 | 435 | } |
417 | 436 | |
Index: trunk/extensions/FlaggedRevs/specialpages/UnreviewedPages_body.php |
— | — | @@ -6,99 +6,115 @@ |
7 | 7 | |
8 | 8 | class UnreviewedPages extends SpecialPage |
9 | 9 | { |
| 10 | + protected $pager = null; |
| 11 | + |
10 | 12 | public function __construct() { |
11 | 13 | parent::__construct( 'UnreviewedPages', 'unreviewedpages' ); |
12 | 14 | } |
13 | 15 | |
14 | 16 | public function execute( $par ) { |
15 | 17 | global $wgRequest, $wgUser, $wgOut; |
| 18 | + |
16 | 19 | $this->setHeaders(); |
17 | 20 | if ( !$wgUser->isAllowed( 'unreviewedpages' ) ) { |
18 | 21 | $wgOut->permissionRequired( 'unreviewedpages' ); |
19 | 22 | return; |
20 | 23 | } |
21 | 24 | $this->skin = $wgUser->getSkin(); |
22 | | - $this->showList( $wgRequest ); |
23 | | - } |
24 | 25 | |
25 | | - protected function showList( $wgRequest ) { |
26 | | - global $wgOut, $wgScript; |
| 26 | + # Get default namespace |
27 | 27 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
28 | 28 | $defaultNS = !$namespaces ? NS_MAIN : $namespaces[0]; |
29 | | - |
30 | | - $namespace = $wgRequest->getIntOrNull( 'namespace', $defaultNS ); |
| 29 | + |
| 30 | + $this->namespace = $wgRequest->getIntOrNull( 'namespace', $defaultNS ); |
31 | 31 | $category = trim( $wgRequest->getVal( 'category' ) ); |
32 | 32 | $catTitle = Title::makeTitleSafe( NS_CATEGORY, $category ); |
33 | | - $category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
34 | | - $level = $wgRequest->getInt( 'level' ); |
35 | | - $hideRedirs = $wgRequest->getBool( 'hideredirs', true ); |
36 | | - |
37 | | - // show/hide links |
| 33 | + $this->category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
| 34 | + $this->level = $wgRequest->getInt( 'level' ); |
| 35 | + $this->hideRedirs = $wgRequest->getBool( 'hideredirs', true ); |
| 36 | + $this->live = self::generalQueryOK(); |
| 37 | + |
| 38 | + $this->pager = new UnreviewedPagesPager( $this, $this->live, |
| 39 | + $this->namespace, !$this->hideRedirs, $this->category, $this->level ); |
| 40 | + |
| 41 | + $this->showForm(); |
| 42 | + $this->showPageList(); |
| 43 | + } |
| 44 | + |
| 45 | + protected function showForm() { |
| 46 | + global $wgOut, $wgLang, $wgScript; |
| 47 | + # Add explanatory text |
| 48 | + $wgOut->addWikiMsg( 'unreviewedpages-list', $this->pager->getNumRows() ); |
| 49 | + |
| 50 | + # show/hide links |
38 | 51 | $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); |
39 | | - $onoff = 1 - $hideRedirs; |
| 52 | + $onoff = 1 - $this->hideRedirs; |
40 | 53 | $link = $this->skin->link( $this->getTitle(), $showhide[$onoff], array(), |
41 | | - array( 'hideredirs' => $onoff, 'category' => $category, 'namespace' => $namespace ) |
| 54 | + array( 'hideredirs' => $onoff, 'category' => $this->category, |
| 55 | + 'namespace' => $this->namespace ) |
42 | 56 | ); |
43 | 57 | $showhideredirs = wfMsgHtml( 'whatlinkshere-hideredirs', $link ); |
44 | 58 | |
45 | | - # Add explanatory text |
46 | | - $wgOut->addWikiMsg( 'unreviewedpages-list' ); |
47 | 59 | # Add form... |
48 | | - $action = htmlspecialchars( $wgScript ); |
49 | | - $wgOut->addHTML( "<form action=\"$action\" method=\"get\">\n" . |
50 | | - '<fieldset><legend>' . wfMsg( 'unreviewedpages-legend' ) . '</legend>' . |
51 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . '<p>' ); |
| 60 | + $form = Html::openElement( 'form', array( 'name' => 'unreviewedpages', |
| 61 | + 'action' => $wgScript, 'method' => 'get' ) ) . "\n"; |
| 62 | + $form .= "<fieldset><legend>" . wfMsg( 'unreviewedpages-legend' ) . "</legend>\n"; |
| 63 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n"; |
52 | 64 | # Add dropdowns as needed |
53 | | - if ( count( $namespaces ) > 1 ) { |
54 | | - $wgOut->addHTML( FlaggedRevsXML::getNamespaceMenu( $namespace ) . ' ' ); |
| 65 | + if ( count( FlaggedRevs::getReviewNamespaces() ) > 1 ) { |
| 66 | + $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' '; |
55 | 67 | } |
56 | 68 | if ( FlaggedRevs::qualityVersions() ) { |
57 | | - $wgOut->addHTML( FlaggedRevsXML::getLevelMenu( $level, false, 1 ) . ' ' ); |
| 69 | + $form .= FlaggedRevsXML::getLevelMenu( $this->level, false, 1 ) . ' '; |
58 | 70 | } |
59 | | - $wgOut->addHTML( |
| 71 | + $form .= |
60 | 72 | "<span style='white-space: nowrap;'>" . |
61 | 73 | Xml::label( wfMsg( "unreviewedpages-category" ), 'category' ) . ' ' . |
62 | | - Xml::input( 'category', 30, $category, array( 'id' => 'category' ) ) . |
63 | | - '</span><br />' . |
64 | | - $showhideredirs . '  ' . |
65 | | - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" . |
66 | | - "</fieldset></form>" |
67 | | - ); |
68 | | - # This will start to get slower if live... |
69 | | - if ( !$live = self::generalQueryOK() ) { |
| 74 | + Xml::input( 'category', 30, $this->category, array( 'id' => 'category' ) ) . |
| 75 | + '</span><br />'; |
| 76 | + $form .= $showhideredirs . '  '; |
| 77 | + $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ); |
| 78 | + $form .= '</fieldset>'; |
| 79 | + $form .= Html::closeElement( 'form' ) . "\n"; |
| 80 | + |
| 81 | + # Query may get too slow to be live... |
| 82 | + if ( !$this->live ) { |
70 | 83 | $dbr = wfGetDB( DB_SLAVE ); |
71 | 84 | $ts = $dbr->selectField( 'querycache_info', 'qci_timestamp', |
72 | 85 | array( 'qci_type' => 'fr_unreviewedpages' ), __METHOD__ ); |
73 | 86 | if ( $ts ) { |
74 | | - global $wgLang; |
75 | 87 | $ts = wfTimestamp( TS_MW, $ts ); |
76 | 88 | $td = $wgLang->timeanddate( $ts ); |
77 | 89 | $d = $wgLang->date( $ts ); |
78 | 90 | $t = $wgLang->time( $ts ); |
79 | | - $wgOut->addHTML( wfMsg( 'perfcachedts', $td, $d, $t ) ); |
| 91 | + $form .= wfMsgExt( 'perfcachedts', 'parse', $td, $d, $t ); |
80 | 92 | } else { |
81 | | - $wgOut->addHTML( wfMsg( 'perfcached' ) ); |
| 93 | + $form .= wfMsgExt( 'perfcached', 'parse' ); |
82 | 94 | } |
83 | 95 | } |
84 | | - $pager = new UnreviewedPagesPager( |
85 | | - $this, $live, $namespace, !$hideRedirs, $category, $level ); |
86 | | - if ( $pager->getNumRows() ) { |
87 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
88 | | - $wgOut->addHTML( $pager->getBody() ); |
89 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 96 | + |
| 97 | + $wgOut->addHTML( $form ); |
| 98 | + } |
| 99 | + |
| 100 | + protected function showPageList() { |
| 101 | + global $wgOut; |
| 102 | + if ( $this->pager->getNumRows() ) { |
| 103 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 104 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 105 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
90 | 106 | } else { |
91 | 107 | $wgOut->addWikiMsg( 'unreviewedpages-none' ); |
92 | 108 | } |
93 | 109 | } |
94 | | - |
| 110 | + |
95 | 111 | public function formatRow( $row ) { |
96 | 112 | global $wgLang, $wgUser; |
| 113 | + $title = Title::newFromRow( $row ); |
97 | 114 | |
98 | 115 | $stxt = $underReview = $watching = ''; |
99 | | - $title = Title::newFromRow( $row ); |
100 | | - $link = $this->skin->makeKnownLinkObj( $title, null, 'redirect=no&reviewing=1' ); |
101 | | - $hist = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), |
102 | | - 'action=history&reviewing=1' ); |
| 116 | + $link = $this->skin->link( $title, null, array(), 'redirect=no&reviewing=1' ); |
| 117 | + $hist = $this->skin->linkKnown( $title, wfMsgHtml( 'hist' ), |
| 118 | + array(), 'action=history&reviewing=1' ); |
103 | 119 | if ( !is_null( $size = $row->page_len ) ) { |
104 | 120 | $stxt = ( $size == 0 ) |
105 | 121 | ? wfMsgHtml( 'historyempty' ) |
— | — | @@ -113,11 +129,13 @@ |
114 | 130 | // After three days, just use days |
115 | 131 | if ( $hours > ( 3 * 24 ) ) { |
116 | 132 | $days = round( $hours / 24, 0 ); |
117 | | - $age = ' ' . wfMsgExt( 'unreviewedpages-days', 'parsemag', $wgLang->formatNum( $days ) ); |
| 133 | + $age = ' ' . wfMsgExt( 'unreviewedpages-days', |
| 134 | + 'parsemag', $wgLang->formatNum( $days ) ); |
118 | 135 | // If one or more hours, use hours |
119 | 136 | } elseif ( $hours >= 1 ) { |
120 | 137 | $hours = round( $hours, 0 ); |
121 | | - $age = ' ' . wfMsgExt( 'unreviewedpages-hours', 'parsemag', $wgLang->formatNum( $hours ) ); |
| 138 | + $age = ' ' . wfMsgExt( 'unreviewedpages-hours', |
| 139 | + 'parsemag', $wgLang->formatNum( $hours ) ); |
122 | 140 | } else { |
123 | 141 | $age = ' ' . wfMsg( 'unreviewedpages-recent' ); // hot off the press :) |
124 | 142 | } |
— | — | @@ -180,9 +198,11 @@ |
181 | 199 | * Query to list out unreviewed pages |
182 | 200 | */ |
183 | 201 | class UnreviewedPagesPager extends AlphabeticPager { |
184 | | - public $mForm, $mConds; |
185 | | - private $live, $namespace, $category, $showredirs; |
| 202 | + public $mForm; |
| 203 | + protected $live, $namespace, $category, $showredirs; |
186 | 204 | |
| 205 | + const PAGE_LIMIT = 50; // Don't get too expensive |
| 206 | + |
187 | 207 | function __construct( |
188 | 208 | $form, $live, $namespace, $redirs = false, $category = null, $level = 0 |
189 | 209 | ) { |
— | — | @@ -204,9 +224,13 @@ |
205 | 225 | parent::__construct(); |
206 | 226 | // Don't get too expensive |
207 | 227 | $this->mLimitsShown = array( 20, 50 ); |
208 | | - $this->mLimit = min( $this->mLimit, 50 ); |
| 228 | + $this->setLimit( $this->mLimit ); // apply max limit |
209 | 229 | } |
210 | 230 | |
| 231 | + function setLimit( $limit ) { |
| 232 | + $this->mLimit = min( $limit, self::PAGE_LIMIT ); |
| 233 | + } |
| 234 | + |
211 | 235 | function formatRow( $row ) { |
212 | 236 | return $this->mForm->formatRow( $row ); |
213 | 237 | } |
— | — | @@ -215,7 +239,6 @@ |
216 | 240 | if ( !$this->live ) { |
217 | 241 | return $this->getQueryCacheInfo(); |
218 | 242 | } |
219 | | - $conds = $this->mConds; |
220 | 243 | $fields = array( 'page_namespace', 'page_title', 'page_len', 'page_id', |
221 | 244 | 'MIN(rev_timestamp) AS creation' ); |
222 | 245 | # Filter by level |
— | — | @@ -325,6 +348,14 @@ |
326 | 349 | } |
327 | 350 | |
328 | 351 | function getStartBody() { |
| 352 | + wfProfileIn( __METHOD__ ); |
| 353 | + # Do a link batch query |
| 354 | + $lb = new LinkBatch(); |
| 355 | + foreach ( $this->mResult as $row ) { |
| 356 | + $lb->add( $row->page_namespace, $row->page_title ); |
| 357 | + } |
| 358 | + $lb->execute(); |
| 359 | + wfProfileOut( __METHOD__ ); |
329 | 360 | return '<ul>'; |
330 | 361 | } |
331 | 362 | |
Index: trunk/extensions/FlaggedRevs/specialpages/ConfiguredPages_body.php |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | // Assumes $wgFlaggedRevsProtection is off |
9 | 9 | class ConfiguredPages extends SpecialPage |
10 | 10 | { |
| 11 | + protected $pager = null; |
| 12 | + |
11 | 13 | public function __construct() { |
12 | 14 | parent::__construct( 'ConfiguredPages' ); |
13 | 15 | } |
— | — | @@ -21,13 +23,18 @@ |
22 | 24 | $this->override = $wgRequest->getIntOrNull( 'stable' ); |
23 | 25 | $this->autoreview = $wgRequest->getVal( 'restriction', '' ); |
24 | 26 | |
| 27 | + $this->pager = new ConfiguredPagesPager( |
| 28 | + $this, array(), $this->namespace, $this->override, $this->autoreview ); |
| 29 | + |
25 | 30 | $this->showForm(); |
26 | 31 | $this->showPageList(); |
27 | 32 | } |
28 | 33 | |
29 | 34 | protected function showForm() { |
30 | 35 | global $wgOut, $wgScript; |
31 | | - $wgOut->addWikiMsg( 'configuredpages-list' ); |
| 36 | + # Explanatory text |
| 37 | + $wgOut->addWikiMsg( 'configuredpages-list', $this->pager->getNumRows() ); |
| 38 | + |
32 | 39 | $fields = array(); |
33 | 40 | # Namespace selector |
34 | 41 | if ( count( FlaggedRevs::getReviewNamespaces() ) > 1 ) { |
— | — | @@ -36,46 +43,47 @@ |
37 | 44 | # Default version selector |
38 | 45 | $fields[] = FlaggedRevsXML::getDefaultFilterMenu( $this->override ); |
39 | 46 | # Restriction level selector |
40 | | - if( FlaggedRevs::getRestrictionLevels() ) { |
| 47 | + if ( FlaggedRevs::getRestrictionLevels() ) { |
41 | 48 | $fields[] = FlaggedRevsXML::getRestrictionFilterMenu( $this->autoreview ); |
42 | 49 | } |
43 | | - if ( count( $fields ) ) { |
44 | | - $form = Xml::openElement( 'form', |
45 | | - array( 'name' => 'configuredpages', 'action' => $wgScript, 'method' => 'get' ) ); |
46 | | - $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
47 | | - $form .= "<fieldset><legend>" . wfMsg( 'configuredpages' ) . "</legend>\n"; |
48 | | - $form .= implode( ' ', $fields ) . '<br/>'; |
49 | | - $form .= Xml::submitButton( wfMsg( 'go' ) ); |
50 | | - $form .= "</fieldset>\n"; |
51 | | - $form .= Xml::closeElement( 'form' ); |
52 | | - $wgOut->addHTML( $form ); |
53 | | - } |
| 50 | + |
| 51 | + $form = Html::openElement( 'form', |
| 52 | + array( 'name' => 'configuredpages', 'action' => $wgScript, 'method' => 'get' ) ); |
| 53 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
| 54 | + $form .= "<fieldset><legend>" . wfMsg( 'configuredpages' ) . "</legend>\n"; |
| 55 | + $form .= implode( ' ', $fields ) . '<br/>'; |
| 56 | + $form .= Xml::submitButton( wfMsg( 'go' ) ); |
| 57 | + $form .= "</fieldset>\n"; |
| 58 | + $form .= Html::closeElement( 'form' ) . "\n"; |
| 59 | + |
| 60 | + $wgOut->addHTML( $form ); |
54 | 61 | } |
55 | 62 | |
56 | 63 | protected function showPageList() { |
57 | 64 | global $wgOut; |
58 | | - $pager = new ConfiguredPagesPager( $this, array(), |
59 | | - $this->namespace, $this->override, $this->autoreview ); |
60 | | - if ( $pager->getNumRows() ) { |
61 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
62 | | - $wgOut->addHTML( $pager->getBody() ); |
63 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 65 | + if ( $this->pager->getNumRows() ) { |
| 66 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 67 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 68 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
64 | 69 | } else { |
65 | 70 | $wgOut->addWikiMsg( 'configuredpages-none' ); |
66 | 71 | } |
67 | | - # Take this opportunity to purge out expired configurations |
68 | | - FlaggedPageConfig::purgeExpiredConfigurations(); |
| 72 | + # Purge expired entries on one in every 10 queries |
| 73 | + if ( !mt_rand( 0, 10 ) ) { |
| 74 | + FlaggedPageConfig::purgeExpiredConfigurations(); |
| 75 | + } |
69 | 76 | } |
70 | 77 | |
71 | 78 | public function formatRow( $row ) { |
72 | 79 | global $wgLang; |
73 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 80 | + $title = Title::newFromRow( $row ); |
74 | 81 | # Link to page |
75 | | - $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
| 82 | + $link = $this->skin->link( $title ); |
76 | 83 | # Link to page configuration |
77 | | - $config = $this->skin->makeKnownLinkObj( |
| 84 | + $config = $this->skin->linkKnown( |
78 | 85 | SpecialPage::getTitleFor( 'Stabilization' ), |
79 | 86 | wfMsgHtml( 'configuredpages-config' ), |
| 87 | + array(), |
80 | 88 | 'page=' . $title->getPrefixedUrl() |
81 | 89 | ); |
82 | 90 | # Show which version is the default (stable or draft) |
— | — | @@ -101,7 +109,8 @@ |
102 | 110 | } else { |
103 | 111 | $expiry_description = ""; |
104 | 112 | } |
105 | | - return "<li>{$link} ({$config}) <b>[$default]</b> {$restr}<i>{$expiry_description}</i></li>"; |
| 113 | + return "<li>{$link} ({$config}) <b>[$default]</b> " . |
| 114 | + "{$restr}<i>{$expiry_description}</i></li>"; |
106 | 115 | } |
107 | 116 | } |
108 | 117 | |
— | — | @@ -111,12 +120,12 @@ |
112 | 121 | class ConfiguredPagesPager extends AlphabeticPager { |
113 | 122 | public $mForm, $mConds, $namespace, $override, $autoreview; |
114 | 123 | |
115 | | - // @param int $namespace (null for "all") |
116 | | - // @param int $override (null for "either") |
117 | | - // @param string $autoreview ('' for "all", 'none' for no restriction) |
118 | | - function __construct( |
119 | | - $form, $conds = array(), $namespace, $override, $autoreview |
120 | | - ) { |
| 124 | + /* |
| 125 | + * @param int $namespace (null for "all") |
| 126 | + * @param int $override (null for "either") |
| 127 | + * @param string $autoreview ('' for "all", 'none' for no restriction) |
| 128 | + */ |
| 129 | + function __construct( $form, $conds = array(), $namespace, $override, $autoreview ) { |
121 | 130 | $this->mForm = $form; |
122 | 131 | $this->mConds = $conds; |
123 | 132 | # Must be content pages... |
— | — | @@ -171,7 +180,7 @@ |
172 | 181 | function getIndexField() { |
173 | 182 | return 'fpc_page_id'; |
174 | 183 | } |
175 | | - |
| 184 | + |
176 | 185 | function getStartBody() { |
177 | 186 | wfProfileIn( __METHOD__ ); |
178 | 187 | # Do a link batch query |
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php |
— | — | @@ -6,6 +6,8 @@ |
7 | 7 | |
8 | 8 | class ProblemChanges extends SpecialPage |
9 | 9 | { |
| 10 | + protected $pager = null; |
| 11 | + |
10 | 12 | public function __construct() { |
11 | 13 | parent::__construct( 'ProblemChanges' ); |
12 | 14 | $this->includable( true ); |
— | — | @@ -13,19 +15,34 @@ |
14 | 16 | |
15 | 17 | public function execute( $par ) { |
16 | 18 | global $wgRequest, $wgUser; |
| 19 | + |
17 | 20 | $this->setHeaders(); |
18 | 21 | $this->skin = $wgUser->getSkin(); |
19 | 22 | $this->level = $wgRequest->getInt( 'level', - 1 ); |
20 | 23 | $this->tag = trim( $wgRequest->getVal( 'tagfilter' ) ); |
21 | | - $this->category = trim( $wgRequest->getVal( 'category' ) ); |
22 | | - $catTitle = Title::newFromText( $this->category ); |
| 24 | + $category = trim( $wgRequest->getVal( 'category' ) ); |
| 25 | + $catTitle = Title::newFromText( $category ); |
23 | 26 | $this->category = is_null( $catTitle ) ? '' : $catTitle->getText(); |
24 | 27 | $feedType = $wgRequest->getVal( 'feed' ); |
25 | | - if ( $feedType ) { |
26 | | - return $this->feed( $feedType ); |
| 28 | + if ( $this->including() ) { |
| 29 | + $incLimit = $this->parseParams( $par ); // apply non-URL params |
27 | 30 | } |
28 | | - $this->setSyndicated(); |
29 | | - $this->showList( $par ); |
| 31 | + |
| 32 | + $this->pager = new ProblemChangesPager( |
| 33 | + $this, $this->level, $this->category, $this->tag ); |
| 34 | + |
| 35 | + # Output appropriate format... |
| 36 | + if ( $feedType != null ) { |
| 37 | + $this->feed( $feedType ); |
| 38 | + } else { |
| 39 | + if ( $this->including() ) { |
| 40 | + $this->pager->setLimit( $incLimit ); // apply non-URL limit |
| 41 | + } else { |
| 42 | + $this->setSyndicated(); |
| 43 | + $this->showForm(); |
| 44 | + } |
| 45 | + $this->showPageList(); |
| 46 | + } |
30 | 47 | } |
31 | 48 | |
32 | 49 | protected function setSyndicated() { |
— | — | @@ -39,60 +56,59 @@ |
40 | 57 | $wgOut->setFeedAppendQuery( wfArrayToCGI( $queryParams ) ); |
41 | 58 | } |
42 | 59 | |
43 | | - public function showList( $par ) { |
| 60 | + public function showForm() { |
44 | 61 | global $wgOut, $wgScript; |
45 | 62 | // Add explanatory text |
46 | | - $wgOut->addWikiMsg( 'problemchanges-list' ); |
47 | | - $limit = $this->parseParams( $par ); |
48 | | - $pager = new ProblemChangesPager( $this, $this->level, $this->category, $this->tag ); |
49 | | - // Apply limit if transcluded |
50 | | - $pager->mLimit = $limit ? $limit : $pager->mLimit; |
| 63 | + $wgOut->addWikiMsg( 'problemchanges-list', $this->pager->getNumRows() ); |
| 64 | + |
| 65 | + $form = Html::openElement( 'form', array( 'name' => 'problemchanges', |
| 66 | + 'action' => $wgScript, 'method' => 'get' ) ) . "\n"; |
| 67 | + $form .= "<fieldset><legend>" . wfMsg( 'problemchanges-legend' ) . "</legend>\n"; |
| 68 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n"; |
| 69 | + $form .= |
| 70 | + ( FlaggedRevs::qualityVersions() |
| 71 | + ? "<span style='white-space: nowrap;'>" . |
| 72 | + FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) . |
| 73 | + '</span> ' |
| 74 | + : "" |
| 75 | + ); |
| 76 | + $tagForm = ChangeTags::buildTagFilterSelector( $this->tag ); |
| 77 | + if ( count( $tagForm ) ) { |
| 78 | + $form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $tagForm[0] ); |
| 79 | + $form .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $tagForm[1] ); |
| 80 | + } |
| 81 | + $form .= '<br />' . |
| 82 | + Xml::label( wfMsg( "problemchanges-category" ), 'wpCategory' ) . ' ' . |
| 83 | + Xml::input( 'category', 30, $this->category, array( 'id' => 'wpCategory' ) ) . ' '; |
| 84 | + $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n"; |
| 85 | + $form .= '</fieldset>'; |
| 86 | + $form .= Html::closeElement( 'form' ) . "\n"; |
| 87 | + |
| 88 | + $wgOut->addHTML( $form ); |
| 89 | + } |
| 90 | + |
| 91 | + public function showPageList() { |
| 92 | + global $wgOut; |
51 | 93 | // Viewing the page normally... |
52 | 94 | if ( !$this->including() ) { |
53 | | - $action = htmlspecialchars( $wgScript ); |
54 | | - $tagForm = ChangeTags::buildTagFilterSelector( $this->tag ); |
55 | | - $wgOut->addHTML( |
56 | | - "<form action=\"$action\" method=\"get\">\n" . |
57 | | - '<fieldset><legend>' . wfMsg( 'problemchanges-legend' ) . '</legend>' . |
58 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) |
59 | | - ); |
60 | | - $form = |
61 | | - ( FlaggedRevs::qualityVersions() |
62 | | - ? "<span style='white-space: nowrap;'>" . |
63 | | - FlaggedRevsXML::getLevelMenu( $this->level, 'revreview-filter-stable' ) . |
64 | | - '</span> ' |
65 | | - : "" |
66 | | - ); |
67 | | - if ( count( $tagForm ) ) { |
68 | | - $form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $tagForm[0] ); |
69 | | - $form .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $tagForm[1] ); |
70 | | - } |
71 | | - $form .= '<br />' . |
72 | | - Xml::label( wfMsg( "problemchanges-category" ), 'wpCategory' ) . ' ' . |
73 | | - Xml::input( 'category', 30, $this->category, |
74 | | - array( 'id' => 'wpCategory' ) ) . ' '; |
75 | | - $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
76 | | - "</fieldset></form>"; |
77 | | - # Add filter options |
78 | | - $wgOut->addHTML( $form ); |
79 | | - # Add list output |
80 | | - if ( $pager->getNumRows() ) { |
81 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
82 | | - $wgOut->addHTML( $pager->getBody() ); |
83 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 95 | + if ( $this->pager->getNumRows() ) { |
| 96 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 97 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 98 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
84 | 99 | } else { |
85 | 100 | $wgOut->addWikiMsg( 'problemchanges-none' ); |
86 | 101 | } |
87 | 102 | // If this page is transcluded... |
88 | 103 | } else { |
89 | | - if ( $pager->getNumRows() ) { |
90 | | - $wgOut->addHTML( $pager->getBody() ); |
| 104 | + if ( $this->pager->getNumRows() ) { |
| 105 | + $wgOut->addHTML( $this->pager->getBody() ); |
91 | 106 | } else { |
92 | 107 | $wgOut->addWikiMsg( 'problemchanges-none' ); |
93 | 108 | } |
94 | 109 | } |
95 | 110 | } |
96 | | - |
| 111 | + |
| 112 | + // set pager parameters from $par, return pager limit |
97 | 113 | protected function parseParams( $par ) { |
98 | 114 | $bits = preg_split( '/\s*,\s*/', trim( $par ) ); |
99 | 115 | $limit = false; |
— | — | @@ -115,30 +131,25 @@ |
116 | 132 | * @param string $type |
117 | 133 | */ |
118 | 134 | protected function feed( $type ) { |
119 | | - global $wgFeed, $wgFeedClasses, $wgRequest; |
| 135 | + global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut; |
120 | 136 | if ( !$wgFeed ) { |
121 | | - global $wgOut; |
122 | 137 | $wgOut->addWikiMsg( 'feed-unavailable' ); |
123 | 138 | return; |
124 | 139 | } |
125 | 140 | if ( !isset( $wgFeedClasses[$type] ) ) { |
126 | | - global $wgOut; |
127 | 141 | $wgOut->addWikiMsg( 'feed-invalid' ); |
128 | 142 | return; |
129 | 143 | } |
130 | 144 | $feed = new $wgFeedClasses[$type]( |
131 | 145 | $this->feedTitle(), |
132 | 146 | wfMsg( 'tagline' ), |
133 | | - $this->getTitle()->getFullUrl() ); |
| 147 | + $this->getTitle()->getFullUrl() |
| 148 | + ); |
| 149 | + $this->pager->mLimit = min( $wgFeedLimit, $this->pager->mLimit ); |
134 | 150 | |
135 | | - $pager = new ProblemChangesPager( $this, $this->category ); |
136 | | - $limit = $wgRequest->getInt( 'limit', 50 ); |
137 | | - global $wgFeedLimit; |
138 | | - $pager->mLimit = min( $wgFeedLimit, $limit ); |
139 | | - |
140 | 151 | $feed->outHeader(); |
141 | | - if ( $pager->getNumRows() > 0 ) { |
142 | | - foreach ( $pager->mResult as $row ) { |
| 152 | + if ( $this->pager->getNumRows() > 0 ) { |
| 153 | + foreach ( $this->pager->mResult as $row ) { |
143 | 154 | $feed->outItem( $this->feedItem( $row ) ); |
144 | 155 | } |
145 | 156 | } |
— | — | @@ -177,9 +188,10 @@ |
178 | 189 | $css = $quality = $tags = $underReview = ''; |
179 | 190 | |
180 | 191 | $title = Title::newFromRow( $row ); |
181 | | - $link = $this->skin->makeKnownLinkObj( $title ); |
182 | | - $review = $this->skin->makeKnownLinkObj( $title, |
| 192 | + $link = $this->skin->link( $title ); |
| 193 | + $review = $this->skin->knownLink( $title, |
183 | 194 | wfMsg( 'pendingchanges-diff' ), |
| 195 | + array(), |
184 | 196 | 'diff=cur&oldid=' . intval($row->stable) . '&diffonly=0' ); |
185 | 197 | # Show quality level if there are several |
186 | 198 | if ( FlaggedRevs::qualityVersions() ) { |
— | — | @@ -272,9 +284,11 @@ |
273 | 285 | * Query to list out outdated reviewed pages |
274 | 286 | */ |
275 | 287 | class ProblemChangesPager extends AlphabeticPager { |
276 | | - public $mForm, $mConds; |
277 | | - private $category, $namespace, $tag; |
| 288 | + public $mForm; |
| 289 | + protected $category, $namespace, $tag; |
278 | 290 | |
| 291 | + const PAGE_LIMIT = 100; // Don't get too expensive |
| 292 | + |
279 | 293 | function __construct( $form, $level = - 1, $category = '', $tag = '' ) |
280 | 294 | { |
281 | 295 | $this->mForm = $form; |
— | — | @@ -287,9 +301,13 @@ |
288 | 302 | parent::__construct(); |
289 | 303 | // Don't get to expensive |
290 | 304 | $this->mLimitsShown = array( 20, 50, 100 ); |
291 | | - $this->mLimit = min( $this->mLimit, 100 ); |
| 305 | + $this->setLimit( $this->mLimit ); // apply max limit |
292 | 306 | } |
293 | 307 | |
| 308 | + function setLimit( $limit ) { |
| 309 | + $this->mLimit = min( $limit, self::PAGE_LIMIT ); |
| 310 | + } |
| 311 | + |
294 | 312 | function formatRow( $row ) { |
295 | 313 | return $this->mForm->formatRow( $row ); |
296 | 314 | } |
— | — | @@ -300,7 +318,6 @@ |
301 | 319 | |
302 | 320 | function getQueryInfo() { |
303 | 321 | global $wgOldChangeTagsIndex; |
304 | | - $conds = $this->mConds; |
305 | 322 | $tables = array( 'revision', 'change_tag', 'page' ); |
306 | 323 | $fields = array( 'page_namespace' , 'page_title', 'page_latest' ); |
307 | 324 | $ctIndex = $wgOldChangeTagsIndex ? |
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php |
— | — | @@ -6,6 +6,8 @@ |
7 | 7 | |
8 | 8 | class ReviewedPages extends SpecialPage |
9 | 9 | { |
| 10 | + protected $pager = null; |
| 11 | + |
10 | 12 | public function __construct() { |
11 | 13 | parent::__construct( 'ReviewedPages' ); |
12 | 14 | } |
— | — | @@ -18,11 +20,15 @@ |
19 | 21 | |
20 | 22 | # Check if there is a featured level |
21 | 23 | $maxType = FlaggedRevs::pristineVersions() ? 2 : 1; |
| 24 | + |
22 | 25 | $this->namespace = $wgRequest->getInt( 'namespace' ); |
23 | 26 | $this->type = $wgRequest->getInt( 'level', - 1 ); |
24 | 27 | $this->type = min( $this->type, $maxType ); |
25 | 28 | $this->hideRedirs = $wgRequest->getBool( 'hideredirs', true ); |
26 | | - |
| 29 | + |
| 30 | + $this->pager = new ReviewedPagesPager( |
| 31 | + $this, array(), $this->type, $this->namespace, $this->hideRedirs ); |
| 32 | + |
27 | 33 | $this->showForm(); |
28 | 34 | $this->showPageList(); |
29 | 35 | } |
— | — | @@ -32,9 +38,9 @@ |
33 | 39 | |
34 | 40 | // Text to explain level select (if there are several levels) |
35 | 41 | if ( FlaggedRevs::qualityVersions() ) { |
36 | | - $wgOut->addWikiMsg( 'reviewedpages-list' ); |
| 42 | + $wgOut->addWikiMsg( 'reviewedpages-list', $this->pager->getNumRows() ); |
37 | 43 | } |
38 | | - $form = Xml::openElement( 'form', |
| 44 | + $form = Html::openElement( 'form', |
39 | 45 | array( 'name' => 'reviewedpages', 'action' => $wgScript, 'method' => 'get' ) ); |
40 | 46 | $form .= "<fieldset><legend>" . wfMsgHtml( 'reviewedpages-leg' ) . "</legend>\n"; |
41 | 47 | |
— | — | @@ -60,22 +66,20 @@ |
61 | 67 | if ( count( $fields ) ) { |
62 | 68 | $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
63 | 69 | } |
64 | | - $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
65 | | - $form .= "</fieldset></form>\n"; |
| 70 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n"; |
| 71 | + $form .= "</fieldset>"; |
| 72 | + $form .= Html::closeElement( 'form ' ) . "\n"; |
66 | 73 | |
67 | 74 | $wgOut->addHTML( $form ); |
68 | 75 | } |
69 | 76 | |
70 | 77 | protected function showPageList() { |
71 | 78 | global $wgOut; |
72 | | - |
73 | | - $pager = new ReviewedPagesPager( $this, array(), $this->type, |
74 | | - $this->namespace, $this->hideRedirs ); |
75 | | - $num = $pager->getNumRows(); |
| 79 | + $num = $this->pager->getNumRows(); |
76 | 80 | if ( $num ) { |
77 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
78 | | - $wgOut->addHTML( $pager->getBody() ); |
79 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 81 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 82 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 83 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
80 | 84 | } else { |
81 | 85 | $wgOut->addHTML( wfMsgExt( 'reviewedpages-none', array( 'parse' ) ) ); |
82 | 86 | } |
— | — | @@ -83,30 +87,34 @@ |
84 | 88 | |
85 | 89 | public function formatRow( $row ) { |
86 | 90 | global $wgLang; |
87 | | - |
88 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
89 | | - $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
90 | | - |
| 91 | + $title = Title::newFromRow( $row ); |
| 92 | + # Link to page |
| 93 | + $link = $this->skin->link( $title ); |
| 94 | + # Size (bytes) |
91 | 95 | $stxt = ''; |
92 | 96 | if ( !is_null( $size = $row->page_len ) ) { |
93 | | - if ( $size == 0 ) |
| 97 | + if ( $size == 0 ) { |
94 | 98 | $stxt = ' <small>' . wfMsgHtml( 'historyempty' ) . '</small>'; |
95 | | - else |
96 | | - $stxt = ' <small>' . wfMsgExt( 'historysize', 'parsemag', |
97 | | - $wgLang->formatNum( $size ) ) . '</small>'; |
| 99 | + } else { |
| 100 | + $stxt = ' <small>' . |
| 101 | + wfMsgExt( 'historysize', 'parsemag', $wgLang->formatNum( $size ) ) . |
| 102 | + '</small>'; |
| 103 | + } |
98 | 104 | } |
99 | | - |
100 | | - $list = $this->skin->makeKnownLinkObj( |
| 105 | + # Link to list of reviewed versions for page |
| 106 | + $list = $this->skin->linkKnown( |
101 | 107 | SpecialPage::getTitleFor( 'ReviewedVersions' ), |
102 | 108 | wfMsgHtml( 'reviewedpages-all' ), |
| 109 | + array(), |
103 | 110 | 'page=' . $title->getPrefixedUrl() |
104 | 111 | ); |
105 | | - |
| 112 | + # Link to highest tier rev |
106 | 113 | $best = ''; |
107 | 114 | if ( FlaggedRevs::qualityVersions() ) { |
108 | | - $best = $this->skin->makeKnownLinkObj( |
| 115 | + $best = $this->skin->linkKnown( |
109 | 116 | $title, |
110 | 117 | wfMsgHtml( 'reviewedpages-best' ), |
| 118 | + array(), |
111 | 119 | 'stableid=best' |
112 | 120 | ); |
113 | 121 | $best = " [$best]"; |
Index: trunk/extensions/FlaggedRevs/specialpages/StablePages_body.php |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | // Assumes $wgFlaggedRevsProtection is on |
9 | 9 | class StablePages extends SpecialPage |
10 | 10 | { |
| 11 | + protected $pager = null; |
| 12 | + |
11 | 13 | public function __construct() { |
12 | 14 | parent::__construct( 'StablePages' ); |
13 | 15 | } |
— | — | @@ -21,51 +23,53 @@ |
22 | 24 | $this->autoreview = $wgRequest->getVal( 'restriction', '' ); |
23 | 25 | $this->indef = $wgRequest->getBool( 'indef', false ); |
24 | 26 | |
| 27 | + $this->pager = new StablePagesPager( $this, array(), |
| 28 | + $this->namespace, $this->autoreview, $this->indef ); |
| 29 | + |
25 | 30 | $this->showForm(); |
26 | 31 | $this->showPageList(); |
27 | 32 | } |
28 | 33 | |
29 | 34 | protected function showForm() { |
30 | 35 | global $wgOut, $wgScript; |
31 | | - $wgOut->addWikiMsg( 'stablepages-list' ); |
| 36 | + $wgOut->addWikiMsg( 'stablepages-list', $this->pager->getNumRows() ); |
32 | 37 | $fields = array(); |
33 | 38 | # Namespace selector |
34 | 39 | if ( count( FlaggedRevs::getReviewNamespaces() ) > 1 ) { |
35 | 40 | $fields[] = FlaggedRevsXML::getNamespaceMenu( $this->namespace, '' ); |
36 | 41 | } |
37 | 42 | # Restriction level selector |
38 | | - if( FlaggedRevs::getRestrictionLevels() ) { |
| 43 | + if ( FlaggedRevs::getRestrictionLevels() ) { |
39 | 44 | $fields[] = FlaggedRevsXML::getRestrictionFilterMenu( $this->autoreview ); |
40 | 45 | } |
41 | 46 | $fields[] = Xml::checkLabel( wfMsg( 'stablepages-indef' ), 'indef', |
42 | 47 | 'stablepages-indef', $this->indef ); |
43 | | - # Use form if it has options |
44 | | - if ( count( $fields ) ) { |
45 | | - $form = Xml::openElement( 'form', |
46 | | - array( 'name' => 'stablepages', 'action' => $wgScript, 'method' => 'get' ) ); |
47 | | - $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
48 | | - $form .= "<fieldset><legend>" . wfMsg( 'stablepages' ) . "</legend>\n"; |
49 | | - $form .= implode( ' ', $fields ) . ' '; |
50 | | - $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
51 | | - $form .= "</fieldset>\n"; |
52 | | - $form .= Xml::closeElement( 'form' ); |
53 | | - $wgOut->addHTML( $form ); |
54 | | - } |
| 48 | + |
| 49 | + $form = Html::openElement( 'form', |
| 50 | + array( 'name' => 'stablepages', 'action' => $wgScript, 'method' => 'get' ) ); |
| 51 | + $form .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
| 52 | + $form .= "<fieldset><legend>" . wfMsg( 'stablepages' ) . "</legend>\n"; |
| 53 | + $form .= implode( ' ', $fields ) . ' '; |
| 54 | + $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
| 55 | + $form .= "</fieldset>\n"; |
| 56 | + $form .= Html::closeElement( 'form' ) . "\n"; |
| 57 | + |
| 58 | + $wgOut->addHTML( $form ); |
55 | 59 | } |
56 | 60 | |
57 | 61 | protected function showPageList() { |
58 | 62 | global $wgOut; |
59 | | - $pager = new StablePagesPager( |
60 | | - $this, array(), $this->namespace, $this->autoreview, $this->indef ); |
61 | | - if ( $pager->getNumRows() ) { |
62 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
63 | | - $wgOut->addHTML( $pager->getBody() ); |
64 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
| 63 | + if ( $this->pager->getNumRows() ) { |
| 64 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
| 65 | + $wgOut->addHTML( $this->pager->getBody() ); |
| 66 | + $wgOut->addHTML( $this->pager->getNavigationBar() ); |
65 | 67 | } else { |
66 | 68 | $wgOut->addWikiMsg( 'stablepages-none' ); |
67 | 69 | } |
68 | | - # Take this opportunity to purge out expired configurations |
69 | | - FlaggedPageConfig::purgeExpiredConfigurations(); |
| 70 | + # Purge expired entries on one in every 10 queries |
| 71 | + if ( !mt_rand( 0, 10 ) ) { |
| 72 | + FlaggedPageConfig::purgeExpiredConfigurations(); |
| 73 | + } |
70 | 74 | } |
71 | 75 | |
72 | 76 | public function formatRow( $row ) { |