Revision 8
Added by stefan about 19 years ago
index.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id: index.php,v 1.2 2005/04/02 06:25:37 rdjurovich Exp $ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
require('../../config.php'); |
|
27 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
28 |
$admin = new admin('Preferences'); |
|
29 |
|
|
30 |
// Create new template object for the preferences form |
|
31 |
$template = new Template(ADMIN_PATH.'/preferences'); |
|
32 |
$template->set_file('page', 'template.html'); |
|
33 |
$template->set_block('page', 'main_block', 'main'); |
|
34 |
|
|
35 |
// Get existing value from database |
|
36 |
$database = new database(); |
|
37 |
$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'"; |
|
38 |
$results = $database->query($query); |
|
39 |
if($database->is_error()) { |
|
40 |
$admin->print_error($database->get_error(), 'index.php'); |
|
41 |
} |
|
42 |
$details = $results->fetchRow(); |
|
43 |
|
|
44 |
// Insert values into form |
|
45 |
$template->set_var('DISPLAY_NAME', $details['display_name']); |
|
46 |
$template->set_var('EMAIL', $details['email']); |
|
47 |
|
|
48 |
// Insert language values |
|
49 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
|
|
5 |
Website Baker Project <http://www.websitebaker.org/> |
|
6 |
Copyright (C) 2004-2005, Ryan Djurovich |
|
7 |
|
|
8 |
Website Baker is free software; you can redistribute it and/or modify |
|
9 |
it under the terms of the GNU General Public License as published by |
|
10 |
the Free Software Foundation; either version 2 of the License, or |
|
11 |
(at your option) any later version. |
|
12 |
|
|
13 |
Website Baker is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with Website Baker; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
|
|
22 |
*/ |
|
23 |
|
|
24 |
require('../../config.php'); |
|
25 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
26 |
$admin = new admin('Preferences'); |
|
27 |
|
|
28 |
// Create new template object for the preferences form |
|
29 |
$template = new Template(ADMIN_PATH.'/preferences'); |
|
30 |
$template->set_file('page', 'template.html'); |
|
31 |
$template->set_block('page', 'main_block', 'main'); |
|
32 |
|
|
33 |
// Get existing value from database |
|
34 |
$database = new database(); |
|
35 |
$query = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."'"; |
|
36 |
$results = $database->query($query); |
|
37 |
if($database->is_error()) { |
|
38 |
$admin->print_error($database->get_error(), 'index.php'); |
|
39 |
} |
|
40 |
$details = $results->fetchRow(); |
|
41 |
|
|
42 |
// Insert values into form |
|
43 |
$template->set_var('DISPLAY_NAME', $details['display_name']); |
|
44 |
$template->set_var('EMAIL', $details['email']); |
|
45 |
|
|
46 |
// Insert language values |
|
47 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
50 | 48 |
if($handle = opendir(WB_PATH.'/languages/')) { |
51 |
while (false !== ($file = readdir($handle))) { |
|
52 |
if($file != '.' AND $file != '..' AND $file != 'CVS' AND $file != 'index.php') { |
|
53 |
// Get language name |
|
54 |
require(WB_PATH.'/languages/'.$file); |
|
55 |
// Insert code and name |
|
56 |
$template->set_var(array( |
|
57 |
'CODE' => $language_code, |
|
58 |
'NAME' => $language_name |
|
59 |
) |
|
60 |
); |
|
61 |
// Check if it is selected |
|
62 |
if(LANGUAGE == $language_code) { |
|
63 |
$template->set_var('SELECTED', ' selected'); |
|
64 |
} else { |
|
65 |
$template->set_var('SELECTED', ''); |
|
66 |
} |
|
67 |
$template->parse('language_list', 'language_list_block', true); |
|
68 |
} |
|
69 |
} |
|
70 |
// Restore language to original file |
|
71 |
require(WB_PATH.'/languages/'.LANGUAGE.'.php'); |
|
72 |
} |
|
73 |
|
|
74 |
// Insert default timezone values |
|
75 |
require(ADMIN_PATH.'/interface/timezones.php'); |
|
76 |
$template->set_block('main_block', 'timezone_list_block', 'timezone_list'); |
|
77 |
foreach($TIMEZONES AS $hour_offset => $title) { |
|
78 |
$template->set_var('VALUE', $hour_offset); |
|
79 |
$template->set_var('NAME', $title); |
|
80 |
if($admin->get_timezone() == $hour_offset*60*60) { |
|
81 |
$template->set_var('SELECTED', 'selected'); |
|
82 |
} else { |
|
83 |
$template->set_var('SELECTED', ''); |
|
84 |
} |
|
85 |
$template->parse('timezone_list', 'timezone_list_block', true); |
|
86 |
} |
|
87 |
|
|
88 |
// Insert date format list |
|
89 |
$user_time = true; |
|
90 |
require(ADMIN_PATH.'/interface/date_formats.php'); |
|
91 |
$template->set_block('main_block', 'date_format_list_block', 'date_format_list'); |
|
92 |
foreach($DATE_FORMATS AS $format => $title) { |
|
93 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
94 |
if($format != 'system_default') { |
|
95 |
$template->set_var('VALUE', $format); |
|
96 |
} else { |
|
97 |
$template->set_var('VALUE', ''); |
|
98 |
} |
|
99 |
$template->set_var('NAME', $title); |
|
100 |
if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
101 |
$template->set_var('SELECTED', 'selected'); |
|
102 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
103 |
$template->set_var('SELECTED', 'selected'); |
|
104 |
} else { |
|
105 |
$template->set_var('SELECTED', ''); |
|
106 |
} |
|
107 |
$template->parse('date_format_list', 'date_format_list_block', true); |
|
108 |
} |
|
109 |
|
|
110 |
// Insert time format list |
|
111 |
require(ADMIN_PATH.'/interface/time_formats.php'); |
|
112 |
$template->set_block('main_block', 'time_format_list_block', 'time_format_list'); |
|
113 |
foreach($TIME_FORMATS AS $format => $title) { |
|
114 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
115 |
if($format != 'system_default') { |
|
116 |
$template->set_var('VALUE', $format); |
|
117 |
} else { |
|
118 |
$template->set_var('VALUE', ''); |
|
119 |
} |
|
120 |
$template->set_var('NAME', $title); |
|
121 |
if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
122 |
$template->set_var('SELECTED', 'selected'); |
|
123 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
124 |
$template->set_var('SELECTED', 'selected'); |
|
125 |
} else { |
|
126 |
$template->set_var('SELECTED', ''); |
|
127 |
} |
|
128 |
$template->parse('time_format_list', 'time_format_list_block', true); |
|
129 |
} |
|
130 |
|
|
131 |
// Insert language headings |
|
132 |
$template->set_var(array( |
|
133 |
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'], |
|
134 |
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'], |
|
135 |
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD'] |
|
136 |
) |
|
137 |
); |
|
138 |
// Insert language text and messages |
|
139 |
$template->set_var(array( |
|
140 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
141 |
'TEXT_RESET' => $TEXT['RESET'], |
|
142 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
143 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
144 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
145 |
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'], |
|
146 |
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'], |
|
147 |
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'], |
|
148 |
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'], |
|
149 |
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'], |
|
150 |
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'] |
|
151 |
) |
|
152 |
); |
|
153 |
|
|
154 |
// Parse template for preferences form |
|
155 |
$template->parse('main', 'main_block', false); |
|
156 |
$template->pparse('output', 'page'); |
|
157 |
|
|
158 |
$admin->print_footer(); |
|
159 |
|
|
160 |
?> |
|
49 |
while (false !== ($file = readdir($handle))) { |
|
50 |
if($file != '.' AND $file != '..' AND !is_dir($file) AND $file != 'index.php') { |
|
51 |
// Get language name |
|
52 |
require(WB_PATH.'/languages/'.$file); |
|
53 |
// Insert code and name |
|
54 |
$template->set_var(array( |
|
55 |
'CODE' => $language_code, |
|
56 |
'NAME' => $language_name |
|
57 |
) |
|
58 |
); |
|
59 |
// Check if it is selected |
|
60 |
if(LANGUAGE == $language_code) { |
|
61 |
$template->set_var('SELECTED', ' selected'); |
|
62 |
} else { |
|
63 |
$template->set_var('SELECTED', ''); |
|
64 |
} |
|
65 |
$template->parse('language_list', 'language_list_block', true); |
|
66 |
} |
|
67 |
} |
|
68 |
// Restore language to original file |
|
69 |
require(WB_PATH.'/languages/'.LANGUAGE.'.php'); |
|
70 |
} |
|
71 |
|
|
72 |
// Insert default timezone values |
|
73 |
require(ADMIN_PATH.'/interface/timezones.php'); |
|
74 |
$template->set_block('main_block', 'timezone_list_block', 'timezone_list'); |
|
75 |
foreach($TIMEZONES AS $hour_offset => $title) { |
|
76 |
$template->set_var('VALUE', $hour_offset); |
|
77 |
$template->set_var('NAME', $title); |
|
78 |
if($admin->get_timezone() == $hour_offset*60*60) { |
|
79 |
$template->set_var('SELECTED', 'selected'); |
|
80 |
} else { |
|
81 |
$template->set_var('SELECTED', ''); |
|
82 |
} |
|
83 |
$template->parse('timezone_list', 'timezone_list_block', true); |
|
84 |
} |
|
85 |
|
|
86 |
// Insert date format list |
|
87 |
$user_time = true; |
|
88 |
require(ADMIN_PATH.'/interface/date_formats.php'); |
|
89 |
$template->set_block('main_block', 'date_format_list_block', 'date_format_list'); |
|
90 |
foreach($DATE_FORMATS AS $format => $title) { |
|
91 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
92 |
if($format != 'system_default') { |
|
93 |
$template->set_var('VALUE', $format); |
|
94 |
} else { |
|
95 |
$template->set_var('VALUE', ''); |
|
96 |
} |
|
97 |
$template->set_var('NAME', $title); |
|
98 |
if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
99 |
$template->set_var('SELECTED', 'selected'); |
|
100 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
101 |
$template->set_var('SELECTED', 'selected'); |
|
102 |
} else { |
|
103 |
$template->set_var('SELECTED', ''); |
|
104 |
} |
|
105 |
$template->parse('date_format_list', 'date_format_list_block', true); |
|
106 |
} |
|
107 |
|
|
108 |
// Insert time format list |
|
109 |
require(ADMIN_PATH.'/interface/time_formats.php'); |
|
110 |
$template->set_block('main_block', 'time_format_list_block', 'time_format_list'); |
|
111 |
foreach($TIME_FORMATS AS $format => $title) { |
|
112 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
113 |
if($format != 'system_default') { |
|
114 |
$template->set_var('VALUE', $format); |
|
115 |
} else { |
|
116 |
$template->set_var('VALUE', ''); |
|
117 |
} |
|
118 |
$template->set_var('NAME', $title); |
|
119 |
if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
120 |
$template->set_var('SELECTED', 'selected'); |
|
121 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
122 |
$template->set_var('SELECTED', 'selected'); |
|
123 |
} else { |
|
124 |
$template->set_var('SELECTED', ''); |
|
125 |
} |
|
126 |
$template->parse('time_format_list', 'time_format_list_block', true); |
|
127 |
} |
|
128 |
|
|
129 |
// Insert language headings |
|
130 |
$template->set_var(array( |
|
131 |
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'], |
|
132 |
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'], |
|
133 |
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD'] |
|
134 |
) |
|
135 |
); |
|
136 |
// Insert language text and messages |
|
137 |
$template->set_var(array( |
|
138 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
139 |
'TEXT_RESET' => $TEXT['RESET'], |
|
140 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
141 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
142 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
143 |
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'], |
|
144 |
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'], |
|
145 |
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'], |
|
146 |
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'], |
|
147 |
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'], |
|
148 |
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'] |
|
149 |
) |
|
150 |
); |
|
151 |
|
|
152 |
// Parse template for preferences form |
|
153 |
$template->parse('main', 'main_block', false); |
|
154 |
$template->pparse('output', 'page'); |
|
155 |
|
|
156 |
$admin->print_footer(); |
|
157 |
|
|
158 |
?> |
Also available in: Unified diff
All occurrences of "CVS" in the code are replace by ".svn"