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 2098 2014-02-11 01:37:03Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/preferences/index.php $
|
14
|
* @lastmodified $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
|
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 $admin )
|
24
|
{
|
25
|
$oReg = WbAdaptor::getInstance();
|
26
|
$oDb = WbDatabase::getInstance();
|
27
|
$oTrans = Translate::getInstance();
|
28
|
$oTrans->enableAddon('admin\\preferences');
|
29
|
include_once(WB_PATH.'/framework/functions-utf8.php');
|
30
|
// Setup template object, parse vars to it, then parse it
|
31
|
// Setup template object, parse vars to it, then parse it
|
32
|
// Create new template object
|
33
|
$template = new Template(dirname($admin->correct_theme_source('preferences.htt')));
|
34
|
$template->set_file( 'page', 'preferences.htt' );
|
35
|
$template->set_block( 'page', 'main_block', 'main' );
|
36
|
$template->set_var($oTrans->getLangArray());
|
37
|
|
38
|
// read user-info from table users and assign it to template
|
39
|
$sql = 'SELECT `display_name`, `username`, `email` FROM `'.$oDb->TablePrefix.'users` ';
|
40
|
$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();
|
41
|
if (($res_user = $oDb->doQuery($sql))) {
|
42
|
if (($rec_user = $res_user->fetchRow(MYSQL_ASSOC))) {
|
43
|
$template->set_var('DISPLAY_NAME', $rec_user['display_name']);
|
44
|
$template->set_var('USERNAME', $rec_user['username']);
|
45
|
$template->set_var('EMAIL', $rec_user['email']);
|
46
|
$template->set_var('ADMIN_URL', ADMIN_URL);
|
47
|
}
|
48
|
}
|
49
|
// read available languages from table addons and assign it to the template
|
50
|
// $sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
51
|
// $sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
52
|
// if( $res_lang = $database->query($sql) )
|
53
|
// {
|
54
|
// $template->set_block('main_block', 'language_list_block', 'language_list');
|
55
|
// while( $rec_lang = $res_lang->fetchRow(MYSQL_ASSOC) )
|
56
|
// {
|
57
|
// $langIcons = (empty($rec_lang['directory'])) ? 'none' : strtolower($rec_lang['directory']);
|
58
|
// $template->set_var('CODE', $rec_lang['directory']);
|
59
|
// $template->set_var('NAME', $rec_lang['name']);
|
60
|
// $template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
61
|
// $template->set_var('SELECTED', (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
62
|
// $template->parse('language_list', 'language_list_block', true);
|
63
|
// }
|
64
|
// }
|
65
|
|
66
|
$aLangAddons = array();
|
67
|
$aLangBrowser = array();
|
68
|
|
69
|
|
70
|
// default, if no information from client available
|
71
|
$sAutoLanguage = DEFAULT_LANGUAGE;
|
72
|
// read available languages from table addons
|
73
|
$aLangAddons = $admin->getAvailableLanguages();
|
74
|
|
75
|
$aLangUsed = array_flip(explode(',',$admin->getLanguagesInUsed()));
|
76
|
$aLangUsed = array_intersect_key($aLangAddons, $aLangUsed);
|
77
|
if( (sizeof($aLangUsed)<2) || !($oReg->PageLanguages) ){
|
78
|
$aLangUsed = $aLangAddons;
|
79
|
}
|
80
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
81
|
foreach( $aLangUsed as $sDirectory => $sName )
|
82
|
{
|
83
|
$langIcons = ( empty($sDirectory) ? 'none' : strtolower($sDirectory));
|
84
|
|
85
|
$template->set_var('CODE', $sDirectory);
|
86
|
$template->set_var('NAME', $sName);
|
87
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
88
|
$template->set_var('SELECTED', ( $_SESSION['LANGUAGE'] == $sDirectory ? ' selected="selected"' : '') );
|
89
|
|
90
|
$template->parse('language_list', 'language_list_block', true);
|
91
|
}
|
92
|
|
93
|
// Insert default timezone values
|
94
|
$user_time = true;
|
95
|
include_once( ADMIN_PATH.'/interface/timezones.php' );
|
96
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
97
|
foreach( $TIMEZONES AS $hour_offset => $title )
|
98
|
{
|
99
|
$template->set_var('VALUE', $hour_offset);
|
100
|
$template->set_var('NAME', $title);
|
101
|
$template->set_var('SELECTED', ($admin->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );
|
102
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
103
|
}
|
104
|
// Insert date format list
|
105
|
$user_time = true;
|
106
|
include_once( ADMIN_PATH.'/interface/date_formats.php' );
|
107
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
108
|
|
109
|
foreach( $DATE_FORMATS AS $format => $title )
|
110
|
{
|
111
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
112
|
$template->set_var( 'VALUE', ($format != 'system_default' ? $format : 'system_default') );
|
113
|
$template->set_var( 'NAME', $title );
|
114
|
if( ($admin->get_session('DATE_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||
|
115
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) )
|
116
|
{
|
117
|
$template->set_var('SELECTED', ' selected="selected"');
|
118
|
}else {
|
119
|
$template->set_var('SELECTED', '');
|
120
|
}
|
121
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
122
|
}
|
123
|
// Insert time format list
|
124
|
$user_time = true;
|
125
|
include_once( ADMIN_PATH.'/interface/time_formats.php' );
|
126
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
127
|
foreach( $TIME_FORMATS AS $format => $title )
|
128
|
{
|
129
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
130
|
$template->set_var('VALUE', $format != 'system_default' ? $format : 'system_default' );
|
131
|
$template->set_var('NAME', $title);
|
132
|
if( ($admin->get_session('TIME_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||
|
133
|
('system_default' == $format && isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) )
|
134
|
{
|
135
|
$template->set_var('SELECTED', ' selected="selected"');
|
136
|
} else {
|
137
|
$template->set_var('SELECTED', '');
|
138
|
}
|
139
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
140
|
}
|
141
|
|
142
|
// assign systemvars to template
|
143
|
$template->set_var(array( 'ADMIN_URL' => ADMIN_URL,
|
144
|
'WB_URL' => WB_URL,
|
145
|
'THEME_URL' => THEME_URL,
|
146
|
'ACTION_URL' => ADMIN_URL.'/preferences/save.php'
|
147
|
)
|
148
|
);
|
149
|
$template->set_var('FTAN', $admin->getFTAN());
|
150
|
$template->set_var('FORM_NAME', 'preferences_save');
|
151
|
// assign language vars
|
152
|
$template->set_var(array(
|
153
|
'EMPTY_STRING' => ''
|
154
|
)
|
155
|
);
|
156
|
// Parse template for preferences form
|
157
|
$template->parse('main', 'main_block', false);
|
158
|
$output = $template->finish($template->parse('output', 'page'));
|
159
|
|
160
|
return $output;
|
161
|
}
|
162
|
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility)
|
163
|
if( !(isset($admin) && is_object($admin) && (get_class($admin) == 'admin')) )
|
164
|
{
|
165
|
require( '../../config.php' );
|
166
|
$admin = new admin('Preferences');
|
167
|
}
|
168
|
echo build_page($admin);
|
169
|
$admin->print_footer();
|