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