Page MenuHomePhabricator

SF_de-americanise_datetime.patch

Authored By
bzimport
Nov 21 2014, 9:57 PM
Size
7 KB
Referenced Files
None
Subscribers
None

SF_de-americanise_datetime.patch

diff -Nur SemanticForms.backup/includes/SF_FormInputs.inc SemanticForms/includes/SF_FormInputs.inc
--- SemanticForms.backup/includes/SF_FormInputs.inc 2008-12-09 11:06:47.000000000 +0800
+++ SemanticForms/includes/SF_FormInputs.inc 2008-12-09 12:10:16.000000000 +0800
@@ -465,6 +465,7 @@
}
function dateEntryHTML($date, $input_name, $is_mandatory, $is_disabled, $other_args) {
+ global $wgAmericanDates;
global $sfgTabIndex, $sfgFieldNum, $sfgJSValidationCalls;
$input_id = "input_$sfgFieldNum";
@@ -496,15 +497,20 @@
$day = null; // no need for day
}
$disabled_text = ($is_disabled) ? "disabled" : "";
- $text = SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled);
- $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n";
+ if ($wgAmericanDates == true) {
+ $text = SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled);
+ $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n";
+ } else {
+ $text = ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_day" name="' . $input_name . '[day]" type="text" value="' . $day . '" size="2" ' . $disabled_text . '/>' . "\n";
+ $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled);
+ }
$text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_year" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n";
$text .= " <span id=\"$info_id\" class=\"errorMessage\"></span>";
return array($text, null);
}
function dateTimeEntryHTML($datetime, $input_name, $is_mandatory, $is_disabled, $other_args) {
- global $sfgTabIndex;
+ global $sfgTabIndex, $wgAmericanDates;
$include_timezone = $other_args['include_timezone'];
@@ -515,14 +521,22 @@
if (isset($datetime['hour'])) $hour = $cur_value['hour'];
if (isset($datetime['minute'])) $minute = $cur_value['minute'];
if (isset($datetime['second'])) $second = $cur_value['second'];
- if (isset($datetime['ampm24h'])) $ampm24h = $cur_value['ampm24h'];
+ if ($wgAmericanDates == true) {
+ if (isset($datetime['ampm24h'])) $ampm24h = $cur_value['ampm24h'];
+ }
if (isset($datetime['timezone'])) $timezone = $cur_value['timezone'];
} else {
$actual_date = strtotime($datetime);
- $hour = date("g", $actual_date);
+ if ($wgAmericanDates == true) {
+ $hour = date("g", $actual_date);
+ } else {
+ $hour = date("G", $actual_date);
+ }
$minute = date("i", $actual_date);
$second = date("s", $actual_date);
- $ampm24h = date("A", $actual_date);
+ if ($wgAmericanDates == true) {
+ $ampm24h = date("A", $actual_date);
+ }
$timezone = date("T", $actual_date);
}
} else {
@@ -541,15 +555,17 @@
$sfgTabIndex++;
$text .= ':<input tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[second]" type="text" value="' . $second . '" size="2"/ ' . $disabled_text . '>' . "\n";
- $sfgTabIndex++;
- $text .= ' <select tabindex="' . $sfgTabIndex . '" name="' . $input_name . "[ampm24h]\" $disabled_text>\n";
- $ampm24h_options = array('', 'AM', 'PM');
- foreach ($ampm24h_options as $value) {
- $text .= " <option value=\"$value\"";
- if ($value == $ampm24h) {$text .= " selected=\"selected\""; }
- $text .= ">$value</option>\n";
+ if ($wgAmericanDates == true) {
+ $sfgTabIndex++;
+ $text .= ' <select tabindex="' . $sfgTabIndex . '" name="' . $input_name . "[ampm24h]\" $disabled_text>\n";
+ $ampm24h_options = array('', 'AM', 'PM');
+ foreach ($ampm24h_options as $value) {
+ $text .= " <option value=\"$value\"";
+ if ($value == $ampm24h) {$text .= " selected=\"selected\""; }
+ $text .= ">$value</option>\n";
+ }
+ $text .= " </select>\n";
}
- $text .= " </select>\n";
if ($include_timezone) {
$sfgTabIndex++;
diff -Nur SemanticForms.backup/includes/SF_FormPrinter.inc SemanticForms/includes/SF_FormPrinter.inc
--- SemanticForms.backup/includes/SF_FormPrinter.inc 2008-12-09 11:06:46.000000000 +0800
+++ SemanticForms/includes/SF_FormPrinter.inc 2008-12-09 11:48:34.000000000 +0800
@@ -76,7 +76,7 @@
}
function formHTML($form_def, $form_submitted, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null) {
- global $wgRequest, $wgUser, $wgParser;
+ global $wgRequest, $wgUser, $wgParser, $wgAmericanDates;
global $sfgTabIndex; // used to represent the current tab index in the form
global $sfgFieldNum; // used for setting various HTML IDs
global $sfgJSValidationCalls; // array of Javascript calls to determine if page can be saved
@@ -595,7 +595,9 @@
if (isset($cur_value['hour'])) $hour = $cur_value['hour'];
if (isset($cur_value['minute'])) $minute = $cur_value['minute'];
if (isset($cur_value['second'])) $second = $cur_value['second'];
- if (isset($cur_value['ampm24h'])) $ampm24h = $cur_value['ampm24h'];
+ if ($wgAmericanDates == true) {
+ if (isset($cur_value['ampm24h'])) $ampm24h = $cur_value['ampm24h'];
+ }
if (isset($cur_value['timezone'])) $timezone = $cur_value['timezone'];
if ($month != '' && $day != '' && $year != '') {
// special handling for American dates - otherwise, just
@@ -609,7 +611,9 @@
// include whatever time information we have
if(isset($hour)) $cur_value_in_template .= " " . str_pad(intval(substr($hour,0,2)),2,'0',STR_PAD_LEFT) . ":" . str_pad(intval(substr($minute,0,2)),2,'0',STR_PAD_LEFT);
if(isset($second)) $cur_value_in_template .= ":" . str_pad(intval(substr($second,0,2)),2,'0',STR_PAD_LEFT);
- if(isset($ampm24h)) $cur_value_in_template .= " $ampm24h";
+ if ($wgAmericanDates == true) {
+ if(isset($ampm24h)) $cur_value_in_template .= " $ampm24h";
+ }
if(isset($timezone)) $cur_value_in_template .= " $timezone";
} else {
$cur_value_in_template = "";
@@ -674,11 +678,19 @@
$cur_value_in_template = "$year/$month/$day";
}
if ($input_type == 'datetime' || $input_type == 'datetime with timezone') {
- $hour = str_pad(intval(substr(date("g", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
+ if ($wgAmericanDates == true) {
+ $hour = str_pad(intval(substr(date("g", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
+ } else {
+ $hour = str_pad(intval(substr(date("G", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
+ }
$minute = str_pad(intval(substr(date("i", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
$second = str_pad(intval(substr(date("s", $cur_time),0,2)),2,'0',STR_PAD_LEFT);
- $ampm = date("A", $cur_time);
- $cur_value_in_template .= " $hour:$minute:$second $ampm";
+ if ($wgAmericanDates == true) {
+ $ampm = date("A", $cur_time);
+ $cur_value_in_template .= " $hour:$minute:$second $ampm";
+ } else {
+ $cur_value_in_template .= " $hour:$minute:$second";
+ }
}
if ($input_type == 'datetime with timezone') {
$timezone = date("T", $cur_time);

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3972
Default Alt Text
SF_de-americanise_datetime.patch (7 KB)

Event Timeline