Bartosz Dziewoński has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344808 )

Change subject: Update to use EditPageGetCheckboxesDefinition hook
......................................................................

Update to use EditPageGetCheckboxesDefinition hook

Depends-On: I3dbe973dcac6cba0c3a1ac5d983cafcfb49d833c
Change-Id: I1613d5f8a792e2e520b974eff9687edd27b43352
---
M FlaggedRevs.php
M frontend/FlaggablePageView.php
M frontend/FlaggedRevsUI.hooks.php
3 files changed, 39 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/08/344808/1

diff --git a/FlaggedRevs.php b/FlaggedRevs.php
index 37ac0aa..66fe3d6 100644
--- a/FlaggedRevs.php
+++ b/FlaggedRevs.php
@@ -558,7 +558,8 @@
 # Tweak submit button name/title
 $wgHooks['EditPageBeforeEditButtons'][] = 
'FlaggedRevsUIHooks::onBeforeEditButtons';
 # Autoreview information from form
-$wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::addReviewCheck';
+$wgHooks['EditPageBeforeEditChecks'][] = 
'FlaggedRevsUIHooks::onEditPageBeforeEditChecks';
+$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: newchange
Gerrit-Change-Id: I1613d5f8a792e2e520b974eff9687edd27b43352
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to