diff options
author | Stefan Parviainen <saparvia@caterva.eu> | 2015-01-01 14:44:50 +0100 |
---|---|---|
committer | Stefan Parviainen <saparvia@caterva.eu> | 2015-01-01 14:44:50 +0100 |
commit | 686b6ee1182c09969e2817b53825a78975c75bf5 (patch) | |
tree | 20ab015bbe6b088a473a98ebb71f3feb49e252d7 | |
parent | ef94747e5eb4d8b2e3566835280c31b848fc28e6 (diff) | |
download | volse-hubzilla-686b6ee1182c09969e2817b53825a78975c75bf5.tar.gz volse-hubzilla-686b6ee1182c09969e2817b53825a78975c75bf5.tar.bz2 volse-hubzilla-686b6ee1182c09969e2817b53825a78975c75bf5.zip |
Use grouped select field for timezone selection
-rw-r--r-- | include/datetime.php | 47 | ||||
-rw-r--r-- | mod/settings.php | 4 | ||||
-rwxr-xr-x | mod/setup.php | 2 | ||||
-rwxr-xr-x | view/tpl/install_settings.tpl | 2 | ||||
-rwxr-xr-x | view/tpl/settings.tpl | 2 |
5 files changed, 13 insertions, 44 deletions
diff --git a/include/datetime.php b/include/datetime.php index 59dad2045..346d03bd4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -14,25 +14,17 @@ function timezone_cmp($a, $b) { return ( t($a) < t($b)) ? -1 : 1; } -// emit a timezone selector grouped (primarily) by continent - -function select_timezone($current = 'America/Los_Angeles') { - +// Return timezones grouped (primarily) by continent +function get_timezones( ){ $timezone_identifiers = DateTimeZone::listIdentifiers(); - - $o ='<select id="timezone_select" name="timezone">'; usort($timezone_identifiers, 'timezone_cmp'); $continent = ''; + $continents = array(); foreach($timezone_identifiers as $value) { $ex = explode("/", $value); if(count($ex) > 1) { - if($ex[0] != $continent) { - if($continent != '') - $o .= '</optgroup>'; - $continent = $ex[0]; - $o .= '<optgroup label="' . t($continent) . '">'; - } + $continent = t($ex[0]); if(count($ex) > 2) $city = substr($value,strpos($value,'/')+1); else @@ -40,35 +32,14 @@ function select_timezone($current = 'America/Los_Angeles') { } else { $city = $ex[0]; - if($continent != t('Miscellaneous')) { - $o .= '</optgroup>'; - $continent = t('Miscellaneous'); - $o .= '<optgroup label="' . t($continent) . '">'; - } + $continent = t('Miscellaneous'); } $city = str_replace('_', ' ', t($city)); - $selected = (($value == $current) ? " selected=\"selected\" " : ""); - $o .= "<option value=\"$value\" $selected >$city</option>"; - } - $o .= '</optgroup></select>'; - return $o; -} - -// return a select using 'field_select_raw' template, with timezones -// groupped (primarily) by continent -// arguments follow convetion as other field_* template array: -// 'name', 'label', $value, 'help' -function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){ - $options = select_timezone($current); - $options = str_replace('<select id="timezone_select" name="timezone">','', $options); - $options = str_replace('</select>','', $options); - - $tpl = get_markup_template('field_select_raw.tpl'); - return replace_macros($tpl, array( - '$field' => array($name, $label, $current, $help, $options), - )); - + if(!x($continents,$ex[0])) $continents[$ex[0]] = array(); + $continents[$continent][$value] = $city; + } + return $continents; } // General purpose date parse/convert function. diff --git a/mod/settings.php b/mod/settings.php index be6f2cfb9..bce04e436 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -1010,12 +1010,10 @@ function settings_content(&$a) { '$uid' => local_user(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, - - '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username,''), '$email' => array('email', t('Email Address:'), $email, ''), - '$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''), + '$timezone' => array('timezone_select' , t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), ((get_pconfig(local_user(),'system','use_browser_location')) ? 1 : ''), ''), diff --git a/mod/setup.php b/mod/setup.php index 044def15a..6f2c7c074 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -349,7 +349,7 @@ function setup_content(&$a) { '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), - '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), + '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()), '$baseurl' => $a->get_baseurl(), diff --git a/view/tpl/install_settings.tpl b/view/tpl/install_settings.tpl index f4fd82fdb..62dcbb8b3 100755 --- a/view/tpl/install_settings.tpl +++ b/view/tpl/install_settings.tpl @@ -20,7 +20,7 @@ {{include file="field_input.tpl" field=$adminmail}} {{include file="field_input.tpl" field=$siteurl}} -{{$timezone}} +{{include file="field_select_grouped.tpl" field=$timezone}} <input id="install-submit" type="submit" name="submit" value="{{$submit}}" /> diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl index 47d85d8e4..83da4f87e 100755 --- a/view/tpl/settings.tpl +++ b/view/tpl/settings.tpl @@ -9,7 +9,7 @@ <h3 class="settings-heading">{{$h_basic}}</h3> {{include file="field_input.tpl" field=$username}} -{{include file="field_custom.tpl" field=$timezone}} +{{include file="field_select_grouped.tpl" field=$timezone}} {{include file="field_input.tpl" field=$defloc}} {{include file="field_checkbox.tpl" field=$allowloc}} |