Huji has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315516

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

Don't use jquery.ui.datepicker in SecurePoll

Bug: T147136
Change-Id: I23304d9a9861323bc77dd64d4f4bea6e191e2700
---
M i18n/en.json
M i18n/qqq.json
M includes/pages/CreatePage.php
3 files changed, 32 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll 
refs/changes/16/315516/1

diff --git a/i18n/en.json b/i18n/en.json
index 680ea01..6d11d4c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -132,12 +132,6 @@
        "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",
@@ -151,8 +145,10 @@
        "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-layout-election_startdate": "Start on $1 (at 00:00 
UTC)",
+       "securepoll-create-label-election_enddate": "Election End Date:",
+       "securepoll-create-layout-election_enddate": "End on $1 (at 00:00 UTC)",
        "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:",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 45f7215..b072e47 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -113,12 +113,6 @@
        "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",
@@ -132,8 +126,10 @@
        "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-layout-election_startdate": "Layout message for the 
date range input on [[Special:SecurePoll/create]].\n\nParameters:\n* $1 - HTML 
for the starting date control",
+       "securepoll-create-label-election_startdate": "Label for form field on 
Special:SecurePoll/create.",
+       "securepoll-create-layout-election_startdate": "Layout message for the 
date range input on [[Special:SecurePoll/create]].\n\nParameters:\n* $1 - HTML 
for the ending date control",
        "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.",
diff --git a/includes/pages/CreatePage.php b/includes/pages/CreatePage.php
index 11cca58..4fa2584 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,17 +157,20 @@
                        'required' => true,
                );
 
-               $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_startdate'] = array(
+                       'label-message' => 
'securepoll-create-label-election_startdate',
+                       'layout-message' => 
'securepoll-create-layout-election_startdate',
+                       'type' => 'date',
                        'required' => true,
                        'min' => gmdate( 'M-d-Y' ),
-                       'options' => $days,
+               );
+
+               $formItems['election_enddate'] = array(
+                       'label-message' => 
'securepoll-create-label-election_enddate',
+                       'layout-message' => 
'securepoll-create-layout-election_enddate',
+                       'type' => 'date',
+                       'required' => true,
+                       'min' => gmdate( 'M-d-Y' ),
                );
 
                $formItems['return-url'] = array(
@@ -339,10 +335,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->setDisplayFormat( 'div' );
                $form->setSubmitTextMsg( $this->election ? 
'securepoll-edit-action' : 'securepoll-create-action' );
                $form->setSubmitCallback( array( $this, 'processInput' ) );
                $form->prepareForm();
@@ -627,10 +623,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_enddate' => $endDate->format( 'Y-m-d' ),
                        '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 +925,19 @@
                $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'];
-
+print_r($formData); // HUJI
                $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 = new DateTime(
+                       "{$formData['election_enddate']}T00:00:00Z",
+                       new DateTimeZone( 'GMT' )
+               );
                $endDate = $date->format( 'YmdHis' );
 
                $this->lang = $formData['election_primaryLang'];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23304d9a9861323bc77dd64d4f4bea6e191e2700
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Huji <huji.h...@gmail.com>

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

Reply via email to