1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package preferences
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.4
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: index.php 1922 2013-06-08 08:56:14Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/preferences/index.php $
|
14
|
* @lastmodified $Date: 2013-06-08 10:56:14 +0200 (Sat, 08 Jun 2013) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
// prevent this file from being accessed directly
|
19
|
//if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
20
|
//Workaround if this is first page (WBAdmin in use)
|
21
|
|
22
|
// put all inside a function to prevent global vars
|
23
|
function build_page( &$admin, &$database )
|
24
|
{
|
25
|
// global $HEADING, $TEXT;
|
26
|
include_once(WB_PATH.'/framework/functions-utf8.php');
|
27
|
// Setup template object, parse vars to it, then parse it
|
28
|
// Setup template object, parse vars to it, then parse it
|
29
|
// Create new template object
|
30
|
$template = new Template(dirname($admin->correct_theme_source('preferences.htt')));
|
31
|
$template->set_file( 'page', 'preferences.htt' );
|
32
|
$template->set_block( 'page', 'main_block', 'main' );
|
33
|
$mLang = Translate::getinstance();
|
34
|
// $mLang->enableAddon('admin\preferences');
|
35
|
$template->set_var($mLang->getLangArray());
|
36
|
|
37
|
// read user-info from table users and assign it to template
|
38
|
$sql = 'SELECT `display_name`, `username`, `email` FROM `'.TABLE_PREFIX.'users` ';
|
39
|
$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();
|
40
|
if( $res_user = $database->query($sql) )
|
41
|
{
|
42
|
if( $rec_user = $res_user->fetchRow() )
|
43
|
{
|
44
|
$template->set_var('DISPLAY_NAME', $rec_user['display_name']);
|
45
|
$template->set_var('USERNAME', $rec_user['username']);
|
46
|
$template->set_var('EMAIL', $rec_user['email']);
|
47
|
$template->set_var('ADMIN_URL', ADMIN_URL);
|
48
|
}
|
49
|
}
|
50
|
// read available languages from table addons and assign it to the template
|
51
|
// $sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
52
|
// $sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
53
|
// if( $res_lang = $database->query($sql) )
|
54
|
// {
|
55
|
// $template->set_block('main_block', 'language_list_block', 'language_list');
|
56
|
// while( $rec_lang = $res_lang->fetchRow(MYSQL_ASSOC) )
|
57
|
// {
|
58
|
// $langIcons = (empty($rec_lang['directory'])) ? 'none' : strtolower($rec_lang['directory']);
|
59
|
// $template->set_var('CODE', $rec_lang['directory']);
|
60
|
// $template->set_var('NAME', $rec_lang['name']);
|
61
|
// $template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
62
|
// $template->set_var('SELECTED', (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
63
|
// $template->parse('language_list', 'language_list_block', true);
|
64
|
// }
|
65
|
// }
|
66
|
|
67
|
$aLangAddons = array();
|
68
|
$aLangBrowser = array();
|
69
|
|
70
|
// read available languages from table addons
|
71
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
72
|
$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
73
|
if( $oLang = $database->query($sql) )
|
74
|
{
|
75
|
while( $aLang = $oLang->fetchRow(MYSQL_ASSOC) )
|
76
|
{
|
77
|
$aLangAddons[$aLang['directory']] = $aLang['name'];
|
78
|
}
|
79
|
}
|
80
|
|
81
|
// default, if no information from client available
|
82
|
$sAutoLanguage = DEFAULT_LANGUAGE;
|
83
|
|
84
|
$aLangUsed = array_flip(explode(',',$admin->GetLanguagesInUsed()));
|
85
|
$aLangUsed = array_intersect_key($aLangAddons, $aLangUsed);
|
86
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
87
|
foreach( $aLangUsed as $sDirectory => $sName )
|
88
|
{
|
89
|
$langIcons = ( empty($sDirectory) ? 'none' : strtolower($sDirectory));
|
90
|
|
91
|
$template->set_var('CODE', $sDirectory);
|
92
|
$template->set_var('NAME', $sName);
|
93
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
94
|
$template->set_var('SELECTED', ( $_SESSION['LANGUAGE'] == $sDirectory ? ' selected="selected"' : '') );
|
95
|
|
96
|
$template->parse('language_list', 'language_list_block', true);
|
97
|
}
|
98
|
|
99
|
// Insert default timezone values
|
100
|
$user_time = true;
|
101
|
include_once( ADMIN_PATH.'/interface/timezones.php' );
|
102
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
103
|
foreach( $TIMEZONES AS $hour_offset => $title )
|
104
|
{
|
105
|
$template->set_var('VALUE', $hour_offset);
|
106
|
$template->set_var('NAME', $title);
|
107
|
$template->set_var('SELECTED', ($admin->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );
|
108
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
109
|
}
|
110
|
// Insert date format list
|
111
|
$user_time = true;
|
112
|
include_once( ADMIN_PATH.'/interface/date_formats.php' );
|
113
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
114
|
|
115
|
foreach( $DATE_FORMATS AS $format => $title )
|
116
|
{
|
117
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
118
|
$template->set_var( 'VALUE', ($format != 'system_default' ? $format : 'system_default') );
|
119
|
$template->set_var( 'NAME', $title );
|
120
|
if( ($admin->get_session('DATE_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||
|
121
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) )
|
122
|
{
|
123
|
$template->set_var('SELECTED', ' selected="selected"');
|
124
|
}else {
|
125
|
$template->set_var('SELECTED', '');
|
126
|
}
|
127
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
128
|
}
|
129
|
// Insert time format list
|
130
|
$user_time = true;
|
131
|
include_once( ADMIN_PATH.'/interface/time_formats.php' );
|
132
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
133
|
foreach( $TIME_FORMATS AS $format => $title )
|
134
|
{
|
135
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
136
|
$template->set_var('VALUE', $format != 'system_default' ? $format : 'system_default' );
|
137
|
$template->set_var('NAME', $title);
|
138
|
if( ($admin->get_session('TIME_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||
|
139
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) )
|
140
|
{
|
141
|
$template->set_var('SELECTED', ' selected="selected"');
|
142
|
} else {
|
143
|
$template->set_var('SELECTED', '');
|
144
|
}
|
145
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
146
|
}
|
147
|
|
148
|
// assign systemvars to template
|
149
|
$template->set_var(array( 'ADMIN_URL' => ADMIN_URL,
|
150
|
'WB_URL' => WB_URL,
|
151
|
'THEME_URL' => THEME_URL,
|
152
|
'ACTION_URL' => ADMIN_URL.'/preferences/save.php'
|
153
|
)
|
154
|
);
|
155
|
$template->set_var('FTAN', $admin->getFTAN());
|
156
|
$template->set_var('FORM_NAME', 'preferences_save');
|
157
|
// assign language vars
|
158
|
$template->set_var(array(
|
159
|
'EMPTY_STRING' => ''
|
160
|
)
|
161
|
);
|
162
|
// Parse template for preferences form
|
163
|
$template->parse('main', 'main_block', false);
|
164
|
$output = $template->finish($template->parse('output', 'page'));
|
165
|
$mLang->disableAddon();
|
166
|
|
167
|
return $output;
|
168
|
}
|
169
|
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility)
|
170
|
if( !(isset($admin) && is_object($admin) && (get_class($admin) == 'admin')) )
|
171
|
{
|
172
|
require( '../../config.php' );
|
173
|
require_once( WB_PATH.'/framework/class.admin.php' );
|
174
|
$admin = new admin('Preferences');
|
175
|
}
|
176
|
echo build_page($admin, $database);
|
177
|
$admin->print_footer();
|