jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/348195 )

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


Update to use EditPageGetCheckboxesDefinition hook

Bug: T161814
Change-Id: Ib1b906a8c745762afb5f92b54e5566ded05e6bcd
---
M TweetANew.php
1 file changed, 39 insertions(+), 26 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/TweetANew.php b/TweetANew.php
index f3e6cf6..062c8ef 100644
--- a/TweetANew.php
+++ b/TweetANew.php
@@ -204,8 +204,11 @@
  */
 $wgHooks['PageContentInsertComplete'][] = 'TweetANew::TweetANewNewPageContent';
 $wgHooks['PageContentSaveComplete'][] = 'TweetANew::TweetANewEditMade';
-$wgHooks['EditPageBeforeEditChecks'][] = 'efTweetANewEditCheckBox';
-
+if ( version_compare( $wgVersion, '1.29', '<' ) ) {
+       $wgHooks['EditPageBeforeEditChecks'][] = 'efTweetANewEditCheckBox';
+} else {
+       $wgHooks['EditPageGetCheckboxesDefinition'][] = 
'efTweetANewEditCheckBox';
+}
 /**
  * Function for tweeting about new or edited articles when auto-tweet if 
disabled
  *
@@ -215,45 +218,55 @@
  *
  * @return bool
  */
-function efTweetANewEditCheckBox( &$editpage, &$checkboxes, &$tabindex ) {
+function efTweetANewEditCheckBox( $editpage, &$checkboxes, &$tabindex = null ) 
{
        global $wgTweetANewEditpage, $wgTweetANewTweet;
 
+
+       $options = array(
+               'label-message' => null,
+               'id' => null,
+               'default' => $wgTweetANewEditpage['Checked'],
+               'title-message' => null,
+               'legacy-name' => 'twitter',
+       );
        # Check if article is new - if checkboxes are enabled and if 
auto-tweets of edits are disabled
        if ( $editpage->mTitle->exists() &&
                $wgTweetANewEditpage['Enable'] &&
                !$wgTweetANewTweet['Edit']
        ) {
                $attribs = array(
-                       'tabindex' => ++$tabindex,
-                       'accesskey' => wfMessage( 'tweetanew-accesskey' 
)->text(),
-                       'id' => 'wpTweetANewEdit',
+                       'accesskey' => wfMessage( 'tweetanew-accesskey' 
)->text()
                );
-
-               # Prepare checkbox
-               $checkboxes['twitter'] =
-                       Xml::check( 'wpTweetANewEdit', 
$wgTweetANewEditpage['Checked'], $attribs ) .
-                       "&nbsp;<label for='wpTweetANewEdit' title='" .
-                       wfMessage( 'tweetanew-edittooltip' )->escaped() .
-                       "'>" .
-                       wfMessage( 'tweetanew-editaction' )->escaped() .
-                       "</label>";
+               $options['title-message'] = 'tweetanew-edittooltip';
+               $options['label-message'] = 'tweetanew-editaction';
+               $options['id'] = 'wpTweetANewEdit';
+               $name = 'wpTweetANewEdit';
        } # Check if article is new - if checkboxes are enabled and if 
auto-tweets of new articles are disabled
        elseif ( $wgTweetANewEditpage['Enable'] && !$wgTweetANewTweet['New'] ) {
                $attribs = array(
-                       'tabindex' => ++$tabindex,
-                       'accesskey' => wfMessage( 'tweetanew-accesskey' 
)->text(),
-                       'id' => 'wpTweetANew',
+                       'accesskey' => wfMessage( 'tweetanew-accesskey' 
)->text()
                );
 
-               # Prepare checkbox
-               $checkboxes['twitter'] =
-                       Xml::check( 'wpTweetANew', 
$wgTweetANewEditpage['Checked'], $attribs ) .
-                       "&nbsp;<label for='wpTweetANew' title='" .
-                       wfMessage( 'tweetanew-newtooltip' )->escaped() .
-                       "'>" .
-                       wfMessage( 'tweetanew-newaction' )->escaped() .
-                       "</label>";
+               $options['title-message'] = 'tweetanew-newtooltip';
+               $options['label-message'] = 'tweetanew-newaction';
+               $options['id'] = 'wpTweetANew';
+               $name = 'wpTweetANew';
+       } else {
+               return true;
        }
 
+       if ( $tabindex === null ) {
+               $checkboxes[$name] = $options;
+       } else {
+               $checkbox = Xml::check(
+                       $name,
+                       $options['default'],
+                       $attribs + [ 'tabindex' => ++$tabindex ]
+               );
+               $attribs = [ 'for' => $options['id'] ];
+               $attribs['title'] = wfMessage( $options['title-message']  
)->escaped();
+               $label = Xml::tags( 'label', $attribs, wfMessage( 
$options['label-message'] )->escaped() );
+               $checkboxes[ $options['legacy-name'] ] = $checkbox . '&#160;' . 
$label;
+       }
        return true;
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/348195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1b906a8c745762afb5f92b54e5566ded05e6bcd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TweetANew
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
Gerrit-Reviewer: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to