jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/344808 )
Change subject: Update to use EditPageGetCheckboxesDefinition hook ...................................................................... Update to use EditPageGetCheckboxesDefinition hook Still using EditPageBeforeEditChecks if running on MW <1.29, EditPageGetCheckboxesDefinition otherwise. Bug: T161810 Change-Id: I1613d5f8a792e2e520b974eff9687edd27b43352 --- M FlaggedRevs.php M frontend/FlaggablePageView.php M frontend/FlaggedRevsUI.hooks.php 3 files changed, 42 insertions(+), 17 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/FlaggedRevs.php b/FlaggedRevs.php index 37ac0aa..212ebdd 100644 --- a/FlaggedRevs.php +++ b/FlaggedRevs.php @@ -558,7 +558,11 @@ # Tweak submit button name/title $wgHooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsUIHooks::onBeforeEditButtons'; # Autoreview information from form -$wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::addReviewCheck'; +if ( version_compare( $wgVersion, '1.29', '<' ) ) { + $wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::onEditPageBeforeEditChecks'; +} else { + $wgHooks['EditPageGetCheckboxesDefinition'][] = 'FlaggedRevsUIHooks::onEditPageGetCheckboxesDefinition'; +} $wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField'; # Add draft link to section edit error $wgHooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection'; diff --git a/frontend/FlaggablePageView.php b/frontend/FlaggablePageView.php index b1eb800..fa98347 100644 --- a/frontend/FlaggablePageView.php +++ b/frontend/FlaggablePageView.php @@ -1877,7 +1877,7 @@ * (a) there are currently any revisions pending (bug 16713) * (b) this is an unreviewed page (bug 23970) */ - public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) { + public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex = null ) { $this->load(); $request = $this->getRequest(); $title = $this->article->getTitle(); // convenience @@ -1891,31 +1891,46 @@ # the user decide if he/she wants it reviewed on the spot. One might # do this if he/she just saw the diff-to-stable and *then* decided to edit. # Note: check not shown when editing old revisions, which is confusing. - $checkbox = Xml::check( - 'wpReviewEdit', - $request->getCheck( 'wpReviewEdit' ), - array( 'tabindex' => ++$tabindex, 'id' => 'wpReviewEdit' ) + $name = 'wpReviewEdit'; + $options = array( + 'label-message' => null, + 'id' => 'wpReviewEdit', + 'default' => $request->getCheck( $name ), + 'title-message' => null, + 'legacy-name' => 'reviewed', ); - $attribs = array( 'for' => 'wpReviewEdit' ); // For reviewed pages... if ( $this->article->getStable() ) { // For pending changes... if ( $this->article->revsArePending() ) { $n = $this->article->getPendingRevCount(); - $attribs['title'] = $this->msg( 'revreview-check-flag-p-title' )->text(); - $labelMsg = $this->msg( 'revreview-check-flag-p' )->numParams( $n )->parse(); + $options['title-message'] = 'revreview-check-flag-p-title'; + $options['label-message'] = $this->msg( 'revreview-check-flag-p' )->numParams( $n ); // For just the user's changes... } else { - $attribs['title'] = $this->msg( 'revreview-check-flag-y-title' )->parse(); - $labelMsg = $this->msg( 'revreview-check-flag-y' )->parse(); + $options['title-message'] = 'revreview-check-flag-y-title'; + $options['label-message'] = 'revreview-check-flag-y'; } // For unreviewed pages... } else { - $attribs['title'] = $this->msg( 'revreview-check-flag-u-title' )->text(); - $labelMsg = $this->msg( 'revreview-check-flag-u' )->parse(); + $options['title-message'] = 'revreview-check-flag-u-title'; + $options['label-message'] = 'revreview-check-flag-u'; } - $label = Xml::element( 'label', $attribs, $labelMsg ); - $checkboxes['reviewed'] = $checkbox . ' ' . $label; + if ( $tabindex === null ) { + // New style + $checkboxes[$name] = $options; + } else { + // Old style + $checkbox = Xml::check( + $name, + $options['default'], + array( 'tabindex' => ++$tabindex, 'id' => $options['id'] ) + ); + $attribs = array( 'for' => $options['id'] ); + $attribs['title'] = $this->msg( $options['title-message'] )->text(); + $label = Xml::tags( 'label', $attribs, $this->msg( $options['label-message'] )->parse() ); + $checkboxes[ $options['legacy-name'] ] = $checkbox . ' ' . $label; + } } return true; } diff --git a/frontend/FlaggedRevsUI.hooks.php b/frontend/FlaggedRevsUI.hooks.php index a717e16..4bcf4c9 100644 --- a/frontend/FlaggedRevsUI.hooks.php +++ b/frontend/FlaggedRevsUI.hooks.php @@ -576,9 +576,15 @@ return true; } - public static function addReviewCheck( $editPage, &$checkboxes, &$tabindex ) { + public static function onEditPageBeforeEditChecks( $editPage, &$checks, &$tabindex ) { $view = FlaggablePageView::singleton(); - $view->addReviewCheck( $editPage, $checkboxes, $tabindex ); + $view->addReviewCheck( $editPage, $checks, $tabindex ); + return true; + } + + public static function onEditPageGetCheckboxesDefinition( $editPage, &$checkboxes ) { + $view = FlaggablePageView::singleton(); + $view->addReviewCheck( $editPage, $checkboxes ); return true; } -- To view, visit https://gerrit.wikimedia.org/r/344808 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1613d5f8a792e2e520b974eff9687edd27b43352 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/FlaggedRevs Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits