Skip to content

Commit

Permalink
Fix #12545: Refactor print_timezone_option_list()
Browse files Browse the repository at this point in the history
This function was not producing well formed XHTML due to missing closing
tags on the <optgroup> elements. It was also neglecting to send line
breaks and tabs to the output engine for each option printed, causing
very long lines to appear in the XHTML output. Shorter lines are easier
to read through and debug.
  • Loading branch information
davidhicks committed Nov 20, 2010
1 parent cb44a76 commit 33043bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion account_prefs_inc.php
Expand Up @@ -293,7 +293,7 @@ function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_
</th>
<td>
<select name="timezone">
<?php print_timezone_option_list( $t_pref->timezone ? $t_pref->timezone : config_get_global( 'default_timezone' ) ) ?>
<?php print_timezone_option_list( $t_pref->timezone ? $t_pref->timezone : config_get_global( 'default_timezone' ) ) ?>
</select>
</td>
</tr>
Expand Down
9 changes: 5 additions & 4 deletions core/print_api.php
Expand Up @@ -1667,7 +1667,7 @@ function swap_content( span ) {
# Print the option list for timezones
function print_timezone_option_list( $p_timezone ) {
if ( !function_exists( 'timezone_identifiers_list' ) ) {
echo '<option value="', $p_timezone, '" selected="selected">', $p_timezone, '</option>';
echo "\t<option value=\"$p_timezone\" selected=\"selected\">$p_timezone</option>\n";
return;
}

Expand Down Expand Up @@ -1697,11 +1697,12 @@ function print_timezone_option_list( $p_timezone ) {
}

foreach( $t_locations as $t_continent => $t_locations ) {
echo '<optgroup label="'.$t_continent.'">';
echo "\t<optgroup label=\"$t_continent\">\n";
foreach ( $t_locations as $t_location ) {
echo '<option value="' . $t_location[1] . '"';
echo "\t\t<option value=\"" . $t_location[1] . '"';
check_selected( $p_timezone, $t_location[1] );
echo '>' . $t_location[0] . '</option>';
echo '>' . $t_location[0] . "</option>\n";
}
echo "\t</optgroup>\n";
}
}

0 comments on commit 33043bc

Please sign in to comment.