From 30813af329c1e3f07932fc53adee1a37d78f01c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 19 Jun 2010 22:14:09 +0000 Subject: [PATCH] Rewrites/fixes for broken template cache, the actual value was rendered but instead it should be inserted at runtime... :( --- DOCS/de/TODO.txt | 3 +++ inc/expression-functions.php | 11 +++++--- inc/filters.php | 27 ++++++++++++++----- inc/functions.php | 16 +++-------- templates/de/html/admin/admin_welcome.tpl | 2 +- .../de/html/admin/admin_welcome_admins.tpl | 2 +- templates/de/html/guest/guest_header.tpl | 2 +- templates/de/html/member/member_header.tpl | 2 +- .../de/html/member/member_support_form.tpl | 2 +- templates/de/html/show_timings.tpl | 2 +- templates/en/html/admin/admin_welcome.tpl | 2 +- 11 files changed, 41 insertions(+), 30 deletions(-) diff --git a/DOCS/de/TODO.txt b/DOCS/de/TODO.txt index f107a994f9..09d5c8f89e 100644 --- a/DOCS/de/TODO.txt +++ b/DOCS/de/TODO.txt @@ -19,6 +19,9 @@ - CSS-Klassen reduzieren und weiter vereinfachen - Von TABLE auf DIV-Container umstellen - AJAX einbinden +- Klick-Smiley unterstuetzen: + + Dazu ist es noetig, dass alle vergueteten Klicks zentral gezaehlt werden + + Empfehlenswert ist hier ein Filter, der dies samt Gutschrift uebernimmt - Hoere auf, "unfreie" Software zu verwenden und trete meiner Community bei. - Kaempft gegen Softwarepatente! Das ist Teufelszeug! diff --git a/inc/expression-functions.php b/inc/expression-functions.php index c3d1f57f8b..eebeb6c0d9 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -151,11 +151,8 @@ function doExpressionExt ($data) { // Expression call-back function for getting configuration data // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again function doExpressionConfig ($data) { - // Read configuration - $configValue = getConfig($data['matches'][4][$data['key']]); - // Default replacer is the config value itself - $replacer = $configValue; + $replacer = '{DQUOTE} . getConfig(' . "'" . $data['matches'][4][$data['key']] . "'" . ') . {DQUOTE}'; // Is there a call-back function provided? if (!empty($data['callback'])) { @@ -175,6 +172,12 @@ function doExpressionPipe ($data) { // We need callback and extra_func: callback is really the call-back function, extra_func is our value $replacer = $data['extra_func']; + // Is the extra_func empty and value set? + if ((empty($replacer)) && (isset($data['value']))) { + // Then use this + $replacer = $data['value']; + } // END - if + // Do we have a call-back? Should always be there! if (!empty($data['callback'])) { // Parse it through this function diff --git a/inc/filters.php b/inc/filters.php index fa28dba400..1570488b12 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -436,7 +436,7 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) { if ($compiled === true) { // Run the code $eval = "\$GLOBALS['compiled_config'][\$uncompiled] = \"" . $GLOBALS['compiled_config'][$uncompiled] . "\";"; - //* DEBUG: */ print(__FUNCTION__.'['.__LINE__.']:
' . str_replace('$', '$', htmlentities($eval)) . '
'); + /* DEBUG: */ print(__FUNCTION__.'['.__LINE__.']:
' . str_replace('$', '$', htmlentities($eval)) . '
'); eval($eval); } // END - if @@ -459,15 +459,29 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { // Replace all matches foreach ($matches[2] as $key => $cmd) { // Init replacer/call-back variable - $replacer = ''; - $callback = ''; + $replacer = ''; + $callback = ''; $extraFunction = ''; + $value = ''; // Extract command and call-back $cmdArray = explode(',', $cmd); $cmd = $cmdArray[0]; - if (isset($cmdArray[1])) $callback = $cmdArray[1]; - if (isset($cmdArray[2])) $extraFunction = $cmdArray[2]; + + // Detect call-back function + if (isset($cmdArray[1])) { + // Call-back function detected + $callback = $cmdArray[1]; + } // END - if + + // Detect extra function + if (isset($cmdArray[2])) { + // Also detected + $extraFunction = $cmdArray[2]; + } elseif (isset($matches[4][$key])) { + // Use this as value + $value = $matches[4][$key]; + } // Construct call-back function name for the command $commandFunction = 'doExpression' . ucfirst(strtolower($cmd)); @@ -481,7 +495,8 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { 'mode' => $outputMode, 'code' => $code, 'callback' => $callback, - 'extra_func' => $extraFunction + 'extra_func' => $extraFunction, + 'value' => $value ); // Call it diff --git a/inc/functions.php b/inc/functions.php index 2edf08a02c..0a38bdf441 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -49,10 +49,6 @@ function outputHtml ($htmlCode, $newLine = true) { $GLOBALS['output'] = ''; } // END - if - // Transfer username - $username = getMessage('USERNAME_UNKNOWN'); - if (isset($GLOBALS['username'])) $username = getUsername(); - // Do we have HTML-Code here? if (!empty($htmlCode)) { // Yes, so we handle it as you have configured @@ -266,9 +262,6 @@ function loadTemplate ($template, $return = false, $content = array()) { // Evaluate the cache eval(readTemplateCache($template)); } elseif (!isset($GLOBALS['template_eval'][$template])) { - // Add more variables which you want to use in your template files - $username = getUsername(); - // Make all template names lowercase $template = strtolower($template); @@ -1077,11 +1070,11 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true if ($constants === true) { // BEFORE 0.2.1 : Language and data constants // WITH 0.2.1+ : Only language constants - $code = str_replace('{--', "\" . getMessage('", str_replace('--}', "') . \"", $code)); + $code = str_replace('{--', "{DQUOTE} . getMessage('", str_replace('--}', "') . {DQUOTE}", $code)); // BEFORE 0.2.1 : Not used // WITH 0.2.1+ : Data constants - $code = str_replace('{!', "\" . constant('", str_replace('!}', "') . \"", $code)); + $code = str_replace('{!', "{DQUOTE} . constant('", str_replace('!}', "') . {DQUOTE}", $code)); } // END - if // Compile QUOT and other non-HTML codes @@ -2426,7 +2419,7 @@ function displayParsingTime () { // Prepare output // @TODO This can be easily moved out after the merge from EL branch to this is complete $content = array( - 'run_time' => translateComma($runTime), + 'run_time' => $runTime, 'sql_time' => translateComma(getConfig('sql_time') * 1000), ); @@ -3618,9 +3611,6 @@ function flushTemplateCache ($template, $eval) { // Generate FQFN $FQFN = generateCacheFqfn($template); - // Replace username with a call - $eval = str_replace('$username', '".getUsername()."', $eval); - // And flush it writeToFile($FQFN, $eval, true); } // END - if diff --git a/templates/de/html/admin/admin_welcome.tpl b/templates/de/html/admin/admin_welcome.tpl index 351e0f2d7e..5c24091bbd 100644 --- a/templates/de/html/admin/admin_welcome.tpl +++ b/templates/de/html/admin/admin_welcome.tpl @@ -7,7 +7,7 @@
- Hallo $username! + Hallo {%pipe,getUsername%}!
diff --git a/templates/de/html/admin/admin_welcome_admins.tpl b/templates/de/html/admin/admin_welcome_admins.tpl index 0e7078c960..afa73d449b 100644 --- a/templates/de/html/admin/admin_welcome_admins.tpl +++ b/templates/de/html/admin/admin_welcome_admins.tpl @@ -4,7 +4,7 @@
- Hallo $username! + Hallo {%pipe,getUsername%}!
diff --git a/templates/de/html/guest/guest_header.tpl b/templates/de/html/guest/guest_header.tpl index b3dcdedc4e..f39efa0898 100644 --- a/templates/de/html/guest/guest_header.tpl +++ b/templates/de/html/guest/guest_header.tpl @@ -9,7 +9,7 @@ class="guest_header">{?MAIN_TITLE?} - - - - + diff --git a/templates/de/html/member/member_header.tpl b/templates/de/html/member/member_header.tpl index 9b0ba9e4c4..ec61a8dcb4 100644 --- a/templates/de/html/member/member_header.tpl +++ b/templates/de/html/member/member_header.tpl @@ -14,7 +14,7 @@
Hallo $username!
Hallo {%pipe,getUsername%}!
{?SLOGAN?}
$content[date_time]
- Hallo $username! + Hallo {%pipe,getUsername%}!
diff --git a/templates/de/html/member/member_support_form.tpl b/templates/de/html/member/member_support_form.tpl index 2cb1543d2b..9194b7544f 100644 --- a/templates/de/html/member/member_support_form.tpl +++ b/templates/de/html/member/member_support_form.tpl @@ -34,7 +34,7 @@
Mit freundlichen Grüßen,
- Ihr $username + Ihr {%pipe,getUsername%}
diff --git a/templates/de/html/show_timings.tpl b/templates/de/html/show_timings.tpl index e9fffa0880..cfa2d464da 100644 --- a/templates/de/html/show_timings.tpl +++ b/templates/de/html/show_timings.tpl @@ -2,7 +2,7 @@
  • {--SHOW_TIMINGS_RUNTIME--} - $content[run_time] {--SHOW_TIMINGS_SECS--} + {%pipe,translateComma=$content[run_time]%} {--SHOW_TIMINGS_SECS--}
  • {--SHOW_TIMINGS_SQL_QUERIES--} diff --git a/templates/en/html/admin/admin_welcome.tpl b/templates/en/html/admin/admin_welcome.tpl index 619da679f5..dac7ad74f0 100644 --- a/templates/en/html/admin/admin_welcome.tpl +++ b/templates/en/html/admin/admin_welcome.tpl @@ -1,3 +1,3 @@ : : : Welcome to the administration's area : : :
    -
    Hello $username !
    +
    Hello {%pipe,getUsername%} !
    -- 2.39.5