1 |
1435
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package preferences
|
6 |
1529
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
1912
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker.org/
|
9 |
1435
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
1912
|
Luisehahne
|
* @platform WebsiteBaker 2.8.4
|
11 |
1435
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
1912
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1435
|
Luisehahne
|
* @lastmodified $Date$
|
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 |
2098
|
darkviper
|
function build_page( admin $admin )
|
24 |
1435
|
Luisehahne
|
{
|
25 |
2098
|
darkviper
|
$oReg = WbAdaptor::getInstance();
|
26 |
|
|
$oDb = WbDatabase::getInstance();
|
27 |
|
|
$oTrans = Translate::getInstance();
|
28 |
|
|
$oTrans->enableAddon('admin\\preferences');
|
29 |
1435
|
Luisehahne
|
include_once(WB_PATH.'/framework/functions-utf8.php');
|
30 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
31 |
1625
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
32 |
1529
|
Luisehahne
|
// Create new template object
|
33 |
1625
|
Luisehahne
|
$template = new Template(dirname($admin->correct_theme_source('preferences.htt')));
|
34 |
1435
|
Luisehahne
|
$template->set_file( 'page', 'preferences.htt' );
|
35 |
|
|
$template->set_block( 'page', 'main_block', 'main' );
|
36 |
2098
|
darkviper
|
$template->set_var($oTrans->getLangArray());
|
37 |
1912
|
Luisehahne
|
|
38 |
1435
|
Luisehahne
|
// read user-info from table users and assign it to template
|
39 |
2098
|
darkviper
|
$sql = 'SELECT `display_name`, `username`, `email` FROM `'.$oDb->TablePrefix.'users` ';
|
40 |
1435
|
Luisehahne
|
$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();
|
41 |
2098
|
darkviper
|
if (($res_user = $oDb->doQuery($sql))) {
|
42 |
|
|
if (($rec_user = $res_user->fetchRow(MYSQL_ASSOC))) {
|
43 |
1435
|
Luisehahne
|
$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 |
1912
|
Luisehahne
|
// $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 |
1986
|
Luisehahne
|
// read available languages from table addons
|
73 |
|
|
$aLangAddons = $admin->getAvailableLanguages();
|
74 |
1912
|
Luisehahne
|
|
75 |
1986
|
Luisehahne
|
$aLangUsed = array_flip(explode(',',$admin->getLanguagesInUsed()));
|
76 |
1912
|
Luisehahne
|
$aLangUsed = array_intersect_key($aLangAddons, $aLangUsed);
|
77 |
1986
|
Luisehahne
|
if( (sizeof($aLangUsed)<2) || !($oReg->PageLanguages) ){
|
78 |
|
|
$aLangUsed = $aLangAddons;
|
79 |
|
|
}
|
80 |
1912
|
Luisehahne
|
$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 |
1435
|
Luisehahne
|
// Insert default timezone values
|
94 |
1872
|
Luisehahne
|
$user_time = true;
|
95 |
1435
|
Luisehahne
|
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 |
1849
|
Luisehahne
|
$user_time = true;
|
106 |
1435
|
Luisehahne
|
include_once( ADMIN_PATH.'/interface/date_formats.php' );
|
107 |
|
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
108 |
1872
|
Luisehahne
|
|
109 |
1435
|
Luisehahne
|
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 |
1872
|
Luisehahne
|
if( ($admin->get_session('DATE_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||
|
115 |
1435
|
Luisehahne
|
('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 |
1872
|
Luisehahne
|
$user_time = true;
|
125 |
1435
|
Luisehahne
|
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 |
1872
|
Luisehahne
|
if( ($admin->get_session('TIME_FORMAT') == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||
|
133 |
1435
|
Luisehahne
|
('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 |
1912
|
Luisehahne
|
$template->set_var(array(
|
153 |
|
|
'EMPTY_STRING' => ''
|
154 |
1435
|
Luisehahne
|
)
|
155 |
|
|
);
|
156 |
|
|
// Parse template for preferences form
|
157 |
|
|
$template->parse('main', 'main_block', false);
|
158 |
|
|
$output = $template->finish($template->parse('output', 'page'));
|
159 |
1912
|
Luisehahne
|
|
160 |
1435
|
Luisehahne
|
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 |
2098
|
darkviper
|
echo build_page($admin);
|
169 |
1435
|
Luisehahne
|
$admin->print_footer();
|