From 706f3b7d03e9bd0f241aa7ee7d2eaa0b2e2869c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 11 Oct 2009 17:33:23 +0000 Subject: [PATCH] Constants rewritten (internal TODO) --- inc/functions.php | 30 ++++++++++--------- inc/modules/admin/admin-inc.php | 16 +++++----- templates/de/html/admin/admin_main_footer.tpl | 4 ++- templates/de/html/admin/admin_main_header.tpl | 7 +++-- templates/de/html/admin/admin_welcome.tpl | 2 +- .../de/html/admin/admin_welcome_admins.tpl | 2 +- 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 6737f45808..361b71180b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -128,6 +128,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { $OUTPUT = str_replace('{!_MYSQL_PREFIX!}', getConfig('_MYSQL_PREFIX'), $OUTPUT); // Prepare the content and eval() it... + $content = array(); $newContent = ''; $eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";"; eval($eval); @@ -1021,20 +1022,6 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true) // But shall I keep simple quotes for later use? if ($simple) $code = str_replace("'", '{QUOT}', $code); - // Compile {?some_var?} to getConfig('some_var') - preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches); - - // Some entries found? - if ((count($matches) > 0) && (count($matches[0]) > 0)) { - // Replace all matches - foreach ($matches[0] as $key => $match) { - // Replace it - //* DEBUG: */ if ($key == 0) { print '
'; debug_print_backtrace(); print '
'; } - //* DEBUG: */ print $match.'='.$matches[1][$key].' ('.$key.')
'; - $code = str_replace($match, getConfig($matches[1][$key]), $code); - } // END - foreach - } // END - if - // Find $content[bla][blub] entries preg_match_all('/\$(content|GLOBALS|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); @@ -1081,6 +1068,21 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true) } // END - foreach } // END - if + // Compile {?some_var?} to getConfig('some_var') + preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches); + + // Some entries found? + if ((count($matches) > 0) && (count($matches[0]) > 0)) { + // Replace all matches + foreach ($matches[0] as $key => $match) { + // Replace it + //* DEBUG: */ if ($key == 0) { print '
'; debug_print_backtrace(); print '
'; } + //* DEBUG: */ print htmlentities($match).'['.strlen($match).']='.$matches[1][$key].'='.getConfig($matches[1][$key]).' (key='.$key.',len='.strlen($code).')
'; + $code = str_replace($match, getConfig($matches[1][$key]), $code); + //* DEBUG: */ if (($match == '{?URL?}') && (strlen($code) > 10000)) die('
'.htmlentities($code).'
'); + } // END - foreach + } // END - if + // Return compiled code return $code; } diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index bb1bb5e5b9..a9d93afa43 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -253,20 +253,20 @@ function ADMIN_DO_ACTION ($wht) { $act = getModeAction(getModule(), $wht); // Define admin login name and ID number - define('__ADMIN_LOGIN', getSession('admin_login')); - define('__ADMIN_ID' , getCurrentAdminId()); + $content['login'] = getSession('admin_login'); + $content['id'] = getCurrentAdminId(); // Preload templates if (EXT_IS_ACTIVE('admins')) { - define('__ADMIN_WELCOME', LOAD_TEMPLATE('admin_welcome_admins', true)); + $content['welcome'] = LOAD_TEMPLATE('admin_welcome_admins', true, $content); } else { - define('__ADMIN_WELCOME', LOAD_TEMPLATE('admin_welcome', true)); + $content['welcome'] = LOAD_TEMPLATE('admin_welcome', true, $content); } - define('__ADMIN_FOOTER' , LOAD_TEMPLATE('admin_footer' , true)); - define('__ADMIN_MENU' , ADD_ADMIN_MENU($act, $wht, true)); + $content['footer'] = LOAD_TEMPLATE('admin_footer' , true, $content); + $content['menu'] = ADD_ADMIN_MENU($act, $wht, true, $content); // Tableset header - LOAD_TEMPLATE('admin_main_header'); + LOAD_TEMPLATE('admin_main_header', false, $content); // Check if action/what pair is valid $result_action = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_admin_menu` @@ -297,7 +297,7 @@ LIMIT 1", array($act, $wht, $wht), __FUNCTION__, __LINE__); SQL_FREERESULT($result_action); // Tableset footer - LOAD_TEMPLATE('admin_main_footer'); + LOAD_TEMPLATE('admin_main_footer', false, $content); } // diff --git a/templates/de/html/admin/admin_main_footer.tpl b/templates/de/html/admin/admin_main_footer.tpl index f522fd0c93..507b5f5b86 100644 --- a/templates/de/html/admin/admin_main_footer.tpl +++ b/templates/de/html/admin/admin_main_footer.tpl @@ -5,6 +5,8 @@   - {!__ADMIN_FOOTER!} + + $content[footer] + \ No newline at end of file diff --git a/templates/de/html/admin/admin_main_header.tpl b/templates/de/html/admin/admin_main_header.tpl index 439a098cf4..c5a800700d 100644 --- a/templates/de/html/admin/admin_main_header.tpl +++ b/templates/de/html/admin/admin_main_header.tpl @@ -1,8 +1,11 @@ + $content[welcome] + - +
- {!__ADMIN_WELCOME!}
{!__ADMIN_MENU!} + $content[menu] + \ No newline at end of file diff --git a/templates/de/html/admin/admin_welcome.tpl b/templates/de/html/admin/admin_welcome.tpl index 919904c961..b9b6fa3a3f 100644 --- a/templates/de/html/admin/admin_welcome.tpl +++ b/templates/de/html/admin/admin_welcome.tpl @@ -6,7 +6,7 @@
  Hallo $username!
- Aktueller Admin: [{!__ADMIN_LOGIN!}] + Aktueller Admin: [$content[login]]
Ausloggen diff --git a/templates/de/html/admin/admin_welcome_admins.tpl b/templates/de/html/admin/admin_welcome_admins.tpl index 30859d627a..01a6d3b58f 100644 --- a/templates/de/html/admin/admin_welcome_admins.tpl +++ b/templates/de/html/admin/admin_welcome_admins.tpl @@ -8,7 +8,7 @@
Aktueller Admin: [{!__ADMIN_LOGIN!}] + href="{?URL?}/modules.php?module=admin&what=admins_edit&admin=$content[id]">$content[login]]
Ausloggen -- 2.39.2