Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -8,9 +8,13 @@ |
9 | 9 | |
10 | 10 | if( !defined( 'FLAGGED_CSS' ) ) |
11 | 11 | define('FLAGGED_CSS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.css' ); |
12 | | -if( !defined( 'FLAGGED_JS' ) ) |
| 12 | +if( !defined( 'FLAGGED_JS' ) ) |
13 | 13 | define('FLAGGED_JS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.js' ); |
14 | | - |
| 14 | +if( !defined( 'FLAGGED_VIS_NORMAL' ) ) |
| 15 | + define('FLAGGED_VIS_NORMAL',0); |
| 16 | +if( !defined( 'FLAGGED_VIS_LATEST' ) ) |
| 17 | + define('FLAGGED_VIS_LATEST',1); |
| 18 | + |
15 | 19 | $wgExtensionCredits['parserhook'][] = array( |
16 | 20 | 'author' => 'Aaron Schulz', |
17 | 21 | 'name' => 'Flagged Revisions', |
— | — | @@ -38,6 +42,8 @@ |
39 | 43 | # Load unreviewed pages list |
40 | 44 | $wgSpecialPages['Unreviewedpages'] = 'Unreviewedpages'; |
41 | 45 | $wgAutoloadClasses['Unreviewedpages'] = dirname(__FILE__) . '/FlaggedRevsPage_body.php'; |
| 46 | +# Stable version config |
| 47 | +extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage_body.php', 'Stabilization', 'Stabilization' ); |
42 | 48 | |
43 | 49 | |
44 | 50 | function efLoadFlaggedRevs() { |
— | — | @@ -69,10 +75,12 @@ |
70 | 76 | # Use only our extension mechanisms |
71 | 77 | $wgGroupPermissions['sysop']['autopatrol'] = false; |
72 | 78 | $wgGroupPermissions['sysop']['patrol'] = false; |
| 79 | + # Visiblity settings |
| 80 | + $wgGroupPermissions['sysop']['stablesettings'] =true; |
73 | 81 | |
74 | 82 | ######### Hook attachments ######### |
75 | 83 | # Main hooks, overrides pages content, adds tags, sets tabs and permalink |
76 | | - $wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setCurrentTab'); |
| 84 | + $wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setActionTabs'); |
77 | 85 | # Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
78 | 86 | $wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'maybeUpdateMainCache'); |
79 | 87 | $wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'setPageContent'); |
— | — | @@ -81,12 +89,15 @@ |
82 | 90 | $wgHooks['EditPage::showEditForm:initial'][] = array($wgFlaggedArticle, 'addToEditView'); |
83 | 91 | # Add review form |
84 | 92 | $wgHooks['BeforePageDisplay'][] = array($wgFlaggedArticle, 'addReviewForm'); |
| 93 | + $wgHooks['BeforePageDisplay'][] = array($wgFlaggedArticle, 'addVisibilityLink'); |
85 | 94 | # Mark of items in page history |
86 | 95 | $wgHooks['PageHistoryLineEnding'][] = array($wgFlaggedArticle, 'addToHistLine'); |
87 | 96 | # Autopromote Editors |
88 | 97 | $wgHooks['ArticleSaveComplete'][] = array($wgFlaggedArticle, 'autoPromoteUser'); |
89 | 98 | # Adds table link references to include ones from the stable version |
90 | 99 | $wgHooks['LinksUpdateConstructed'][] = array($wgFlaggedArticle, 'extraLinksUpdate'); |
| 100 | + # Empty flagged page settings row on delete |
| 101 | + $wgHooks['ArticleDelete'][] = array($wgFlaggedArticle, 'deleteVisiblitySettings'); |
91 | 102 | # Check on undelete/merge/revisiondelete for changes to stable version |
92 | 103 | $wgHooks['ArticleUndelete'][] = array($wgFlaggedArticle, 'articleLinksUpdate2'); |
93 | 104 | $wgHooks['ArticleRevisionVisiblitySet'][] = array($wgFlaggedArticle, 'articleLinksUpdate2'); |
— | — | @@ -204,8 +215,9 @@ |
205 | 216 | $wgLogTypes[] = 'review'; |
206 | 217 | $wgLogNames['review'] = 'review-logpage'; |
207 | 218 | $wgLogHeaders['review'] = 'review-logpagetext'; |
208 | | -$wgLogActions['review/approve'] = 'review-logentrygrant'; |
209 | | -$wgLogActions['review/unapprove'] = 'review-logentryrevoke'; |
| 219 | +$wgLogActions['review/approve'] = 'review-logentry-app'; |
| 220 | +$wgLogActions['review/unapprove'] = 'review-logentry-dis'; |
| 221 | +$wgLogActions['review/config'] = 'review-logentry-conf'; |
210 | 222 | $wgLogActions['rights/erevoke'] = 'rights-editor-revoke'; |
211 | 223 | $wgLogActions['rights/egrant'] = 'rights-editor-grant'; |
212 | 224 | |
— | — | @@ -383,58 +395,109 @@ |
384 | 396 | |
385 | 397 | /** |
386 | 398 | * Get latest quality rev, if not, the latest reviewed one. |
387 | | - * @param Title $title, unused |
| 399 | + * @param Title $title, page title |
388 | 400 | * @param bool $getText, fetch fr_text and fr_flags too? |
389 | 401 | * @param bool $forUpdate, use master DB and avoid using page_ext_stable? |
390 | 402 | * @return Row |
391 | 403 | */ |
392 | | - public function getOverridingRev( $title=NULL, $getText=false, $forUpdate=false ) { |
393 | | - if( is_null($title) ) |
394 | | - return null; |
395 | | - |
| 404 | + public function getStableRev( $title, $getText=false, $forUpdate=false ) { |
| 405 | + return $this->getStablePageRev( $title, $getText, $forUpdate ); |
| 406 | + } |
| 407 | + |
| 408 | + /** |
| 409 | + * Get latest quality rev, if not, the latest reviewed one. |
| 410 | + * @param Title $title, page title |
| 411 | + * @param bool $getText, fetch fr_text and fr_flags too? |
| 412 | + * @param bool $forUpdate, use master DB and avoid using page_ext_stable? |
| 413 | + * @param bool $def, is this for the default version of a page? |
| 414 | + * @returns Row |
| 415 | + */ |
| 416 | + public function getStablePageRev( $title, $getText=false, $forUpdate=false ) { |
396 | 417 | $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp'); |
397 | 418 | if( $getText ) { |
398 | 419 | $selectColumns[] = 'fr_text'; |
399 | 420 | $selectColumns[] = 'fr_flags'; |
400 | 421 | } |
| 422 | + $row = null; |
| 423 | + // Get visiblity settings... |
| 424 | + $config = $this->getVisibilitySettings( $title, $forUpdate ); |
401 | 425 | # If we want the text, then get the text flags too |
402 | 426 | if( !$forUpdate ) { |
403 | 427 | $dbr = wfGetDB( DB_SLAVE ); |
404 | 428 | $result = $dbr->select( array('page', 'flaggedrevs', 'revision'), |
405 | 429 | $selectColumns, |
406 | | - array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), |
407 | | - 'page_ext_stable = fr_rev_id', 'fr_rev_id = rev_id', |
| 430 | + array('page_namespace' => $title->getNamespace(), |
| 431 | + 'page_title' => $title->getDBkey(), |
| 432 | + 'page_ext_stable = fr_rev_id', |
| 433 | + 'fr_rev_id = rev_id', |
408 | 434 | 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
409 | 435 | __METHOD__, |
410 | 436 | array('LIMIT' => 1) ); |
411 | 437 | if( !$row = $dbr->fetchObject($result) ) |
412 | 438 | return null; |
413 | | - |
414 | | - return $row; |
| 439 | + } else { |
| 440 | + $dbw = wfGetDB( DB_MASTER ); |
| 441 | + // Look for the latest quality revision |
| 442 | + if( $config['select'] !== FLAGGED_VIS_LATEST ) { |
| 443 | + $result = $dbw->select( array('flaggedrevs', 'revision'), |
| 444 | + $selectColumns, |
| 445 | + array('fr_namespace' => $title->getNamespace(), |
| 446 | + 'fr_title' => $title->getDBkey(), |
| 447 | + 'fr_quality >= 1', |
| 448 | + 'fr_rev_id = rev_id', |
| 449 | + 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 450 | + __METHOD__, |
| 451 | + array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
| 452 | + $row = $dbw->fetchObject($result); |
| 453 | + } |
| 454 | + // Do we have one? If not, try the latest reviewed revision... |
| 455 | + if( !$row ) { |
| 456 | + $result = $dbw->select( array('flaggedrevs', 'revision'), |
| 457 | + $selectColumns, |
| 458 | + array('fr_namespace' => $title->getNamespace(), |
| 459 | + 'fr_title' => $title->getDBkey(), |
| 460 | + 'fr_rev_id = rev_id', |
| 461 | + 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
| 462 | + __METHOD__, |
| 463 | + array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
| 464 | + if( !$row = $dbw->fetchObject($result) ) |
| 465 | + return null; |
| 466 | + } |
415 | 467 | } |
416 | | - |
417 | | - $dbw = wfGetDB( DB_MASTER ); |
418 | | - // Look for quality revision |
419 | | - $result = $dbw->select( array('flaggedrevs', 'revision'), |
420 | | - $selectColumns, |
421 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
422 | | - 'fr_quality >= 1', 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
423 | | - __METHOD__, |
424 | | - array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
425 | | - // Do we have one? If not, try any reviewed revision... |
426 | | - if( !$row = $dbw->fetchObject($result) ) { |
427 | | - $result = $dbw->select( array('flaggedrevs', 'revision'), |
428 | | - $selectColumns, |
429 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
430 | | - 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
431 | | - __METHOD__, |
432 | | - array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
433 | | - if( !$row = $dbw->fetchObject($result) ) |
434 | | - return null; |
435 | | - } |
436 | 468 | return $row; |
437 | 469 | } |
438 | 470 | |
| 471 | + /** |
| 472 | + * Get visiblity restrictions on page |
| 473 | + * @param Title $title, page title |
| 474 | + * @param bool $forUpdate, use master DB? |
| 475 | + * @returns Array |
| 476 | + */ |
| 477 | + public function getVisibilitySettings( $title, $forUpdate=false ) { |
| 478 | + return $this->getPageVisibilitySettings( $title, $forUpdate ); |
| 479 | + } |
| 480 | + |
| 481 | + /** |
| 482 | + * Get visiblity restrictions on page |
| 483 | + * @param Title $title, page title |
| 484 | + * @param bool $forUpdate, use master DB? |
| 485 | + * @returns Array |
| 486 | + */ |
| 487 | + public function getPageVisibilitySettings( $title, $forUpdate=false ) { |
| 488 | + $db = $forUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); |
| 489 | + $row = $db->selectRow( 'flaggedpages', |
| 490 | + array( 'fp_select', 'fp_override' ), |
| 491 | + array( 'fp_page_id' => $title->getArticleID() ), |
| 492 | + __METHOD__ ); |
| 493 | + if( !$row ) { |
| 494 | + global $wgFlaggedRevsOverride; |
| 495 | + // Keep this consistent across settings. 1 -> override, 0 -> don't |
| 496 | + $override = $wgFlaggedRevsOverride ? 1 : 0; |
| 497 | + return array('select' => 0, 'override' => $override); |
| 498 | + } |
| 499 | + return array('select' => $row->fp_select, 'override' => $row->fp_override); |
| 500 | + } |
| 501 | + |
439 | 502 | /** |
440 | 503 | * Get flags for a revision |
441 | 504 | * @param int $rev_id |
— | — | @@ -453,7 +516,7 @@ |
454 | 517 | array('frt_rev_id' => $rev_id), |
455 | 518 | __METHOD__ ); |
456 | 519 | # Iterate through each tag result |
457 | | - while ( $row = $db->fetchObject($result) ) { |
| 520 | + while( $row = $db->fetchObject($result) ) { |
458 | 521 | $flags[$row->frt_dimension] = $row->frt_value; |
459 | 522 | } |
460 | 523 | return $flags; |
— | — | @@ -496,8 +559,10 @@ |
497 | 560 | |
498 | 561 | $levelmarker = $level * 20 + 20; //XXX do this better |
499 | 562 | if( $prettyBox ) { |
500 | | - $tag .= "<tr><td><span class='fr-group'><span class='fr-text'>" . wfMsgHtml("revreview-$quality") . |
501 | | - "</span></td><td><span class='fr-marker fr_value$levelmarker'>$valuetext</span></span></td></tr>\n"; |
| 563 | + $tag .= "<tr><td><span class='fr-group'><span class='fr-text'>" . |
| 564 | + wfMsgHtml("revreview-$quality") . |
| 565 | + "</span></td><td><span class='fr-marker fr_value$levelmarker'>" . |
| 566 | + $valuetext . "</span></span></td></tr>\n"; |
502 | 567 | } else { |
503 | 568 | $tag .= " <span class='fr-marker-$levelmarker'><strong>" . |
504 | 569 | wfMsgHtml("revreview-$quality") . |
— | — | @@ -826,12 +891,21 @@ |
827 | 892 | public function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
828 | 893 | $dbw = wfGetDB( DB_MASTER ); |
829 | 894 | $dbw->update( 'flaggedrevs', |
830 | | - array('fr_namespace' => $newtitle->getNamespace(), 'fr_title' => $newtitle->getDBkey() ), |
831 | | - array('fr_namespace' => $oldtitle->getNamespace(), 'fr_title' => $oldtitle->getDBkey() ), |
| 895 | + array('fr_namespace' => $newtitle->getNamespace(), |
| 896 | + 'fr_title' => $newtitle->getDBkey() ), |
| 897 | + array('fr_namespace' => $oldtitle->getNamespace(), |
| 898 | + 'fr_title' => $oldtitle->getDBkey() ), |
832 | 899 | __METHOD__ ); |
833 | 900 | |
834 | 901 | return true; |
835 | 902 | } |
| 903 | + |
| 904 | + public function deleteVisiblitySettings( $article, $user, $reason ) { |
| 905 | + $dbw = wfGetDB( DB_MASTER ); |
| 906 | + $dbw->delete( 'flaggedpage_settings', |
| 907 | + array('fps_page_id' => $article->getID() ), |
| 908 | + __METHOD__ ); |
| 909 | + } |
836 | 910 | |
837 | 911 | /** |
838 | 912 | * Clears cache for a page when merges are done. |
— | — | @@ -885,7 +959,7 @@ |
886 | 960 | if( !$this->isReviewable( $linksUpdate->mTitle ) ) |
887 | 961 | return true; |
888 | 962 | # Check if this page has a stable version |
889 | | - $sv = $this->getOverridingRev( $linksUpdate->mTitle, true, true ); |
| 963 | + $sv = $this->getStableRev( $linksUpdate->mTitle, true, true ); |
890 | 964 | if( !$sv ) |
891 | 965 | return true; |
892 | 966 | # Parse the revision |
— | — | @@ -1035,7 +1109,7 @@ |
1036 | 1110 | if( !$wgReviewChangesAfterEdit || !$wgUser->isAllowed( 'review' ) ) |
1037 | 1111 | return true; |
1038 | 1112 | |
1039 | | - $frev = $this->getOverridingRev( $article->getTitle() ); |
| 1113 | + $frev = $this->getStableRev( $article->getTitle() ); |
1040 | 1114 | if( $frev ) { |
1041 | 1115 | $frev_id = $frev->fr_rev_id; |
1042 | 1116 | $extraq .= "oldid={$frev_id}&diff=cur&editreview=1"; |
— | — | @@ -1055,7 +1129,7 @@ |
1056 | 1130 | if( !$wgUser->isAllowed( 'review') || !$wgRequest->getBool('editreview') || !$NewRev->isCurrent() ) |
1057 | 1131 | return true; |
1058 | 1132 | |
1059 | | - $frev = $this->getOverridingRev( $diff->mTitle ); |
| 1133 | + $frev = $this->getStableRev( $diff->mTitle ); |
1060 | 1134 | if( !$frev || $frev->fr_rev_id != $OldRev->getID() ) |
1061 | 1135 | return true; |
1062 | 1136 | |
— | — | @@ -1091,7 +1165,7 @@ |
1092 | 1166 | $prev_id = $article->mTitle->getPreviousRevisionID( $rev->getID() ); |
1093 | 1167 | if( !$prev_id ) |
1094 | 1168 | return true; |
1095 | | - $frev = $this->getOverridingRev( $article->mTitle ); |
| 1169 | + $frev = $this->getStableRev( $article->mTitle ); |
1096 | 1170 | # Is this an edit directly to the stable version? |
1097 | 1171 | if( is_null($frev) || $prev_id != $frev->fr_rev_id ) |
1098 | 1172 | return true; |
— | — | @@ -1252,6 +1326,8 @@ |
1253 | 1327 | |
1254 | 1328 | function pageOverride() { return false; } |
1255 | 1329 | |
| 1330 | + function showStableByDefault() { return false; } |
| 1331 | + |
1256 | 1332 | function setPageContent( $article, &$outputDone, &$pcache ) {} |
1257 | 1333 | |
1258 | 1334 | function addToEditView( $editform ) {} |
— | — | @@ -1260,15 +1336,13 @@ |
1261 | 1337 | |
1262 | 1338 | function setPermaLink( $sktmp, &$nav_urls, &$revid, &$revid ) {} |
1263 | 1339 | |
1264 | | - function setCurrentTab( $sktmp, &$content_actions ) {} |
| 1340 | + function setActionTabs( $sktmp, &$content_actions ) {} |
1265 | 1341 | |
1266 | 1342 | function addToHistLine( $row, &$s ) {} |
1267 | 1343 | |
1268 | 1344 | function addQuickReview( $id=NULL, $out ) {} |
1269 | 1345 | |
1270 | | - function getLatestQualityRev() {} |
1271 | | - |
1272 | | - function getLatestStableRev() {} |
| 1346 | + function addVisibilityLink( $out ) {} |
1273 | 1347 | |
1274 | 1348 | ######### |
1275 | 1349 | |
— | — | @@ -1280,26 +1354,41 @@ |
1281 | 1355 | * for overriding by stable revisions? |
1282 | 1356 | */ |
1283 | 1357 | function pageOverride() { |
1284 | | - global $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgFlaggedRevs, |
| 1358 | + global $wgFlaggedRevsAnonOnly, $wgFlaggedRevs, |
1285 | 1359 | $wgTitle, $wgUser, $wgRequest, $action; |
1286 | 1360 | # This only applies to viewing content pages |
1287 | 1361 | if( $action !='view' || !$this->isReviewable( $wgTitle ) ) |
1288 | | - return; |
| 1362 | + return false; |
1289 | 1363 | # Does not apply to diffs/old revisions |
1290 | 1364 | if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) |
1291 | | - return; |
| 1365 | + return false; |
| 1366 | + # Get page config |
| 1367 | + $config = $wgFlaggedRevs->getVisibilitySettings( $wgTitle ); |
1292 | 1368 | # Does the stable version override the current one? |
1293 | | - if( $wgFlaggedRevsOverride ) { |
| 1369 | + if( $config['override'] ) { |
1294 | 1370 | # If $wgFlaggedRevsAnonOnly is set to false, stable version are only requested explicitly |
1295 | 1371 | if( $wgFlaggedRevsAnonOnly && $wgUser->isAnon() ) { |
1296 | | - return !( $wgRequest->getIntOrNull('stable')===0 ); |
| 1372 | + return !( $wgRequest->getIntOrNull('stable') === 0 ); |
1297 | 1373 | } else { |
1298 | | - return ( $wgRequest->getIntOrNull('stable')===1 ); |
| 1374 | + return ( $wgRequest->getIntOrNull('stable') === 1 ); |
1299 | 1375 | } |
1300 | | - } else { |
1301 | | - return !( $wgRequest->getIntOrNull('stable') !==1 ); |
| 1376 | + # We are explicity requesting the stable version? |
| 1377 | + } else if( $wgRequest->getIntOrNull('stable') === 1 ) { |
| 1378 | + return true; |
1302 | 1379 | } |
| 1380 | + return false; |
1303 | 1381 | } |
| 1382 | + |
| 1383 | + /** |
| 1384 | + * Is this user shown the stable version by default for this page? |
| 1385 | + */ |
| 1386 | + function showStableByDefault() { |
| 1387 | + global $wgFlaggedRevsOverride, $wgFlaggedRevsAnonOnly, $wgUser; |
| 1388 | + |
| 1389 | + $config = $this->getVisibilitySettings(); |
| 1390 | + |
| 1391 | + return ( $config['override'] && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ); |
| 1392 | + } |
1304 | 1393 | |
1305 | 1394 | /** |
1306 | 1395 | * Replaces a page with the last stable version if possible |
— | — | @@ -1320,9 +1409,9 @@ |
1321 | 1410 | $skin = $wgUser->getSkin(); |
1322 | 1411 | |
1323 | 1412 | $vis_id = $revid; |
1324 | | - $tag = ''; $notes = ''; |
| 1413 | + $tag = $notes = ''; |
1325 | 1414 | # Check the newest stable version... |
1326 | | - $tfrev = $this->getOverridingRev( null, true ); |
| 1415 | + $tfrev = $this->getStableRev( null, true ); |
1327 | 1416 | $simpleTag = false; |
1328 | 1417 | if( $wgRequest->getVal('diff') || $wgRequest->getVal('oldid') ) { |
1329 | 1418 | // Do not clutter up diffs any further... |
— | — | @@ -1445,7 +1534,7 @@ |
1446 | 1535 | # Set new body html text as that of now |
1447 | 1536 | $tag = ''; |
1448 | 1537 | # Check the newest stable version |
1449 | | - $tfrev = $this->getOverridingRev(); |
| 1538 | + $tfrev = $this->getStableRev(); |
1450 | 1539 | if( is_object($tfrev) ) { |
1451 | 1540 | global $wgLang, $wgUser, $wgFlaggedRevsAutoReview; |
1452 | 1541 | |
— | — | @@ -1501,7 +1590,7 @@ |
1502 | 1591 | # review a revision that parses out newer templates/images than what they saw. |
1503 | 1592 | # Revisions are always reviewed based on current templates/images. |
1504 | 1593 | if( $this->pageOverride() ) { |
1505 | | - $tfrev = $this->getOverridingRev(); |
| 1594 | + $tfrev = $this->getStableRev(); |
1506 | 1595 | if( $tfrev ) |
1507 | 1596 | return true; |
1508 | 1597 | } |
— | — | @@ -1510,12 +1599,25 @@ |
1511 | 1600 | return true; |
1512 | 1601 | } |
1513 | 1602 | |
| 1603 | + function addVisibilityLink( $out ) { |
| 1604 | + global $wgUser, $wgRequest, $action; |
| 1605 | + |
| 1606 | + if( $action=='protect' || $action=='unprotect' ) { |
| 1607 | + $title = SpecialPage::getTitleFor( 'Stabilization' ); |
| 1608 | + # Give a link to the page to configure the stable version |
| 1609 | + $out->mBodytext = '<span class="plainlinks">' . |
| 1610 | + wfMsgExt( 'revreview-visibility',array('parseinline'), $title->getPrefixedText() ) . |
| 1611 | + '</span>' . $out->mBodytext; |
| 1612 | + } |
| 1613 | + return true; |
| 1614 | + } |
| 1615 | + |
1514 | 1616 | function setPermaLink( $sktmp, &$nav_urls, &$revid, &$revid ) { |
1515 | 1617 | # Non-content pages cannot be validated |
1516 | 1618 | if( !$this->pageOverride() ) |
1517 | 1619 | return true; |
1518 | 1620 | # Check for an overridabe revision |
1519 | | - $tfrev = $this->getOverridingRev(); |
| 1621 | + $tfrev = $this->getStableRev(); |
1520 | 1622 | if( !$tfrev ) |
1521 | 1623 | return true; |
1522 | 1624 | # Replace "permalink" with an actual permanent link |
— | — | @@ -1536,23 +1638,23 @@ |
1537 | 1639 | return true; |
1538 | 1640 | } |
1539 | 1641 | |
1540 | | - function setCurrentTab( $sktmp, &$content_actions ) { |
1541 | | - global $wgRequest, $wgUser, $action, $wgFlaggedRevsAnonOnly, |
1542 | | - $wgFlaggedRevsOverride, $wgFlaggedRevTabs; |
| 1642 | + function setActionTabs( $sktmp, &$content_actions ) { |
| 1643 | + global $wgRequest, $wgUser, $action, $wgFlaggedRevsAnonOnly, $wgFlaggedRevTabs; |
1543 | 1644 | # Get the subject page, not all skins have it :( |
1544 | 1645 | if( !isset($sktmp->mTitle) ) |
1545 | 1646 | return true; |
1546 | 1647 | $title = $sktmp->mTitle->getSubjectPage(); |
1547 | 1648 | # Non-content pages cannot be validated |
1548 | | - if( !$this->isReviewable( $title ) || !$title->exists() ) |
| 1649 | + if( !$this->isReviewable( $title ) || !$title->exists() ) |
1549 | 1650 | return true; |
1550 | 1651 | $article = new Article( $title ); |
1551 | 1652 | # If we are viewing a page normally, and it was overridden, |
1552 | 1653 | # change the edit tab to a "current revision" tab |
1553 | | - $tfrev = $this->getOverridingRev(); |
| 1654 | + $tfrev = $this->getStableRev(); |
1554 | 1655 | # No quality revs? Find the last reviewed one |
1555 | | - if( !is_object($tfrev) ) |
| 1656 | + if( !is_object($tfrev) ) { |
1556 | 1657 | return true; |
| 1658 | + } |
1557 | 1659 | /* |
1558 | 1660 | // If the stable version is the same is the current, move along... |
1559 | 1661 | if( $article->getLatest() == $tfrev->fr_rev_id ) { |
— | — | @@ -1560,32 +1662,28 @@ |
1561 | 1663 | } |
1562 | 1664 | */ |
1563 | 1665 | # Be clear about what is being edited... |
1564 | | - if( !$sktmp->mTitle->isTalkPage() && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 1666 | + if( !$sktmp->mTitle->isTalkPage() && $this->showStableByDefault() ) { |
1565 | 1667 | if( isset( $content_actions['edit'] ) ) |
1566 | 1668 | $content_actions['edit']['text'] = wfMsg('revreview-edit'); |
1567 | 1669 | if( isset( $content_actions['viewsource'] ) ) |
1568 | 1670 | $content_actions['viewsource']['text'] = wfMsg('revreview-source'); |
1569 | 1671 | } |
1570 | | - |
1571 | 1672 | if( !$wgFlaggedRevTabs ) { |
1572 | 1673 | return true; |
1573 | 1674 | } |
1574 | 1675 | // We are looking at the stable version |
1575 | 1676 | if( $this->pageOverride() ) { |
1576 | 1677 | $new_actions = array(); $counter = 0; |
1577 | | - # Straighten out order |
| 1678 | + # Straighten out order, set the tab AFTER the main tab is set |
1578 | 1679 | foreach( $content_actions as $tab_action => $data ) { |
1579 | 1680 | if( $counter==1 ) { |
1580 | | - # Set the tab AFTER the main tab is set |
1581 | | - if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 1681 | + if( $this->showStableByDefault() ) { |
1582 | 1682 | $new_actions['current'] = array( |
1583 | 1683 | 'class' => '', |
1584 | 1684 | 'text' => wfMsg('revreview-current'), |
1585 | 1685 | 'href' => $title->getLocalUrl( 'stable=0' ) |
1586 | 1686 | ); |
1587 | 1687 | } else { |
1588 | | - # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
1589 | | - # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
1590 | 1688 | $new_actions['stable'] = array( |
1591 | 1689 | 'class' => 'selected', |
1592 | 1690 | 'text' => wfMsg('revreview-stable'), |
— | — | @@ -1598,22 +1696,19 @@ |
1599 | 1697 | } |
1600 | 1698 | # Reset static array |
1601 | 1699 | $content_actions = $new_actions; |
1602 | | - } else if( $action !='view' || $wgRequest->getVal('oldid') || $sktmp->mTitle->isTalkPage() ) { |
1603 | | - // We are looking at the talk page or diffs/hist/oldids |
| 1700 | + } else if( $action !='view' || $sktmp->mTitle->isTalkPage() ) { |
| 1701 | + // We are looking at the talk page or diffs/hist/oldids, or in edit mode |
1604 | 1702 | $new_actions = array(); $counter = 0; |
1605 | | - # Straighten out order |
| 1703 | + # Straighten out order, set the tab AFTER the main tab is set |
1606 | 1704 | foreach( $content_actions as $tab_action => $data ) { |
1607 | 1705 | if( $counter==1 ) { |
1608 | | - # Set the tab AFTER the main tab is set |
1609 | | - if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 1706 | + if( $this->showStableByDefault() ) { |
1610 | 1707 | $new_actions['current'] = array( |
1611 | 1708 | 'class' => '', |
1612 | 1709 | 'text' => wfMsg('revreview-current'), |
1613 | 1710 | 'href' => $title->getLocalUrl( 'stable=0' ) |
1614 | 1711 | ); |
1615 | 1712 | } else { |
1616 | | - # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
1617 | | - # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
1618 | 1713 | $new_actions['stable'] = array( |
1619 | 1714 | 'class' => '', |
1620 | 1715 | 'text' => wfMsg('revreview-stable'), |
— | — | @@ -1629,19 +1724,16 @@ |
1630 | 1725 | } else if( $wgFlaggedRevTabs ) { |
1631 | 1726 | // We are looking at the current revision |
1632 | 1727 | $new_actions = array(); $counter = 0; |
1633 | | - # Straighten out order |
| 1728 | + # Straighten out order, set the tab AFTER the main tab is set |
1634 | 1729 | foreach( $content_actions as $tab_action => $data ) { |
1635 | 1730 | if( $counter==1 ) { |
1636 | | - # Set the tab AFTER the main tab is set |
1637 | | - if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 1731 | + if( $this->showStableByDefault() ) { |
1638 | 1732 | $new_actions['current'] = array( |
1639 | 1733 | 'class' => 'selected', |
1640 | 1734 | 'text' => wfMsg('revreview-current'), |
1641 | 1735 | 'href' => $title->getLocalUrl( 'stable=0' ) |
1642 | 1736 | ); |
1643 | 1737 | } else { |
1644 | | - # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
1645 | | - # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
1646 | 1738 | $new_actions['stable'] = array( |
1647 | 1739 | 'class' => '', |
1648 | 1740 | 'text' => wfMsg('revreview-stable'), |
— | — | @@ -1690,8 +1782,8 @@ |
1691 | 1783 | } |
1692 | 1784 | |
1693 | 1785 | function addQuickReview( $id=NULL, $out, $top=false ) { |
1694 | | - global $wgOut, $wgTitle, $wgUser, $wgRequest, |
1695 | | - $wgFlaggedRevsOverride, $wgFlaggedRevComments, $wgFlaggedRevsWatch; |
| 1786 | + global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgFlaggedRevComments, |
| 1787 | + $wgFlaggedRevsWatch; |
1696 | 1788 | # User must have review rights |
1697 | 1789 | if( !$wgUser->isAllowed( 'review' ) ) |
1698 | 1790 | return; |
— | — | @@ -1798,135 +1890,50 @@ |
1799 | 1891 | * Same params for the sake of inheritance |
1800 | 1892 | * @return Row |
1801 | 1893 | */ |
1802 | | - function getOverridingRev( $title = NULL, $getText=false, $forUpdate=false ) { |
1803 | | - global $wgTitle; |
| 1894 | + function getStableRev( $t=null, $getText=false, $forUpdate=false ) { |
| 1895 | + global $wgTitle, $wgFlaggedRevs; |
| 1896 | + # Cached results available? |
| 1897 | + if( $getText ) { |
| 1898 | + if( isset($this->stablerev) && isset($this->stablerev->fr_text) ) { |
| 1899 | + return $this->stablerev; |
| 1900 | + } |
| 1901 | + } else { |
| 1902 | + if( isset($this->stablerev) ) { |
| 1903 | + return $this->stablerev; |
| 1904 | + } |
| 1905 | + } |
1804 | 1906 | # Get the content page, skip talk |
1805 | 1907 | $title = $wgTitle->getSubjectPage(); |
1806 | | - |
1807 | | - if( !$forUpdate ) { |
1808 | | - if( !$row = $this->getLatestQualityRev( $getText ) ) { |
1809 | | - if( !$row = $this->getLatestStableRev( $getText ) ) { |
1810 | | - $this->stablefound = false; |
1811 | | - return null; |
1812 | | - } |
1813 | | - } |
1814 | | - $this->stablefound = true; |
1815 | | - $this->stablerev = $row; |
1816 | | - return $row; |
1817 | | - } |
1818 | | - # Cached results available? |
1819 | | - if( isset($this->stablefound) ) { |
1820 | | - return ( $this->stablefound ) ? $this->stablerev : null; |
1821 | | - } |
1822 | | - |
1823 | | - $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp'); |
1824 | | - if( $getText ) { |
1825 | | - $selectColumns[] = 'fr_text'; |
1826 | | - $selectColumns[] = 'fr_flags'; |
1827 | | - } |
1828 | | - |
1829 | | - $dbw = wfGetDB( DB_MASTER ); |
1830 | | - $result = $dbw->select( array('page', 'flaggedrevs', 'revision'), |
1831 | | - $selectColumns, |
1832 | | - array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), |
1833 | | - 'page_ext_stable = fr_rev_id', 'fr_rev_id = rev_id', |
1834 | | - 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
1835 | | - __METHOD__, |
1836 | | - array('LIMIT' => 1) ); |
1837 | 1908 | # Do we have one? |
1838 | | - if( $row = $dbw->fetchObject($result) ) { |
1839 | | - $this->stablefound = true; |
| 1909 | + $row = $this->getStablePageRev( $title, $getText, $forUpdate ); |
| 1910 | + if( $row ) { |
1840 | 1911 | $this->stablerev = $row; |
1841 | 1912 | return $row; |
1842 | 1913 | } else { |
1843 | | - $this->stablefound = false; |
| 1914 | + $this->stablerev = null; |
1844 | 1915 | return null; |
1845 | 1916 | } |
1846 | | - |
1847 | | - return $row; |
1848 | 1917 | } |
1849 | | - |
1850 | | - /** |
1851 | | - * Get latest flagged revision that meets requirments |
1852 | | - * per the $wgFlaggedRevTags variable |
1853 | | - * This passes rev_deleted revisions |
1854 | | - * This is based on the current article and caches results |
1855 | | - * @output array ( rev, flags ) |
1856 | | - */ |
1857 | | - function getLatestQualityRev( $getText=false ) { |
1858 | | - global $wgTitle; |
1859 | | - # Get the content page, skip talk |
1860 | | - $title = $wgTitle->getSubjectPage(); |
| 1918 | + |
| 1919 | + /** |
| 1920 | + * Get visiblity restrictions on page |
| 1921 | + * Same params for the sake of inheritance |
| 1922 | + * @returns Array |
| 1923 | + */ |
| 1924 | + public function getVisibilitySettings( $t=null, $forUpdate=false ) { |
| 1925 | + global $wgTitle; |
1861 | 1926 | # Cached results available? |
1862 | | - if( isset($this->qualityfound) ) { |
1863 | | - return ( $this->qualityfound ) ? $this->qualityrev : null; |
| 1927 | + if( isset($this->pageconfig) ) { |
| 1928 | + return $this->pageconfig; |
1864 | 1929 | } |
1865 | | - |
1866 | | - $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp'); |
1867 | | - if( $getText ) { |
1868 | | - $selectColumns[] = 'fr_text'; |
1869 | | - $selectColumns[] = 'fr_flags'; |
1870 | | - } |
1871 | | - |
1872 | | - $dbr = wfGetDB( DB_SLAVE ); |
1873 | | - $result = $dbr->select( array('flaggedrevs', 'revision'), |
1874 | | - $selectColumns, |
1875 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), 'fr_quality >= 1', |
1876 | | - 'fr_rev_id = rev_id', 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
1877 | | - __METHOD__, |
1878 | | - array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
1879 | | - |
1880 | | - // Do we have one? |
1881 | | - if( $row = $dbr->fetchObject($result) ) { |
1882 | | - $this->qualityfound = true; |
1883 | | - $this->qualityrev = $row; |
1884 | | - return $row; |
1885 | | - } else { |
1886 | | - $this->qualityfound = false; |
1887 | | - return null; |
1888 | | - } |
1889 | | - } |
1890 | | - |
1891 | | - /** |
1892 | | - * Get latest flagged revision |
1893 | | - * This passes rev_deleted revisions |
1894 | | - * This is based on the current article and caches results |
1895 | | - * The cache here doesn't make sense for arbitrary articles |
1896 | | - * @output array ( rev, flags ) |
1897 | | - */ |
1898 | | - function getLatestStableRev( $getText=false ) { |
1899 | | - global $wgTitle; |
1900 | 1930 | # Get the content page, skip talk |
1901 | 1931 | $title = $wgTitle->getSubjectPage(); |
1902 | | - # Cached results available? |
1903 | | - if( isset($this->latestfound) ) { |
1904 | | - return ( $this->latestfound ) ? $this->latestrev : NULL; |
1905 | | - } |
1906 | 1932 | |
1907 | | - $selectColumns = array('fr_rev_id','fr_user','fr_timestamp','fr_comment','rev_timestamp'); |
1908 | | - if( $getText ) { |
1909 | | - $selectColumns[] = 'fr_text'; |
1910 | | - $selectColumns[] = 'fr_flags'; |
1911 | | - } |
| 1933 | + $config = $this->getPageVisibilitySettings( $title, $forUpdate ); |
| 1934 | + $this->pageconfig = $config; |
1912 | 1935 | |
1913 | | - $dbr = wfGetDB( DB_SLAVE ); |
1914 | | - $result = $dbr->select( array('flaggedrevs', 'revision'), |
1915 | | - $selectColumns, |
1916 | | - array('fr_namespace' => $title->getNamespace(), 'fr_title' => $title->getDBkey(), |
1917 | | - 'fr_rev_id = rev_id', 'rev_page' => $title->getArticleID(), |
1918 | | - 'rev_deleted & '.Revision::DELETED_TEXT.' = 0'), |
1919 | | - __METHOD__, |
1920 | | - array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1) ); |
1921 | | - # Do we have one? |
1922 | | - if( $row = $dbr->fetchObject($result) ) { |
1923 | | - $this->latestfound = true; |
1924 | | - $this->latestrev = $row; |
1925 | | - return $row; |
1926 | | - } else { |
1927 | | - $this->latestfound = false; |
1928 | | - return null; |
1929 | | - } |
1930 | | - } |
| 1936 | + return $config; |
| 1937 | + } |
1931 | 1938 | |
1932 | 1939 | /** |
1933 | 1940 | * @param int $rev_id |
— | — | @@ -1960,5 +1967,3 @@ |
1961 | 1968 | } |
1962 | 1969 | |
1963 | 1970 | } |
1964 | | - |
1965 | | - |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql |
— | — | @@ -19,13 +19,26 @@ |
20 | 20 | fr_text mediumblob NOT NULL default '', |
21 | 21 | -- Comma-separated list of flags: |
22 | 22 | -- gzip: text is compressed with PHP's gzdeflate() function. |
| 23 | + -- utf8: in UTF-8 |
23 | 24 | fr_flags tinyblob NOT NULL, |
24 | 25 | |
25 | 26 | PRIMARY KEY (fr_namespace,fr_title,fr_rev_id), |
26 | | - UNIQUE KEY (fr_rev_id), |
27 | | - INDEX namespace_title_qal_rev (fr_namespace,fr_title,fr_quality,fr_rev_id) |
| 27 | + UNIQUE KEY (fr_rev_id) |
28 | 28 | ) TYPE=InnoDB; |
29 | 29 | |
| 30 | +-- This stores settings on how to select the default revision |
| 31 | +CREATE TABLE /*$wgDBprefix*/flaggedpages ( |
| 32 | + fp_page_id int(10) NOT NULL, |
| 33 | + -- Integers to represent what to show by default: |
| 34 | + -- 0: quality -> stable -> current |
| 35 | + -- 1: latest reviewed |
| 36 | + fp_select int(10) NOT NULL, |
| 37 | + -- Override the page? |
| 38 | + fp_override bool NOT NULL, |
| 39 | + |
| 40 | + PRIMARY KEY (fps_page_id) |
| 41 | +) TYPE=InnoDB; |
| 42 | + |
30 | 43 | -- This stores all of our tag data |
31 | 44 | -- These are attached to specific flagged revisions |
32 | 45 | CREATE TABLE /*$wgDBprefix*/flaggedrevtags ( |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php |
— | — | @@ -537,13 +537,12 @@ |
538 | 538 | global $wgOut, $wgTitle, $wgScript; |
539 | 539 | |
540 | 540 | $encPage = str_replace( '_', ' ', $this->target ); |
541 | | - $encId = $this->oldid; |
542 | 541 | |
543 | 542 | $form = "<form name='stableversions' action='$wgScript' method='get'>"; |
544 | 543 | $form .= "<fieldset><legend>".wfMsg('stableversions-leg1')."</legend>"; |
545 | 544 | $form .= "<table><tr>"; |
546 | 545 | $form .= "<td>".Xml::hidden( 'title', $wgTitle->getPrefixedText() )."</td>"; |
547 | | - $form .= "<td>".wfMsgHtml("stableversions-page").":</td>"; |
| 546 | + $form .= "<td>".wfMsgHtml("stableversions-page")."</td>"; |
548 | 547 | $form .= "<td>".Xml::input('page', 40, $encPage, array( 'id' => 'page' ) )."</td>"; |
549 | 548 | $form .= "<td>".wfSubmitButton( wfMsgHtml( 'go' ) )."</td>"; |
550 | 549 | $form .= "</tr></table>"; |
— | — | @@ -836,3 +835,171 @@ |
837 | 836 | return( "{$link} {$stxt} {$review}" ); |
838 | 837 | } |
839 | 838 | } |
| 839 | + |
| 840 | +class Stabilization extends SpecialPage |
| 841 | +{ |
| 842 | + |
| 843 | + function Stabilization() { |
| 844 | + SpecialPage::SpecialPage('Stabilization','stablesettings'); |
| 845 | + } |
| 846 | + |
| 847 | + function execute( $par ) { |
| 848 | + global $wgRequest, $wgUser, $wgOut; |
| 849 | + |
| 850 | + $confirm = $wgRequest->wasPosted() && |
| 851 | + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
| 852 | + $this->isAllowed = $wgUser->isAllowed( 'stablesettings' ); |
| 853 | + # Let anyone view, but not submit... |
| 854 | + if( $wgRequest->wasPosted() ) { |
| 855 | + if( $wgUser->isBlocked( !$confirm ) ) { |
| 856 | + $wgOut->blockedPage(); |
| 857 | + return; |
| 858 | + } else if( !$this->isAllowed ) { |
| 859 | + $wgOut->permissionRequired( 'stablesettings' ); |
| 860 | + return; |
| 861 | + } else if( wfReadOnly() ) { |
| 862 | + $wgOut->readOnlyPage(); |
| 863 | + return; |
| 864 | + } |
| 865 | + } |
| 866 | + |
| 867 | + $this->setHeaders(); |
| 868 | + $this->skin = $wgUser->getSkin(); |
| 869 | + # Our target page |
| 870 | + $this->target = $wgRequest->getText( 'page' ); |
| 871 | + $this->page = Title::newFromUrl( $this->target ); |
| 872 | + # Params |
| 873 | + $this->select = $wgRequest->getInt( 'select' ); |
| 874 | + $this->override = intval( $wgRequest->getBool( 'override' ) ); |
| 875 | + $this->comment = $wgRequest->getVal( 'wpReason' ); |
| 876 | + |
| 877 | + $this->showForm( $wgRequest ); |
| 878 | + # Only 0 or 1 |
| 879 | + if( $this->select && ($this->select !==0 && $this->select !==1) ) { |
| 880 | + return; |
| 881 | + } |
| 882 | + # We need a page... |
| 883 | + if( is_null($this->page) ) { |
| 884 | + return; |
| 885 | + } |
| 886 | + # And it must actually be there... |
| 887 | + if( !$this->page->exists() ) { |
| 888 | + $wgOut->addHTML( wfMsgExt( 'stabilization-dne', array('parseinline'), |
| 889 | + $this->page->getPrefixedText() ) ); |
| 890 | + return; |
| 891 | + } |
| 892 | + |
| 893 | + if( $confirm ) { |
| 894 | + $this->submit(); |
| 895 | + } else { |
| 896 | + $this->showSettings( $wgRequest ); |
| 897 | + } |
| 898 | + } |
| 899 | + |
| 900 | + function showForm( $wgRequest ) { |
| 901 | + global $wgOut, $wgTitle, $wgScript; |
| 902 | + |
| 903 | + $encPage = str_replace( '_', ' ', $this->target ); |
| 904 | + $form = "<form name='stabilization' action='$wgScript' method='get'>"; |
| 905 | + $form .= "<fieldset><legend>".wfMsg('stabilization-leg')."</legend>"; |
| 906 | + $form .= "<table><tr>"; |
| 907 | + $form .= "<td>".Xml::hidden( 'title', $wgTitle->getPrefixedText() )."</td>"; |
| 908 | + $form .= "<td>".wfMsgHtml("stabilization-page")."</td>"; |
| 909 | + $form .= "<td>".Xml::input('page', 40, $encPage, array( 'id' => 'page' ) )."</td>"; |
| 910 | + $form .= "<td>".wfSubmitButton( wfMsgHtml( 'go' ) )."</td>"; |
| 911 | + $form .= "</tr></table>"; |
| 912 | + $form .= "</fieldset></form>\n"; |
| 913 | + |
| 914 | + $wgOut->addHTML( $form ); |
| 915 | + } |
| 916 | + |
| 917 | + function showSettings() { |
| 918 | + global $wgOut, $wgScript, $wgTitle, $wgUser, $wgFlaggedRevs; |
| 919 | + // Must be a content page |
| 920 | + if( !$wgFlaggedRevs->isReviewable( $this->page ) ) { |
| 921 | + $wgOut->addHTML( wfMsgExt('stableversions-none', array('parse'), |
| 922 | + $this->page->getPrefixedText() ) ); |
| 923 | + return; |
| 924 | + } |
| 925 | + // Get visiblity settings... |
| 926 | + $config = $wgFlaggedRevs->getVisibilitySettings( $this->page, true ); |
| 927 | + $encselect = $this->select ? $this->select : $config['select']; |
| 928 | + $encoverride = $this->override ? $this->override : $config['override']; |
| 929 | + |
| 930 | + if( !$this->isAllowed ) { |
| 931 | + $form = '<p>'.wfMsgExt( 'stabilization-perm', array('parse'), $this->page->getPrefixedText() ).'</p>'; |
| 932 | + $off = array('disabled' => 'true'); |
| 933 | + } else { |
| 934 | + $form = wfMsgExt( 'stabilization-text', array('parse'), $this->page->getPrefixedText() ); |
| 935 | + $off = array(); |
| 936 | + } |
| 937 | + |
| 938 | + $form .= "<form name='stabilization' action='$wgScript' method='post'>"; |
| 939 | + $form .= "<fieldset><legend>".wfMsg('stabilization-select')."</legend>"; |
| 940 | + $form .= "<table><tr>"; |
| 941 | + |
| 942 | + $form .= "<td>".Xml::radio( 'select', 0, (0==$encselect), array('id' => 'select1') + $off )."</td>"; |
| 943 | + $form .= "<td>".Xml::label( wfMsg('stabilization-select1'), 'select1' )."</td>"; |
| 944 | + $form .= "</tr><tr>"; |
| 945 | + $form .= "<td>".Xml::radio( 'select', 1, (1==$encselect), array('id' => 'select2') + $off )."</td>"; |
| 946 | + $form .= "<td>".Xml::label( wfMsg('stabilization-select2'), 'select2' )."</td>"; |
| 947 | + $form .= "</tr></table></fieldset>"; |
| 948 | + |
| 949 | + $form .= "<fieldset><legend>".wfMsg('stabilization-def')."</legend>"; |
| 950 | + $form .= "<table><tr>"; |
| 951 | + $form .= "<td>".Xml::radio( 'override', 1, (1==$encoverride), array('id' => 'default1') + $off)."</td>"; |
| 952 | + $form .= "<td>".Xml::label( wfMsg('stabilization-def1'), 'default1' )."</td>"; |
| 953 | + $form .= "</tr><tr>"; |
| 954 | + $form .= "<td>".Xml::radio( 'override', 0, (0==$encoverride), array('id' => 'default2') + $off)."</td>"; |
| 955 | + $form .= "<td>".Xml::label( wfMsg('stabilization-def2'), 'default2' )."</td>"; |
| 956 | + $form .= "</tr></table></fieldset>"; |
| 957 | + |
| 958 | + $form .= Xml::hidden('title', $wgTitle->getPrefixedText() ); |
| 959 | + $form .= Xml::hidden('page', $this->page->getPrefixedText() ); |
| 960 | + $form .= wfHidden( 'wpEditToken', $wgUser->editToken() ); |
| 961 | + |
| 962 | + $form .= '<p>'.wfInputLabel( wfMsgHtml( 'revreview-log' ), 'wpReason', 'wpReason', 60 ).'</p>'; |
| 963 | + $form .= wfSubmitButton( wfMsgHtml( 'stabilization-submit' ) ); |
| 964 | + $form .= '</form>'; |
| 965 | + |
| 966 | + $wgOut->addHTML( $form ); |
| 967 | + } |
| 968 | + |
| 969 | + function submit() { |
| 970 | + global $wgOut, $wgFlaggedRevs; |
| 971 | + # Get current config |
| 972 | + $config = $wgFlaggedRevs->getVisibilitySettings( $this->page, true ); |
| 973 | + |
| 974 | + $comment = $this->comment; |
| 975 | + |
| 976 | + $dbw = wfGetDB( DB_MASTER ); |
| 977 | + $success = $dbw->replace( 'flaggedpages', |
| 978 | + array( 'fp_page_id' ), |
| 979 | + array( 'fp_page_id' => $this->page->getArticleID(), |
| 980 | + 'fp_select' => $this->select, |
| 981 | + 'fp_override' => $this->override ), |
| 982 | + __METHOD__ ); |
| 983 | + |
| 984 | + $wgOut->addHTML( wfMsgExt('stabilization-success',array('parse'), |
| 985 | + $this->page->getPrefixedText() ) ); |
| 986 | + # Log if changed |
| 987 | + if( $config['select'] != $this->select || $config['override'] != $this->override ) { |
| 988 | + $log = new LogPage( 'review' ); |
| 989 | + // ID, accuracy, depth, style |
| 990 | + $set = array(); |
| 991 | + $set[] = wfMsg( "stabilization-sel-short" ) . ": " . |
| 992 | + wfMsg("stabilization-sel-short-{$this->select}"); |
| 993 | + $set[] = wfMsg( "stabilization-def-short" ) . ": " . |
| 994 | + wfMsg("stabilization-def-short-{$this->override}"); |
| 995 | + |
| 996 | + $settings = ' [' . implode(', ',$set). ']'; |
| 997 | + // Append comment with action |
| 998 | + // FIXME: do this better |
| 999 | + $comment = ($comment) ? "$comment$settings" : "$settings"; |
| 1000 | + |
| 1001 | + $log->addEntry( 'config', $this->page, $comment ); |
| 1002 | + } |
| 1003 | + // Update the page rows and the stable version |
| 1004 | + $wgFlaggedRevs->articleLinksUpdate2( $this->page ); |
| 1005 | + } |
| 1006 | +} |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
— | — | @@ -61,13 +61,14 @@ |
62 | 62 | 'hist-stable' => '[sighted]', |
63 | 63 | 'hist-quality' => '[quality]', |
64 | 64 | |
65 | | - 'flaggedrevs' => 'Flagged Revisions', |
66 | | - 'review-logpage' => 'Article review log', |
67 | | - 'review-logpagetext' => 'This is a log of changes to revisions\' [[Help:Article validation|approval]] status |
| 65 | + 'flaggedrevs' => 'Flagged Revisions', |
| 66 | + 'review-logpage' => 'Article review log', |
| 67 | + 'review-logpagetext' => 'This is a log of changes to revisions\' [[Help:Article validation|approval]] status |
68 | 68 | for content pages.', |
69 | | - 'review-logentrygrant' => 'reviewed $1', |
70 | | - 'review-logentryrevoke' => 'depreciated a version of $1', |
71 | | - 'review-logaction' => 'revision ID $1', |
| 69 | + 'review-logentry-app' => 'reviewed $1', |
| 70 | + 'review-logentry-dis' => 'depreciated a version of $1', |
| 71 | + 'review-logentry-conf' => 'set stable version settings for $1', |
| 72 | + 'review-logaction' => 'revision ID $1', |
72 | 73 | |
73 | 74 | 'revisionreview' => 'Review revisions', |
74 | 75 | 'revreview-main' => 'You must select a particular revision from a content page in order to review. |
— | — | @@ -108,7 +109,7 @@ |
109 | 110 | |
110 | 111 | 'stableversions' => 'Stable versions', |
111 | 112 | 'stableversions-leg1' => 'List reviewed revisions for a page', |
112 | | - 'stableversions-page' => 'Page name', |
| 113 | + 'stableversions-page' => 'Page name:', |
113 | 114 | 'stableversions-none' => '"[[:$1]]" has no reviewed revisions.', |
114 | 115 | 'stableversions-list' => 'The following is a list of revisions of "[[:$1]]" that have been reviewed:', |
115 | 116 | 'stableversions-review' => 'Reviewed on <i>$1</i> by $2', |
— | — | @@ -122,6 +123,32 @@ |
123 | 124 | 'unreviewed-category' => 'Category:', |
124 | 125 | 'unreviewed-diff' => 'Changes', |
125 | 126 | 'unreviewed-list' => 'This page lists articles that have not been reviewed or have new, unreviewed, revisions.', |
| 127 | + |
| 128 | + 'revreview-visibility' => 'This page has a [[Help:Article validation|stable version]], which can be |
| 129 | + [{{fullurl:Special:Stabilization|page={{FULLPAGENAMEE}}}} configured].', |
| 130 | + |
| 131 | + 'stabilization' => 'Page stabilization', |
| 132 | + 'stabilization-text' => 'Change the settings below to adjust how the stable version of [[:$1|$1]] is selected and displayed.', |
| 133 | + 'stabilization-perm' => 'Your account does not have permission to change the stable version configuration. |
| 134 | + Here are the current settings for [[:$1|$1]]:', |
| 135 | + 'stabilization-page' => 'Page name:', |
| 136 | + 'stabilization-leg' => 'Configure the stable version for a page', |
| 137 | + 'stabilization-select' => 'How the stable version is selected:', |
| 138 | + 'stabilization-select1' => 'The latest quality revision; if not present, then the latest reviewed one', |
| 139 | + 'stabilization-select2' => 'The latest reviewed revision', |
| 140 | + 'stabilization-def' => 'Revision displayed on default page view:', |
| 141 | + 'stabilization-def1' => 'The stable revision', |
| 142 | + 'stabilization-def2' => 'The current revision', |
| 143 | + 'stabilization-submit' => 'Confirm', |
| 144 | + 'stabilization-dne' => 'There is no page called "[[:$1|$1]]". No configuration possible.', |
| 145 | + 'stabilization-success' => 'Stable version configuration for [[:$1|$1]] successfuly set.', |
| 146 | + |
| 147 | + 'stabilization-sel-short' => 'Precedence', |
| 148 | + 'stabilization-sel-short-0' => 'Quality', |
| 149 | + 'stabilization-sel-short-1' => 'None', |
| 150 | + 'stabilization-def-short' => 'Default', |
| 151 | + 'stabilization-def-short-0' => 'Current', |
| 152 | + 'stabilization-def-short-1' => 'Stable', |
126 | 153 | ); |
127 | 154 | |
128 | 155 | /* Arabic (Meno25) */ |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.pg.sql |
— | — | @@ -16,6 +16,12 @@ |
17 | 17 | ); |
18 | 18 | CREATE INDEX fr_namespace_title ON flaggedrevs (fr_namespace,fr_title,fr_quality,fr_rev_id); |
19 | 19 | |
| 20 | +CREATE TABLE flaggedpages ( |
| 21 | + fp_page_id INTEGER NOT NULL PRIMARY KEY DEFAULT 0, |
| 22 | + fp_select INTEGER NOT NULL DEFAULT 0, |
| 23 | + fp_override bool NOT NULL |
| 24 | +) |
| 25 | + |
20 | 26 | CREATE TABLE flaggedrevtags ( |
21 | 27 | frt_rev_id INTEGER NOT NULL DEFAULT 0 , |
22 | 28 | frt_dimension TEXT NOT NULL DEFAULT '', |