WikiPage: Update comments related to new PreparedEdit object
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index 167a025..3845649 100644 (file)
@@ -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,
+                       ] ) . '<br>' .
+                       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' ]
                );