X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialContributions.php;h=38456493140b3e2fcdfa92f9bb09f154d8594e95;hb=50ea235528289fa3b7b31a2281c6c7683053b7f4;hp=167a0257861663243955fc37ee1e4392f59d76ea;hpb=cf35ff756c89ca6d6e003b440076df5ebe7ccef7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 167a025786..3845649314 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use MediaWiki\Widget\DateInputWidget; + /** * Special:Contributions, show user contributions in a paged list * @@ -40,8 +42,11 @@ class SpecialContributions extends IncludableSpecialPage { $out->addModuleStyles( [ 'mediawiki.special', 'mediawiki.special.changeslist', + 'mediawiki.widgets.DateInputWidget.styles', ] ); + $out->addModules( 'mediawiki.special.contributions' ); $this->addHelpLink( 'Help:User contributions' ); + $out->enableOOUI(); $this->opts = []; $request = $this->getRequest(); @@ -130,8 +135,12 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['year'] = ''; $this->opts['month'] = ''; } else { - $this->opts['year'] = $request->getIntOrNull( 'year' ); - $this->opts['month'] = $request->getIntOrNull( 'month' ); + $this->opts['year'] = $request->getVal( 'year' ); + $this->opts['month'] = $request->getVal( 'month' ); + + $this->opts['start'] = $request->getVal( 'start' ); + $this->opts['end'] = $request->getVal( 'end' ); + $this->opts = ContribsPager::processDateFilter( $this->opts ); } $feedType = $request->getVal( 'feed' ); @@ -190,8 +199,8 @@ class SpecialContributions extends IncludableSpecialPage { 'contribs' => $this->opts['contribs'], 'namespace' => $this->opts['namespace'], 'tagfilter' => $this->opts['tagfilter'], - 'year' => $this->opts['year'], - 'month' => $this->opts['month'], + 'start' => $this->opts['start'], + 'end' => $this->opts['end'], 'deletedOnly' => $this->opts['deletedOnly'], 'topOnly' => $this->opts['topOnly'], 'newOnly' => $this->opts['newOnly'], @@ -320,7 +329,6 @@ class SpecialContributions extends IncludableSpecialPage { * @return array */ public static function getUserLinks( SpecialPage $sp, User $target ) { - $id = $target->getId(); $username = $target->getName(); $userpage = $target->getUserPage(); @@ -432,12 +440,12 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['contribs'] = 'user'; } - if ( !isset( $this->opts['year'] ) ) { - $this->opts['year'] = ''; + if ( !isset( $this->opts['start'] ) ) { + $this->opts['start'] = ''; } - if ( !isset( $this->opts['month'] ) ) { - $this->opts['month'] = ''; + if ( !isset( $this->opts['end'] ) ) { + $this->opts['end'] = ''; } if ( $this->opts['contribs'] == 'newbie' ) { @@ -478,6 +486,8 @@ class SpecialContributions extends IncludableSpecialPage { 'contribs', 'year', 'month', + 'start', + 'end', 'topOnly', 'newOnly', 'hideMinor', @@ -652,15 +662,32 @@ class SpecialContributions extends IncludableSpecialPage { implode( '', $filters ) ); - $dateSelectionAndSubmit = Xml::tags( 'div', [], - Xml::dateMenu( - $this->opts['year'] === '' ? MWTimestamp::getInstance()->format( 'Y' ) : $this->opts['year'], - $this->opts['month'] - ) . ' ' . - Html::submitButton( - $this->msg( 'sp-contributions-submit' )->text(), - [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ] - ) + $dateRangeSelection = Html::rawElement( + 'div', + [], + Xml::label( wfMessage( 'date-range-from' )->text(), 'mw-date-start' ) . ' ' . + new DateInputWidget( [ + 'infusable' => true, + 'id' => 'mw-date-start', + 'name' => 'start', + 'value' => $this->opts['start'], + 'longDisplayFormat' => true, + ] ) . '
' . + Xml::label( wfMessage( 'date-range-to' )->text(), 'mw-date-end' ) . ' ' . + new DateInputWidget( [ + 'infusable' => true, + 'id' => 'mw-date-end', + 'name' => 'end', + 'value' => $this->opts['end'], + 'longDisplayFormat' => true, + ] ) + ); + + $submit = Xml::tags( 'div', [], + Html::submitButton( + $this->msg( 'sp-contributions-submit' )->text(), + [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ] + ) ); $form .= Xml::fieldset( @@ -669,7 +696,8 @@ class SpecialContributions extends IncludableSpecialPage { $namespaceSelection . $filterSelection . $extraOptions . - $dateSelectionAndSubmit, + $dateRangeSelection . + $submit, [ 'class' => 'mw-contributions-table' ] );