Constants rewritten (internal TODO)
authorRoland Häder <roland@mxchange.org>
Sun, 11 Oct 2009 17:33:23 +0000 (17:33 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 11 Oct 2009 17:33:23 +0000 (17:33 +0000)
inc/functions.php
inc/modules/admin/admin-inc.php
templates/de/html/admin/admin_main_footer.tpl
templates/de/html/admin/admin_main_header.tpl
templates/de/html/admin/admin_welcome.tpl
templates/de/html/admin/admin_welcome_admins.tpl

index 6737f45..361b711 100644 (file)
@@ -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 '<pre>'; debug_print_backtrace(); print '</pre>'; }
-                       //* DEBUG: */ print $match.'='.$matches[1][$key].' ('.$key.')<br />';
-                       $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 '<pre>'; debug_print_backtrace(); print '</pre>'; }
+                       //* DEBUG: */ print htmlentities($match).'['.strlen($match).']='.$matches[1][$key].'='.getConfig($matches[1][$key]).' (key='.$key.',len='.strlen($code).')<br />';
+                       $code = str_replace($match, getConfig($matches[1][$key]), $code);
+                       //* DEBUG: */ if (($match == '{?URL?}') && (strlen($code) > 10000)) die('<pre>'.htmlentities($code).'</pre>');
+               } // END - foreach
+       } // END - if
+
        // Return compiled code
        return $code;
 }
index bb1bb5e..a9d93af 100644 (file)
@@ -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);
 }
 
 //
index f522fd0..507b5f5 100644 (file)
@@ -5,6 +5,8 @@
        <td class="admin_content">&nbsp;</td>
 </tr>
 <tr>
-       <td align="center" colspan="2">{!__ADMIN_FOOTER!}</td>
+       <td align="center" colspan="2">
+               $content[footer]
+       </td>
 </tr>
 </table>
\ No newline at end of file
index 439a098..c5a8007 100644 (file)
@@ -1,8 +1,11 @@
 <table border="0" cellspacing="0" cellpadding="0" class="admin_main">
        <tr>
                <td colspan="2" align="center" class="admin_welcome">
-               {!__ADMIN_WELCOME!}</td>
+                       $content[welcome]
+               </td>
        </tr>
        <tr>
-               <td class="admin_menu" valign="top">{!__ADMIN_MENU!}</td>
+               <td class="admin_menu" valign="top">
+                       $content[menu]
+               </td>
                <td class="admin_content" valign="top">
\ No newline at end of file
index 919904c..b9b6fa3 100644 (file)
@@ -6,7 +6,7 @@
                        <div align="left" class="tiny">&nbsp;&nbsp;Hallo $username!</div>
                </td>
                <td align="center" width="300" class="dashed"><div class="tiny">
-                       Aktueller Admin:&nbsp;[<span class="admin_note" title="Erweiterung admins nicht installiert.">{!__ADMIN_LOGIN!}</span>]
+                       Aktueller Admin:&nbsp;[<span class="admin_note" title="Erweiterung admins nicht installiert.">$content[login]</span>]
                </div></td>
                <td align="center" width="100" class="top2 bottom2 right2"><div class="tiny"> <a class="menu_blur admin_logout"
                        href="{?URL?}/modules.php?module=admin&amp;action=logout">Ausloggen</a>
index 30859d6..01a6d3b 100644 (file)
@@ -8,7 +8,7 @@
                </td>
                <td align="center" width="300" class="dashed"><div class="tiny">
                Aktueller Admin:&nbsp;[<a
-                       href="{?URL?}/modules.php?module=admin&amp;what=admins_edit&admin={!__ADMIN_ID!}"><strong>{!__ADMIN_LOGIN!}</strong></a>]
+                       href="{?URL?}/modules.php?module=admin&amp;what=admins_edit&amp;admin=$content[id]"><strong>$content[login]</strong></a>]
                </div></td>
                <td align="center" width="100" class="top2 bottom2 right2"><div class="tiny">
                        <a class="menu_blur admin_logout" href="{?URL?}/modules.php?module=admin&amp;action=logout">Ausloggen</a>