2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: functions_selects.php,v 1.3.2.5 2005/05/06 20:50:11 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
22 ***************************************************************************/
25 // Pick a language, any language ...
27 function language_select($default, $select_name = "language", $dirname="language")
29 global $phpEx, $phpbb_root_path;
31 $dir = opendir($phpbb_root_path . $dirname);
34 while ( $file = readdir($dir) )
36 if (preg_match('#^lang_#i', $file) && !is_file(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file)) && !is_link(@phpbb_realpath($phpbb_root_path . $dirname . '/' . $file)))
38 $filename = trim(str_replace("lang_", "", $file));
39 $displayname = preg_replace("/^(.*?)_(.*)$/", "\\1 [ \\2 ]", $filename);
40 $displayname = preg_replace("/\[(.*?)_(.*)\]/", "[ \\1 - \\2 ]", $displayname);
41 $lang[$displayname] = $filename;
50 $lang_select = '<select name="' . $select_name . '">';
51 while ( list($displayname, $filename) = @each($lang) )
53 $selected = ( strtolower($default) == strtolower($filename) ) ? ' selected="selected"' : '';
54 $lang_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
56 $lang_select .= '</select>';
62 // Pick a template/theme combo,
64 function style_select($default_style, $select_name = "style", $dirname = "templates")
68 $sql = "SELECT themes_id, style_name
69 FROM " . THEMES_TABLE . "
70 ORDER BY template_name, themes_id";
71 if ( !($result = $db->sql_query($sql)) )
73 message_die(GENERAL_ERROR, "Couldn't query themes table", "", __LINE__, __FILE__, $sql);
76 $style_select = '<select name="' . $select_name . '">';
77 while ( $row = $db->sql_fetchrow($result) )
79 $selected = ( $row['themes_id'] == $default_style ) ? ' selected="selected"' : '';
81 $style_select .= '<option value="' . $row['themes_id'] . '"' . $selected . '>' . $row['style_name'] . '</option>';
83 $style_select .= "</select>";
91 function tz_select($default, $select_name = 'timezone')
93 global $sys_timezone, $lang;
95 if ( !isset($default) )
97 $default == $sys_timezone;
99 $tz_select = '<select name="' . $select_name . '">';
101 while( list($offset, $zone) = @each($lang['tz']) )
103 $selected = ( $offset == $default ) ? ' selected="selected"' : '';
104 $tz_select .= '<option value="' . $offset . '"' . $selected . '>' . $zone . '</option>';
106 $tz_select .= '</select>';