X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FTimeZone.php;h=26f2232d45c1a5961d45380acf52de0beafd5b70;hb=5eb724785209fd0ddf34784be8f872d83208eb54;hp=ccbef918b3f6f9c6db91c50c17df5c7b8ce7a7af;hpb=874f858b8fbacfcd31cd64e21555f03927d4e15a;p=github%2Fshaarli%2FShaarli.git
diff --git a/application/TimeZone.php b/application/TimeZone.php
index ccbef918..26f2232d 100644
--- a/application/TimeZone.php
+++ b/application/TimeZone.php
@@ -5,30 +5,33 @@
* Note: 'UTC/UTC' is mapped to 'UTC' to form a valid option
*
* Example: preselect Europe/Paris
- * list($htmlform, $js) = templateTZform('Europe/Paris');
+ * list($htmlform, $js) = generateTimeZoneForm('Europe/Paris');
*
* @param string $preselected_timezone preselected timezone (optional)
*
* @return an array containing the generated HTML form and Javascript code
**/
-function generateTimeZoneForm($preselected_timezone='')
+function generateTimeZoneForm($preselectedTimezone='')
{
- // Select the first available timezone if no preselected value is passed
- if ($preselected_timezone == '') {
- $l = timezone_identifiers_list();
- $preselected_timezone = $l[0];
+ // Select the server timezone
+ if ($preselectedTimezone == '') {
+ $preselectedTimezone = date_default_timezone_get();
}
- // Try to split the provided timezone
- $spos = strpos($preselected_timezone, '/');
- $pcontinent = substr($preselected_timezone, 0, $spos);
- $pcity = substr($preselected_timezone, $spos+1);
+ if ($preselectedTimezone == 'UTC') {
+ $pcity = $pcontinent = 'UTC';
+ } else {
+ // Try to split the provided timezone
+ $spos = strpos($preselectedTimezone, '/');
+ $pcontinent = substr($preselectedTimezone, 0, $spos);
+ $pcity = substr($preselectedTimezone, $spos+1);
+ }
// Display config form:
- $timezone_form = '';
- $timezone_js = '';
+ $timezoneForm = '';
+ $timezoneJs = '';
- // The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires'...
+ // The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires'
// We split the list in continents/cities.
$continents = array();
$cities = array();
@@ -57,33 +60,33 @@ function generateTimeZoneForm($preselected_timezone='')
}
}
- $continents_html = '';
+ $continentsHtml = '';
$continents = array_keys($continents);
foreach ($continents as $continent) {
- $continents_html .= '';
}
// Timezone selection form
- $timezone_form = 'Continent:';
- $timezone_form .= '';
- $timezone_form .= ' City:';
- $timezone_form .= '
';
+ $timezoneForm = 'Continent:';
+ $timezoneForm .= '';
+ $timezoneForm .= ' City:';
+ $timezoneForm .= '
';
// Javascript handler - updates the city list when the user selects a continent
- $timezone_js = '';
+ $timezoneJs = '';
- return array($timezone_form, $timezone_js);
+ return array($timezoneForm, $timezoneJs);
}
/**
@@ -98,13 +101,8 @@ function generateTimeZoneForm($preselected_timezone='')
*/
function isTimeZoneValid($continent, $city)
{
- if ($continent == 'UTC' && $city == 'UTC') {
- return true;
- }
-
return in_array(
$continent.'/'.$city,
timezone_identifiers_list()
);
}
-?>