Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -277,70 +277,73 @@ |
278 | 278 | $specialActionDir = $dir . 'specialpages/actions/'; |
279 | 279 | # Load revision review UI |
280 | 280 | $wgAutoloadClasses['RevisionReview'] = $specialActionDir . 'RevisionReview_body.php'; |
| 281 | +// @TODO: move review action related messages to separate file? |
281 | 282 | # Stable version config UI |
282 | 283 | $wgAutoloadClasses['Stabilization'] = $specialActionDir . 'Stabilization_body.php'; |
283 | 284 | $wgExtensionMessagesFiles['Stabilization'] = $langDir . 'Stabilization.i18n.php'; |
284 | 285 | |
285 | 286 | $specialReportDir = $dir . 'specialpages/reports/'; |
286 | | -# Load reviewed versions UI |
| 287 | +# Reviewed versions list |
287 | 288 | $wgAutoloadClasses['ReviewedVersions'] = $specialReportDir . 'ReviewedVersions_body.php'; |
288 | 289 | $wgExtensionMessagesFiles['ReviewedVersions'] = $langDir . 'ReviewedVersions.i18n.php'; |
289 | | -# Load unreviewed pages list |
| 290 | +# Unreviewed pages list |
290 | 291 | $wgAutoloadClasses['UnreviewedPages'] = $specialReportDir . 'UnreviewedPages_body.php'; |
291 | 292 | $wgExtensionMessagesFiles['UnreviewedPages'] = $langDir . 'UnreviewedPages.i18n.php'; |
292 | 293 | $wgSpecialPageGroups['UnreviewedPages'] = 'quality'; |
293 | | -# Load "in need of re-review" pages list |
| 294 | +# Pages with pending changes list |
294 | 295 | $wgAutoloadClasses['PendingChanges'] = $specialReportDir . 'PendingChanges_body.php'; |
295 | 296 | $wgExtensionMessagesFiles['PendingChanges'] = $langDir . 'PendingChanges.i18n.php'; |
296 | 297 | $wgSpecialPageGroups['PendingChanges'] = 'quality'; |
297 | | -# Load "suspicious changes" pages list |
| 298 | +# Pages with tagged pending changes list |
298 | 299 | $wgAutoloadClasses['ProblemChanges'] = $specialReportDir . 'ProblemChanges_body.php'; |
299 | 300 | $wgExtensionMessagesFiles['ProblemChanges'] = $langDir . 'ProblemChanges.i18n.php'; |
300 | 301 | $wgSpecialPageGroups['ProblemChanges'] = 'quality'; |
301 | | -# Load reviewed pages list |
| 302 | +# Reviewed pages list |
302 | 303 | $wgAutoloadClasses['ReviewedPages'] = $specialReportDir . 'ReviewedPages_body.php'; |
303 | 304 | $wgExtensionMessagesFiles['ReviewedPages'] = $langDir . 'ReviewedPages.i18n.php'; |
304 | 305 | $wgSpecialPageGroups['ReviewedPages'] = 'quality'; |
305 | | -# Load stable pages list (for protection config) |
| 306 | +# Stable pages list (for protection config) |
306 | 307 | $wgAutoloadClasses['StablePages'] = $specialReportDir . 'StablePages_body.php'; |
307 | 308 | $wgExtensionMessagesFiles['StablePages'] = $langDir . 'StablePages.i18n.php'; |
308 | 309 | $wgSpecialPageGroups['StablePages'] = 'quality'; |
309 | | -# Load configured pages list (non-protection config) |
| 310 | +# Configured pages list (non-protection config) |
310 | 311 | $wgAutoloadClasses['ConfiguredPages'] = $specialReportDir . 'ConfiguredPages_body.php'; |
311 | 312 | $wgExtensionMessagesFiles['ConfiguredPages'] = $langDir . 'ConfiguredPages.i18n.php'; |
312 | 313 | $wgSpecialPageGroups['ConfiguredPages'] = 'quality'; |
313 | | -# To oversee quality revisions |
| 314 | +# Filterable review log page to oversee reviews |
314 | 315 | $wgAutoloadClasses['QualityOversight'] = $specialReportDir . 'QualityOversight_body.php'; |
315 | 316 | $wgExtensionMessagesFiles['QualityOversight'] = $langDir . 'QualityOversight.i18n.php'; |
316 | 317 | $wgSpecialPageGroups['QualityOversight'] = 'quality'; |
317 | | -# Statistics |
| 318 | +# Review statistics |
318 | 319 | $wgAutoloadClasses['ValidationStatistics'] = $specialReportDir . 'ValidationStatistics_body.php'; |
319 | 320 | $wgExtensionMessagesFiles['ValidationStatistics'] = $langDir . 'ValidationStatistics.i18n.php'; |
320 | 321 | $wgSpecialPageGroups['ValidationStatistics'] = 'quality'; |
321 | 322 | |
322 | | -# API Modules |
| 323 | +$apiActionDir = $dir . 'api/actions/'; |
| 324 | +# Page review module for API |
| 325 | +$wgAutoloadClasses['ApiReview'] = $apiActionDir . 'ApiReview.php'; |
| 326 | +$wgAPIModules['review'] = 'ApiReview'; |
| 327 | +# Stability config module for API |
| 328 | +$wgAutoloadClasses['ApiStabilize'] = $apiActionDir . 'ApiStabilize.php'; |
| 329 | +$wgAutoloadClasses['ApiStabilizeGeneral'] = $apiActionDir . 'ApiStabilize.php'; |
| 330 | +$wgAutoloadClasses['ApiStabilizeProtect'] = $apiActionDir . 'ApiStabilize.php'; |
| 331 | + |
| 332 | +$apiReportDir = $dir . 'api/reports/'; |
323 | 333 | # OldReviewedPages for API |
324 | | -$wgAutoloadClasses['ApiQueryOldreviewedpages'] = $dir . 'api/ApiQueryOldreviewedpages.php'; |
| 334 | +$wgAutoloadClasses['ApiQueryOldreviewedpages'] = $apiReportDir . 'ApiQueryOldreviewedpages.php'; |
325 | 335 | $wgAPIListModules['oldreviewedpages'] = 'ApiQueryOldreviewedpages'; |
326 | 336 | # UnreviewedPages for API |
327 | | -$wgAutoloadClasses['ApiQueryUnreviewedpages'] = $dir . 'api/ApiQueryUnreviewedpages.php'; |
| 337 | +$wgAutoloadClasses['ApiQueryUnreviewedpages'] = $apiReportDir . 'ApiQueryUnreviewedpages.php'; |
328 | 338 | # ReviewedPages for API |
329 | | -$wgAutoloadClasses['ApiQueryReviewedpages'] = $dir . 'api/ApiQueryReviewedpages.php'; |
| 339 | +$wgAutoloadClasses['ApiQueryReviewedpages'] = $apiReportDir . 'ApiQueryReviewedpages.php'; |
330 | 340 | # ConfiguredPages for API |
331 | | -$wgAutoloadClasses['ApiQueryConfiguredpages'] = $dir . 'api/ApiQueryConfiguredpages.php'; |
| 341 | +$wgAutoloadClasses['ApiQueryConfiguredpages'] = $apiReportDir . 'ApiQueryConfiguredpages.php'; |
332 | 342 | # Flag metadata for pages for API |
333 | | -$wgAutoloadClasses['ApiQueryFlagged'] = $dir . 'api/ApiQueryFlagged.php'; |
| 343 | +$wgAutoloadClasses['ApiQueryFlagged'] = $apiReportDir . 'ApiQueryFlagged.php'; |
334 | 344 | $wgAPIPropModules['flagged'] = 'ApiQueryFlagged'; |
335 | 345 | # Site flag config for API |
336 | | -$wgAutoloadClasses['ApiFlagConfig'] = $dir . 'api/ApiFlagConfig.php'; |
| 346 | +$wgAutoloadClasses['ApiFlagConfig'] = $apiReportDir . 'ApiFlagConfig.php'; |
337 | 347 | $wgAPIModules['flagconfig'] = 'ApiFlagConfig'; |
338 | | -# Page review module for API |
339 | | -$wgAutoloadClasses['ApiReview'] = $dir . 'api/ApiReview.php'; |
340 | | -$wgAPIModules['review'] = 'ApiReview'; |
341 | | -# Stability config module for API |
342 | | -$wgAutoloadClasses['ApiStabilize'] = $dir . 'api/ApiStabilize.php'; |
343 | | -$wgAutoloadClasses['ApiStabilizeGeneral'] = $dir . 'api/ApiStabilize.php'; |
344 | | -$wgAutoloadClasses['ApiStabilizeProtect'] = $dir . 'api/ApiStabilize.php'; |
345 | 348 | |
346 | 349 | # Special case cache invalidations |
347 | 350 | $wgJobClasses['flaggedrevs_CacheUpdate'] = 'FRExtraCacheUpdateJob'; |
Index: trunk/extensions/FlaggedRevs/api/ApiFlagConfig.php |
— | — | @@ -1,86 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on November 6, 2009 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * API module to get flag config info |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiFlagConfig extends ApiBase { |
31 | | - |
32 | | - public function execute() { |
33 | | - $this->getMain()->setCacheMode( 'public' ); |
34 | | - $minQLTags = FlaggedRevs::quickTags( FR_QUALITY ); |
35 | | - $minPLTags = FlaggedRevs::quickTags( FR_PRISTINE ); |
36 | | - $data = array(); |
37 | | - foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) { |
38 | | - $data[] = array( |
39 | | - 'name' => $tag, |
40 | | - 'levels' => count( $levels ) - 1, // exclude '0' level |
41 | | - 'tier1' => 1, |
42 | | - 'tier2' => $minQLTags[$tag], |
43 | | - 'tier3' => $minPLTags[$tag] |
44 | | - ); |
45 | | - } |
46 | | - $result = $this->getResult(); |
47 | | - $result->setIndexedTagName( $data, 'tag' ); |
48 | | - $result->addValue( null, $this->getModuleName(), $data ); |
49 | | - } |
50 | | - |
51 | | - public function mustBePosted() { |
52 | | - return false; |
53 | | - } |
54 | | - |
55 | | - public function isWriteMode() { |
56 | | - return false; |
57 | | - } |
58 | | - |
59 | | - public function getAllowedParams() { |
60 | | - return array(); |
61 | | - } |
62 | | - |
63 | | - public function getParamDescription() { |
64 | | - return array(); |
65 | | - } |
66 | | - |
67 | | - public function getDescription() { |
68 | | - return array( |
69 | | - 'Get basic information about review flag configuration for this site.', |
70 | | - 'The following parameters are returned for each tag:', |
71 | | - '* name : The key name of this tag', |
72 | | - '* levels : Number of levels the tag has (above "not tagged")', |
73 | | - '* tier2 : Level the tag must reach for a revision to be tier 2 (quality)', |
74 | | - '* tier3 : Level the tag must reach for a revision to be tier 3 (pristine)', |
75 | | - 'Flagged revisions have an assigned level for each tag. The highest tier', |
76 | | - 'that all the tags meet is the review tier of the entire revision.' |
77 | | - ); |
78 | | - } |
79 | | - |
80 | | - protected function getExamples() { |
81 | | - return 'api.php?action=flagconfig'; |
82 | | - } |
83 | | - |
84 | | - public function getVersion() { |
85 | | - return __CLASS__ . ': $Id$'; |
86 | | - } |
87 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryFlagged.php |
— | — | @@ -1,89 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on Sep 17, 2008 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * Query module to get flagging information about pages via 'prop=flagged' |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiQueryFlagged extends ApiQueryBase { |
31 | | - |
32 | | - public function execute() { |
33 | | - $pageSet = $this->getPageSet(); |
34 | | - $pageids = array_keys( $pageSet->getGoodTitles() ); |
35 | | - if ( !$pageids ) { |
36 | | - return true; |
37 | | - } |
38 | | - |
39 | | - // Construct SQL Query |
40 | | - $this->addTables( 'flaggedpages' ); |
41 | | - $this->addFields( array( |
42 | | - 'fp_page_id', 'fp_stable', 'fp_quality', 'fp_pending_since' |
43 | | - ) ); |
44 | | - $this->addWhereFld( 'fp_page_id', $pageids ); |
45 | | - $res = $this->select( __METHOD__ ); |
46 | | - |
47 | | - $result = $this->getResult(); |
48 | | - foreach( $res as $row ) { |
49 | | - $data = array( |
50 | | - 'stable_revid' => intval( $row->fp_stable ), |
51 | | - 'level' => intval( $row->fp_quality ), |
52 | | - 'level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
53 | | - ); |
54 | | - if ( $row->fp_pending_since ) { |
55 | | - $data['pending_since'] = wfTimestamp( TS_ISO_8601, $row->fp_pending_since ); |
56 | | - } |
57 | | - $result->addValue( array( 'query', 'pages', $row->fp_page_id ), 'flagged', $data ); |
58 | | - } |
59 | | - } |
60 | | - |
61 | | - public function getCacheMode( $params ) { |
62 | | - return 'public'; |
63 | | - } |
64 | | - |
65 | | - public function getAllowedParams() { |
66 | | - return array(); |
67 | | - } |
68 | | - |
69 | | - public function getDescription() { |
70 | | - return array( |
71 | | - 'Get information about the flagging status of the given pages.', |
72 | | - 'If a page is flagged, the following parameters are returned:', |
73 | | - '* stable_revid : The revision id of the latest stable revision', |
74 | | - '* level, level_text : The highest flagging level of the page', |
75 | | - '* pending_since : If there are any current unreviewed revisions' |
76 | | - . ' for that page, holds the timestamp of the first of them' |
77 | | - ); |
78 | | - } |
79 | | - |
80 | | - protected function getExamples() { |
81 | | - return array ( |
82 | | - 'api.php?action=query&prop=info|flagged&titles=Main%20Page', |
83 | | - 'api.php?action=query&generator=allpages&gapfrom=K&prop=flagged' |
84 | | - ); |
85 | | - } |
86 | | - |
87 | | - public function getVersion() { |
88 | | - return __CLASS__ . ': $Id$'; |
89 | | - } |
90 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryOldreviewedpages.php |
— | — | @@ -1,247 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on Sep 17, 2008 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * Query module to list pages with outdated review flag. |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiQueryOldreviewedpages extends ApiQueryGeneratorBase { |
31 | | - |
32 | | - public function __construct( $query, $moduleName ) { |
33 | | - parent::__construct( $query, $moduleName, 'or' ); |
34 | | - } |
35 | | - |
36 | | - public function execute() { |
37 | | - $this->run(); |
38 | | - } |
39 | | - |
40 | | - public function executeGenerator( $resultPageSet ) { |
41 | | - $this->run( $resultPageSet ); |
42 | | - } |
43 | | - |
44 | | - private function run( $resultPageSet = null ) { |
45 | | - global $wgUser, $wgMemc; |
46 | | - $params = $this->extractRequestParams(); |
47 | | - |
48 | | - // Construct SQL Query |
49 | | - $this->addTables( array( 'page', 'flaggedpages', 'revision' ) ); |
50 | | - $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
51 | | - $useIndex = array( 'flaggedpages' => 'fp_pending_since' ); |
52 | | - if ( $params['filterredir'] == 'redirects' ) { |
53 | | - $this->addWhereFld( 'page_is_redirect', 1 ); |
54 | | - } |
55 | | - if ( $params['filterredir'] == 'nonredirects' ) { |
56 | | - $this->addWhereFld( 'page_is_redirect', 0 ); |
57 | | - } |
58 | | - if ( $params['maxsize'] !== null ) { |
59 | | - # Get absolute difference for comparison. ABS(x-y) |
60 | | - # is broken due to mysql unsigned int design. |
61 | | - $this->addWhere( 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= ' . |
62 | | - intval( $params['maxsize'] ) ); |
63 | | - } |
64 | | - if ( $params['filterwatched'] == 'watched' ) { |
65 | | - if ( !( $uid = $wgUser->getId() ) ) { |
66 | | - $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
67 | | - } |
68 | | - $this->addTables( 'watchlist' ); |
69 | | - $this->addWhereFld( 'wl_user', $uid ); |
70 | | - $this->addWhere( 'page_namespace = wl_namespace' ); |
71 | | - $this->addWhere( 'page_title = wl_title' ); |
72 | | - } |
73 | | - if ( $params['category'] != '' ) { |
74 | | - $this->addTables( 'categorylinks' ); |
75 | | - $this->addWhere( 'cl_from = fp_page_id' ); |
76 | | - $this->addWhereFld( 'cl_to', $params['category'] ); |
77 | | - $useIndex['categorylinks'] = 'cl_from'; |
78 | | - } |
79 | | - |
80 | | - $this->addWhereRange( |
81 | | - 'fp_pending_since', |
82 | | - $params['dir'], |
83 | | - $params['start'], |
84 | | - $params['end'] |
85 | | - ); |
86 | | - $this->addWhere( 'page_id=fp_page_id' ); |
87 | | - $this->addWhere( 'rev_id=fp_stable' ); |
88 | | - if ( !isset( $params['start'] ) && !isset( $params['end'] ) ) { |
89 | | - $this->addWhere( 'fp_pending_since IS NOT NULL' ); |
90 | | - } |
91 | | - $this->addOption( 'USE INDEX', $useIndex ); |
92 | | - |
93 | | - if ( is_null( $resultPageSet ) ) { |
94 | | - $this->addFields( array( |
95 | | - 'page_id', |
96 | | - 'page_namespace', |
97 | | - 'page_title', |
98 | | - 'page_latest', |
99 | | - 'page_len', |
100 | | - 'rev_len', |
101 | | - 'fp_stable', |
102 | | - 'fp_pending_since', |
103 | | - 'fp_quality' |
104 | | - ) ); |
105 | | - } else { |
106 | | - $this->addFields( $resultPageSet->getPageTableFields() ); |
107 | | - $this->addFields ( 'fp_pending_since' ); |
108 | | - } |
109 | | - |
110 | | - $limit = $params['limit']; |
111 | | - $this->addOption( 'LIMIT', $limit + 1 ); |
112 | | - $res = $this->select( __METHOD__ ); |
113 | | - |
114 | | - $data = array(); |
115 | | - $count = 0; |
116 | | - foreach( $res as $row ) { |
117 | | - if ( ++$count > $limit ) { |
118 | | - // We've reached the one extra which shows that there are |
119 | | - // additional pages to be had. Stop here... |
120 | | - $this->setContinueEnumParameter( |
121 | | - 'start', |
122 | | - wfTimestamp( TS_ISO_8601, $row->fp_pending_since ) |
123 | | - ); |
124 | | - break; |
125 | | - } |
126 | | - |
127 | | - if ( is_null( $resultPageSet ) ) { |
128 | | - $title = Title::newFromRow( $row ); |
129 | | - $underReview = FRUserActivity::diffIsUnderReview( |
130 | | - $row->fp_stable, $row->page_latest ); |
131 | | - $data[] = array( |
132 | | - 'pageid' => intval( $row->page_id ), |
133 | | - 'ns' => intval( $row->page_namespace ), |
134 | | - 'title' => $title->getPrefixedText(), |
135 | | - 'revid' => intval( $row->page_latest ), |
136 | | - 'stable_revid' => intval( $row->fp_stable ), |
137 | | - 'pending_since' => wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
138 | | - 'flagged_level' => intval( $row->fp_quality ), |
139 | | - 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ), |
140 | | - 'diff_size' => (int)$row->page_len - (int)$row->rev_len, |
141 | | - 'under_review' => $underReview |
142 | | - ); |
143 | | - } else { |
144 | | - $resultPageSet->processDbRow( $row ); |
145 | | - } |
146 | | - } |
147 | | - |
148 | | - if ( is_null( $resultPageSet ) ) { |
149 | | - $result = $this->getResult(); |
150 | | - $result->setIndexedTagName( $data, 'p' ); |
151 | | - $result->addValue( 'query', $this->getModuleName(), $data ); |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - public function getCacheMode( $params ) { |
156 | | - if ( $params['filterwatched'] == 'watched' ) { |
157 | | - // Private data |
158 | | - return 'private'; |
159 | | - } else { |
160 | | - return 'public'; |
161 | | - } |
162 | | - } |
163 | | - |
164 | | - public function getAllowedParams() { |
165 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
166 | | - return array( |
167 | | - 'start' => array( |
168 | | - ApiBase::PARAM_TYPE => 'timestamp' |
169 | | - ), |
170 | | - 'end' => array( |
171 | | - ApiBase::PARAM_TYPE => 'timestamp' |
172 | | - ), |
173 | | - 'dir' => array( |
174 | | - ApiBase::PARAM_DFLT => 'newer', |
175 | | - ApiBase::PARAM_TYPE => array( 'newer', 'older' ) |
176 | | - ), |
177 | | - 'maxsize' => array( |
178 | | - ApiBase::PARAM_TYPE => 'integer', |
179 | | - ApiBase::PARAM_DFLT => null, |
180 | | - ApiBase::PARAM_MIN => 0 |
181 | | - ), |
182 | | - 'filterwatched' => array( |
183 | | - ApiBase::PARAM_DFLT => 'all', |
184 | | - ApiBase::PARAM_TYPE => array( 'watched', 'all' ) |
185 | | - ), |
186 | | - 'namespace' => array( |
187 | | - ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
188 | | - ApiBase::PARAM_TYPE => 'namespace', |
189 | | - ApiBase::PARAM_ISMULTI => true, |
190 | | - ), |
191 | | - 'category' => array( |
192 | | - ApiBase::PARAM_TYPE => 'string' |
193 | | - ), |
194 | | - 'filterredir' => array( |
195 | | - ApiBase::PARAM_DFLT => 'all', |
196 | | - ApiBase::PARAM_TYPE => array( 'redirects', 'nonredirects', 'all' ) |
197 | | - ), |
198 | | - 'limit' => array( |
199 | | - ApiBase::PARAM_DFLT => 10, |
200 | | - ApiBase::PARAM_TYPE => 'limit', |
201 | | - ApiBase::PARAM_MIN => 1, |
202 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
203 | | - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
204 | | - ) |
205 | | - ); |
206 | | - } |
207 | | - |
208 | | - public function getParamDescription() { |
209 | | - return array( |
210 | | - 'start' => 'Start listing at this timestamp.', |
211 | | - 'end' => 'Stop listing at this timestamp.', |
212 | | - 'namespace' => 'The namespaces to enumerate.', |
213 | | - 'filterredir' => 'How to filter for redirects.', |
214 | | - 'maxsize' => 'Maximum character count change size.', |
215 | | - 'category' => 'Show pages only in the given category.', |
216 | | - 'filterwatched' => 'How to filter for pages on your watchlist.', |
217 | | - 'limit' => 'How many total pages to return.', |
218 | | - 'dir' => array( |
219 | | - 'In which direction to list.', |
220 | | - '*newer: list the longest waiting pages first', |
221 | | - '*older: list the newest items first' |
222 | | - ) |
223 | | - ); |
224 | | - } |
225 | | - |
226 | | - public function getDescription() { |
227 | | - return 'Enumerates pages that have changes pending review'; |
228 | | - } |
229 | | - |
230 | | - public function getPossibleErrors() { |
231 | | - return array_merge( parent::getPossibleErrors(), array( |
232 | | - array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ), |
233 | | - ) ); |
234 | | - } |
235 | | - |
236 | | - protected function getExamples() { |
237 | | - return array( |
238 | | - 'Show a list of pages with pending unreviewed changes', |
239 | | - ' api.php?action=query&list=oldreviewedpages&ornamespace=0', |
240 | | - 'Show info about some old reviewed pages', |
241 | | - ' api.php?action=query&generator=oldreviewedpages&gorlimit=4&prop=info', |
242 | | - ); |
243 | | - } |
244 | | - |
245 | | - public function getVersion() { |
246 | | - return __CLASS__ . ': $Id$'; |
247 | | - } |
248 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryReviewedpages.php |
— | — | @@ -1,205 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on June 29, 2009 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * Query module to list pages reviewed pages |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiQueryReviewedpages extends ApiQueryGeneratorBase { |
31 | | - |
32 | | - public function __construct( $query, $moduleName ) { |
33 | | - parent::__construct( $query, $moduleName, 'rp' ); |
34 | | - } |
35 | | - |
36 | | - public function execute() { |
37 | | - $this->run(); |
38 | | - } |
39 | | - |
40 | | - public function executeGenerator( $resultPageSet ) { |
41 | | - $this->run( $resultPageSet ); |
42 | | - } |
43 | | - |
44 | | - private function run( $resultPageSet = null ) { |
45 | | - $params = $this->extractRequestParams(); |
46 | | - |
47 | | - // Construct SQL Query |
48 | | - $this->addTables( array( 'page', 'flaggedpages' ) ); |
49 | | - $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
50 | | - if ( $params['filterredir'] == 'redirects' ) { |
51 | | - $this->addWhereFld( 'page_is_redirect', 1 ); |
52 | | - } |
53 | | - if ( $params['filterredir'] == 'nonredirects' ) { |
54 | | - $this->addWhereFld( 'page_is_redirect', 0 ); |
55 | | - } |
56 | | - if ( $params['filterlevel'] !== null ) { |
57 | | - $this->addWhereFld( 'fp_quality', $params['filterlevel'] ); |
58 | | - } |
59 | | - $this->addWhereRange( |
60 | | - 'fp_page_id', |
61 | | - $params['dir'], |
62 | | - $params['start'], |
63 | | - $params['end'] |
64 | | - ); |
65 | | - $this->addWhere( 'page_id=fp_page_id' ); |
66 | | - $this->addOption( |
67 | | - 'USE INDEX', |
68 | | - array( 'flaggedpages' => 'PRIMARY' ) |
69 | | - ); |
70 | | - |
71 | | - if ( is_null( $resultPageSet ) ) { |
72 | | - $this->addFields( array ( |
73 | | - 'page_id', |
74 | | - 'page_namespace', |
75 | | - 'page_title', |
76 | | - 'page_len', |
77 | | - 'page_latest', |
78 | | - 'fp_page_id', |
79 | | - 'fp_quality', |
80 | | - 'fp_stable' |
81 | | - ) ); |
82 | | - } else { |
83 | | - $this->addFields( $resultPageSet->getPageTableFields() ); |
84 | | - $this->addFields ( 'fp_page_id' ); |
85 | | - } |
86 | | - |
87 | | - $limit = $params['limit']; |
88 | | - $this->addOption( 'LIMIT', $limit + 1 ); |
89 | | - $res = $this->select( __METHOD__ ); |
90 | | - |
91 | | - $data = array (); |
92 | | - $count = 0; |
93 | | - foreach( $res as $row ) { |
94 | | - if ( ++$count > $limit ) { |
95 | | - // We've reached the one extra which shows that there are |
96 | | - // additional pages to be had. Stop here... |
97 | | - $this->setContinueEnumParameter( 'start', $row->fp_page_id ); |
98 | | - break; |
99 | | - } |
100 | | - |
101 | | - if ( is_null( $resultPageSet ) ) { |
102 | | - $title = Title::newFromRow( $row ); |
103 | | - $data[] = array( |
104 | | - 'pageid' => intval( $row->page_id ), |
105 | | - 'ns' => intval( $title->getNamespace() ), |
106 | | - 'title' => $title->getPrefixedText(), |
107 | | - 'revid' => intval( $row->page_latest ), |
108 | | - 'stable_revid' => intval( $row->fp_stable ), |
109 | | - 'flagged_level' => intval( $row->fp_quality ), |
110 | | - 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
111 | | - ); |
112 | | - } else { |
113 | | - $resultPageSet->processDbRow( $row ); |
114 | | - } |
115 | | - } |
116 | | - |
117 | | - if ( is_null( $resultPageSet ) ) { |
118 | | - $result = $this->getResult(); |
119 | | - $result->setIndexedTagName( $data, 'p' ); |
120 | | - $result->addValue( 'query', $this->getModuleName(), $data ); |
121 | | - } |
122 | | - } |
123 | | - |
124 | | - public function getCacheMode( $params ) { |
125 | | - return 'public'; |
126 | | - } |
127 | | - |
128 | | - public function getAllowedParams() { |
129 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
130 | | - return array ( |
131 | | - 'start' => array ( |
132 | | - ApiBase::PARAM_TYPE => 'integer' |
133 | | - ), |
134 | | - 'end' => array ( |
135 | | - ApiBase::PARAM_TYPE => 'integer' |
136 | | - ), |
137 | | - 'dir' => array ( |
138 | | - ApiBase::PARAM_DFLT => 'newer', |
139 | | - ApiBase::PARAM_TYPE => array ( |
140 | | - 'newer', |
141 | | - 'older' |
142 | | - ) |
143 | | - ), |
144 | | - 'namespace' => array ( |
145 | | - ApiBase::PARAM_DFLT => !$namespaces ? |
146 | | - NS_MAIN : $namespaces[0], |
147 | | - ApiBase::PARAM_TYPE => 'namespace', |
148 | | - ApiBase::PARAM_ISMULTI => true, |
149 | | - ), |
150 | | - 'filterredir' => array ( |
151 | | - ApiBase::PARAM_DFLT => 'all', |
152 | | - ApiBase::PARAM_TYPE => array ( |
153 | | - 'redirects', |
154 | | - 'nonredirects', |
155 | | - 'all' |
156 | | - ) |
157 | | - ), |
158 | | - 'filterlevel' => array ( |
159 | | - ApiBase::PARAM_DFLT => null, |
160 | | - ApiBase::PARAM_TYPE => 'integer', |
161 | | - ApiBase::PARAM_MIN => 0, |
162 | | - ApiBase::PARAM_MAX => 2, |
163 | | - ), |
164 | | - 'limit' => array ( |
165 | | - ApiBase::PARAM_DFLT => 10, |
166 | | - ApiBase::PARAM_TYPE => 'limit', |
167 | | - ApiBase::PARAM_MIN => 1, |
168 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
169 | | - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
170 | | - ) |
171 | | - ); |
172 | | - } |
173 | | - |
174 | | - public function getParamDescription() { |
175 | | - return array ( |
176 | | - 'start' => 'Start listing at this page id.', |
177 | | - 'end' => 'Stop listing at this page id.', |
178 | | - 'namespace' => 'The namespaces to enumerate.', |
179 | | - 'filterredir' => 'How to filter for redirects', |
180 | | - 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
181 | | - 'limit' => 'How many total pages to return.', |
182 | | - 'dir' => array( |
183 | | - 'In which direction to list.', |
184 | | - '*newer: list the newest pages first', |
185 | | - '*older: list the oldest pages first' |
186 | | - ) |
187 | | - ); |
188 | | - } |
189 | | - |
190 | | - public function getDescription() { |
191 | | - return 'Enumerates pages that have a reviewed version'; |
192 | | - } |
193 | | - |
194 | | - protected function getExamples() { |
195 | | - return array ( |
196 | | - 'Show a list of reviewed pages', |
197 | | - ' api.php?action=query&list=reviewedpages&rpnamespace=0&rpfilterlevel=0', |
198 | | - 'Show info about some reviewed pages', |
199 | | - ' api.php?action=query&generator=reviewedpages&grplimit=4&prop=info', |
200 | | - ); |
201 | | - } |
202 | | - |
203 | | - public function getVersion() { |
204 | | - return __CLASS__ . ': $Id$'; |
205 | | - } |
206 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php |
— | — | @@ -1,189 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on Dec 20, 2008 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * API module to review revisions |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiReview extends ApiBase { |
31 | | - |
32 | | - /** |
33 | | - * This function does essentially the same as RevisionReview::AjaxReview, |
34 | | - * except that it generates the template and image parameters itself. |
35 | | - */ |
36 | | - public function execute() { |
37 | | - global $wgUser, $wgOut, $wgParser; |
38 | | - $params = $this->extractRequestParams(); |
39 | | - // Check basic permissions |
40 | | - if ( !$wgUser->isAllowed( 'review' ) ) { |
41 | | - // FIXME: better msg? |
42 | | - $this->dieUsageMsg( array( 'badaccess-group0' ) ); |
43 | | - } elseif ( $wgUser->isBlocked( false ) ) { |
44 | | - $this->dieUsageMsg( array( 'blockedtext' ) ); |
45 | | - } |
46 | | - // Construct submit form |
47 | | - $form = new RevisionReviewForm( $wgUser ); |
48 | | - $revid = (int)$params['revid']; |
49 | | - $rev = Revision::newFromId( $revid ); |
50 | | - if ( !$rev ) { |
51 | | - $this->dieUsage( "Cannot find a revision with the specified ID.", 'notarget' ); |
52 | | - } |
53 | | - $title = $rev->getTitle(); |
54 | | - $form->setPage( $title ); |
55 | | - $form->setOldId( $revid ); |
56 | | - $form->setApprove( empty( $params['unapprove'] ) ); |
57 | | - $form->setUnapprove( !empty( $params['unapprove'] ) ); |
58 | | - if ( isset( $params['comment'] ) ) { |
59 | | - $form->setComment( $params['comment'] ); |
60 | | - } |
61 | | - // The flagging parameters have the form 'flag_$name'. |
62 | | - // Extract them and put the values into $form->dims |
63 | | - foreach ( FlaggedRevs::getTags() as $tag ) { |
64 | | - $form->setDim( $tag, (int)$params['flag_' . $tag] ); |
65 | | - } |
66 | | - if ( $form->getAction() === 'approve' ) { |
67 | | - $article = new FlaggedArticle( $title ); |
68 | | - // Now get the template and image parameters needed |
69 | | - list( $templateIds, $fileTimeKeys ) = |
70 | | - RevisionReviewForm::currentIncludeVersions( $article, $rev ); |
71 | | - // Get version parameters for review submission (flat strings) |
72 | | - list( $templateParams, $imageParams, $fileVersion ) = |
73 | | - RevisionReviewForm::getIncludeParams( $article, $templateIds, $fileTimeKeys ); |
74 | | - // Set the version parameters... |
75 | | - $form->setTemplateParams( $templateParams ); |
76 | | - $form->setFileParams( $imageParams ); |
77 | | - $form->setFileVersion( $fileVersion ); |
78 | | - $key = RevisionReviewForm::validationKey( |
79 | | - $templateParams, $imageParams, $fileVersion, $revid ); |
80 | | - $form->setValidatedParams( $key ); # always OK |
81 | | - } |
82 | | - |
83 | | - $status = $form->ready(); // all params set |
84 | | - if ( $status === 'review_page_unreviewable' ) { |
85 | | - $this->dieUsage( "Provided page is not reviewable.", 'notreviewable' ); |
86 | | - // Check basic page permissions |
87 | | - } elseif ( !$title->quickUserCan( 'review' ) || !$title->quickUserCan( 'edit' ) ) { |
88 | | - $this->dieUsage( "Insufficient rights to set the specified flags.", |
89 | | - 'permissiondenied' ); |
90 | | - } |
91 | | - |
92 | | - # Try to do the actual review |
93 | | - $status = $form->submit(); |
94 | | - # Approve/de-approve success |
95 | | - if ( $status === true ) { |
96 | | - $this->getResult()->addValue( |
97 | | - null, $this->getModuleName(), array( 'result' => 'Success' ) ); |
98 | | - # De-approve failure |
99 | | - } elseif ( $form->getAction() !== 'approve' ) { |
100 | | - $this->dieUsage( "Cannot find a flagged revision with the specified ID.", 'notarget' ); |
101 | | - # Approval failures |
102 | | - } else { |
103 | | - if ( $status === 'review_too_low' ) { |
104 | | - $this->dieUsage( "Either all or none of the flags have to be set to zero.", |
105 | | - 'mixedapproval' ); |
106 | | - } elseif ( $status === 'review_denied' ) { |
107 | | - $this->dieUsage( "You don't have the necessary rights to set the specified flags.", |
108 | | - 'permissiondenied' ); |
109 | | - } elseif ( $status === 'review_bad_key' ) { |
110 | | - $this->dieUsage( "You don't have the necessary rights to set the specified flags.", |
111 | | - 'permissiondenied' ); |
112 | | - } else { |
113 | | - // FIXME: review_param_missing? better msg? |
114 | | - $this->dieUsageMsg( array( 'unknownerror', '' ) ); |
115 | | - } |
116 | | - } |
117 | | - } |
118 | | - |
119 | | - public function mustBePosted() { |
120 | | - return true; |
121 | | - } |
122 | | - |
123 | | - public function isWriteMode() { |
124 | | - return true; |
125 | | - } |
126 | | - |
127 | | - public function getAllowedParams() { |
128 | | - $pars = array( |
129 | | - 'revid' => null, |
130 | | - 'token' => null, |
131 | | - 'comment' => null, |
132 | | - 'unapprove' => false |
133 | | - ); |
134 | | - if ( !FlaggedRevs::binaryFlagging() ) { |
135 | | - foreach ( FlaggedRevs::getDimensions() as $flagname => $levels ) { |
136 | | - $pars['flag_' . $flagname] = array( |
137 | | - ApiBase::PARAM_DFLT => 1, // default |
138 | | - ApiBase::PARAM_TYPE => array_keys( $levels ) // array of allowed values |
139 | | - ); |
140 | | - } |
141 | | - } |
142 | | - return $pars; |
143 | | - } |
144 | | - |
145 | | - public function getParamDescription() { |
146 | | - $desc = array( |
147 | | - 'revid' => 'The revision ID for which to set the flags', |
148 | | - 'token' => 'An edit token retrieved through prop=info', |
149 | | - 'comment' => 'Comment for the review (optional)', |
150 | | - 'unapprove' => 'If set, revision will be unapproved rather than approved.' |
151 | | - ); |
152 | | - if ( !FlaggedRevs::binaryFlagging() ) { |
153 | | - foreach ( FlaggedRevs::getTags() as $flagname ) { |
154 | | - $desc['flag_' . $flagname] = "Set the flag ''{$flagname}'' to the specified value"; |
155 | | - } |
156 | | - } |
157 | | - return $desc; |
158 | | - } |
159 | | - |
160 | | - public function getDescription() { |
161 | | - return 'Review a revision via FlaggedRevs.'; |
162 | | - } |
163 | | - |
164 | | - public function getPossibleErrors() { |
165 | | - return array_merge( parent::getPossibleErrors(), array( |
166 | | - array( 'badaccess-group0' ), |
167 | | - array( 'blockedtext' ), |
168 | | - array( 'code' => 'notarget', 'info' => 'Provided revision or page can not be found.' ), |
169 | | - array( 'code' => 'notreviewable', 'info' => 'Provided page is not reviewable.' ), |
170 | | - array( 'code' => 'mixedapproval', 'info' => 'No flags can be set to zero when accepting a revision.' ), |
171 | | - array( 'code' => 'permissiondenied', 'info' => 'Insufficient rights to set the specified flags.' ), |
172 | | - ) ); |
173 | | - } |
174 | | - |
175 | | - public function needsToken() { |
176 | | - return true; |
177 | | - } |
178 | | - |
179 | | - public function getTokenSalt() { |
180 | | - return ''; |
181 | | - } |
182 | | - |
183 | | - protected function getExamples() { |
184 | | - return 'api.php?action=review&revid=12345&token=123AB&flag_accuracy=1&comment=Ok'; |
185 | | - } |
186 | | - |
187 | | - public function getVersion() { |
188 | | - return __CLASS__ . ': $Id$'; |
189 | | - } |
190 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryUnreviewedpages.php |
— | — | @@ -1,189 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on June 29, 2009 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * Query module to list pages unreviewed pages |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiQueryUnreviewedpages extends ApiQueryGeneratorBase { |
31 | | - |
32 | | - public function __construct( $query, $moduleName ) { |
33 | | - parent::__construct( $query, $moduleName, 'ur' ); |
34 | | - } |
35 | | - |
36 | | - public function execute() { |
37 | | - $this->run(); |
38 | | - } |
39 | | - |
40 | | - public function executeGenerator( $resultPageSet ) { |
41 | | - $this->run( $resultPageSet ); |
42 | | - } |
43 | | - |
44 | | - private function run( $resultPageSet = null ) { |
45 | | - global $wgMemc; |
46 | | - $params = $this->extractRequestParams(); |
47 | | - |
48 | | - // Construct SQL Query |
49 | | - $this->addTables( array( 'page', 'flaggedpages' ) ); |
50 | | - $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
51 | | - if ( $params['filterredir'] == 'redirects' ) { |
52 | | - $this->addWhereFld( 'page_is_redirect', 1 ); |
53 | | - } |
54 | | - if ( $params['filterredir'] == 'nonredirects' ) { |
55 | | - $this->addWhereFld( 'page_is_redirect', 0 ); |
56 | | - } |
57 | | - |
58 | | - $this->addWhereRange( |
59 | | - 'page_title', |
60 | | - 'newer', |
61 | | - $params['start'], |
62 | | - $params['end'] |
63 | | - ); |
64 | | - $this->addJoinConds( |
65 | | - array( 'flaggedpages' => array ( 'LEFT JOIN', 'fp_page_id=page_id' ) ) |
66 | | - ); |
67 | | - $this->addWhere( 'fp_page_id IS NULL OR |
68 | | - fp_quality < ' . intval( $params['filterlevel'] ) ); |
69 | | - $this->addOption( |
70 | | - 'USE INDEX', |
71 | | - array( 'page' => 'name_title', 'flaggedpages' => 'PRIMARY' ) |
72 | | - ); |
73 | | - |
74 | | - if ( is_null( $resultPageSet ) ) { |
75 | | - $this->addFields( array ( |
76 | | - 'page_id', |
77 | | - 'page_namespace', |
78 | | - 'page_title', |
79 | | - 'page_len', |
80 | | - 'page_latest', |
81 | | - ) ); |
82 | | - } else { |
83 | | - $this->addFields( $resultPageSet->getPageTableFields() ); |
84 | | - } |
85 | | - |
86 | | - $limit = $params['limit']; |
87 | | - $this->addOption( 'LIMIT', $limit + 1 ); |
88 | | - $res = $this->select( __METHOD__ ); |
89 | | - |
90 | | - $data = array (); |
91 | | - $count = 0; |
92 | | - foreach( $res as $row ) { |
93 | | - if ( ++$count > $limit ) { |
94 | | - // We've reached the one extra which shows that there are |
95 | | - // additional pages to be had. Stop here... |
96 | | - $this->setContinueEnumParameter( 'start', $row->page_title ); |
97 | | - break; |
98 | | - } |
99 | | - |
100 | | - if ( is_null( $resultPageSet ) ) { |
101 | | - $title = Title::newFromRow( $row ); |
102 | | - $data[] = array( |
103 | | - 'pageid' => intval( $row->page_id ), |
104 | | - 'ns' => intval( $title->getNamespace() ), |
105 | | - 'title' => $title->getPrefixedText(), |
106 | | - 'revid' => intval( $row->page_latest ), |
107 | | - 'under_review' => FRUserActivity::pageIsUnderReview( $row->page_id ) |
108 | | - ); |
109 | | - } else { |
110 | | - $resultPageSet->processDbRow( $row ); |
111 | | - } |
112 | | - } |
113 | | - |
114 | | - if ( is_null( $resultPageSet ) ) { |
115 | | - $result = $this->getResult(); |
116 | | - $result->setIndexedTagName( $data, 'p' ); |
117 | | - $result->addValue( 'query', $this->getModuleName(), $data ); |
118 | | - } |
119 | | - } |
120 | | - |
121 | | - public function getCacheMode( $params ) { |
122 | | - return 'public'; |
123 | | - } |
124 | | - |
125 | | - public function getAllowedParams() { |
126 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
127 | | - return array ( |
128 | | - 'start' => array ( |
129 | | - ApiBase::PARAM_TYPE => 'string' |
130 | | - ), |
131 | | - 'end' => array ( |
132 | | - ApiBase::PARAM_TYPE => 'string' |
133 | | - ), |
134 | | - 'namespace' => array ( |
135 | | - ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
136 | | - ApiBase::PARAM_TYPE => 'namespace', |
137 | | - ApiBase::PARAM_ISMULTI => true, |
138 | | - ), |
139 | | - 'filterredir' => array ( |
140 | | - ApiBase::PARAM_DFLT => 'all', |
141 | | - ApiBase::PARAM_TYPE => array ( |
142 | | - 'redirects', |
143 | | - 'nonredirects', |
144 | | - 'all' |
145 | | - ) |
146 | | - ), |
147 | | - 'filterlevel' => array ( |
148 | | - ApiBase::PARAM_DFLT => 0, |
149 | | - ApiBase::PARAM_TYPE => 'integer', |
150 | | - ApiBase::PARAM_MIN => 0, |
151 | | - ApiBase::PARAM_MAX => 2, |
152 | | - ), |
153 | | - 'limit' => array ( |
154 | | - ApiBase::PARAM_DFLT => 10, |
155 | | - ApiBase::PARAM_TYPE => 'limit', |
156 | | - ApiBase::PARAM_MIN => 1, |
157 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
158 | | - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
159 | | - ) |
160 | | - ); |
161 | | - } |
162 | | - |
163 | | - public function getParamDescription() { |
164 | | - return array ( |
165 | | - 'start' => 'Start listing at this page title.', |
166 | | - 'end' => 'Stop listing at this page title.', |
167 | | - 'namespace' => 'The namespaces to enumerate.', |
168 | | - 'filterredir' => 'How to filter for redirects', |
169 | | - 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
170 | | - 'limit' => 'How many total pages to return.', |
171 | | - ); |
172 | | - } |
173 | | - |
174 | | - public function getDescription() { |
175 | | - return 'Enumerates pages that have not been reviewed to a given quality level ("filterlevel")'; |
176 | | - } |
177 | | - |
178 | | - protected function getExamples() { |
179 | | - return array ( |
180 | | - 'Show a list of unreviewed pages', |
181 | | - ' api.php?action=query&list=unreviewedpages&urnamespace=0&urfilterlevel=0', |
182 | | - 'Show info about some unreviewed pages', |
183 | | - ' api.php?action=query&generator=unreviewedpages&urnamespace=0&gurlimit=4&prop=info', |
184 | | - ); |
185 | | - } |
186 | | - |
187 | | - public function getVersion() { |
188 | | - return __CLASS__ . ': $Id$'; |
189 | | - } |
190 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiStabilize.php |
— | — | @@ -1,276 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on Sep 19, 2009 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * API module to stabilize pages |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -abstract class ApiStabilize extends ApiBase { |
31 | | - |
32 | | - // Title param |
33 | | - protected $title; |
34 | | - |
35 | | - public function execute() { |
36 | | - global $wgUser; |
37 | | - $params = $this->extractRequestParams(); |
38 | | - |
39 | | - if ( !isset( $params['title'] ) ) { |
40 | | - $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
41 | | - } elseif ( !isset( $params['token'] ) ) { |
42 | | - $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
43 | | - } |
44 | | - |
45 | | - $this->title = Title::newFromText( $params['title'] ); |
46 | | - if ( $this->title == null ) { |
47 | | - $this->dieUsage( "Invalid title given.", "invalidtitle" ); |
48 | | - } |
49 | | - $errors = $this->title->getUserPermissionsErrors( 'stablesettings', $wgUser ); |
50 | | - if ( $errors ) { |
51 | | - // We don't care about multiple errors, just report one of them |
52 | | - $this->dieUsageMsg( reset( $errors ) ); |
53 | | - } |
54 | | - |
55 | | - $this->doExecute(); // child class |
56 | | - } |
57 | | - |
58 | | - public abstract function doExecute(); |
59 | | - |
60 | | - public function mustBePosted() { |
61 | | - return true; |
62 | | - } |
63 | | - |
64 | | - public function isWriteMode() { |
65 | | - return true; |
66 | | - } |
67 | | - |
68 | | - public function needsToken() { |
69 | | - return true; |
70 | | - } |
71 | | - |
72 | | - public function getTokenSalt() { |
73 | | - return ''; |
74 | | - } |
75 | | - |
76 | | - public function getVersion() { |
77 | | - return __CLASS__ . ': $Id$'; |
78 | | - } |
79 | | -} |
80 | | - |
81 | | -// Assumes $wgFlaggedRevsProtection is off |
82 | | -class ApiStabilizeGeneral extends ApiStabilize { |
83 | | - public function doExecute() { |
84 | | - global $wgUser; |
85 | | - $params = $this->extractRequestParams(); |
86 | | - |
87 | | - $form = new PageStabilityGeneralForm( $wgUser ); |
88 | | - $form->setPage( $this->title ); # Our target page |
89 | | - $form->setWatchThis( $params['watch'] ); # Watch this page |
90 | | - $form->setReason( $params['reason'] ); # Reason |
91 | | - $form->setReasonSelection( 'other' ); # Reason dropdown |
92 | | - $form->setExpiry( $params['expiry'] ); # Expiry |
93 | | - $form->setExpirySelection( 'other' ); # Expiry dropdown |
94 | | - $restriction = $params['autoreview']; |
95 | | - // Fill in config fields from URL params |
96 | | - if ( $params['default'] === null ) { |
97 | | - // Default version setting not optional |
98 | | - $this->dieUsageMsg( array( 'missingparam', 'default' ) ); |
99 | | - } else { |
100 | | - $form->setOverride( $this->defaultFromKey( $params['default'] ) ); |
101 | | - } |
102 | | - $form->setReviewThis( $params['review'] ); # Auto-review option |
103 | | - if ( $restriction == 'none' ) { |
104 | | - $restriction = ''; // 'none' => '' |
105 | | - } |
106 | | - $form->setAutoreview( $restriction ); # Autoreview restriction |
107 | | - $form->ready(); |
108 | | - |
109 | | - $status = $form->submit(); // true/error message key |
110 | | - if ( $status !== true ) { |
111 | | - $this->dieUsageMsg( wfMsg( $status ) ); |
112 | | - } |
113 | | - |
114 | | - # Output success line with the title and config parameters |
115 | | - $res = array(); |
116 | | - $res['title'] = $this->title->getPrefixedText(); |
117 | | - $res['default'] = $params['default']; |
118 | | - $res['autoreview'] = $params['autoreview']; |
119 | | - $res['expiry'] = $form->getExpiry(); |
120 | | - $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
121 | | - } |
122 | | - |
123 | | - protected function defaultFromKey( $key ) { |
124 | | - if ( $key == 'stable' ) { |
125 | | - return 1; |
126 | | - } else if ( $key == 'latest' ) { |
127 | | - return 0; |
128 | | - } |
129 | | - return null; // bad key? |
130 | | - } |
131 | | - |
132 | | - public function getAllowedParams() { |
133 | | - // Replace '' with more readable 'none' in autoreview restiction levels |
134 | | - $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
135 | | - $autoreviewLevels[] = 'none'; |
136 | | - $pars = array( |
137 | | - 'default' => array( |
138 | | - ApiBase :: PARAM_TYPE => array( 'latest', 'stable' ), |
139 | | - ApiBase :: PARAM_DFLT => null, |
140 | | - ), |
141 | | - 'autoreview' => array( |
142 | | - ApiBase :: PARAM_TYPE => $autoreviewLevels, |
143 | | - ApiBase :: PARAM_DFLT => 'none', |
144 | | - ), |
145 | | - 'expiry' => 'infinite', |
146 | | - 'reason' => '', |
147 | | - 'review' => false, |
148 | | - 'watch' => null, |
149 | | - 'token' => null, |
150 | | - 'title' => null, |
151 | | - ); |
152 | | - return $pars; |
153 | | - } |
154 | | - |
155 | | - public function getParamDescription() { |
156 | | - return array( |
157 | | - 'default' => 'Default revision to show', |
158 | | - 'autoreview' => 'Auto-review restriction', |
159 | | - 'expiry' => 'Expiry for these settings', |
160 | | - 'title' => 'Title of page to be stabilized', |
161 | | - 'reason' => 'Reason', |
162 | | - 'review' => 'Review this page', |
163 | | - 'watch' => 'Watch this page', |
164 | | - 'token' => 'An edit token retrieved through prop=info' |
165 | | - ); |
166 | | - } |
167 | | - |
168 | | - public function getDescription() { |
169 | | - return 'Change page stability settings.'; |
170 | | - } |
171 | | - |
172 | | - // @TODO: fill in stabilize_* values from PageStabilityGeneralForm |
173 | | - public function getPossibleErrors() { |
174 | | - return array_merge( parent::getPossibleErrors(), array( |
175 | | - array( 'missingparam', 'title' ), |
176 | | - array( 'missingparam', 'token' ), |
177 | | - array( 'missingparam', 'default' ), |
178 | | - array( 'code' => 'invalidtitle', 'info' => 'Invalid title given.' ), |
179 | | - array( 'code' => 'invalidtitle', 'info' => 'Target page does not exist.' ), |
180 | | - array( 'code' => 'invalidtitle', 'info' => 'Title given does not correspond to a reviewable page.' ), |
181 | | - ) ); |
182 | | - } |
183 | | - |
184 | | - protected function getExamples() { |
185 | | - return 'api.php?action=stabilize&title=Test&default=stable&reason=Test&token=123ABC'; |
186 | | - } |
187 | | - |
188 | | - public function getVersion() { |
189 | | - return __CLASS__ . ': $Id$'; |
190 | | - } |
191 | | -} |
192 | | - |
193 | | -// Assumes $wgFlaggedRevsProtection is on |
194 | | -class ApiStabilizeProtect extends ApiStabilize { |
195 | | - public function doExecute() { |
196 | | - global $wgUser; |
197 | | - $params = $this->extractRequestParams(); |
198 | | - |
199 | | - $form = new PageStabilityProtectForm( $wgUser ); |
200 | | - $form->setPage( $this->title ); # Our target page |
201 | | - $form->setWatchThis( $params['watch'] ); # Watch this page |
202 | | - $form->setReason( $params['reason'] ); # Reason |
203 | | - $form->setReasonSelection( 'other' ); # Reason dropdown |
204 | | - $form->setExpiry( $params['expiry'] ); # Expiry |
205 | | - $form->setExpirySelection( 'other' ); # Expiry dropdown |
206 | | - $restriction = $params['protectlevel']; |
207 | | - if ( $restriction == 'none' ) { |
208 | | - $restriction = ''; // 'none' => '' |
209 | | - } |
210 | | - $form->setAutoreview( $restriction ); # Autoreview restriction |
211 | | - $form->ready(); |
212 | | - |
213 | | - $status = $form->submit(); // true/error message key |
214 | | - if ( $status !== true ) { |
215 | | - $this->dieUsageMsg( wfMsg( $status ) ); |
216 | | - } |
217 | | - |
218 | | - # Output success line with the title and config parameters |
219 | | - $res = array(); |
220 | | - $res['title'] = $this->title->getPrefixedText(); |
221 | | - $res['protectlevel'] = $params['protectlevel']; |
222 | | - $res['expiry'] = $form->getExpiry(); |
223 | | - $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
224 | | - } |
225 | | - |
226 | | - public function getAllowedParams() { |
227 | | - // Replace '' with more readable 'none' in autoreview restiction levels |
228 | | - $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
229 | | - $autoreviewLevels[] = 'none'; |
230 | | - return array( |
231 | | - 'protectlevel' => array( |
232 | | - ApiBase :: PARAM_TYPE => $autoreviewLevels, |
233 | | - ApiBase :: PARAM_DFLT => 'none', |
234 | | - ), |
235 | | - 'expiry' => 'infinite', |
236 | | - 'reason' => '', |
237 | | - 'watch' => null, |
238 | | - 'token' => null, |
239 | | - 'title' => null, |
240 | | - ); |
241 | | - } |
242 | | - |
243 | | - public function getParamDescription() { |
244 | | - return array( |
245 | | - 'protectlevel' => 'The review-protection level', |
246 | | - 'expiry' => 'Review-protection expiry', |
247 | | - 'title' => 'Title of page to be review-protected', |
248 | | - 'reason' => 'Reason', |
249 | | - 'watch' => 'Watch this page', |
250 | | - 'token' => 'An edit token retrieved through prop=info', |
251 | | - ); |
252 | | - } |
253 | | - |
254 | | - public function getDescription() { |
255 | | - return 'Configure review-protection settings for a page'; |
256 | | - } |
257 | | - |
258 | | - // @TODO: fill in stabilize_* values from PageStabilityProtectForm |
259 | | - public function getPossibleErrors() { |
260 | | - return array_merge( parent::getPossibleErrors(), array( |
261 | | - array( 'missingparam', 'title' ), |
262 | | - array( 'missingparam', 'token' ), |
263 | | - array( 'missingparam', 'default' ), |
264 | | - array( 'code' => 'invalidtitle', 'info' => 'Invalid title given.' ), |
265 | | - array( 'code' => 'invalidtitle', 'info' => 'Target page does not exist.' ), |
266 | | - array( 'code' => 'invalidtitle', 'info' => 'Title given does not correspond to a reviewable page.' ), |
267 | | - ) ); |
268 | | - } |
269 | | - |
270 | | - protected function getExamples() { |
271 | | - return 'api.php?action=stabilize&title=Test&protectlevel=none&reason=Test&token=123ABC'; |
272 | | - } |
273 | | - |
274 | | - public function getVersion() { |
275 | | - return __CLASS__ . ': $Id$'; |
276 | | - } |
277 | | -} |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryConfiguredPages.php |
— | — | @@ -1,209 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/* |
5 | | - * Created on April 8, 2011 |
6 | | - * |
7 | | - * API module for MediaWiki's FlaggedRevs extension |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - */ |
24 | | - |
25 | | -/** |
26 | | - * Query module to list pages with custom review configurations |
27 | | - * |
28 | | - * @ingroup FlaggedRevs |
29 | | - */ |
30 | | -class ApiQueryConfiguredpages extends ApiQueryGeneratorBase { |
31 | | - |
32 | | - public function __construct( $query, $moduleName ) { |
33 | | - parent::__construct( $query, $moduleName, 'cp' ); |
34 | | - } |
35 | | - |
36 | | - public function execute() { |
37 | | - $this->run(); |
38 | | - } |
39 | | - |
40 | | - public function executeGenerator( $resultPageSet ) { |
41 | | - $this->run( $resultPageSet ); |
42 | | - } |
43 | | - |
44 | | - private function run( $resultPageSet = null ) { |
45 | | - $params = $this->extractRequestParams(); |
46 | | - |
47 | | - // Construct SQL Query |
48 | | - $this->addTables( array( 'page', 'flaggedpage_config', 'flaggedpages' ) ); |
49 | | - if ( isset( $params['namespace'] ) ) { |
50 | | - $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
51 | | - } |
52 | | - if ( isset( $params['default'] ) ) { |
53 | | - // Convert readable 'stable'/'latest' to 0/1 (DB format) |
54 | | - $override = ( $params['default'] === 'stable' ) ? 1 : 0; |
55 | | - $this->addWhereFld( 'fpc_override', $override ); |
56 | | - } |
57 | | - if ( isset( $params['autoreview'] ) ) { |
58 | | - // Convert readable 'none' to '' (DB format) |
59 | | - $level = ( $params['autoreview'] === 'none' ) ? '' : $params['autoreview']; |
60 | | - $this->addWhereFld( 'fpc_level', $level ); |
61 | | - } |
62 | | - |
63 | | - $this->addWhereRange( |
64 | | - 'fpc_page_id', |
65 | | - $params['dir'], |
66 | | - $params['start'], |
67 | | - $params['end'] |
68 | | - ); |
69 | | - $this->addJoinConds( array( |
70 | | - 'flaggedpage_config' => array( 'INNER JOIN', 'page_id=fpc_page_id' ), |
71 | | - 'flaggedpages' => array( 'LEFT JOIN', 'page_id=fp_page_id' ) |
72 | | - ) ); |
73 | | - $this->addOption( |
74 | | - 'USE INDEX', |
75 | | - array( 'flaggedpage_config' => 'PRIMARY' ) |
76 | | - ); |
77 | | - |
78 | | - if ( is_null( $resultPageSet ) ) { |
79 | | - $this->addFields( array( |
80 | | - 'page_id', |
81 | | - 'page_namespace', |
82 | | - 'page_title', |
83 | | - 'page_len', |
84 | | - 'page_latest', |
85 | | - 'fpc_page_id', |
86 | | - 'fpc_override', |
87 | | - 'fpc_level', |
88 | | - 'fpc_expiry', |
89 | | - 'fp_stable' |
90 | | - ) ); |
91 | | - } else { |
92 | | - $this->addFields( $resultPageSet->getPageTableFields() ); |
93 | | - $this->addFields( 'fpc_page_id' ); |
94 | | - } |
95 | | - |
96 | | - $limit = $params['limit']; |
97 | | - $this->addOption( 'LIMIT', $limit + 1 ); |
98 | | - $res = $this->select( __METHOD__ ); |
99 | | - |
100 | | - $data = array(); |
101 | | - $count = 0; |
102 | | - foreach( $res as $row ) { |
103 | | - if ( ++$count > $limit ) { |
104 | | - // We've reached the one extra which shows that there are |
105 | | - // additional pages to be had. Stop here... |
106 | | - $this->setContinueEnumParameter( 'start', $row->fpc_page_id ); |
107 | | - break; |
108 | | - } |
109 | | - |
110 | | - if ( is_null( $resultPageSet ) ) { |
111 | | - $title = Title::newFromRow( $row ); |
112 | | - $data[] = array( |
113 | | - 'pageid' => intval( $row->page_id ), |
114 | | - 'ns' => intval( $row->page_namespace ), |
115 | | - 'title' => $title->getPrefixedText(), |
116 | | - 'last_revid' => intval( $row->page_latest ), |
117 | | - 'stable_revid' => intval( $row->fp_stable ), |
118 | | - 'stable_is_default' => intval( $row->fpc_override ), |
119 | | - 'autoreview' => $row->fpc_level, |
120 | | - 'expiry' => ( $row->fpc_expiry === 'infinity' ) ? |
121 | | - 'infinity' : wfTimestamp( TS_ISO_8601, $row->fpc_expiry ), |
122 | | - ); |
123 | | - } else { |
124 | | - $resultPageSet->processDbRow( $row ); |
125 | | - } |
126 | | - } |
127 | | - |
128 | | - if ( is_null( $resultPageSet ) ) { |
129 | | - $result = $this->getResult(); |
130 | | - $result->setIndexedTagName( $data, 'p' ); |
131 | | - $result->addValue( 'query', $this->getModuleName(), $data ); |
132 | | - } |
133 | | - } |
134 | | - |
135 | | - public function getCacheMode( $params ) { |
136 | | - return 'public'; |
137 | | - } |
138 | | - |
139 | | - public function getAllowedParams() { |
140 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
141 | | - // Replace '' with more readable 'none' in autoreview restiction levels |
142 | | - $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
143 | | - $autoreviewLevels[] = 'none'; |
144 | | - return array( |
145 | | - 'start' => array( |
146 | | - ApiBase::PARAM_TYPE => 'integer' |
147 | | - ), |
148 | | - 'end' => array( |
149 | | - ApiBase::PARAM_TYPE => 'integer' |
150 | | - ), |
151 | | - 'dir' => array( |
152 | | - ApiBase::PARAM_DFLT => 'newer', |
153 | | - ApiBase::PARAM_TYPE => array( 'newer', 'older' ) |
154 | | - ), |
155 | | - 'namespace' => array( |
156 | | - ApiBase::PARAM_DFLT => null, |
157 | | - ApiBase::PARAM_TYPE => 'namespace', |
158 | | - ApiBase::PARAM_ISMULTI => true, |
159 | | - ), |
160 | | - 'default' => array( |
161 | | - ApiBase :: PARAM_DFLT => null, |
162 | | - ApiBase :: PARAM_TYPE => array( 'latest', 'stable' ), |
163 | | - ), |
164 | | - 'autoreview' => array( |
165 | | - ApiBase :: PARAM_DFLT => null, |
166 | | - ApiBase :: PARAM_TYPE => $autoreviewLevels, |
167 | | - ), |
168 | | - 'limit' => array( |
169 | | - ApiBase::PARAM_DFLT => 10, |
170 | | - ApiBase::PARAM_TYPE => 'limit', |
171 | | - ApiBase::PARAM_MIN => 1, |
172 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
173 | | - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
174 | | - ) |
175 | | - ); |
176 | | - } |
177 | | - |
178 | | - public function getParamDescription() { |
179 | | - return array( |
180 | | - 'start' => 'Start listing at this page id.', |
181 | | - 'end' => 'Stop listing at this page id.', |
182 | | - 'namespace' => 'The namespaces to enumerate.', |
183 | | - 'default' => 'The default page view version.', |
184 | | - 'autoreview' => 'Review/autoreview restriction level.', |
185 | | - 'limit' => 'How many total pages to return.', |
186 | | - 'dir' => array( |
187 | | - 'In which direction to list.', |
188 | | - '*newer: list the newest pages first', |
189 | | - '*older: list the oldest pages first' |
190 | | - ) |
191 | | - ); |
192 | | - } |
193 | | - |
194 | | - public function getDescription() { |
195 | | - return 'Enumerate all pages that have custom review configurations'; |
196 | | - } |
197 | | - |
198 | | - protected function getExamples() { |
199 | | - return array( |
200 | | - 'Show a list of pages with custom review configurations', |
201 | | - ' api.php?action=query&list=configuredpages&cpnamespace=0', |
202 | | - 'Get some info about pages with custom review configurations', |
203 | | - ' api.php?action=query&generator=configuredpages&gcplimit=4&prop=info', |
204 | | - ); |
205 | | - } |
206 | | - |
207 | | - public function getVersion() { |
208 | | - return __CLASS__ . ': $Id: $'; |
209 | | - } |
210 | | -} |
Index: trunk/extensions/FlaggedRevs/api/actions/ApiReview.php |
— | — | @@ -0,0 +1,189 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on Dec 20, 2008 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * API module to review revisions |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiReview extends ApiBase { |
| 31 | + |
| 32 | + /** |
| 33 | + * This function does essentially the same as RevisionReview::AjaxReview, |
| 34 | + * except that it generates the template and image parameters itself. |
| 35 | + */ |
| 36 | + public function execute() { |
| 37 | + global $wgUser, $wgOut, $wgParser; |
| 38 | + $params = $this->extractRequestParams(); |
| 39 | + // Check basic permissions |
| 40 | + if ( !$wgUser->isAllowed( 'review' ) ) { |
| 41 | + // FIXME: better msg? |
| 42 | + $this->dieUsageMsg( array( 'badaccess-group0' ) ); |
| 43 | + } elseif ( $wgUser->isBlocked( false ) ) { |
| 44 | + $this->dieUsageMsg( array( 'blockedtext' ) ); |
| 45 | + } |
| 46 | + // Construct submit form |
| 47 | + $form = new RevisionReviewForm( $wgUser ); |
| 48 | + $revid = (int)$params['revid']; |
| 49 | + $rev = Revision::newFromId( $revid ); |
| 50 | + if ( !$rev ) { |
| 51 | + $this->dieUsage( "Cannot find a revision with the specified ID.", 'notarget' ); |
| 52 | + } |
| 53 | + $title = $rev->getTitle(); |
| 54 | + $form->setPage( $title ); |
| 55 | + $form->setOldId( $revid ); |
| 56 | + $form->setApprove( empty( $params['unapprove'] ) ); |
| 57 | + $form->setUnapprove( !empty( $params['unapprove'] ) ); |
| 58 | + if ( isset( $params['comment'] ) ) { |
| 59 | + $form->setComment( $params['comment'] ); |
| 60 | + } |
| 61 | + // The flagging parameters have the form 'flag_$name'. |
| 62 | + // Extract them and put the values into $form->dims |
| 63 | + foreach ( FlaggedRevs::getTags() as $tag ) { |
| 64 | + $form->setDim( $tag, (int)$params['flag_' . $tag] ); |
| 65 | + } |
| 66 | + if ( $form->getAction() === 'approve' ) { |
| 67 | + $article = new FlaggedArticle( $title ); |
| 68 | + // Now get the template and image parameters needed |
| 69 | + list( $templateIds, $fileTimeKeys ) = |
| 70 | + RevisionReviewForm::currentIncludeVersions( $article, $rev ); |
| 71 | + // Get version parameters for review submission (flat strings) |
| 72 | + list( $templateParams, $imageParams, $fileVersion ) = |
| 73 | + RevisionReviewForm::getIncludeParams( $article, $templateIds, $fileTimeKeys ); |
| 74 | + // Set the version parameters... |
| 75 | + $form->setTemplateParams( $templateParams ); |
| 76 | + $form->setFileParams( $imageParams ); |
| 77 | + $form->setFileVersion( $fileVersion ); |
| 78 | + $key = RevisionReviewForm::validationKey( |
| 79 | + $templateParams, $imageParams, $fileVersion, $revid ); |
| 80 | + $form->setValidatedParams( $key ); # always OK |
| 81 | + } |
| 82 | + |
| 83 | + $status = $form->ready(); // all params set |
| 84 | + if ( $status === 'review_page_unreviewable' ) { |
| 85 | + $this->dieUsage( "Provided page is not reviewable.", 'notreviewable' ); |
| 86 | + // Check basic page permissions |
| 87 | + } elseif ( !$title->quickUserCan( 'review' ) || !$title->quickUserCan( 'edit' ) ) { |
| 88 | + $this->dieUsage( "Insufficient rights to set the specified flags.", |
| 89 | + 'permissiondenied' ); |
| 90 | + } |
| 91 | + |
| 92 | + # Try to do the actual review |
| 93 | + $status = $form->submit(); |
| 94 | + # Approve/de-approve success |
| 95 | + if ( $status === true ) { |
| 96 | + $this->getResult()->addValue( |
| 97 | + null, $this->getModuleName(), array( 'result' => 'Success' ) ); |
| 98 | + # De-approve failure |
| 99 | + } elseif ( $form->getAction() !== 'approve' ) { |
| 100 | + $this->dieUsage( "Cannot find a flagged revision with the specified ID.", 'notarget' ); |
| 101 | + # Approval failures |
| 102 | + } else { |
| 103 | + if ( $status === 'review_too_low' ) { |
| 104 | + $this->dieUsage( "Either all or none of the flags have to be set to zero.", |
| 105 | + 'mixedapproval' ); |
| 106 | + } elseif ( $status === 'review_denied' ) { |
| 107 | + $this->dieUsage( "You don't have the necessary rights to set the specified flags.", |
| 108 | + 'permissiondenied' ); |
| 109 | + } elseif ( $status === 'review_bad_key' ) { |
| 110 | + $this->dieUsage( "You don't have the necessary rights to set the specified flags.", |
| 111 | + 'permissiondenied' ); |
| 112 | + } else { |
| 113 | + // FIXME: review_param_missing? better msg? |
| 114 | + $this->dieUsageMsg( array( 'unknownerror', '' ) ); |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + public function mustBePosted() { |
| 120 | + return true; |
| 121 | + } |
| 122 | + |
| 123 | + public function isWriteMode() { |
| 124 | + return true; |
| 125 | + } |
| 126 | + |
| 127 | + public function getAllowedParams() { |
| 128 | + $pars = array( |
| 129 | + 'revid' => null, |
| 130 | + 'token' => null, |
| 131 | + 'comment' => null, |
| 132 | + 'unapprove' => false |
| 133 | + ); |
| 134 | + if ( !FlaggedRevs::binaryFlagging() ) { |
| 135 | + foreach ( FlaggedRevs::getDimensions() as $flagname => $levels ) { |
| 136 | + $pars['flag_' . $flagname] = array( |
| 137 | + ApiBase::PARAM_DFLT => 1, // default |
| 138 | + ApiBase::PARAM_TYPE => array_keys( $levels ) // array of allowed values |
| 139 | + ); |
| 140 | + } |
| 141 | + } |
| 142 | + return $pars; |
| 143 | + } |
| 144 | + |
| 145 | + public function getParamDescription() { |
| 146 | + $desc = array( |
| 147 | + 'revid' => 'The revision ID for which to set the flags', |
| 148 | + 'token' => 'An edit token retrieved through prop=info', |
| 149 | + 'comment' => 'Comment for the review (optional)', |
| 150 | + 'unapprove' => 'If set, revision will be unapproved rather than approved.' |
| 151 | + ); |
| 152 | + if ( !FlaggedRevs::binaryFlagging() ) { |
| 153 | + foreach ( FlaggedRevs::getTags() as $flagname ) { |
| 154 | + $desc['flag_' . $flagname] = "Set the flag ''{$flagname}'' to the specified value"; |
| 155 | + } |
| 156 | + } |
| 157 | + return $desc; |
| 158 | + } |
| 159 | + |
| 160 | + public function getDescription() { |
| 161 | + return 'Review a revision via FlaggedRevs.'; |
| 162 | + } |
| 163 | + |
| 164 | + public function getPossibleErrors() { |
| 165 | + return array_merge( parent::getPossibleErrors(), array( |
| 166 | + array( 'badaccess-group0' ), |
| 167 | + array( 'blockedtext' ), |
| 168 | + array( 'code' => 'notarget', 'info' => 'Provided revision or page can not be found.' ), |
| 169 | + array( 'code' => 'notreviewable', 'info' => 'Provided page is not reviewable.' ), |
| 170 | + array( 'code' => 'mixedapproval', 'info' => 'No flags can be set to zero when accepting a revision.' ), |
| 171 | + array( 'code' => 'permissiondenied', 'info' => 'Insufficient rights to set the specified flags.' ), |
| 172 | + ) ); |
| 173 | + } |
| 174 | + |
| 175 | + public function needsToken() { |
| 176 | + return true; |
| 177 | + } |
| 178 | + |
| 179 | + public function getTokenSalt() { |
| 180 | + return ''; |
| 181 | + } |
| 182 | + |
| 183 | + protected function getExamples() { |
| 184 | + return 'api.php?action=review&revid=12345&token=123AB&flag_accuracy=1&comment=Ok'; |
| 185 | + } |
| 186 | + |
| 187 | + public function getVersion() { |
| 188 | + return __CLASS__ . ': $Id$'; |
| 189 | + } |
| 190 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/actions/ApiReview.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 191 | + Id |
Added: svn:eol-style |
2 | 192 | + native |
Index: trunk/extensions/FlaggedRevs/api/actions/ApiStabilize.php |
— | — | @@ -0,0 +1,276 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on Sep 19, 2009 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * API module to stabilize pages |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +abstract class ApiStabilize extends ApiBase { |
| 31 | + |
| 32 | + // Title param |
| 33 | + protected $title; |
| 34 | + |
| 35 | + public function execute() { |
| 36 | + global $wgUser; |
| 37 | + $params = $this->extractRequestParams(); |
| 38 | + |
| 39 | + if ( !isset( $params['title'] ) ) { |
| 40 | + $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
| 41 | + } elseif ( !isset( $params['token'] ) ) { |
| 42 | + $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
| 43 | + } |
| 44 | + |
| 45 | + $this->title = Title::newFromText( $params['title'] ); |
| 46 | + if ( $this->title == null ) { |
| 47 | + $this->dieUsage( "Invalid title given.", "invalidtitle" ); |
| 48 | + } |
| 49 | + $errors = $this->title->getUserPermissionsErrors( 'stablesettings', $wgUser ); |
| 50 | + if ( $errors ) { |
| 51 | + // We don't care about multiple errors, just report one of them |
| 52 | + $this->dieUsageMsg( reset( $errors ) ); |
| 53 | + } |
| 54 | + |
| 55 | + $this->doExecute(); // child class |
| 56 | + } |
| 57 | + |
| 58 | + public abstract function doExecute(); |
| 59 | + |
| 60 | + public function mustBePosted() { |
| 61 | + return true; |
| 62 | + } |
| 63 | + |
| 64 | + public function isWriteMode() { |
| 65 | + return true; |
| 66 | + } |
| 67 | + |
| 68 | + public function needsToken() { |
| 69 | + return true; |
| 70 | + } |
| 71 | + |
| 72 | + public function getTokenSalt() { |
| 73 | + return ''; |
| 74 | + } |
| 75 | + |
| 76 | + public function getVersion() { |
| 77 | + return __CLASS__ . ': $Id$'; |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +// Assumes $wgFlaggedRevsProtection is off |
| 82 | +class ApiStabilizeGeneral extends ApiStabilize { |
| 83 | + public function doExecute() { |
| 84 | + global $wgUser; |
| 85 | + $params = $this->extractRequestParams(); |
| 86 | + |
| 87 | + $form = new PageStabilityGeneralForm( $wgUser ); |
| 88 | + $form->setPage( $this->title ); # Our target page |
| 89 | + $form->setWatchThis( $params['watch'] ); # Watch this page |
| 90 | + $form->setReason( $params['reason'] ); # Reason |
| 91 | + $form->setReasonSelection( 'other' ); # Reason dropdown |
| 92 | + $form->setExpiry( $params['expiry'] ); # Expiry |
| 93 | + $form->setExpirySelection( 'other' ); # Expiry dropdown |
| 94 | + $restriction = $params['autoreview']; |
| 95 | + // Fill in config fields from URL params |
| 96 | + if ( $params['default'] === null ) { |
| 97 | + // Default version setting not optional |
| 98 | + $this->dieUsageMsg( array( 'missingparam', 'default' ) ); |
| 99 | + } else { |
| 100 | + $form->setOverride( $this->defaultFromKey( $params['default'] ) ); |
| 101 | + } |
| 102 | + $form->setReviewThis( $params['review'] ); # Auto-review option |
| 103 | + if ( $restriction == 'none' ) { |
| 104 | + $restriction = ''; // 'none' => '' |
| 105 | + } |
| 106 | + $form->setAutoreview( $restriction ); # Autoreview restriction |
| 107 | + $form->ready(); |
| 108 | + |
| 109 | + $status = $form->submit(); // true/error message key |
| 110 | + if ( $status !== true ) { |
| 111 | + $this->dieUsageMsg( wfMsg( $status ) ); |
| 112 | + } |
| 113 | + |
| 114 | + # Output success line with the title and config parameters |
| 115 | + $res = array(); |
| 116 | + $res['title'] = $this->title->getPrefixedText(); |
| 117 | + $res['default'] = $params['default']; |
| 118 | + $res['autoreview'] = $params['autoreview']; |
| 119 | + $res['expiry'] = $form->getExpiry(); |
| 120 | + $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
| 121 | + } |
| 122 | + |
| 123 | + protected function defaultFromKey( $key ) { |
| 124 | + if ( $key == 'stable' ) { |
| 125 | + return 1; |
| 126 | + } else if ( $key == 'latest' ) { |
| 127 | + return 0; |
| 128 | + } |
| 129 | + return null; // bad key? |
| 130 | + } |
| 131 | + |
| 132 | + public function getAllowedParams() { |
| 133 | + // Replace '' with more readable 'none' in autoreview restiction levels |
| 134 | + $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
| 135 | + $autoreviewLevels[] = 'none'; |
| 136 | + $pars = array( |
| 137 | + 'default' => array( |
| 138 | + ApiBase :: PARAM_TYPE => array( 'latest', 'stable' ), |
| 139 | + ApiBase :: PARAM_DFLT => null, |
| 140 | + ), |
| 141 | + 'autoreview' => array( |
| 142 | + ApiBase :: PARAM_TYPE => $autoreviewLevels, |
| 143 | + ApiBase :: PARAM_DFLT => 'none', |
| 144 | + ), |
| 145 | + 'expiry' => 'infinite', |
| 146 | + 'reason' => '', |
| 147 | + 'review' => false, |
| 148 | + 'watch' => null, |
| 149 | + 'token' => null, |
| 150 | + 'title' => null, |
| 151 | + ); |
| 152 | + return $pars; |
| 153 | + } |
| 154 | + |
| 155 | + public function getParamDescription() { |
| 156 | + return array( |
| 157 | + 'default' => 'Default revision to show', |
| 158 | + 'autoreview' => 'Auto-review restriction', |
| 159 | + 'expiry' => 'Expiry for these settings', |
| 160 | + 'title' => 'Title of page to be stabilized', |
| 161 | + 'reason' => 'Reason', |
| 162 | + 'review' => 'Review this page', |
| 163 | + 'watch' => 'Watch this page', |
| 164 | + 'token' => 'An edit token retrieved through prop=info' |
| 165 | + ); |
| 166 | + } |
| 167 | + |
| 168 | + public function getDescription() { |
| 169 | + return 'Change page stability settings.'; |
| 170 | + } |
| 171 | + |
| 172 | + // @TODO: fill in stabilize_* values from PageStabilityGeneralForm |
| 173 | + public function getPossibleErrors() { |
| 174 | + return array_merge( parent::getPossibleErrors(), array( |
| 175 | + array( 'missingparam', 'title' ), |
| 176 | + array( 'missingparam', 'token' ), |
| 177 | + array( 'missingparam', 'default' ), |
| 178 | + array( 'code' => 'invalidtitle', 'info' => 'Invalid title given.' ), |
| 179 | + array( 'code' => 'invalidtitle', 'info' => 'Target page does not exist.' ), |
| 180 | + array( 'code' => 'invalidtitle', 'info' => 'Title given does not correspond to a reviewable page.' ), |
| 181 | + ) ); |
| 182 | + } |
| 183 | + |
| 184 | + protected function getExamples() { |
| 185 | + return 'api.php?action=stabilize&title=Test&default=stable&reason=Test&token=123ABC'; |
| 186 | + } |
| 187 | + |
| 188 | + public function getVersion() { |
| 189 | + return __CLASS__ . ': $Id$'; |
| 190 | + } |
| 191 | +} |
| 192 | + |
| 193 | +// Assumes $wgFlaggedRevsProtection is on |
| 194 | +class ApiStabilizeProtect extends ApiStabilize { |
| 195 | + public function doExecute() { |
| 196 | + global $wgUser; |
| 197 | + $params = $this->extractRequestParams(); |
| 198 | + |
| 199 | + $form = new PageStabilityProtectForm( $wgUser ); |
| 200 | + $form->setPage( $this->title ); # Our target page |
| 201 | + $form->setWatchThis( $params['watch'] ); # Watch this page |
| 202 | + $form->setReason( $params['reason'] ); # Reason |
| 203 | + $form->setReasonSelection( 'other' ); # Reason dropdown |
| 204 | + $form->setExpiry( $params['expiry'] ); # Expiry |
| 205 | + $form->setExpirySelection( 'other' ); # Expiry dropdown |
| 206 | + $restriction = $params['protectlevel']; |
| 207 | + if ( $restriction == 'none' ) { |
| 208 | + $restriction = ''; // 'none' => '' |
| 209 | + } |
| 210 | + $form->setAutoreview( $restriction ); # Autoreview restriction |
| 211 | + $form->ready(); |
| 212 | + |
| 213 | + $status = $form->submit(); // true/error message key |
| 214 | + if ( $status !== true ) { |
| 215 | + $this->dieUsageMsg( wfMsg( $status ) ); |
| 216 | + } |
| 217 | + |
| 218 | + # Output success line with the title and config parameters |
| 219 | + $res = array(); |
| 220 | + $res['title'] = $this->title->getPrefixedText(); |
| 221 | + $res['protectlevel'] = $params['protectlevel']; |
| 222 | + $res['expiry'] = $form->getExpiry(); |
| 223 | + $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
| 224 | + } |
| 225 | + |
| 226 | + public function getAllowedParams() { |
| 227 | + // Replace '' with more readable 'none' in autoreview restiction levels |
| 228 | + $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
| 229 | + $autoreviewLevels[] = 'none'; |
| 230 | + return array( |
| 231 | + 'protectlevel' => array( |
| 232 | + ApiBase :: PARAM_TYPE => $autoreviewLevels, |
| 233 | + ApiBase :: PARAM_DFLT => 'none', |
| 234 | + ), |
| 235 | + 'expiry' => 'infinite', |
| 236 | + 'reason' => '', |
| 237 | + 'watch' => null, |
| 238 | + 'token' => null, |
| 239 | + 'title' => null, |
| 240 | + ); |
| 241 | + } |
| 242 | + |
| 243 | + public function getParamDescription() { |
| 244 | + return array( |
| 245 | + 'protectlevel' => 'The review-protection level', |
| 246 | + 'expiry' => 'Review-protection expiry', |
| 247 | + 'title' => 'Title of page to be review-protected', |
| 248 | + 'reason' => 'Reason', |
| 249 | + 'watch' => 'Watch this page', |
| 250 | + 'token' => 'An edit token retrieved through prop=info', |
| 251 | + ); |
| 252 | + } |
| 253 | + |
| 254 | + public function getDescription() { |
| 255 | + return 'Configure review-protection settings for a page'; |
| 256 | + } |
| 257 | + |
| 258 | + // @TODO: fill in stabilize_* values from PageStabilityProtectForm |
| 259 | + public function getPossibleErrors() { |
| 260 | + return array_merge( parent::getPossibleErrors(), array( |
| 261 | + array( 'missingparam', 'title' ), |
| 262 | + array( 'missingparam', 'token' ), |
| 263 | + array( 'missingparam', 'default' ), |
| 264 | + array( 'code' => 'invalidtitle', 'info' => 'Invalid title given.' ), |
| 265 | + array( 'code' => 'invalidtitle', 'info' => 'Target page does not exist.' ), |
| 266 | + array( 'code' => 'invalidtitle', 'info' => 'Title given does not correspond to a reviewable page.' ), |
| 267 | + ) ); |
| 268 | + } |
| 269 | + |
| 270 | + protected function getExamples() { |
| 271 | + return 'api.php?action=stabilize&title=Test&protectlevel=none&reason=Test&token=123ABC'; |
| 272 | + } |
| 273 | + |
| 274 | + public function getVersion() { |
| 275 | + return __CLASS__ . ': $Id$'; |
| 276 | + } |
| 277 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/actions/ApiStabilize.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 278 | + Id |
Added: svn:eol-style |
2 | 279 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiFlagConfig.php |
— | — | @@ -0,0 +1,86 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on November 6, 2009 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * API module to get flag config info |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiFlagConfig extends ApiBase { |
| 31 | + |
| 32 | + public function execute() { |
| 33 | + $this->getMain()->setCacheMode( 'public' ); |
| 34 | + $minQLTags = FlaggedRevs::quickTags( FR_QUALITY ); |
| 35 | + $minPLTags = FlaggedRevs::quickTags( FR_PRISTINE ); |
| 36 | + $data = array(); |
| 37 | + foreach ( FlaggedRevs::getDimensions() as $tag => $levels ) { |
| 38 | + $data[] = array( |
| 39 | + 'name' => $tag, |
| 40 | + 'levels' => count( $levels ) - 1, // exclude '0' level |
| 41 | + 'tier1' => 1, |
| 42 | + 'tier2' => $minQLTags[$tag], |
| 43 | + 'tier3' => $minPLTags[$tag] |
| 44 | + ); |
| 45 | + } |
| 46 | + $result = $this->getResult(); |
| 47 | + $result->setIndexedTagName( $data, 'tag' ); |
| 48 | + $result->addValue( null, $this->getModuleName(), $data ); |
| 49 | + } |
| 50 | + |
| 51 | + public function mustBePosted() { |
| 52 | + return false; |
| 53 | + } |
| 54 | + |
| 55 | + public function isWriteMode() { |
| 56 | + return false; |
| 57 | + } |
| 58 | + |
| 59 | + public function getAllowedParams() { |
| 60 | + return array(); |
| 61 | + } |
| 62 | + |
| 63 | + public function getParamDescription() { |
| 64 | + return array(); |
| 65 | + } |
| 66 | + |
| 67 | + public function getDescription() { |
| 68 | + return array( |
| 69 | + 'Get basic information about review flag configuration for this site.', |
| 70 | + 'The following parameters are returned for each tag:', |
| 71 | + '* name : The key name of this tag', |
| 72 | + '* levels : Number of levels the tag has (above "not tagged")', |
| 73 | + '* tier2 : Level the tag must reach for a revision to be tier 2 (quality)', |
| 74 | + '* tier3 : Level the tag must reach for a revision to be tier 3 (pristine)', |
| 75 | + 'Flagged revisions have an assigned level for each tag. The highest tier', |
| 76 | + 'that all the tags meet is the review tier of the entire revision.' |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + protected function getExamples() { |
| 81 | + return 'api.php?action=flagconfig'; |
| 82 | + } |
| 83 | + |
| 84 | + public function getVersion() { |
| 85 | + return __CLASS__ . ': $Id$'; |
| 86 | + } |
| 87 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiFlagConfig.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 88 | + Id |
Added: svn:eol-style |
2 | 89 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiQueryFlagged.php |
— | — | @@ -0,0 +1,89 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on Sep 17, 2008 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Query module to get flagging information about pages via 'prop=flagged' |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiQueryFlagged extends ApiQueryBase { |
| 31 | + |
| 32 | + public function execute() { |
| 33 | + $pageSet = $this->getPageSet(); |
| 34 | + $pageids = array_keys( $pageSet->getGoodTitles() ); |
| 35 | + if ( !$pageids ) { |
| 36 | + return true; |
| 37 | + } |
| 38 | + |
| 39 | + // Construct SQL Query |
| 40 | + $this->addTables( 'flaggedpages' ); |
| 41 | + $this->addFields( array( |
| 42 | + 'fp_page_id', 'fp_stable', 'fp_quality', 'fp_pending_since' |
| 43 | + ) ); |
| 44 | + $this->addWhereFld( 'fp_page_id', $pageids ); |
| 45 | + $res = $this->select( __METHOD__ ); |
| 46 | + |
| 47 | + $result = $this->getResult(); |
| 48 | + foreach( $res as $row ) { |
| 49 | + $data = array( |
| 50 | + 'stable_revid' => intval( $row->fp_stable ), |
| 51 | + 'level' => intval( $row->fp_quality ), |
| 52 | + 'level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
| 53 | + ); |
| 54 | + if ( $row->fp_pending_since ) { |
| 55 | + $data['pending_since'] = wfTimestamp( TS_ISO_8601, $row->fp_pending_since ); |
| 56 | + } |
| 57 | + $result->addValue( array( 'query', 'pages', $row->fp_page_id ), 'flagged', $data ); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + public function getCacheMode( $params ) { |
| 62 | + return 'public'; |
| 63 | + } |
| 64 | + |
| 65 | + public function getAllowedParams() { |
| 66 | + return array(); |
| 67 | + } |
| 68 | + |
| 69 | + public function getDescription() { |
| 70 | + return array( |
| 71 | + 'Get information about the flagging status of the given pages.', |
| 72 | + 'If a page is flagged, the following parameters are returned:', |
| 73 | + '* stable_revid : The revision id of the latest stable revision', |
| 74 | + '* level, level_text : The highest flagging level of the page', |
| 75 | + '* pending_since : If there are any current unreviewed revisions' |
| 76 | + . ' for that page, holds the timestamp of the first of them' |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + protected function getExamples() { |
| 81 | + return array ( |
| 82 | + 'api.php?action=query&prop=info|flagged&titles=Main%20Page', |
| 83 | + 'api.php?action=query&generator=allpages&gapfrom=K&prop=flagged' |
| 84 | + ); |
| 85 | + } |
| 86 | + |
| 87 | + public function getVersion() { |
| 88 | + return __CLASS__ . ': $Id$'; |
| 89 | + } |
| 90 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiQueryFlagged.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 91 | + Id |
Added: svn:eol-style |
2 | 92 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiQueryOldreviewedpages.php |
— | — | @@ -0,0 +1,247 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on Sep 17, 2008 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Query module to list pages with outdated review flag. |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiQueryOldreviewedpages extends ApiQueryGeneratorBase { |
| 31 | + |
| 32 | + public function __construct( $query, $moduleName ) { |
| 33 | + parent::__construct( $query, $moduleName, 'or' ); |
| 34 | + } |
| 35 | + |
| 36 | + public function execute() { |
| 37 | + $this->run(); |
| 38 | + } |
| 39 | + |
| 40 | + public function executeGenerator( $resultPageSet ) { |
| 41 | + $this->run( $resultPageSet ); |
| 42 | + } |
| 43 | + |
| 44 | + private function run( $resultPageSet = null ) { |
| 45 | + global $wgUser, $wgMemc; |
| 46 | + $params = $this->extractRequestParams(); |
| 47 | + |
| 48 | + // Construct SQL Query |
| 49 | + $this->addTables( array( 'page', 'flaggedpages', 'revision' ) ); |
| 50 | + $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
| 51 | + $useIndex = array( 'flaggedpages' => 'fp_pending_since' ); |
| 52 | + if ( $params['filterredir'] == 'redirects' ) { |
| 53 | + $this->addWhereFld( 'page_is_redirect', 1 ); |
| 54 | + } |
| 55 | + if ( $params['filterredir'] == 'nonredirects' ) { |
| 56 | + $this->addWhereFld( 'page_is_redirect', 0 ); |
| 57 | + } |
| 58 | + if ( $params['maxsize'] !== null ) { |
| 59 | + # Get absolute difference for comparison. ABS(x-y) |
| 60 | + # is broken due to mysql unsigned int design. |
| 61 | + $this->addWhere( 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= ' . |
| 62 | + intval( $params['maxsize'] ) ); |
| 63 | + } |
| 64 | + if ( $params['filterwatched'] == 'watched' ) { |
| 65 | + if ( !( $uid = $wgUser->getId() ) ) { |
| 66 | + $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
| 67 | + } |
| 68 | + $this->addTables( 'watchlist' ); |
| 69 | + $this->addWhereFld( 'wl_user', $uid ); |
| 70 | + $this->addWhere( 'page_namespace = wl_namespace' ); |
| 71 | + $this->addWhere( 'page_title = wl_title' ); |
| 72 | + } |
| 73 | + if ( $params['category'] != '' ) { |
| 74 | + $this->addTables( 'categorylinks' ); |
| 75 | + $this->addWhere( 'cl_from = fp_page_id' ); |
| 76 | + $this->addWhereFld( 'cl_to', $params['category'] ); |
| 77 | + $useIndex['categorylinks'] = 'cl_from'; |
| 78 | + } |
| 79 | + |
| 80 | + $this->addWhereRange( |
| 81 | + 'fp_pending_since', |
| 82 | + $params['dir'], |
| 83 | + $params['start'], |
| 84 | + $params['end'] |
| 85 | + ); |
| 86 | + $this->addWhere( 'page_id=fp_page_id' ); |
| 87 | + $this->addWhere( 'rev_id=fp_stable' ); |
| 88 | + if ( !isset( $params['start'] ) && !isset( $params['end'] ) ) { |
| 89 | + $this->addWhere( 'fp_pending_since IS NOT NULL' ); |
| 90 | + } |
| 91 | + $this->addOption( 'USE INDEX', $useIndex ); |
| 92 | + |
| 93 | + if ( is_null( $resultPageSet ) ) { |
| 94 | + $this->addFields( array( |
| 95 | + 'page_id', |
| 96 | + 'page_namespace', |
| 97 | + 'page_title', |
| 98 | + 'page_latest', |
| 99 | + 'page_len', |
| 100 | + 'rev_len', |
| 101 | + 'fp_stable', |
| 102 | + 'fp_pending_since', |
| 103 | + 'fp_quality' |
| 104 | + ) ); |
| 105 | + } else { |
| 106 | + $this->addFields( $resultPageSet->getPageTableFields() ); |
| 107 | + $this->addFields ( 'fp_pending_since' ); |
| 108 | + } |
| 109 | + |
| 110 | + $limit = $params['limit']; |
| 111 | + $this->addOption( 'LIMIT', $limit + 1 ); |
| 112 | + $res = $this->select( __METHOD__ ); |
| 113 | + |
| 114 | + $data = array(); |
| 115 | + $count = 0; |
| 116 | + foreach( $res as $row ) { |
| 117 | + if ( ++$count > $limit ) { |
| 118 | + // We've reached the one extra which shows that there are |
| 119 | + // additional pages to be had. Stop here... |
| 120 | + $this->setContinueEnumParameter( |
| 121 | + 'start', |
| 122 | + wfTimestamp( TS_ISO_8601, $row->fp_pending_since ) |
| 123 | + ); |
| 124 | + break; |
| 125 | + } |
| 126 | + |
| 127 | + if ( is_null( $resultPageSet ) ) { |
| 128 | + $title = Title::newFromRow( $row ); |
| 129 | + $underReview = FRUserActivity::diffIsUnderReview( |
| 130 | + $row->fp_stable, $row->page_latest ); |
| 131 | + $data[] = array( |
| 132 | + 'pageid' => intval( $row->page_id ), |
| 133 | + 'ns' => intval( $row->page_namespace ), |
| 134 | + 'title' => $title->getPrefixedText(), |
| 135 | + 'revid' => intval( $row->page_latest ), |
| 136 | + 'stable_revid' => intval( $row->fp_stable ), |
| 137 | + 'pending_since' => wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
| 138 | + 'flagged_level' => intval( $row->fp_quality ), |
| 139 | + 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ), |
| 140 | + 'diff_size' => (int)$row->page_len - (int)$row->rev_len, |
| 141 | + 'under_review' => $underReview |
| 142 | + ); |
| 143 | + } else { |
| 144 | + $resultPageSet->processDbRow( $row ); |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + if ( is_null( $resultPageSet ) ) { |
| 149 | + $result = $this->getResult(); |
| 150 | + $result->setIndexedTagName( $data, 'p' ); |
| 151 | + $result->addValue( 'query', $this->getModuleName(), $data ); |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + public function getCacheMode( $params ) { |
| 156 | + if ( $params['filterwatched'] == 'watched' ) { |
| 157 | + // Private data |
| 158 | + return 'private'; |
| 159 | + } else { |
| 160 | + return 'public'; |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + public function getAllowedParams() { |
| 165 | + $namespaces = FlaggedRevs::getReviewNamespaces(); |
| 166 | + return array( |
| 167 | + 'start' => array( |
| 168 | + ApiBase::PARAM_TYPE => 'timestamp' |
| 169 | + ), |
| 170 | + 'end' => array( |
| 171 | + ApiBase::PARAM_TYPE => 'timestamp' |
| 172 | + ), |
| 173 | + 'dir' => array( |
| 174 | + ApiBase::PARAM_DFLT => 'newer', |
| 175 | + ApiBase::PARAM_TYPE => array( 'newer', 'older' ) |
| 176 | + ), |
| 177 | + 'maxsize' => array( |
| 178 | + ApiBase::PARAM_TYPE => 'integer', |
| 179 | + ApiBase::PARAM_DFLT => null, |
| 180 | + ApiBase::PARAM_MIN => 0 |
| 181 | + ), |
| 182 | + 'filterwatched' => array( |
| 183 | + ApiBase::PARAM_DFLT => 'all', |
| 184 | + ApiBase::PARAM_TYPE => array( 'watched', 'all' ) |
| 185 | + ), |
| 186 | + 'namespace' => array( |
| 187 | + ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
| 188 | + ApiBase::PARAM_TYPE => 'namespace', |
| 189 | + ApiBase::PARAM_ISMULTI => true, |
| 190 | + ), |
| 191 | + 'category' => array( |
| 192 | + ApiBase::PARAM_TYPE => 'string' |
| 193 | + ), |
| 194 | + 'filterredir' => array( |
| 195 | + ApiBase::PARAM_DFLT => 'all', |
| 196 | + ApiBase::PARAM_TYPE => array( 'redirects', 'nonredirects', 'all' ) |
| 197 | + ), |
| 198 | + 'limit' => array( |
| 199 | + ApiBase::PARAM_DFLT => 10, |
| 200 | + ApiBase::PARAM_TYPE => 'limit', |
| 201 | + ApiBase::PARAM_MIN => 1, |
| 202 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 203 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 204 | + ) |
| 205 | + ); |
| 206 | + } |
| 207 | + |
| 208 | + public function getParamDescription() { |
| 209 | + return array( |
| 210 | + 'start' => 'Start listing at this timestamp.', |
| 211 | + 'end' => 'Stop listing at this timestamp.', |
| 212 | + 'namespace' => 'The namespaces to enumerate.', |
| 213 | + 'filterredir' => 'How to filter for redirects.', |
| 214 | + 'maxsize' => 'Maximum character count change size.', |
| 215 | + 'category' => 'Show pages only in the given category.', |
| 216 | + 'filterwatched' => 'How to filter for pages on your watchlist.', |
| 217 | + 'limit' => 'How many total pages to return.', |
| 218 | + 'dir' => array( |
| 219 | + 'In which direction to list.', |
| 220 | + '*newer: list the longest waiting pages first', |
| 221 | + '*older: list the newest items first' |
| 222 | + ) |
| 223 | + ); |
| 224 | + } |
| 225 | + |
| 226 | + public function getDescription() { |
| 227 | + return 'Enumerates pages that have changes pending review'; |
| 228 | + } |
| 229 | + |
| 230 | + public function getPossibleErrors() { |
| 231 | + return array_merge( parent::getPossibleErrors(), array( |
| 232 | + array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ), |
| 233 | + ) ); |
| 234 | + } |
| 235 | + |
| 236 | + protected function getExamples() { |
| 237 | + return array( |
| 238 | + 'Show a list of pages with pending unreviewed changes', |
| 239 | + ' api.php?action=query&list=oldreviewedpages&ornamespace=0', |
| 240 | + 'Show info about some old reviewed pages', |
| 241 | + ' api.php?action=query&generator=oldreviewedpages&gorlimit=4&prop=info', |
| 242 | + ); |
| 243 | + } |
| 244 | + |
| 245 | + public function getVersion() { |
| 246 | + return __CLASS__ . ': $Id$'; |
| 247 | + } |
| 248 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiQueryOldreviewedpages.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 249 | + Id |
Added: svn:eol-style |
2 | 250 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiQueryReviewedpages.php |
— | — | @@ -0,0 +1,205 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on June 29, 2009 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Query module to list pages reviewed pages |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiQueryReviewedpages extends ApiQueryGeneratorBase { |
| 31 | + |
| 32 | + public function __construct( $query, $moduleName ) { |
| 33 | + parent::__construct( $query, $moduleName, 'rp' ); |
| 34 | + } |
| 35 | + |
| 36 | + public function execute() { |
| 37 | + $this->run(); |
| 38 | + } |
| 39 | + |
| 40 | + public function executeGenerator( $resultPageSet ) { |
| 41 | + $this->run( $resultPageSet ); |
| 42 | + } |
| 43 | + |
| 44 | + private function run( $resultPageSet = null ) { |
| 45 | + $params = $this->extractRequestParams(); |
| 46 | + |
| 47 | + // Construct SQL Query |
| 48 | + $this->addTables( array( 'page', 'flaggedpages' ) ); |
| 49 | + $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
| 50 | + if ( $params['filterredir'] == 'redirects' ) { |
| 51 | + $this->addWhereFld( 'page_is_redirect', 1 ); |
| 52 | + } |
| 53 | + if ( $params['filterredir'] == 'nonredirects' ) { |
| 54 | + $this->addWhereFld( 'page_is_redirect', 0 ); |
| 55 | + } |
| 56 | + if ( $params['filterlevel'] !== null ) { |
| 57 | + $this->addWhereFld( 'fp_quality', $params['filterlevel'] ); |
| 58 | + } |
| 59 | + $this->addWhereRange( |
| 60 | + 'fp_page_id', |
| 61 | + $params['dir'], |
| 62 | + $params['start'], |
| 63 | + $params['end'] |
| 64 | + ); |
| 65 | + $this->addWhere( 'page_id=fp_page_id' ); |
| 66 | + $this->addOption( |
| 67 | + 'USE INDEX', |
| 68 | + array( 'flaggedpages' => 'PRIMARY' ) |
| 69 | + ); |
| 70 | + |
| 71 | + if ( is_null( $resultPageSet ) ) { |
| 72 | + $this->addFields( array ( |
| 73 | + 'page_id', |
| 74 | + 'page_namespace', |
| 75 | + 'page_title', |
| 76 | + 'page_len', |
| 77 | + 'page_latest', |
| 78 | + 'fp_page_id', |
| 79 | + 'fp_quality', |
| 80 | + 'fp_stable' |
| 81 | + ) ); |
| 82 | + } else { |
| 83 | + $this->addFields( $resultPageSet->getPageTableFields() ); |
| 84 | + $this->addFields ( 'fp_page_id' ); |
| 85 | + } |
| 86 | + |
| 87 | + $limit = $params['limit']; |
| 88 | + $this->addOption( 'LIMIT', $limit + 1 ); |
| 89 | + $res = $this->select( __METHOD__ ); |
| 90 | + |
| 91 | + $data = array (); |
| 92 | + $count = 0; |
| 93 | + foreach( $res as $row ) { |
| 94 | + if ( ++$count > $limit ) { |
| 95 | + // We've reached the one extra which shows that there are |
| 96 | + // additional pages to be had. Stop here... |
| 97 | + $this->setContinueEnumParameter( 'start', $row->fp_page_id ); |
| 98 | + break; |
| 99 | + } |
| 100 | + |
| 101 | + if ( is_null( $resultPageSet ) ) { |
| 102 | + $title = Title::newFromRow( $row ); |
| 103 | + $data[] = array( |
| 104 | + 'pageid' => intval( $row->page_id ), |
| 105 | + 'ns' => intval( $title->getNamespace() ), |
| 106 | + 'title' => $title->getPrefixedText(), |
| 107 | + 'revid' => intval( $row->page_latest ), |
| 108 | + 'stable_revid' => intval( $row->fp_stable ), |
| 109 | + 'flagged_level' => intval( $row->fp_quality ), |
| 110 | + 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
| 111 | + ); |
| 112 | + } else { |
| 113 | + $resultPageSet->processDbRow( $row ); |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + if ( is_null( $resultPageSet ) ) { |
| 118 | + $result = $this->getResult(); |
| 119 | + $result->setIndexedTagName( $data, 'p' ); |
| 120 | + $result->addValue( 'query', $this->getModuleName(), $data ); |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + public function getCacheMode( $params ) { |
| 125 | + return 'public'; |
| 126 | + } |
| 127 | + |
| 128 | + public function getAllowedParams() { |
| 129 | + $namespaces = FlaggedRevs::getReviewNamespaces(); |
| 130 | + return array ( |
| 131 | + 'start' => array ( |
| 132 | + ApiBase::PARAM_TYPE => 'integer' |
| 133 | + ), |
| 134 | + 'end' => array ( |
| 135 | + ApiBase::PARAM_TYPE => 'integer' |
| 136 | + ), |
| 137 | + 'dir' => array ( |
| 138 | + ApiBase::PARAM_DFLT => 'newer', |
| 139 | + ApiBase::PARAM_TYPE => array ( |
| 140 | + 'newer', |
| 141 | + 'older' |
| 142 | + ) |
| 143 | + ), |
| 144 | + 'namespace' => array ( |
| 145 | + ApiBase::PARAM_DFLT => !$namespaces ? |
| 146 | + NS_MAIN : $namespaces[0], |
| 147 | + ApiBase::PARAM_TYPE => 'namespace', |
| 148 | + ApiBase::PARAM_ISMULTI => true, |
| 149 | + ), |
| 150 | + 'filterredir' => array ( |
| 151 | + ApiBase::PARAM_DFLT => 'all', |
| 152 | + ApiBase::PARAM_TYPE => array ( |
| 153 | + 'redirects', |
| 154 | + 'nonredirects', |
| 155 | + 'all' |
| 156 | + ) |
| 157 | + ), |
| 158 | + 'filterlevel' => array ( |
| 159 | + ApiBase::PARAM_DFLT => null, |
| 160 | + ApiBase::PARAM_TYPE => 'integer', |
| 161 | + ApiBase::PARAM_MIN => 0, |
| 162 | + ApiBase::PARAM_MAX => 2, |
| 163 | + ), |
| 164 | + 'limit' => array ( |
| 165 | + ApiBase::PARAM_DFLT => 10, |
| 166 | + ApiBase::PARAM_TYPE => 'limit', |
| 167 | + ApiBase::PARAM_MIN => 1, |
| 168 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 169 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 170 | + ) |
| 171 | + ); |
| 172 | + } |
| 173 | + |
| 174 | + public function getParamDescription() { |
| 175 | + return array ( |
| 176 | + 'start' => 'Start listing at this page id.', |
| 177 | + 'end' => 'Stop listing at this page id.', |
| 178 | + 'namespace' => 'The namespaces to enumerate.', |
| 179 | + 'filterredir' => 'How to filter for redirects', |
| 180 | + 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
| 181 | + 'limit' => 'How many total pages to return.', |
| 182 | + 'dir' => array( |
| 183 | + 'In which direction to list.', |
| 184 | + '*newer: list the newest pages first', |
| 185 | + '*older: list the oldest pages first' |
| 186 | + ) |
| 187 | + ); |
| 188 | + } |
| 189 | + |
| 190 | + public function getDescription() { |
| 191 | + return 'Enumerates pages that have a reviewed version'; |
| 192 | + } |
| 193 | + |
| 194 | + protected function getExamples() { |
| 195 | + return array ( |
| 196 | + 'Show a list of reviewed pages', |
| 197 | + ' api.php?action=query&list=reviewedpages&rpnamespace=0&rpfilterlevel=0', |
| 198 | + 'Show info about some reviewed pages', |
| 199 | + ' api.php?action=query&generator=reviewedpages&grplimit=4&prop=info', |
| 200 | + ); |
| 201 | + } |
| 202 | + |
| 203 | + public function getVersion() { |
| 204 | + return __CLASS__ . ': $Id$'; |
| 205 | + } |
| 206 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiQueryReviewedpages.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 207 | + Id |
Added: svn:eol-style |
2 | 208 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiQueryUnreviewedpages.php |
— | — | @@ -0,0 +1,189 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on June 29, 2009 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Query module to list pages unreviewed pages |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiQueryUnreviewedpages extends ApiQueryGeneratorBase { |
| 31 | + |
| 32 | + public function __construct( $query, $moduleName ) { |
| 33 | + parent::__construct( $query, $moduleName, 'ur' ); |
| 34 | + } |
| 35 | + |
| 36 | + public function execute() { |
| 37 | + $this->run(); |
| 38 | + } |
| 39 | + |
| 40 | + public function executeGenerator( $resultPageSet ) { |
| 41 | + $this->run( $resultPageSet ); |
| 42 | + } |
| 43 | + |
| 44 | + private function run( $resultPageSet = null ) { |
| 45 | + global $wgMemc; |
| 46 | + $params = $this->extractRequestParams(); |
| 47 | + |
| 48 | + // Construct SQL Query |
| 49 | + $this->addTables( array( 'page', 'flaggedpages' ) ); |
| 50 | + $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
| 51 | + if ( $params['filterredir'] == 'redirects' ) { |
| 52 | + $this->addWhereFld( 'page_is_redirect', 1 ); |
| 53 | + } |
| 54 | + if ( $params['filterredir'] == 'nonredirects' ) { |
| 55 | + $this->addWhereFld( 'page_is_redirect', 0 ); |
| 56 | + } |
| 57 | + |
| 58 | + $this->addWhereRange( |
| 59 | + 'page_title', |
| 60 | + 'newer', |
| 61 | + $params['start'], |
| 62 | + $params['end'] |
| 63 | + ); |
| 64 | + $this->addJoinConds( |
| 65 | + array( 'flaggedpages' => array ( 'LEFT JOIN', 'fp_page_id=page_id' ) ) |
| 66 | + ); |
| 67 | + $this->addWhere( 'fp_page_id IS NULL OR |
| 68 | + fp_quality < ' . intval( $params['filterlevel'] ) ); |
| 69 | + $this->addOption( |
| 70 | + 'USE INDEX', |
| 71 | + array( 'page' => 'name_title', 'flaggedpages' => 'PRIMARY' ) |
| 72 | + ); |
| 73 | + |
| 74 | + if ( is_null( $resultPageSet ) ) { |
| 75 | + $this->addFields( array ( |
| 76 | + 'page_id', |
| 77 | + 'page_namespace', |
| 78 | + 'page_title', |
| 79 | + 'page_len', |
| 80 | + 'page_latest', |
| 81 | + ) ); |
| 82 | + } else { |
| 83 | + $this->addFields( $resultPageSet->getPageTableFields() ); |
| 84 | + } |
| 85 | + |
| 86 | + $limit = $params['limit']; |
| 87 | + $this->addOption( 'LIMIT', $limit + 1 ); |
| 88 | + $res = $this->select( __METHOD__ ); |
| 89 | + |
| 90 | + $data = array (); |
| 91 | + $count = 0; |
| 92 | + foreach( $res as $row ) { |
| 93 | + if ( ++$count > $limit ) { |
| 94 | + // We've reached the one extra which shows that there are |
| 95 | + // additional pages to be had. Stop here... |
| 96 | + $this->setContinueEnumParameter( 'start', $row->page_title ); |
| 97 | + break; |
| 98 | + } |
| 99 | + |
| 100 | + if ( is_null( $resultPageSet ) ) { |
| 101 | + $title = Title::newFromRow( $row ); |
| 102 | + $data[] = array( |
| 103 | + 'pageid' => intval( $row->page_id ), |
| 104 | + 'ns' => intval( $title->getNamespace() ), |
| 105 | + 'title' => $title->getPrefixedText(), |
| 106 | + 'revid' => intval( $row->page_latest ), |
| 107 | + 'under_review' => FRUserActivity::pageIsUnderReview( $row->page_id ) |
| 108 | + ); |
| 109 | + } else { |
| 110 | + $resultPageSet->processDbRow( $row ); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + if ( is_null( $resultPageSet ) ) { |
| 115 | + $result = $this->getResult(); |
| 116 | + $result->setIndexedTagName( $data, 'p' ); |
| 117 | + $result->addValue( 'query', $this->getModuleName(), $data ); |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + public function getCacheMode( $params ) { |
| 122 | + return 'public'; |
| 123 | + } |
| 124 | + |
| 125 | + public function getAllowedParams() { |
| 126 | + $namespaces = FlaggedRevs::getReviewNamespaces(); |
| 127 | + return array ( |
| 128 | + 'start' => array ( |
| 129 | + ApiBase::PARAM_TYPE => 'string' |
| 130 | + ), |
| 131 | + 'end' => array ( |
| 132 | + ApiBase::PARAM_TYPE => 'string' |
| 133 | + ), |
| 134 | + 'namespace' => array ( |
| 135 | + ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
| 136 | + ApiBase::PARAM_TYPE => 'namespace', |
| 137 | + ApiBase::PARAM_ISMULTI => true, |
| 138 | + ), |
| 139 | + 'filterredir' => array ( |
| 140 | + ApiBase::PARAM_DFLT => 'all', |
| 141 | + ApiBase::PARAM_TYPE => array ( |
| 142 | + 'redirects', |
| 143 | + 'nonredirects', |
| 144 | + 'all' |
| 145 | + ) |
| 146 | + ), |
| 147 | + 'filterlevel' => array ( |
| 148 | + ApiBase::PARAM_DFLT => 0, |
| 149 | + ApiBase::PARAM_TYPE => 'integer', |
| 150 | + ApiBase::PARAM_MIN => 0, |
| 151 | + ApiBase::PARAM_MAX => 2, |
| 152 | + ), |
| 153 | + 'limit' => array ( |
| 154 | + ApiBase::PARAM_DFLT => 10, |
| 155 | + ApiBase::PARAM_TYPE => 'limit', |
| 156 | + ApiBase::PARAM_MIN => 1, |
| 157 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 158 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 159 | + ) |
| 160 | + ); |
| 161 | + } |
| 162 | + |
| 163 | + public function getParamDescription() { |
| 164 | + return array ( |
| 165 | + 'start' => 'Start listing at this page title.', |
| 166 | + 'end' => 'Stop listing at this page title.', |
| 167 | + 'namespace' => 'The namespaces to enumerate.', |
| 168 | + 'filterredir' => 'How to filter for redirects', |
| 169 | + 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
| 170 | + 'limit' => 'How many total pages to return.', |
| 171 | + ); |
| 172 | + } |
| 173 | + |
| 174 | + public function getDescription() { |
| 175 | + return 'Enumerates pages that have not been reviewed to a given quality level ("filterlevel")'; |
| 176 | + } |
| 177 | + |
| 178 | + protected function getExamples() { |
| 179 | + return array ( |
| 180 | + 'Show a list of unreviewed pages', |
| 181 | + ' api.php?action=query&list=unreviewedpages&urnamespace=0&urfilterlevel=0', |
| 182 | + 'Show info about some unreviewed pages', |
| 183 | + ' api.php?action=query&generator=unreviewedpages&urnamespace=0&gurlimit=4&prop=info', |
| 184 | + ); |
| 185 | + } |
| 186 | + |
| 187 | + public function getVersion() { |
| 188 | + return __CLASS__ . ': $Id$'; |
| 189 | + } |
| 190 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiQueryUnreviewedpages.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 191 | + Id |
Added: svn:eol-style |
2 | 192 | + native |
Index: trunk/extensions/FlaggedRevs/api/reports/ApiQueryConfiguredPages.php |
— | — | @@ -0,0 +1,209 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on April 8, 2011 |
| 6 | + * |
| 7 | + * API module for MediaWiki's FlaggedRevs extension |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation; either version 2 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License along |
| 20 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | + * http://www.gnu.org/copyleft/gpl.html |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Query module to list pages with custom review configurations |
| 27 | + * |
| 28 | + * @ingroup FlaggedRevs |
| 29 | + */ |
| 30 | +class ApiQueryConfiguredpages extends ApiQueryGeneratorBase { |
| 31 | + |
| 32 | + public function __construct( $query, $moduleName ) { |
| 33 | + parent::__construct( $query, $moduleName, 'cp' ); |
| 34 | + } |
| 35 | + |
| 36 | + public function execute() { |
| 37 | + $this->run(); |
| 38 | + } |
| 39 | + |
| 40 | + public function executeGenerator( $resultPageSet ) { |
| 41 | + $this->run( $resultPageSet ); |
| 42 | + } |
| 43 | + |
| 44 | + private function run( $resultPageSet = null ) { |
| 45 | + $params = $this->extractRequestParams(); |
| 46 | + |
| 47 | + // Construct SQL Query |
| 48 | + $this->addTables( array( 'page', 'flaggedpage_config', 'flaggedpages' ) ); |
| 49 | + if ( isset( $params['namespace'] ) ) { |
| 50 | + $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
| 51 | + } |
| 52 | + if ( isset( $params['default'] ) ) { |
| 53 | + // Convert readable 'stable'/'latest' to 0/1 (DB format) |
| 54 | + $override = ( $params['default'] === 'stable' ) ? 1 : 0; |
| 55 | + $this->addWhereFld( 'fpc_override', $override ); |
| 56 | + } |
| 57 | + if ( isset( $params['autoreview'] ) ) { |
| 58 | + // Convert readable 'none' to '' (DB format) |
| 59 | + $level = ( $params['autoreview'] === 'none' ) ? '' : $params['autoreview']; |
| 60 | + $this->addWhereFld( 'fpc_level', $level ); |
| 61 | + } |
| 62 | + |
| 63 | + $this->addWhereRange( |
| 64 | + 'fpc_page_id', |
| 65 | + $params['dir'], |
| 66 | + $params['start'], |
| 67 | + $params['end'] |
| 68 | + ); |
| 69 | + $this->addJoinConds( array( |
| 70 | + 'flaggedpage_config' => array( 'INNER JOIN', 'page_id=fpc_page_id' ), |
| 71 | + 'flaggedpages' => array( 'LEFT JOIN', 'page_id=fp_page_id' ) |
| 72 | + ) ); |
| 73 | + $this->addOption( |
| 74 | + 'USE INDEX', |
| 75 | + array( 'flaggedpage_config' => 'PRIMARY' ) |
| 76 | + ); |
| 77 | + |
| 78 | + if ( is_null( $resultPageSet ) ) { |
| 79 | + $this->addFields( array( |
| 80 | + 'page_id', |
| 81 | + 'page_namespace', |
| 82 | + 'page_title', |
| 83 | + 'page_len', |
| 84 | + 'page_latest', |
| 85 | + 'fpc_page_id', |
| 86 | + 'fpc_override', |
| 87 | + 'fpc_level', |
| 88 | + 'fpc_expiry', |
| 89 | + 'fp_stable' |
| 90 | + ) ); |
| 91 | + } else { |
| 92 | + $this->addFields( $resultPageSet->getPageTableFields() ); |
| 93 | + $this->addFields( 'fpc_page_id' ); |
| 94 | + } |
| 95 | + |
| 96 | + $limit = $params['limit']; |
| 97 | + $this->addOption( 'LIMIT', $limit + 1 ); |
| 98 | + $res = $this->select( __METHOD__ ); |
| 99 | + |
| 100 | + $data = array(); |
| 101 | + $count = 0; |
| 102 | + foreach( $res as $row ) { |
| 103 | + if ( ++$count > $limit ) { |
| 104 | + // We've reached the one extra which shows that there are |
| 105 | + // additional pages to be had. Stop here... |
| 106 | + $this->setContinueEnumParameter( 'start', $row->fpc_page_id ); |
| 107 | + break; |
| 108 | + } |
| 109 | + |
| 110 | + if ( is_null( $resultPageSet ) ) { |
| 111 | + $title = Title::newFromRow( $row ); |
| 112 | + $data[] = array( |
| 113 | + 'pageid' => intval( $row->page_id ), |
| 114 | + 'ns' => intval( $row->page_namespace ), |
| 115 | + 'title' => $title->getPrefixedText(), |
| 116 | + 'last_revid' => intval( $row->page_latest ), |
| 117 | + 'stable_revid' => intval( $row->fp_stable ), |
| 118 | + 'stable_is_default' => intval( $row->fpc_override ), |
| 119 | + 'autoreview' => $row->fpc_level, |
| 120 | + 'expiry' => ( $row->fpc_expiry === 'infinity' ) ? |
| 121 | + 'infinity' : wfTimestamp( TS_ISO_8601, $row->fpc_expiry ), |
| 122 | + ); |
| 123 | + } else { |
| 124 | + $resultPageSet->processDbRow( $row ); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + if ( is_null( $resultPageSet ) ) { |
| 129 | + $result = $this->getResult(); |
| 130 | + $result->setIndexedTagName( $data, 'p' ); |
| 131 | + $result->addValue( 'query', $this->getModuleName(), $data ); |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + public function getCacheMode( $params ) { |
| 136 | + return 'public'; |
| 137 | + } |
| 138 | + |
| 139 | + public function getAllowedParams() { |
| 140 | + $namespaces = FlaggedRevs::getReviewNamespaces(); |
| 141 | + // Replace '' with more readable 'none' in autoreview restiction levels |
| 142 | + $autoreviewLevels = FlaggedRevs::getRestrictionLevels(); |
| 143 | + $autoreviewLevels[] = 'none'; |
| 144 | + return array( |
| 145 | + 'start' => array( |
| 146 | + ApiBase::PARAM_TYPE => 'integer' |
| 147 | + ), |
| 148 | + 'end' => array( |
| 149 | + ApiBase::PARAM_TYPE => 'integer' |
| 150 | + ), |
| 151 | + 'dir' => array( |
| 152 | + ApiBase::PARAM_DFLT => 'newer', |
| 153 | + ApiBase::PARAM_TYPE => array( 'newer', 'older' ) |
| 154 | + ), |
| 155 | + 'namespace' => array( |
| 156 | + ApiBase::PARAM_DFLT => null, |
| 157 | + ApiBase::PARAM_TYPE => 'namespace', |
| 158 | + ApiBase::PARAM_ISMULTI => true, |
| 159 | + ), |
| 160 | + 'default' => array( |
| 161 | + ApiBase :: PARAM_DFLT => null, |
| 162 | + ApiBase :: PARAM_TYPE => array( 'latest', 'stable' ), |
| 163 | + ), |
| 164 | + 'autoreview' => array( |
| 165 | + ApiBase :: PARAM_DFLT => null, |
| 166 | + ApiBase :: PARAM_TYPE => $autoreviewLevels, |
| 167 | + ), |
| 168 | + 'limit' => array( |
| 169 | + ApiBase::PARAM_DFLT => 10, |
| 170 | + ApiBase::PARAM_TYPE => 'limit', |
| 171 | + ApiBase::PARAM_MIN => 1, |
| 172 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 173 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 174 | + ) |
| 175 | + ); |
| 176 | + } |
| 177 | + |
| 178 | + public function getParamDescription() { |
| 179 | + return array( |
| 180 | + 'start' => 'Start listing at this page id.', |
| 181 | + 'end' => 'Stop listing at this page id.', |
| 182 | + 'namespace' => 'The namespaces to enumerate.', |
| 183 | + 'default' => 'The default page view version.', |
| 184 | + 'autoreview' => 'Review/autoreview restriction level.', |
| 185 | + 'limit' => 'How many total pages to return.', |
| 186 | + 'dir' => array( |
| 187 | + 'In which direction to list.', |
| 188 | + '*newer: list the newest pages first', |
| 189 | + '*older: list the oldest pages first' |
| 190 | + ) |
| 191 | + ); |
| 192 | + } |
| 193 | + |
| 194 | + public function getDescription() { |
| 195 | + return 'Enumerate all pages that have custom review configurations'; |
| 196 | + } |
| 197 | + |
| 198 | + protected function getExamples() { |
| 199 | + return array( |
| 200 | + 'Show a list of pages with custom review configurations', |
| 201 | + ' api.php?action=query&list=configuredpages&cpnamespace=0', |
| 202 | + 'Get some info about pages with custom review configurations', |
| 203 | + ' api.php?action=query&generator=configuredpages&gcplimit=4&prop=info', |
| 204 | + ); |
| 205 | + } |
| 206 | + |
| 207 | + public function getVersion() { |
| 208 | + return __CLASS__ . ': $Id: $'; |
| 209 | + } |
| 210 | +} |
Property changes on: trunk/extensions/FlaggedRevs/api/reports/ApiQueryConfiguredPages.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 211 | + native |