jenkins-bot has submitted this change and it was merged.

Change subject: Don't use jquery.ui.datepicker in SecurePoll
......................................................................


Don't use jquery.ui.datepicker in SecurePoll

Bug: T147136
Change-Id: I23304d9a9861323bc77dd64d4f4bea6e191e2700
---
M extension.json
M i18n/en.json
M i18n/qqq.json
D includes/htmlform/HTMLDateField.php
D includes/htmlform/HTMLDateRangeField.php
M includes/jobs/PopulateVoterListJob.php
M includes/pages/CreatePage.php
M includes/pages/VoterEligibilityPage.php
M modules/ext.securepoll.css
M modules/ext.securepoll.htmlform.js
10 files changed, 87 insertions(+), 449 deletions(-)

Approvals:
  Anomie: Looks good to me, but someone else must approve
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index f530c23..824c186 100644
--- a/extension.json
+++ b/extension.json
@@ -85,8 +85,6 @@
                "SecurePoll_PopulateVoterListJob": 
"includes/jobs/PopulateVoterListJob.php",
                "SecurePollContentHandler": 
"includes/main/SecurePollContentHandler.php",
                "SecurePollContent": "includes/main/SecurePollContent.php",
-               "SecurePoll_HTMLDateField": 
"includes/htmlform/HTMLDateField.php",
-               "SecurePoll_HTMLDateRangeField": 
"includes/htmlform/HTMLDateRangeField.php",
                "SecurePoll_HTMLFormRadioRangeColumnLabels": 
"includes/htmlform/HTMLFormRadioRangeColumnLabels.php",
                "SecurePollHooks": "includes/SecurePollHooks.php"
        },
diff --git a/i18n/en.json b/i18n/en.json
index f60f80c..82f8622 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -128,18 +128,7 @@
        "securepoll-round": "Round $1",
        "securepoll-spoilt": "(Spoilt)",
        "securepoll-exhausted": "(Exhausted)",
-       "securepoll-htmlform-date-placeholder": "YYYY-MM-DD",
-       "securepoll-htmlform-date-invalid": "The value you specified is not a 
recognized date. Try using YYYY-MM-DD format.",
-       "securepoll-htmlform-date-toolow": "The value you specified is before 
the earliest allowed date of $1.",
-       "securepoll-htmlform-date-toohigh": "The value you specified is after 
the latest allowed date of $1.",
-       "securepoll-htmlform-daterange-relative-layout": "Start on $1 and run 
for $2 days",
-       "securepoll-htmlform-daterange-absolute-layout": "Start on $1 and end 
on $2",
-       "securepoll-htmlform-daterange-days-badoption": "The value you 
specified for the number of days to run is not a valid option.",
-       "securepoll-htmlform-daterange-days-invalid": "The value you specified 
for the number of days to run is not an integer.",
-       "securepoll-htmlform-daterange-days-toolow": "The value you specified 
for the number of days to run is below the minimum of {{PLURAL:$1|$1}}.",
-       "securepoll-htmlform-daterange-days-toohigh": "The value you specified 
for the number of days to run is above the maximum of {{PLURAL:$1|$1}}.",
        "securepoll-htmlform-daterange-end-before-start": "The end date given 
is before the start date.",
-       "securepoll-htmlform-daterange-error-partial": "Both date fields must 
be filled or left empty.",
        "securepoll-htmlform-radiorange-missing-message": "Please specify a 
value for column $1",
        "securepoll-create-title": "{{int:securepoll}}: Create poll",
        "securepoll-create-action": "Create poll",
@@ -151,8 +140,8 @@
        "securepoll-create-option-wiki-all_wikis": "All wikis",
        "securepoll-create-option-wiki-other_wiki": "Other specific wiki",
        "securepoll-create-label-election_primaryLang": "Primary Language:",
-       "securepoll-create-label-election_dates": "Election Dates:",
-       "securepoll-create-layout-election_dates": "Start on $1 (at 00:00 UTC) 
and run for $2 day(s)",
+       "securepoll-create-label-election_startdate": "Election Start Date:",
+       "securepoll-create-label-election_duration": "Election Duration 
(Days):",
        "securepoll-create-label-election_disallow-change": "Prevent voters 
from changing their votes",
        "securepoll-create-label-election_return-url": "Return-to URL:",
        "securepoll-create-label-election_jump-text": "Jump text:",
@@ -234,8 +223,8 @@
        "securepoll-votereligibility-label-edits_before_date": "Before date",
        "securepoll-votereligibility-label-edits_between": "Require a minimum 
number of edits between two dates",
        "securepoll-votereligibility-label-edits_between_count": "Minimum edit 
count",
-       "securepoll-votereligibility-label-edits_between_dates": "Between 
dates",
-       "securepoll-votereligibility-layout-edits_between_dates": "Between $1 
and $2",
+       "securepoll-votereligibility-label-edits_startdate": "Edits on or 
after:",
+       "securepoll-votereligibility-label-edits_enddate": "And before:",
        "securepoll-votereligibility-label-exclude_groups": "Exclude users in 
these groups",
        "securepoll-votereligibility-label-include_groups": "Include users in 
these groups, regardless of edits or other groups",
        "securepoll-votereligibility-label-names": "User names",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 45f7215..4aa0a42 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -109,18 +109,7 @@
        "securepoll-round": "Column header for tables on tallies which take 
place over multiple rounds.\n\nParameters:\n* $1 - roman numeral (I, II, III, 
IV, ...)",
        "securepoll-spoilt": "Row label for counting ballots which were spoilt, 
that is not correctly filled in or indecipherable.",
        "securepoll-exhausted": "Row label for counting ballots which have been 
exhausted in a multi-round counting system",
-       "securepoll-htmlform-date-placeholder": "Used as initial placeholder 
text in \"date\" input boxes.\n{{DataFormatSpecifiers/en}}",
-       "securepoll-htmlform-date-invalid": "Used as error message in HTML 
forms. This date MUST be formatted in the 
https://en.wikipedia.org/wiki/ISO_8601 format. You can localise the letters to 
your language or script, but you should not change the format.\n\n* 
{{msg-mw|Htmlform-invalid-input}}\n* 
{{msg-mw|Securepoll-htmlform-date-placeholder}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}\n* {{msg-mw|Htmlform-required}}",
-       "securepoll-htmlform-date-toolow": "Used as error message in HTML 
forms. Parameters:\n* $1 - minimum date\nSee also:\n* 
{{msg-mw|Htmlform-invalid-input}}\n* {{msg-mw|Htmlform-required}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}",
-       "securepoll-htmlform-date-toohigh": "Used as error message in HTML 
forms. Parameters:\n* $1 - maximum date\nSee also:\n* 
{{msg-mw|Htmlform-invalid-input}}\n* {{msg-mw|Htmlform-required}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}",
-       "securepoll-htmlform-daterange-relative-layout": "Used to give context 
to the form fields in an HTML form date-range element.\n* $1 - HTML for the 
starting date control\n* $2 - HTML for the number-of-days control. This is an 
input field to be added by the user and the number is not shown initially, so 
\"days\" should be translated as a generic plural of an unknown number.",
-       "securepoll-htmlform-daterange-absolute-layout": "Used to give context 
to the form fields in an HTML form date-range element.\n* $1 - HTML for the 
starting date control\n* $2 - HTML for the ending date control",
-       "securepoll-htmlform-daterange-days-badoption": "Used as error message 
in HTML forms.\n\n* {{msg-mw|Htmlform-invalid-input}}\n* 
{{msg-mw|Htmlform-required}}\n* {{msg-mw|Htmlform-int-invalid}}\n* 
{{msg-mw|Htmlform-int-toolow}}\n* {{msg-mw|Htmlform-int-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toohigh}}",
-       "securepoll-htmlform-daterange-days-invalid": "Used as error message in 
HTML forms.\n\n* {{msg-mw|Htmlform-invalid-input}}\n* 
{{msg-mw|Htmlform-required}}\n* {{msg-mw|Htmlform-int-invalid}}\n* 
{{msg-mw|Htmlform-int-toolow}}\n* {{msg-mw|Htmlform-int-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-badoption}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toohigh}}",
-       "securepoll-htmlform-daterange-days-toolow": "Used as error message in 
HTML forms. Parameters:\n* $1 - minimum value\nSee also:\n* 
{{msg-mw|Htmlform-invalid-input}}\n* {{msg-mw|Htmlform-required}}\n* 
{{msg-mw|Htmlform-int-invalid}}\n* {{msg-mw|Htmlform-int-toolow}}\n* 
{{msg-mw|Htmlform-int-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-badoption}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toohigh}}",
-       "securepoll-htmlform-daterange-days-toohigh": "Used as error message in 
HTML forms. Parameters:\n* $1 - maximum value\nSee also:\n* 
{{msg-mw|Htmlform-invalid-input}}\n* {{msg-mw|Htmlform-required}}\n* 
{{msg-mw|Htmlform-int-invalid}}\n* {{msg-mw|Htmlform-int-toolow}}\n* 
{{msg-mw|Htmlform-int-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-date-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-date-toolow}}\n* 
{{msg-mw|Securepoll-htmlform-date-toohigh}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-badoption}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-invalid}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-toolow}}",
        "securepoll-htmlform-daterange-end-before-start": "Used as error 
message in HTML forms.",
-       "securepoll-htmlform-daterange-error-partial": "Used as error message 
in HTML forms.",
        "securepoll-htmlform-radiorange-missing-message": "Used as error 
message in HTML forms. Parameters:\n* $1 - Column number",
        "securepoll-create-title": "Title for 
[[Special:SecurePoll/create]].\n\nRefers to 
{{msg-mw|Securepoll}}.\n{{Identical|Create poll}}",
        "securepoll-create-action": "Text for submit button on 
Special:SecurePoll/create.\n{{Identical|Create poll}}",
@@ -132,8 +121,8 @@
        "securepoll-create-option-wiki-all_wikis": "Label for form option on 
Special:SecurePoll/create.\n{{Identical|All wikis}}",
        "securepoll-create-option-wiki-other_wiki": "Label for form option on 
Special:SecurePoll/create.",
        "securepoll-create-label-election_primaryLang": "Label for form field 
on Special:SecurePoll/create.\n{{Identical|Primary language}}",
-       "securepoll-create-label-election_dates": "Label for form field on 
Special:SecurePoll/create.",
-       "securepoll-create-layout-election_dates": "Layout message for the date 
range input on [[Special:SecurePoll/create]].\n\nParameters:\n* $1 - HTML for 
the starting date control\n* $2 - HTML for the number-of-days control, cannot 
be used for PLURAL\nSee also:\n* 
{{msg-mw|Securepoll-htmlform-daterange-absolute-layout}}\n* 
{{msg-mw|Securepoll-htmlform-daterange-relative-layout}}",
+       "securepoll-create-label-election_startdate": "Label for form field on 
Special:SecurePoll/create.",
+       "securepoll-create-label-election_duration": "Label for form field on 
Special:SecurePoll/create.",
        "securepoll-create-label-election_disallow-change": "Label for form 
field on Special:SecurePoll/create.",
        "securepoll-create-label-election_return-url": "Label for form field on 
Special:SecurePoll/create.",
        "securepoll-create-label-election_jump-text": "Label for form field on 
Special:SecurePoll/create. Value is used to inform the user why they are being 
sent to a different wiki to cast their vote when going to the voting page on 
their home wiki.",
@@ -215,8 +204,8 @@
        "securepoll-votereligibility-label-edits_before_date": "Label for form 
field on Special:SecurePoll/votereligibility.",
        "securepoll-votereligibility-label-edits_between": "Label for form 
field on Special:SecurePoll/votereligibility.",
        "securepoll-votereligibility-label-edits_between_count": "Label for 
form field on Special:SecurePoll/votereligibility.",
-       "securepoll-votereligibility-label-edits_between_dates": "Label for 
form field on Special:SecurePoll/votereligibility.",
-       "securepoll-votereligibility-layout-edits_between_dates": "Message for 
laying out date-range fields on 
Special:SecurePoll/votereligibility.\n\nParameters:\n* $1 - HTML for start-date 
field\n* $2 - HTML for end-date field",
+       "securepoll-votereligibility-label-edits_startdate": "Label for form 
field on Special:SecurePoll/votereligibility.",
+       "securepoll-votereligibility-label-edits_enddate": "Label for form 
field on Special:SecurePoll/votereligibility.",
        "securepoll-votereligibility-label-exclude_groups": "Label for form 
field on Special:SecurePoll/votereligibility.",
        "securepoll-votereligibility-label-include_groups": "Label for form 
field on Special:SecurePoll/votereligibility.",
        "securepoll-votereligibility-label-names": "Label for form field on 
Special:SecurePoll/votereligibility/#/edit/X.\n{{Identical|Username}}",
diff --git a/includes/htmlform/HTMLDateField.php 
b/includes/htmlform/HTMLDateField.php
deleted file mode 100644
index 4189fc9..0000000
--- a/includes/htmlform/HTMLDateField.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-
-/**
- * A field that will contain a date
- *
- * Currently recognizes only YYYY-MM-DD formatted dates.
- *
- * Besides the parameters recognized by HTMLTextField, additional recognized
- * parameters in the field descriptor array include:
- *  min - The minimum date to allow, in any recognized format.
- *  max - The maximum date to allow, in any recognized format.
- *  placeholder - The default comes from the htmlform-date-placeholder message.
- *
- * The result is a formatted date.
- *
- *  @todo These should be migrated to core, once the jquery.ui objectors write
- *  their own date picker.
- */
-class SecurePoll_HTMLDateField extends HTMLTextField {
-       function getSize() {
-               return isset( $this->mParams['size'] ) ? $this->mParams['size'] 
: 10;
-       }
-
-       public function getAttributes( array $list ) {
-               $parentList = array_diff( $list, array( 'min', 'max' ) );
-               $ret = parent::getAttributes( $parentList );
-
-               if ( in_array( 'placeholder', $list ) && !isset( 
$ret['placeholder'] ) ) {
-                       $ret['placeholder'] = $this->msg( 
'securepoll-htmlform-date-placeholder' )->text();
-               }
-
-               if ( in_array( 'min', $list ) && isset( $this->mParams['min'] ) 
) {
-                       $min = $this->parseDate( $this->mParams['min'] );
-                       if ( $min ) {
-                               $ret['min'] = $this->formatDate( $min );
-                               // Because Html::expandAttributes filters it out
-                               $ret['data-min'] = $ret['min'];
-                       }
-               }
-               if ( in_array( 'max', $list ) && isset( $this->mParams['max'] ) 
) {
-                       $max = $this->parseDate( $this->mParams['max'] );
-                       if ( $max ) {
-                               $ret['max'] = $this->formatDate( $max );
-                               // Because Html::expandAttributes filters it out
-                               $ret['data-max'] = $ret['max'];
-                       }
-               }
-
-               $ret['type'] = 'date';
-
-               return $ret;
-       }
-
-       function loadDataFromRequest( $request ) {
-               if ( !$request->getCheck( $this->mName ) ) {
-                       return $this->getDefault();
-               }
-
-               $value = $request->getText( $this->mName );
-               $date = $this->parseDate( $value );
-               return $date ? $this->formatDate( $date ) : $value;
-       }
-
-       function validate( $value, $alldata ) {
-               $p = parent::validate( $value, $alldata );
-
-               if ( $p !== true ) {
-                       return $p;
-               }
-
-               if ( $value === '' ) {
-                       // required was already checked by parent::validate
-                       return true;
-               }
-
-               $date = $this->parseDate( $value );
-               if ( !$date ) {
-                       return $this->msg( 'securepoll-htmlform-date-invalid' 
)->parseAsBlock();
-               }
-
-               if ( isset( $this->mParams['min'] ) ) {
-                       $min = $this->parseDate( $this->mParams['min'] );
-                       if ( $min && $date < $min ) {
-                               return $this->msg( 
'securepoll-htmlform-date-toolow', $this->formatDate( $min ) )
-                                       ->parseAsBlock();
-                       }
-               }
-
-               if ( isset( $this->mParams['max'] ) ) {
-                       $max = $this->parseDate( $this->mParams['max'] );
-                       if ( $max && $date > $max ) {
-                               return $this->msg( 
'securepoll-htmlform-date-toohigh', $this->formatDate( $max ) )
-                                       ->parseAsBlock();
-                       }
-               }
-
-               return true;
-       }
-
-       protected function parseDate( $value ) {
-               $value = trim( $value );
-
-               /* @todo: Language should probably provide a "parseDate" method 
of some sort. */
-               try {
-                       $date = new DateTime( "$value T00:00:00+0000", new 
DateTimeZone( 'GMT' ) );
-                       return $date->getTimestamp();
-               } catch ( Exception $ex ) {
-                       return 0;
-               }
-       }
-
-       protected function formatDate( $value ) {
-               // For now just use Y-m-d. At some point someone may want to 
add a
-               // config option.
-               return gmdate( 'Y-m-d', $value );
-       }
-
-}
diff --git a/includes/htmlform/HTMLDateRangeField.php 
b/includes/htmlform/HTMLDateRangeField.php
deleted file mode 100644
index d218491..0000000
--- a/includes/htmlform/HTMLDateRangeField.php
+++ /dev/null
@@ -1,206 +0,0 @@
-<?php
-
-/**
- * A field that will contain a date range
- *
- * Besides the parameters recognized by HTMLDateField, additional recognized
- * parameters in the field descriptor array include:
- *   absolute - Boolean, whether to select the end date absolutely rather
- *     than as a number of days offset from the start date.
- *   options - If specified, the "number of days" field is displayed as a
- *     <select>. Otherwise it's an 'int' textbox.
- *   min-days - If the "number of days" field is a textbox, this is the minimum
- *     allowed. If less than 1, 1 is used.
- *   max-days - If the "number of days" field is a textbox, this is the maximum
- *     allowed.
- *   layout-message - The starting date field (as $1) and "number of days" or
- *     ending date field (as $2) are layed out using this message. Default is
- *     'securepoll-htmlform-daterange-relative-layout' or
- *     'securepoll-htmlform-daterange-absolute-layout', depending on 
'absolute'.
- *
- * The result is an empty array or an array with two values, the first being
- * the starting date and the second being either the number of days or the
- * ending date.
- *
- *  @todo These should be migrated to core, once the jquery.ui objectors write
- *  their own date picker.
- */
-class SecurePoll_HTMLDateRangeField extends SecurePoll_HTMLDateField {
-       function loadDataFromRequest( $request ) {
-               $absolute = !empty( $this->mParams['absolute'] );
-               if ( !$request->getCheck( $this->mName ) ||
-                       !$request->getCheck( $this->mName . ( $absolute ? 
'-end' : '-days' ) )
-               ) {
-                       return $this->getDefault();
-               }
-
-               $value1 = $request->getText( $this->mName );
-               if ( $value1 !== '' ) {
-                       $startDate = $this->parseDate( $value1 );
-                       $value1 = $startDate ? $this->formatDate( $startDate ) 
: $value1;
-               }
-
-               if ( $absolute ) {
-                       $value2 = $request->getText( $this->mName . '-end' );
-                       if ( $value2 !== '' ) {
-                               $endDate = $this->parseDate( $value2 );
-                               $value2 = $endDate ? $this->formatDate( 
$endDate ) : $value2;
-                       }
-               } else {
-                       $value2 = $request->getText( $this->mName . '-days' );
-               }
-
-               if ( $value1 === '' && ( !$absolute || $value2 === '' ) ) {
-                       return array();
-               }
-
-               return array( $value1, $value2 );
-       }
-
-       function validate( $value, $alldata ) {
-               if ( $this->isHidden( $alldata ) ) {
-                       return true;
-               }
-
-               if ( $value === array() ) {
-                       if ( isset( $this->mParams['required'] ) && 
$this->mParams['required'] !== false ) {
-                               return $this->msg( 'htmlform-required' 
)->parse();
-                       }
-                       return true;
-               }
-
-               $p = parent::validate( $value[0], $alldata );
-               if ( $p !== true ) {
-                       return $p;
-               }
-
-               if ( !empty( $this->mParams['absolute'] ) ) {
-                       if ( $value[0] === '' || $value[1] === '' ) {
-                               return $this->msg( 
'securepoll-htmlform-daterange-error-partial' )->parse();
-                       }
-
-                       $endDate = $value[1];
-                       if ( $this->parseDate( $value[0] ) >= $this->parseDate( 
$value[1] ) ) {
-                               return $this->msg( 
'securepoll-htmlform-daterange-end-before-start' )->parseAsBlock();
-                       }
-               } else {
-                       $opts = $this->getOptions();
-                       if ( $opts ) {
-                               if ( !in_array( $value[1], $opts ) ) {
-                                       return $this->msg( 
'securepoll-htmlform-daterange-days-badoption' )->parseAsBlock();
-                               }
-                       } else {
-                               if ( !preg_match( '/^(\+|\-)?\d+$/', trim( 
$value[1] ) ) ) {
-                                       return $this->msg( 
'securepoll-htmlform-daterange-days-invalid' )->parseAsBlock();
-                               }
-
-                               if ( isset( $this->mParams['min-days'] ) ) {
-                                       $min = max( 1, 
$this->mParams['min-days'] );
-                               } else {
-                                       $min = 1;
-                               }
-                               if ( $min > $value[1] ) {
-                                       return $this->msg( 
'securepoll-htmlform-daterange-days-toolow' )->numParams( $min )
-                                               ->parseAsBlock();
-                               }
-
-                               if ( isset( $this->mParams['max-days'] ) ) {
-                                       $max = $this->mParams['max-days'];
-
-                                       if ( $max < $value[1] ) {
-                                               return $this->msg( 
'securepoll-htmlform-daterange-days-toohigh' )->numParams( $max )
-                                                       ->parseAsBlock();
-                                       }
-                               }
-                       }
-
-                       $endDate = $this->formatDate( $this->parseDate( 
$value[0] ) + $value[1] * 86400 );
-               }
-
-               $p = parent::validate( $endDate, $alldata );
-               if ( $p !== true ) {
-                       return $p;
-               }
-
-               return true;
-       }
-
-       function getInputHTML( $value ) {
-               if ( $value === array() ) {
-                       $value = array( '', '' );
-               }
-
-               $startpicker = parent::getInputHTML( $value[0] );
-
-               if ( !empty( $this->mParams['absolute'] ) ) {
-                       $msg = 'securepoll-htmlform-daterange-absolute-layout';
-                       $oldName = $this->mName;
-                       $oldID= $this->mID;
-                       $this->mName .= '-end';
-                       $this->mID .= '-end';
-                       $endpicker = parent::getInputHTML( $value[1] );
-                       $this->mName = $oldName;
-                       $this->mID = $oldID;
-               } else {
-                       $msg = 'securepoll-htmlform-daterange-relative-layout';
-                       $opts = $this->getOptions();
-                       if ( $opts ) {
-                               $select = new XmlSelect(
-                                       $this->mName . '-days', $this->mID . 
'-days', strval( $value[1] )
-                               );
-
-                               if ( !empty( $this->mParams['disabled'] ) ) {
-                                       $select->setAttribute( 'disabled', 
'disabled' );
-                               }
-
-                               if ( isset( $this->mParams['tabindex'] ) ) {
-                                       $select->setAttribute( 'tabindex', 
$this->mParams['tabindex'] );
-                               }
-
-                               if ( $this->mClass !== '' ) {
-                                       $select->setAttribute( 'class', 
$this->mClass );
-                               }
-
-                               $select->addOptions( $this->getOptions() );
-
-                               $endpicker = $select->getHTML();
-                       } else {
-                               $textAttribs = array(
-                                       'id' => $this->mID . '-days',
-                                       'size' => $this->getSize(),
-                                       'min' => 1,
-                               );
-
-                               if ( $this->mClass !== '' ) {
-                                       $textAttribs['class'] = $this->mClass;
-                               }
-
-                               $allowedParams = array(
-                                       'required',
-                                       'autofocus',
-                                       'disabled',
-                                       'tabindex'
-                               );
-
-                               $textAttribs += $this->getAttributes( 
$allowedParams );
-
-                               if ( isset( $this->mParams['min-days'] ) ) {
-                                       $textAttribs['min'] = max( 1, 
$this->mParams['min-days'] );
-                               }
-
-                               if ( isset( $this->mParams['max-days'] ) ) {
-                                       $textAttribs['max'] = 
$this->mParams['max-days'];
-                               }
-
-                               $endpicker = Html::input( $this->mName . 
'-days', $value[1], 'number', $textAttribs );
-                       }
-               }
-
-               if ( isset( $this->mParams['layout-message'] ) ) {
-                       $msg = $this->mParams['layout-message'];
-               }
-
-               return $this->msg( $msg )->rawParams( $startpicker, $endpicker 
)->parse();
-       }
-
-}
diff --git a/includes/jobs/PopulateVoterListJob.php 
b/includes/jobs/PopulateVoterListJob.php
index 5454959..03d380e 100644
--- a/includes/jobs/PopulateVoterListJob.php
+++ b/includes/jobs/PopulateVoterListJob.php
@@ -10,12 +10,13 @@
                static $props = array(
                        'need-list', 'list_populate',
                        'list_edits-before', 'list_edits-before-count', 
'list_edits-before-date',
-                       'list_edits-between', 'list_edits-between-count', 
'list_edits-between-dates',
-                       'list_exclude-groups',
-                       'list_include-groups',
+                       'list_edits-between', 'list_edits-between-count',
+                       'list_edits-startdate', 'list_edits-enddate',
+                       'list_exclude-groups', 'list_include-groups',
                );
                static $listProps = array(
-                       'list_edits-between-dates', 'list_exclude-groups', 
'list_include-groups',
+                       'list_edits-startdate', 'list_edits-enddate',
+                       'list_exclude-groups', 'list_include-groups',
                );
 
                $dbw = $election->context->getDB();
@@ -231,8 +232,8 @@
 
                        // Criterion 2: $NUM edits bewteen $DATE1 and $DATE2
                        if ( $this->params['list_edits-between'] ) {
-                               $timestamp1 = $dbr->addQuotes( $dbr->timestamp( 
$this->params['list_edits-between-dates'][0] ) );
-                               $timestamp2 = $dbr->addQuotes( $dbr->timestamp( 
$this->params['list_edits-between-dates'][1] ) );
+                               $timestamp1 = $dbr->addQuotes( $dbr->timestamp( 
$this->params['list_edits-startdate'] ) );
+                               $timestamp2 = $dbr->addQuotes( $dbr->timestamp( 
$this->params['list_edits-enddate'] ) );
 
                                $res = $dbr->select(
                                        'revision',
diff --git a/includes/pages/CreatePage.php b/includes/pages/CreatePage.php
index f2f071d..8ee4f06 100644
--- a/includes/pages/CreatePage.php
+++ b/includes/pages/CreatePage.php
@@ -60,13 +60,6 @@
                        }
                }
 
-               /** @todo These should be migrated to core, once the jquery.ui
-                * objectors write their own date picker. */
-               if ( !isset( HTMLForm::$typeMappings['date'] ) || !isset( 
HTMLForm::$typeMappings['daterange'] ) ) {
-                       HTMLForm::$typeMappings['date'] = 
'SecurePoll_HTMLDateField';
-                       HTMLForm::$typeMappings['daterange'] = 
'SecurePoll_HTMLDateRangeField';
-               }
-
                $out->addModules( 'ext.securepoll.htmlform' );
                $out->addModules( 'ext.securepoll' );
                $out->setPageTitle( $this->msg( 'securepoll-create-title' ) );
@@ -164,16 +157,21 @@
                        'required' => true,
                );
 
+               $formItems['election_startdate'] = array(
+                       'label-message' => 
'securepoll-create-label-election_startdate',
+                       'type' => 'date',
+                       'required' => true,
+                       'min' => gmdate( 'M-d-Y' ),
+               );
+
                $days = array();
                for ( $i = 1; $i <= 28; $i++ ) {
                        $days[$i] = $i;
                }
-               $formItems['election_dates'] = array(
-                       'label-message' => 
'securepoll-create-label-election_dates',
-                       'layout-message' => 
'securepoll-create-layout-election_dates',
-                       'type' => 'daterange',
+               $formItems['election_duration'] = array(
+                       'type' => 'select',
+                       'label-message' => 
'securepoll-create-label-election_duration',
                        'required' => true,
-                       'min' => gmdate( 'M-d-Y' ),
                        'options' => $days,
                );
 
@@ -339,10 +337,10 @@
                        );
                }
 
-               $form = new HTMLForm( $formItems, 
$this->specialPage->getContext(),
+               $form = HTMLForm::factory('div', $formItems, 
$this->specialPage->getContext(),
                        $this->election ? 'securepoll-edit' : 
'securepoll-create'
                );
-               $form->setDisplayFormat( 'div' );
+
                $form->setSubmitTextMsg( $this->election ? 
'securepoll-edit-action' : 'securepoll-create-action' );
                $form->setSubmitCallback( array( $this, 'processInput' ) );
                $form->prepareForm();
@@ -617,6 +615,7 @@
 
                $startDate = new MWTimestamp( $data['startDate'] );
                $endDate = new MWTimestamp( $data['endDate'] );
+               $duration = $endDate->diff( $startDate )->format( '%a' );
 
                $ballot = $data['ballot'];
                $tally = $data['tally'];
@@ -627,10 +626,8 @@
                        'election_title' => $data['title'],
                        'property_wiki' => isset( $p['wikis-val'] ) ? 
$p['wikis-val'] : null,
                        'election_primaryLang' => $data['lang'],
-                       'election_dates' => array(
-                               $startDate->format( 'Y-m-d' ),
-                               $endDate->diff( $startDate )->format( '%a' ),
-                       ),
+                       'election_startdate' => $startDate->format( 'Y-m-d' ),
+                       'election_duration' => $duration,
                        'return-url' => isset( $p['return-url'] ) ? 
$p['return-url'] : null,
                        'jump-text' => isset( $m['jump-text'] ) ? 
$m['jump-text'] : null,
                        'election_type' => "{$ballot}+{$tally}",
@@ -931,15 +928,16 @@
                $this->remoteWikis = array_diff( $wikis, array( wfWikiID() ) );
 
                // Create the entry for the election
-               list( $ballot,$tally ) = explode( '+', 
$formData['election_type'] );
+               list( $ballot, $tally ) = explode( '+', 
$formData['election_type'] );
                $crypt = $formData['election_crypt'];
 
                $date = new DateTime(
-                       "{$formData['election_dates'][0]}T00:00:00Z",
+                       "{$formData['election_startdate']}T00:00:00Z",
                        new DateTimeZone( 'GMT' )
                );
                $startDate = $date->format( 'YmdHis' );
-               $date->add( new DateInterval( 
"P{$formData['election_dates'][1]}D" ) );
+
+               $date->add( new DateInterval( 
"P{$formData['election_duration']}D" ) );
                $endDate = $date->format( 'YmdHis' );
 
                $this->lang = $formData['election_primaryLang'];
diff --git a/includes/pages/VoterEligibilityPage.php 
b/includes/pages/VoterEligibilityPage.php
index bfde069..4ce15c2 100644
--- a/includes/pages/VoterEligibilityPage.php
+++ b/includes/pages/VoterEligibilityPage.php
@@ -336,14 +336,6 @@
        private function executeConfig() {
                global $wgSecurePollUseNamespace;
 
-               /** @todo These should be migrated to core, once the jquery.ui
-                * objectors write their own date picker. */
-               if ( !isset( HTMLForm::$typeMappings['date'] ) || !isset( 
HTMLForm::$typeMappings['daterange'] ) ) {
-                       HTMLForm::$typeMappings['date'] = 
'SecurePoll_HTMLDateField';
-                       HTMLForm::$typeMappings['daterange'] = 
'SecurePoll_HTMLDateRangeField';
-               }
-
-               $this->specialPage->getOutput()->addModules( 
'ext.securepoll.htmlform' );
                $this->specialPage->getOutput()->addModules( 'ext.securepoll' );
 
                $out = $this->specialPage->getOutput();
@@ -540,32 +532,42 @@
                                        'default' => 
$this->election->getProperty( 'list_edits-between-count', '' ),
                                );
 
-                               $dates = $this->election->getProperty( 
'list_edits-between-dates', '' );
-                               if ( $dates === '' ) {
-                                       $dates = array(
-                                               gmdate( 'Y-m-d', strtotime( '2 
days ago' ) ),
-                                               gmdate( 'Y-m-d', strtotime( 
'yesterday' ) )
-                                       );
-                               } else {
-                                       $dates = explode( '|', $dates );
-                                       $dates = array(
-                                               gmdate( 'Y-m-d', wfTimestamp( 
TS_UNIX, $dates[0] ) ),
-                                               gmdate( 'Y-m-d', wfTimestamp( 
TS_UNIX, $dates[1] ) ),
-                                       );
+                               $editCountStartDate = 
$this->election->getProperty( 'list_edits-startdate', '' );
+                               if ( $editCountStartDate !== '' ) {
+                                       $editCountStartDate = gmdate( 'Y-m-d', 
wfTimestamp( TS_UNIX, $editCountStartDate ) );
                                }
-                               $formItems['list_edits-between-dates'] = array(
+
+                               $formItems['list_edits-startdate'] = array(
                                        'section' => 'lists',
-                                       'label-message' => 
'securepoll-votereligibility-label-edits_between_dates',
-                                       'layout-message' => 
'securepoll-votereligibility-layout-edits_between_dates',
-                                       'type' => 'daterange',
-                                       'absolute' => true,
+                                       'label-message' => 
'securepoll-votereligibility-label-edits_startdate',
+                                       'type' => 'date',
                                        'max' => gmdate( 'Y-m-d', strtotime( 
'yesterday' ) ),
                                        'required' => true,
                                        'hide-if' => array( 'OR',
                                                array( '===', 'list_populate', 
'' ),
                                                array( '===', 
'list_edits-between', '' ),
                                        ),
-                                       'default' => $dates,
+                                       'default' => $editCountStartDate,
+                               );
+
+                               $editCountEndDate = 
$this->election->getProperty( 'list_edits-enddate', '' );
+                               if ( $editCountEndDate === '' ) {
+                                       $editCountEndDate = gmdate( 'Y-m-d', 
strtotime( 'yesterday' ) );
+                               } else {
+                                       $editCountEndDate = gmdate( 'Y-m-d', 
wfTimestamp( TS_UNIX, $editCountEndDate ) );
+                               }
+
+                               $formItems['list_edits-enddate'] = array(
+                                       'section' => 'lists',
+                                       'label-message' => 
'securepoll-votereligibility-label-edits_enddate',
+                                       'type' => 'date',
+                                       'max' => gmdate( 'Y-m-d', strtotime( 
'yesterday' ) ),
+                                       'required' => true,
+                                       'hide-if' => array( 'OR',
+                                               array( '===', 'list_populate', 
'' ),
+                                               array( '===', 
'list_edits-between', '' ),
+                                       ),
+                                       'default' => $editCountEndDate,
                                );
 
                                $groups = $this->election->getProperty( 
'list_exclude-groups', array() );
@@ -641,14 +643,14 @@
                        );
                }
 
-               $form = new HTMLForm( $formItems, 
$this->specialPage->getContext(), 'securepoll-votereligibility' );
+               $form = HTMLForm::factory('div', $formItems, 
$this->specialPage->getContext(), 'securepoll-votereligibility' );
                $form->addHeaderText(
                        $this->msg( 'securepoll-votereligibility-basic-info' 
)->parseAsBlock(), 'basic'
                );
                $form->addHeaderText(
                        $this->msg( 'securepoll-votereligibility-lists-info' 
)->parseAsBlock(), 'lists'
                );
-               $form->setDisplayFormat( 'div' );
+
                $form->setSubmitTextMsg( 'securepoll-votereligibility-action' );
                $form->setSubmitCallback( array( $this, 'processConfig' ) );
                $result = $form->show();
@@ -660,6 +662,19 @@
                }
        }
 
+       // Based on HTMLDateRangeField::praseDate()
+       protected function parseDate( $value ) {
+               $value = trim( $value );
+               $value .= ' T00:00:00+0000';
+
+               try {
+                       $date = new DateTime( $value, new DateTimeZone( 'GMT' ) 
);
+                       return $date->getTimestamp();
+               } catch ( Exception $ex ) {
+                       return 0;
+               }
+       }
+
        public function processConfig( $formData, $form ) {
                static $props = array(
                        'min-edits', 'not-blocked', 'not-centrally-blocked',
@@ -668,7 +683,8 @@
                        'list_edits-between', 'list_edits-between-count',
                );
                static $dateProps = array(
-                       'max-registration', 'list_edits-before-date', 
'list_edits-between-dates',
+                       'max-registration', 'list_edits-before-date',
+                       'list_edits-startdate', 'list_edits-enddate',
                );
                static $listProps = array(
                        'list_exclude-groups', 'list_include-groups',
@@ -723,7 +739,13 @@
                        $properties['need-list'] = 'need-list-' . 
$this->election->getId();
                }
 
-               $this->saveProperties( $properties, $deleteProperties, 
$formData['comment'] );
+               if ( $this->parseDate($formData['list_edits-startdate']) >= 
$this->parseDate($formData['list_edits-enddate']) ) {
+                       return $this->msg( 
'securepoll-htmlform-daterange-end-before-start' )->parseAsBlock();
+               }
+
+               $comment = isset( $formData['comment'] ) ? $formData['comment'] 
: '';
+
+               $this->saveProperties( $properties, $deleteProperties, $comment 
);
 
                if ( $populate ) {
                        // Run pushJobsForElection() in a deferred update to 
give it outer transaction
diff --git a/modules/ext.securepoll.css b/modules/ext.securepoll.css
index fc2eaf3..08c3b62 100644
--- a/modules/ext.securepoll.css
+++ b/modules/ext.securepoll.css
@@ -6,8 +6,7 @@
 /* Add spacing between controls */
 .mw-htmlform-field-HTMLTextField,
 .mw-htmlform-field-HTMLIntField,
-.mw-htmlform-field-SecurePoll_HTMLDateField,
-.mw-htmlform-field-SecurePoll_HTMLDateRangeField,
+.mw-htmlform-field-HTMLDateTimeField,
 .mw-htmlform-field-HTMLFormFieldCloner,
 .mw-htmlform-field-HTMLSelectField,
 .mw-htmlform-field-HTMLAutoCompleteSelectField,
diff --git a/modules/ext.securepoll.htmlform.js 
b/modules/ext.securepoll.htmlform.js
index c70efbb..c549686 100644
--- a/modules/ext.securepoll.htmlform.js
+++ b/modules/ext.securepoll.htmlform.js
@@ -4,40 +4,6 @@
 ( function ( mw, $ ) {
 
        mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
-               var inputs, i;
-
-               inputs = $root.find( 'input[type=date]' );
-               if ( inputs.length === 0 ) {
-                       return;
-               }
-
-               // Assume that if the browser implements validation for <input 
type=date>
-               // (so it rejects "bogus" as a value) then it supports a date 
picker too.
-               i = document.createElement( 'input' );
-               i.setAttribute( 'type', 'date' );
-               i.value = 'bogus';
-               if ( i.value === 'bogus' ) {
-                       mw.loader.using( 'jquery.ui.datepicker', function () {
-                               inputs.each( function () {
-                                       var $i = $( this );
-                                       // Reset the type, Just In Case
-                                       $i.prop( 'type', 'text' );
-                                       $i.datepicker( {
-                                               dateFormat: 'yy-mm-dd',
-                                               constrainInput: true,
-                                               showOn: 'focus',
-                                               changeMonth: true,
-                                               changeYear: true,
-                                               showButtonPanel: true,
-                                               minDate: $i.data( 'min' ),
-                                               maxDate: $i.data( 'max' ),
-                                       } );
-                               } );
-                       } );
-               }
-       } );
-
-       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
                var numRegex = /^[+-]?\d+$/;
 
                $root.find( '.securepoll-radiorange-messages' ).each( 
function() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I23304d9a9861323bc77dd64d4f4bea6e191e2700
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Huji <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Huji <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to