Revision 1912
Added by Dietmar over 11 years ago
index.php | ||
---|---|---|
4 | 4 |
* @category admin |
5 | 5 |
* @package preferences |
6 | 6 |
* @author Ryan Djurovich, WebsiteBaker Project |
7 |
* @copyright 2009-2011, Website Baker Org. e.V.
|
|
8 |
* @link http://www.websitebaker2.org/
|
|
7 |
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
|
8 |
* @link http://www.websitebaker.org/
|
|
9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
10 |
* @platform WebsiteBaker 2.8.x
|
|
10 |
* @platform WebsiteBaker 2.8.4
|
|
11 | 11 |
* @requirements PHP 5.2.2 and higher |
12 | 12 |
* @version $Id$ |
13 |
* @filesource $HeadURL$
|
|
13 |
* @filesource $HeadURL$
|
|
14 | 14 |
* @lastmodified $Date$ |
15 | 15 |
* |
16 | 16 |
*/ |
... | ... | |
22 | 22 |
// put all inside a function to prevent global vars |
23 | 23 |
function build_page( &$admin, &$database ) |
24 | 24 |
{ |
25 |
global $HEADING, $TEXT; |
|
25 |
// global $HEADING, $TEXT;
|
|
26 | 26 |
include_once(WB_PATH.'/framework/functions-utf8.php'); |
27 | 27 |
// Setup template object, parse vars to it, then parse it |
28 | 28 |
// Setup template object, parse vars to it, then parse it |
... | ... | |
30 | 30 |
$template = new Template(dirname($admin->correct_theme_source('preferences.htt'))); |
31 | 31 |
$template->set_file( 'page', 'preferences.htt' ); |
32 | 32 |
$template->set_block( 'page', 'main_block', 'main' ); |
33 |
$mLang = Translate::getinstance(); |
|
34 |
$mLang->enableAddon('admin\preferences'); |
|
35 |
$template->set_var($mLang->getLangArray()); |
|
36 |
|
|
33 | 37 |
// read user-info from table users and assign it to template |
34 | 38 |
$sql = 'SELECT `display_name`, `username`, `email` FROM `'.TABLE_PREFIX.'users` '; |
35 | 39 |
$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id(); |
... | ... | |
44 | 48 |
} |
45 | 49 |
} |
46 | 50 |
// read available languages from table addons and assign it to the template |
47 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '; |
|
48 |
$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`'; |
|
49 |
if( $res_lang = $database->query($sql) ) |
|
50 |
{ |
|
51 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
52 |
while( $rec_lang = $res_lang->fetchRow() ) |
|
53 |
{ |
|
54 |
$langIcons = (empty($rec_lang['directory'])) ? 'none' : strtolower($rec_lang['directory']); |
|
55 |
$template->set_var('CODE', $rec_lang['directory']); |
|
56 |
$template->set_var('NAME', $rec_lang['name']); |
|
57 |
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons); |
|
58 |
$template->set_var('SELECTED', (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') ); |
|
59 |
$template->parse('language_list', 'language_list_block', true); |
|
60 |
} |
|
61 |
} |
|
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 |
|
|
62 | 99 |
// Insert default timezone values |
63 | 100 |
$user_time = true; |
64 | 101 |
include_once( ADMIN_PATH.'/interface/timezones.php' ); |
... | ... | |
118 | 155 |
$template->set_var('FTAN', $admin->getFTAN()); |
119 | 156 |
$template->set_var('FORM_NAME', 'preferences_save'); |
120 | 157 |
// assign language vars |
121 |
$template->set_var(array( 'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'], |
|
122 |
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'], |
|
123 |
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD'], |
|
124 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
125 |
'TEXT_RESET' => $TEXT['RESET'], |
|
126 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
127 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
128 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
129 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
130 |
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'], |
|
131 |
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'], |
|
132 |
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'], |
|
133 |
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'], |
|
134 |
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'], |
|
135 |
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'], |
|
136 |
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'], |
|
137 |
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'], |
|
138 |
'TEXT_NEED_CURRENT_PASSWORD' => $TEXT['NEED_CURRENT_PASSWORD'], |
|
139 |
'EMPTY_STRING' => '' |
|
158 |
$template->set_var(array( |
|
159 |
'EMPTY_STRING' => '' |
|
140 | 160 |
) |
141 | 161 |
); |
142 | 162 |
// Parse template for preferences form |
143 | 163 |
$template->parse('main', 'main_block', false); |
144 | 164 |
$output = $template->finish($template->parse('output', 'page')); |
165 |
$mLang->disableAddon(); |
|
166 |
|
|
145 | 167 |
return $output; |
146 | 168 |
} |
147 | 169 |
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility) |
... | ... | |
153 | 175 |
} |
154 | 176 |
echo build_page($admin, $database); |
155 | 177 |
$admin->print_footer(); |
156 |
|
|
157 |
?> |
Also available in: Unified diff
! /admin/preferences/index.php change to new Translate class
languages only given for existing page languages
! /admin/settings/ change to new Translate class