Revision 2094
Added by darkviper over 11 years ago
| class.admin.php | ||
|---|---|---|
| 57 | 57 |
parent::__construct(SecureForm::BACKEND); |
| 58 | 58 |
if( $section_name != '##skip##' ) |
| 59 | 59 |
{
|
| 60 |
global $database, $MESSAGE, $TEXT;
|
|
| 60 |
global $database; |
|
| 61 | 61 |
// Specify the current applications name |
| 62 | 62 |
$this->section_name = $section_name; |
| 63 | 63 |
$this->section_permission = $section_permission; |
| ... | ... | |
| 84 | 84 |
$oTpl->set_file( 'page', 'ErrorMsgFile.htt' ); |
| 85 | 85 |
$oTpl->set_var( 'THEME_URL', THEME_URL ); |
| 86 | 86 |
$oTpl->set_var( 'PAGE_ICON', 'negative'); |
| 87 |
$oTpl->set_var( 'ERROR_TITLE', $MESSAGE['MEDIA_DIR_ACCESS_DENIED']);
|
|
| 88 |
$oTpl->set_var( 'PAGE_TITLE', $MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES'] );
|
|
| 87 |
$oTpl->set_var( 'ERROR_TITLE', $this->_oTrans->MESSAGE_MEDIA_DIR_ACCESS_DENIED);
|
|
| 88 |
$oTpl->set_var( 'PAGE_TITLE', $this->_oTrans->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
|
|
| 89 | 89 |
$oTpl->set_var( 'BACK_LINK', $sBackLink ); |
| 90 |
$oTpl->set_var( 'TEXT_BACK', $TEXT['BACK'] );
|
|
| 90 |
$oTpl->set_var( 'TEXT_BACK', $this->_oTrans->TEXT_BACK);
|
|
| 91 | 91 |
$output = $oTpl->finish($oTpl->parse('output', 'page'));
|
| 92 | 92 |
} |
| 93 | 93 |
throw new ErrorMsgException($output); |
| ... | ... | |
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 | 103 |
// Check if the backend language is also the selected language. If not, send headers again. |
| 104 |
$sql = 'SELECT `language` FROM `'.TABLE_PREFIX.'users` '; |
|
| 105 |
$sql .= 'WHERE `user_id`='.(int)$this->get_user_id(); |
|
| 106 |
$get_user_language = @$database->query($sql); |
|
| 107 |
$user_language = ($get_user_language) ? $get_user_language->fetchRow() : ''; |
|
| 108 |
// prevent infinite loop if language file is not XX.php (e.g. DE_du.php) |
|
| 109 |
$user_language = substr($user_language[0],0,2); |
|
| 104 |
$sql = 'SELECT `language` FROM `'.$this->_oDb->TablePrefix.'users` ' |
|
| 105 |
. 'WHERE `user_id`='.(int)$this->get_user_id(); |
|
| 106 |
$user_language = preg_replace('/([a-z]{2}).*/i', '\1', strtoupper((string)$this->_oDb->getOne($sql)));
|
|
| 110 | 107 |
// obtain the admin folder (e.g. /admin) |
| 111 | 108 |
$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH); |
| 112 | 109 |
|
| ... | ... | |
| 139 | 136 |
*/ |
| 140 | 137 |
function print_header($body_tags = '') |
| 141 | 138 |
{
|
| 142 |
// Get vars from the language file |
|
| 143 |
global $MENU, $MESSAGE, $TEXT; |
|
| 144 |
// Connect to database and get website title |
|
| 145 |
global $database; |
|
| 146 | 139 |
// $GLOBALS['FTAN'] = $this->getFTAN(); |
| 147 | 140 |
$this->createFTAN(); |
| 148 |
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` WHERE `name`=\'website_title\'';
|
|
| 149 |
$get_title = $database->query($sql);
|
|
| 150 |
$title = $get_title->fetchRow();
|
|
| 141 |
$sql = 'SELECT `value` FROM `'.$this->_oDb->TablePrefix.'settings` '
|
|
| 142 |
. 'WHERE `name`=\'website_title\'';
|
|
| 143 |
$title = (string)$this->_oDb->getOne($sql);
|
|
| 151 | 144 |
// Setup template object, parse vars to it, then parse it |
| 152 | 145 |
$header_template = new Template(dirname($this->correct_theme_source('header.htt')) );
|
| 153 | 146 |
$header_template->set_file('page', 'header.htt');
|
| 154 | 147 |
$header_template->set_block('page', 'header_block', 'header');
|
| 148 |
$this->_oTrans->enableAddon('templates\\'.$this->_oReg->DefaultTheme);
|
|
| 149 |
$header_template->set_var($this->_oTrans->getLangArray()); |
|
| 155 | 150 |
if(defined('DEFAULT_CHARSET')) {
|
| 156 | 151 |
$charset=DEFAULT_CHARSET; |
| 157 | 152 |
} else {
|
| ... | ... | |
| 163 | 158 |
$view_url = WB_URL; |
| 164 | 159 |
if(isset($_GET['page_id'])) {
|
| 165 | 160 |
// extract page link from the database |
| 166 |
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` '; |
|
| 167 |
$sql .= 'WHERE `page_id`='.intval($_GET['page_id']); |
|
| 168 |
$result = @$database->query($sql); |
|
| 169 |
$row = @$result->fetchRow(); |
|
| 170 |
if($row) $view_url .= PAGES_DIRECTORY .$row['link']. PAGE_EXTENSION; |
|
| 161 |
$sql = 'SELECT `link` FROM `'.$this->_oDb->TablePrefix.'pages` ' |
|
| 162 |
. 'WHERE `page_id`='.intval($_GET['page_id']); |
|
| 163 |
$row = (string)$this->_oDb->getOne($sql); |
|
| 164 |
if ($row) { $view_url .= PAGES_DIRECTORY .$row. PAGE_EXTENSION; }
|
|
| 171 | 165 |
} |
| 172 | 166 |
|
| 173 | 167 |
$HelpUrl = ((strtolower(LANGUAGE)!='de') ? '/en/help.php' : '/de/hilfe.php'); |
| 174 | 168 |
$sServerAdress = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1'; |
| 175 | 169 |
$header_template->set_var( array( |
| 176 |
'SECTION_FORGOT' => $MENU['FORGOT'],
|
|
| 177 |
'SECTION_NAME' => $MENU['LOGIN'],
|
|
| 170 |
'SECTION_FORGOT' => $this->_oTrans->MENU_FORGOT,
|
|
| 171 |
'SECTION_NAME' => $this->_oTrans->MENU_LOGIN,
|
|
| 178 | 172 |
'BODY_TAGS' => $body_tags, |
| 179 |
'WEBSITE_TITLE' => ($title['value']),
|
|
| 180 |
'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'],
|
|
| 181 |
'CURRENT_USER' => $MESSAGE['START_CURRENT_USER'],
|
|
| 173 |
'WEBSITE_TITLE' => $title,
|
|
| 174 |
'TEXT_ADMINISTRATION' => $this->_oTrans->TEXT_ADMINISTRATION,
|
|
| 175 |
'CURRENT_USER' => $this->_oTrans->MESSAGE_START_CURRENT_USER,
|
|
| 182 | 176 |
'DISPLAY_NAME' => $this->get_display_name(), |
| 183 | 177 |
'CHARSET' => $charset, |
| 184 | 178 |
//'LANGUAGE' => strtolower(LANGUAGE), |
| ... | ... | |
| 192 | 186 |
'THEME_URL' => THEME_URL, |
| 193 | 187 |
'START_URL' => ADMIN_URL.'/index.php', |
| 194 | 188 |
'START_CLASS' => 'start', |
| 195 |
'TITLE_START' => $TEXT['READ_MORE'],
|
|
| 196 |
'TITLE_VIEW' => $TEXT['WEBSITE'],
|
|
| 197 |
'TITLE_HELP' => 'WebsiteBaker '.$MENU['HELP'],
|
|
| 189 |
'TITLE_START' => $this->_oTrans->TEXT_READ_MORE,
|
|
| 190 |
'TITLE_VIEW' => $this->_oTrans->TEXT_WEBSITE,
|
|
| 191 |
'TITLE_HELP' => 'WebsiteBaker '.$this->_oTrans->MENU_HELP,
|
|
| 198 | 192 |
'URL_VIEW' => $view_url, |
| 199 |
'TITLE_LOGOUT' => $MENU['LOGIN'],
|
|
| 193 |
'TITLE_LOGOUT' => $this->_oTrans->MENU_LOGIN,
|
|
| 200 | 194 |
'LOGIN_DISPLAY_HIDDEN' => !$this->is_authenticated() ? 'hidden' : '', |
| 201 | 195 |
'LOGIN_DISPLAY_NONE' => !$this->is_authenticated() ? 'none' : '', |
| 202 | 196 |
'LOGIN_LINK' => $_SERVER['SCRIPT_NAME'], |
| ... | ... | |
| 211 | 205 |
if($this->get_user_id() == 1) |
| 212 | 206 |
{
|
| 213 | 207 |
$sys_locked = (((int)(defined('SYSTEM_LOCKED') ? SYSTEM_LOCKED : 0)) == 1);
|
| 214 |
$header_template->set_var('MAINTENANCE_MODE', ($sys_locked ? $TEXT['MAINTENANCE_OFF'] : $TEXT['MAINTENANCE_ON']));
|
|
| 208 |
$header_template->set_var('MAINTENANCE_MODE', ($sys_locked ? $this->_oTrans->TEXT_MAINTENANCE_OFF : $this->_oTrans->TEXT_MAINTENANCE_ON));
|
|
| 215 | 209 |
$header_template->set_var('MAINTENANCE_ICON', THEME_URL.'/images/'.($sys_locked ? 'lock' : 'unlock').'.png');
|
| 216 | 210 |
$header_template->set_var('MAINTAINANCE_URL', ADMIN_URL.'/settings/locking.php');
|
| 217 | 211 |
$header_template->parse('maintenance', 'maintenance_block', true);
|
| ... | ... | |
| 233 | 227 |
} else {
|
| 234 | 228 |
$header_template->set_var('STYLE', 'start');
|
| 235 | 229 |
$header_template->set_var( array( |
| 236 |
'SECTION_NAME' => $MENU[strtoupper($this->section_name)],
|
|
| 237 |
'TITLE_LOGOUT' => $MENU['LOGOUT'],
|
|
| 230 |
'SECTION_NAME' => $this->_oTrans->{'MENU'.strtoupper($this->section_name)},
|
|
| 231 |
'TITLE_LOGOUT' => $this->_oTrans->MENU_LOGOUT,
|
|
| 238 | 232 |
'LOGIN_DISPLAY_NONE' => '', |
| 239 | 233 |
'START_ICON' => 'home', |
| 240 | 234 |
'LOGIN_ICON' => 'logout', |
| 241 | 235 |
'LOGIN_LINK' => ADMIN_URL.'/logout/index.php', |
| 242 |
'TITLE_START' => $MENU['START']
|
|
| 236 |
'TITLE_START' => $this->_oTrans->MENU_START
|
|
| 243 | 237 |
) |
| 244 | 238 |
); |
| 245 | 239 |
|
| 246 | 240 |
// @array ( $url, $target, $title, $page_permission, $permission_required ) |
| 247 | 241 |
$menu = array( |
| 248 | 242 |
// array(ADMIN_URL.'/index.php', '', $MENU['START'], 'start', 1 ), |
| 249 |
array(ADMIN_URL.'/pages/index.php', '', $MENU['PAGES'], 'pages', 1),
|
|
| 243 |
array(ADMIN_URL.'/pages/index.php', '', $this->_oTrans->MENU_PAGES, 'pages', 1),
|
|
| 250 | 244 |
// array($view_url, '_blank', $MENU['FRONTEND'], 'pages', 1), |
| 251 |
array(ADMIN_URL.'/media/index.php', '', $MENU['MEDIA'], 'media', 1),
|
|
| 252 |
array(ADMIN_URL.'/addons/index.php', '', $MENU['ADDONS'], 'addons', 1),
|
|
| 253 |
array(ADMIN_URL.'/preferences/index.php', '', $MENU['PREFERENCES'], 'preferences', 1),
|
|
| 254 |
array(ADMIN_URL.'/settings/index.php', '', $MENU['SETTINGS'], 'settings', 1),
|
|
| 255 |
array(ADMIN_URL.'/admintools/index.php', '', $MENU['ADMINTOOLS'], 'admintools', 1),
|
|
| 256 |
array(ADMIN_URL.'/access/index.php', '', $MENU['ACCESS'], 'access', 1),
|
|
| 245 |
array(ADMIN_URL.'/media/index.php', '', $this->_oTrans->MENU_MEDIA, 'media', 1),
|
|
| 246 |
array(ADMIN_URL.'/addons/index.php', '', $this->_oTrans->MENU_ADDONS, 'addons', 1),
|
|
| 247 |
array(ADMIN_URL.'/preferences/index.php', '', $this->_oTrans->MENU_PREFERENCES, 'preferences', 1),
|
|
| 248 |
array(ADMIN_URL.'/settings/index.php', '', $this->_oTrans->MENU_SETTINGS, 'settings', 1),
|
|
| 249 |
array(ADMIN_URL.'/admintools/index.php', '', $this->_oTrans->MENU_ADMINTOOLS, 'admintools', 1),
|
|
| 250 |
array(ADMIN_URL.'/access/index.php', '', $this->_oTrans->MENU_ACCESS, 'access', 1),
|
|
| 257 | 251 |
// array('http://addons.websitebaker2.org/', '', 'WB-Addons', 'preferences', 1),
|
| 258 | 252 |
// array('http://template.websitebaker2.org/', '', 'WB-Template', 'preferences', 1),
|
| 259 | 253 |
// array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', '', 0),
|
| ... | ... | |
| 289 | 283 |
$header_template->parse('header', 'header_block', false);
|
| 290 | 284 |
$header_template->pparse('output', 'page');
|
| 291 | 285 |
unset($header_template); |
| 286 |
$this->_oTrans->disableAddon(); |
|
| 292 | 287 |
} |
| 293 | 288 |
|
| 294 | 289 |
// Print the admin footer |
| 295 |
function print_footer($activateJsAdmin = false) {
|
|
| 296 |
global $database,$starttime,$iPhpDeclaredClasses; |
|
| 297 |
$oTrans = Translate::getInstance(); |
|
| 298 |
$oTrans->disableAddon(); |
|
| 290 |
function print_footer($activateJsAdmin = false) {
|
|
| 291 |
global $starttime, $iPhpDeclaredClasses; |
|
| 299 | 292 |
// include the required file for Javascript admin |
| 300 | 293 |
if($activateJsAdmin == true) {
|
| 301 | 294 |
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php')){
|
| 302 | 295 |
@include_once(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'); |
| 303 | 296 |
} |
| 304 | 297 |
} |
| 305 |
|
|
| 306 | 298 |
// Setup template object, parse vars to it, then parse it |
| 307 | 299 |
$footer_template = new Template(dirname($this->correct_theme_source('footer.htt')));
|
| 308 | 300 |
$footer_template->set_file('page', 'footer.htt');
|
| 309 | 301 |
$footer_template->set_block('page', 'footer_block', 'header');
|
| 302 |
$this->_oTrans->enableAddon('templates\\'.$this->_oReg->DefaultTheme);
|
|
| 303 |
$footer_template->set_var($this->_oTrans->getLangArray()); |
|
| 310 | 304 |
$footer_template->set_var(array( |
| 311 | 305 |
'BACKEND_BODY_MODULE_JS' => $this->register_backend_modfiles_body('js'),
|
| 312 | 306 |
'WB_URL' => WB_URL, |
| ... | ... | |
| 324 | 318 |
|
| 325 | 319 |
$footer_template->set_var('MEMORY', number_format(memory_get_peak_usage(true), 0, ',', '.').' Byte' );
|
| 326 | 320 |
// $footer_template->set_var('MEMORY', number_format(memory_get_usage(true), 0, ',', '.').' Byte' );
|
| 327 |
$footer_template->set_var('QUERIES', $database->getQueryCount );
|
|
| 321 |
$footer_template->set_var('QUERIES', $this->_oDb->getQueryCount );
|
|
| 328 | 322 |
// $footer_template->set_var('QUERIES', 'disabled' );
|
| 329 | 323 |
$included_files = get_included_files(); |
| 330 | 324 |
$footer_template->set_var('INCLUDES', sizeof($included_files) );
|
| ... | ... | |
| 374 | 368 |
$footer_template->parse('header', 'footer_block', false);
|
| 375 | 369 |
$footer_template->pparse('output', 'page');
|
| 376 | 370 |
unset($footer_template); |
| 371 |
|
|
| 377 | 372 |
} |
| 378 | 373 |
|
| 379 | 374 |
// Return a system permission |
Also available in: Unified diff
! admin::print_header() now provides all translations in theme::header.htt and accepts language files in theme
! admin::print_footer() now provides all translations in theme::footer.htt and accepts language files in theme