Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -416,6 +416,11 @@ |
417 | 417 | $wgHooks['SkinTemplateNavigation'][] = 'FlaggedRevsHooks::setNavigation'; // Vector |
418 | 418 | # Add notice tags to edit view |
419 | 419 | $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsHooks::addToEditView'; |
| 420 | +# Tweak submit button name/title |
| 421 | +$wgHooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsHooks::onBeforeEditButtons'; |
| 422 | +# Autoreview information from form |
| 423 | +$wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsHooks::addReviewCheck'; |
| 424 | +$wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsHooks::addRevisionIDField'; |
420 | 425 | # Add draft link to section edit error |
421 | 426 | $wgHooks['EditPageNoSuchSection'][] = 'FlaggedRevsHooks::onNoSuchSection'; |
422 | 427 | # Add notice tags to history |
— | — | @@ -437,9 +442,6 @@ |
438 | 443 | $wgHooks['DiffViewHeader'][] = 'FlaggedRevsHooks::onDiffViewHeader'; |
439 | 444 | # Add diff=review url param alias |
440 | 445 | $wgHooks['NewDifferenceEngine'][] = 'FlaggedRevsHooks::checkDiffUrl'; |
441 | | -# Autoreview stuff |
442 | | -$wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsHooks::addRevisionIDField'; |
443 | | -$wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsHooks::addReviewCheck'; |
444 | 446 | # Local user account preference |
445 | 447 | $wgHooks['GetPreferences'][] = 'FlaggedRevsHooks::onGetPreferences'; |
446 | 448 | # Show unreviewed pages links |
Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php |
— | — | @@ -49,9 +49,9 @@ |
50 | 50 | 'revreview-hist-basic-auto' => '[{{fullurl:$1|stableid=$2}} automatically checked]', |
51 | 51 | 'revreview-hist-quality-auto' => '[{{fullurl:$1|stableid=$2}} automatically approved]', |
52 | 52 | 'revreview-hist-pending' => '\'\'\'[[{{fullurl:$1|oldid=$2&diff=$3}} pending review]]\'\'\'', |
53 | | - 'review-edit-diff' => '\'\'\'NOTICE: Some pending changes to the accepted version are incorporated into the edit form below.\'\'\'', |
54 | | - 'revreview-diff-toggle-show' => 'show changes', |
55 | | - 'revreview-diff-toggle-hide' => 'hide changes', |
| 53 | + 'review-edit-diff' => '\'\'\'NOTICE: Some of the pending changes affect the area of the page you are editing.\'\'\'', |
| 54 | + 'revreview-diff-toggle-show' => 'show those changes', |
| 55 | + 'revreview-diff-toggle-hide' => 'hide those changes', |
56 | 56 | 'revreview-diff-toggle-title' => 'Toggle display of pending changes to the accepted version', |
57 | 57 | 'revreview-log-toggle-show' => 'show stability log', |
58 | 58 | 'revreview-log-toggle-hide' => 'hide stability log', |
— | — | @@ -111,7 +111,9 @@ |
112 | 112 | 'revreview-draft-title' => 'Pending changes are displayed on this page', |
113 | 113 | 'revreview-edit' => 'Edit', |
114 | 114 | 'revreview-editnotice' => '\'\'\'Your changes will be accepted once an authorized user reviews them. ([[{{MediaWiki:Validationpage}}|?]])\'\'\'', |
115 | | - 'revreview-check-flag' => 'Accept currently pending changes', |
| 115 | + 'revreview-check-flag' => 'Accept the pending changes', |
| 116 | + 'revreview-submitedit' => 'Submit changes', |
| 117 | + 'revreview-submitedit-title' => 'Submit your changes for review', |
116 | 118 | 'revreview-edited' => '\'\'\'Changes will be accepted once an authorized user reviews them. ([[{{MediaWiki:Validationpage}}|?]])\'\'\' |
117 | 119 | |
118 | 120 | There {{PLURAL:$2|is|are}} [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur&diffonly=0}} $2 pending {{PLURAL:$2|change|changes}}] \'\'(shown below)\'\' awaiting review.', |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * FlaggedArticle::getTitleInstance() is preferred over constructor calls |
7 | 7 | */ |
8 | 8 | class FlaggedArticle extends Article { |
9 | | - # Process cache variables |
| 9 | + /* Process cache variables */ |
10 | 10 | protected $stableRev = null; |
11 | 11 | protected $pageConfig = null; |
12 | 12 | |
— | — | @@ -43,6 +43,39 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
| 47 | + * Do edits have to be reviewed before being shown by default? |
| 48 | + * @param int $flags, FR_MASTER |
| 49 | + * @returns bool |
| 50 | + */ |
| 51 | + public function editsRequireReview( $flags = 0 ) { |
| 52 | + return ( |
| 53 | + $this->isReviewable( $flags ) && // reviewable page |
| 54 | + $this->isStableShownByDefault( $flags ) && // and stable versions override |
| 55 | + $this->getStableRev( $flags ) // and there is a stable version |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Are edits to this page currently pending? |
| 61 | + * @param int $flags, FR_MASTER |
| 62 | + * @returns bool |
| 63 | + */ |
| 64 | + public function editsArePending( $flags = 0 ) { |
| 65 | + if ( $this->isReviewable() ) { |
| 66 | + $srev = $this->getStableRev( $flags ); |
| 67 | + if ( $srev ) { |
| 68 | + if ( $flags & FR_MASTER ) { |
| 69 | + $latest = $this->getTitle()->getLatestRevID( GAID_FOR_UPDATE ); |
| 70 | + } else { |
| 71 | + $latest = $this->getLatest(); |
| 72 | + } |
| 73 | + return ( $srev->getRevId() != $latest ); // edits need review |
| 74 | + } |
| 75 | + } |
| 76 | + return false; // all edits go live |
| 77 | + } |
| 78 | + |
| 79 | + /** |
47 | 80 | * Is this page less open than the site defaults? |
48 | 81 | * @returns bool |
49 | 82 | */ |
— | — | @@ -122,9 +155,7 @@ |
123 | 156 | if ( !( $flags & FR_MASTER ) && $this->pageConfig !== null ) { |
124 | 157 | return $this->pageConfig; |
125 | 158 | } |
126 | | - # Get the content page, skip talk |
127 | | - $title = $this->getTitle()->getSubjectPage(); |
128 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, $flags ); |
| 159 | + $config = FlaggedRevs::getPageVisibilitySettings( $this->getTitle(), $flags ); |
129 | 160 | $this->pageConfig = $config; |
130 | 161 | return $config; |
131 | 162 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -67,8 +67,8 @@ |
68 | 68 | $encJsFile = htmlspecialchars( "$stylePath/review.js?$wgFlaggedRevStyleVersion" ); |
69 | 69 | $head .= "\n<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
70 | 70 | } |
71 | | - # Set basic messages |
72 | | - $msgs = (object) array( |
| 71 | + # Set basic messages for all users... |
| 72 | + $msgs = array( |
73 | 73 | 'diffToggleShow' => wfMsgHtml( 'revreview-diff-toggle-show' ), |
74 | 74 | 'diffToggleHide' => wfMsgHtml( 'revreview-diff-toggle-hide' ), |
75 | 75 | 'logToggleShow' => wfMsgHtml( 'revreview-log-toggle-show' ), |
— | — | @@ -78,8 +78,16 @@ |
79 | 79 | 'toggleShow' => wfMsgHtml( 'revreview-toggle-show' ), |
80 | 80 | 'toggleHide' => wfMsgHtml( 'revreview-toggle-hide' ) |
81 | 81 | ); |
| 82 | + # Extra reviewer messages... |
| 83 | + if ( $wgUser->isAllowed( 'review' ) ) { |
| 84 | + $msgs['saveArticle'] = wfMsgHtml( 'savearticle' ); |
| 85 | + $msgs['tooltipSave'] = wfMsgHtml( 'tooltip-save' ).' ['.wfMsgHtml( 'accesskey-save' ).']'; |
| 86 | + $msgs['submitArticle'] = wfMsg( 'revreview-submitedit' ); |
| 87 | + $msgs['tooltipSubmit'] = wfMsg( 'revreview-submitedit-title' ) . |
| 88 | + ' ['. wfMsg( 'accesskey-save' ) . ']'; |
| 89 | + } |
82 | 90 | $head .= "\n<script type=\"{$wgJsMimeType}\">" . |
83 | | - "FlaggedRevs.messages = " . Xml::encodeJsVar( $msgs ) . ";</script>\n"; |
| 91 | + "FlaggedRevs.messages = " . Xml::encodeJsVar( (object)$msgs ) . ";</script>\n"; |
84 | 92 | $wgOut->addHeadItem( 'FlaggedRevs', $head ); |
85 | 93 | |
86 | 94 | return true; |
— | — | @@ -814,7 +822,8 @@ |
815 | 823 | # Enforce autoreview/review restrictions |
816 | 824 | } else if ( $action === 'autoreview' || $action === 'review' ) { |
817 | 825 | # Get autoreview restriction settings... |
818 | | - $config = FlaggedRevs::getPageVisibilitySettings( $title, FR_MASTER ); |
| 826 | + $fa = FlaggedArticle::getTitleInstance( $title ); |
| 827 | + $config = $fa->getVisibilitySettings(); |
819 | 828 | # Convert Sysop -> protect |
820 | 829 | $right = ( $config['autoreview'] === 'sysop' ) ? |
821 | 830 | 'protect' : $config['autoreview']; |
— | — | @@ -1704,6 +1713,12 @@ |
1705 | 1714 | return true; |
1706 | 1715 | } |
1707 | 1716 | |
| 1717 | + public static function onBeforeEditButtons( &$editPage, &$buttons ) { |
| 1718 | + $view = FlaggedArticleView::singleton(); |
| 1719 | + $view->changeSaveButton( $editPage, $buttons ); |
| 1720 | + return true; |
| 1721 | + } |
| 1722 | + |
1708 | 1723 | public static function onNoSuchSection( &$editPage, &$s ) { |
1709 | 1724 | $view = FlaggedArticleView::singleton(); |
1710 | 1725 | $view->addToNoSuchSection( $editPage, $s ); |
— | — | @@ -1983,6 +1998,8 @@ |
1984 | 1999 | return true; |
1985 | 2000 | } |
1986 | 2001 | |
| 2002 | + // TODO: move to articleview class? |
| 2003 | + // FIXME: add title attrib |
1987 | 2004 | public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) { |
1988 | 2005 | global $wgUser, $wgRequest; |
1989 | 2006 | if ( !$wgUser->isAllowed( 'review' ) ) { |
— | — | @@ -1998,7 +2015,7 @@ |
1999 | 2016 | # the user decide if he/she wants it reviewed on the spot. One might |
2000 | 2017 | # do this if he/she just saw the diff-to-stable and *then* decided to edit. |
2001 | 2018 | if ( !$srev || $srev->getRevId() != $editPage->getArticle()->getLatest() ) { |
2002 | | - $reviewLabel = wfMsgExt( 'revreview-check-flag', array( 'parseinline' ) ); |
| 2019 | + $reviewLabel = wfMsgExt( 'revreview-check-flag', 'parseinline' ); |
2003 | 2020 | $attribs = array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' ); |
2004 | 2021 | $checkboxes['reviewed'] = Xml::check( 'wpReviewEdit', |
2005 | 2022 | $wgRequest->getCheck( 'wpReviewEdit' ), $attribs ) . |
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.js |
— | — | @@ -151,3 +151,28 @@ |
152 | 152 | }; |
153 | 153 | |
154 | 154 | addOnloadHook(FlaggedRevs.enableShowhide); |
| 155 | + |
| 156 | +FlaggedRevs.setCheckTrigger = function() { |
| 157 | + var checkbox = document.getElementById("wpReviewEdit"); |
| 158 | + if( checkbox ) { |
| 159 | + checkbox.onclick = FlaggedRevs.updateSaveButton; |
| 160 | + } |
| 161 | +} |
| 162 | + |
| 163 | +hookEvent("load", FlaggedRevs.setCheckTrigger); |
| 164 | + |
| 165 | +FlaggedRevs.updateSaveButton = function() { |
| 166 | + var checkbox = document.getElementById("wpReviewEdit"); |
| 167 | + var save = document.getElementById("wpSave"); |
| 168 | + if( checkbox && save ) { |
| 169 | + // Review pending changes |
| 170 | + if ( checkbox.checked ) { |
| 171 | + save.value = FlaggedRevs.messages.saveArticle; |
| 172 | + save.title = FlaggedRevs.messages.tooltipSave; |
| 173 | + // Submit for review |
| 174 | + } else { |
| 175 | + save.value = FlaggedRevs.messages.submitArticle; |
| 176 | + save.title = FlaggedRevs.messages.tooltipSubmit; |
| 177 | + } |
| 178 | + } |
| 179 | +} |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -100,8 +100,11 @@ |
101 | 101 | */ |
102 | 102 | public function isStableShownByDefaultUser() { |
103 | 103 | $this->load(); |
104 | | - $config = $this->article->getVisibilitySettings(); // page configuration |
105 | | - return ( $config['override'] && !FlaggedRevs::ignoreDefaultVersion() ); |
| 104 | + if ( $this->article->isReviewable() ) { |
| 105 | + $config = $this->article->getVisibilitySettings(); // page configuration |
| 106 | + return ( $config['override'] && !FlaggedRevs::ignoreDefaultVersion() ); |
| 107 | + } |
| 108 | + return false; // no stable |
106 | 109 | } |
107 | 110 | |
108 | 111 | /** |
— | — | @@ -1492,6 +1495,36 @@ |
1493 | 1496 | } |
1494 | 1497 | |
1495 | 1498 | /** |
| 1499 | + * If submitting the edit will leave it pending, then change the button text |
| 1500 | + * Note: interacts with 'review pending changes' checkbox |
| 1501 | + * @TODO: would be nice if hook passed in button attribs, not XML |
| 1502 | + */ |
| 1503 | + public function changeSaveButton( EditPage $editPage, array &$buttons ) { |
| 1504 | + if ( !$this->article->editsRequireReview() ) { |
| 1505 | + return true; // edit will go live immediatly |
| 1506 | + } elseif ( !$this->article->editsArePending() |
| 1507 | + && $this->article->getTitle()->userCan( 'autoreview' ) ) |
| 1508 | + { |
| 1509 | + return true; // edit will be autoreviewed anyway |
| 1510 | + } |
| 1511 | + if ( extension_loaded( 'domxml' ) ) { |
| 1512 | + wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" ); |
| 1513 | + return true; # PECL extension conflicts with the core DOM extension (see bug 13770) |
| 1514 | + } elseif ( isset( $buttons['save'] ) && extension_loaded( 'dom' ) ) { |
| 1515 | + $dom = new DOMDocument(); |
| 1516 | + $result = $dom->loadXML( $buttons['save'] ); // load button XML from hook |
| 1517 | + foreach ( $dom->getElementsByTagName( 'input' ) as $input ) { // one <input> |
| 1518 | + $input->setAttribute( 'value', wfMsg( 'revreview-submitedit' ) ); |
| 1519 | + $input->setAttribute( 'title', // keep accesskey |
| 1520 | + wfMsg( 'revreview-submitedit-title' ).' ['.wfMsg( 'accesskey-save' ).']' ); |
| 1521 | + # Change submit button text & title |
| 1522 | + $buttons['save'] = $dom->saveXML( $dom->documentElement ); |
| 1523 | + } |
| 1524 | + } |
| 1525 | + return true; |
| 1526 | + } |
| 1527 | + |
| 1528 | + /** |
1496 | 1529 | * (a) Add a hidden field that has the rev ID the text is based off. |
1497 | 1530 | * (b) If an edit was undone, add a hidden field that has the rev ID of that edit. |
1498 | 1531 | * Needed for autoreview and user stats (for autopromote). |