From 6560179e7c8dc565485503f374d4e31f333ffd0e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 9 Oct 2012 19:43:43 +0000 Subject: [PATCH] Caching of XML/email templates finished: - Added very basic (but working) support for caching XML and email templates - Added new XML templates for listing user sub ids - Added filter to "hook" another member action for listing member's sub ids - Some other minor improvements - TODOs.txt updated --- .gitattributes | 4 +- DOCS/TODOs.txt | 23 +- inc/ajax/ajax_admin.php | 2 +- inc/ajax/ajax_installer.php | 2 +- .../_compiled/{emails => email}/.htaccess | 0 inc/cache/_compiled/xml/.htaccess | 1 + inc/extensions/ext-user.php | 13 +- inc/filter/user_filter.php | 11 + inc/filters.php | 10 +- inc/functions.php | 2 +- inc/language/user_de.php | 4 + inc/modules/admin/what-list_ | 6 +- inc/modules/admin/what-list_nickname.php | 4 +- inc/modules/admin/what-list_user.php | 1 - inc/modules/admin/what-list_user_subid.php | 88 ++++++++ inc/template-functions.php | 199 +++++++++++------- inc/xml-functions.php | 22 +- .../xml/admin/admin_list_nickname_history.xml | 2 +- templates/xml/admin/admin_list_user_subid.xml | 120 +++++++++++ templates/xml/admin_list_data_template.xml | 2 +- 20 files changed, 410 insertions(+), 106 deletions(-) rename inc/cache/_compiled/{emails => email}/.htaccess (100%) create mode 100644 inc/cache/_compiled/xml/.htaccess create mode 100644 inc/modules/admin/what-list_user_subid.php create mode 100644 templates/xml/admin/admin_list_user_subid.xml diff --git a/.gitattributes b/.gitattributes index 2d9eb52fc5..94f1970bd2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -96,8 +96,9 @@ inc/autopurge/purge-tsks.php svneol=native#text/plain inc/autopurge/purge-unconfirmed.php svneol=native#text/plain inc/cache/.htaccess svneol=native#text/plain inc/cache/_compiled/.htaccess svneol=native#text/plain -inc/cache/_compiled/emails/.htaccess svneol=native#text/plain +inc/cache/_compiled/email/.htaccess svneol=native#text/plain inc/cache/_compiled/html/.htaccess svneol=native#text/plain +inc/cache/_compiled/xml/.htaccess svneol=native#text/plain inc/callback-functions.php svneol=native#text/plain inc/classes/.htaccess svneol=native#text/plain inc/classes/cachesystem.class.php svneol=native#text/plain @@ -602,6 +603,7 @@ inc/modules/admin/what-list_task.php svneol=native#text/plain inc/modules/admin/what-list_transfer.php svneol=native#text/plain inc/modules/admin/what-list_unconfirmed.php svneol=native#text/plain inc/modules/admin/what-list_user.php svneol=native#text/plain +inc/modules/admin/what-list_user_subid.php svneol=native#text/plain inc/modules/admin/what-list_wernis.php svneol=native#text/plain inc/modules/admin/what-list_yoomedia_tm.php svneol=native#text/plain inc/modules/admin/what-lock_sponsor.php svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 1b1007647e..a93a44a6a7 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -134,8 +134,8 @@ ./inc/modules/admin/what-list_refs.php:101: // @TODO Try to rewrite some to EL ./inc/modules/admin/what-list_unconfirmed.php:107: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_unconfirmed.php:84: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_user.php:290: // @TODO Rewrite this into a filter -./inc/modules/admin/what-list_user.php:355: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:289: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:354: // @TODO Rewrite this into a filter ./inc/modules/admin/what-logs.php:64: // @TODO Fix content-type here ./inc/modules/admin/what-logs.php:70: // @TODO Fix content-type here ./inc/modules/admin/what-mem_add.php:124: // @TODO This can be somehow rewritten to a function @@ -176,19 +176,20 @@ ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter ./inc/revision-functions.php:168:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1108: // @TODO Deprecate this thing -./inc/template-functions.php:1119: // @TODO Deprecate this thing -./inc/template-functions.php:1226: // @TODO This can be easily moved out after the merge from EL branch to this is complete -./inc/template-functions.php:1275: // @TODO Add a little more infos here -./inc/template-functions.php:1643:// @TODO Lame description for this function -./inc/template-functions.php:1665: // @TODO Move this in a filter +./inc/template-functions.php:1126: // @TODO Deprecate this thing +./inc/template-functions.php:1137: // @TODO Deprecate this thing +./inc/template-functions.php:1244: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1293: // @TODO Add a little more infos here +./inc/template-functions.php:1667:// @TODO Lame description for this function +./inc/template-functions.php:1689: // @TODO Move this in a filter ./inc/template-functions.php:197: * @TODO On some pages this is buggy +./inc/template-functions.php:2292: // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent); ./inc/template-functions.php:285: // @TODO Remove these sanity checks if all is fine -./inc/template-functions.php:599:// @TODO $simple/$constants are deprecated -./inc/template-functions.php:697: // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates +./inc/template-functions.php:617:// @TODO $simple/$constants are deprecated +./inc/template-functions.php:715: // @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates ./inc/wrapper-functions.php:3010: // @TODO Find a way to not use direct module comparison ./inc/wrapper-functions.php:494:// @TODO Do some more sanity check here -./inc/xml-functions.php:209: // @TODO Handle characters +./inc/xml-functions.php:221: // @TODO Handle characters ./mailid.php:102: // @TODO Rewrite this to a filter ./mailid.php:145: // @TODO Rewrite this to a filter ./mailid_top.php:112: // @TODO Rewrite this to a filter/function diff --git a/inc/ajax/ajax_admin.php b/inc/ajax/ajax_admin.php index dc5733e835..ae95def44c 100644 --- a/inc/ajax/ajax_admin.php +++ b/inc/ajax/ajax_admin.php @@ -99,7 +99,7 @@ function doAjaxAdminRequestContent () { setAjaxReplyContent(loadTemplate('admin_area_' . trim(postRequestElement('tab')), true)); // Has the template been loaded? - if (isset($GLOBALS['tpl_content']['admin_page_' . trim(postRequestElement('tab'))])) { + if (isset($GLOBALS['template_content']['html']['admin_page_' . trim(postRequestElement('tab'))])) { // All okay if we reach this point setHttpStatus('200 OK'); } else { diff --git a/inc/ajax/ajax_installer.php b/inc/ajax/ajax_installer.php index 1f6f9fc2a2..f9c50322d0 100644 --- a/inc/ajax/ajax_installer.php +++ b/inc/ajax/ajax_installer.php @@ -150,7 +150,7 @@ function doAjaxInstallerRequestContent () { setAjaxReplyContent(loadTemplate('install_page_' . trim(postRequestElement('tab')), true)); // Has the template been loaded? - if (isset($GLOBALS['tpl_content']['install_page_' . trim(postRequestElement('tab'))])) { + if (isset($GLOBALS['template_content']['html']['install_page_' . trim(postRequestElement('tab'))])) { // All okay if we reach this point setHttpStatus('200 OK'); } else { diff --git a/inc/cache/_compiled/emails/.htaccess b/inc/cache/_compiled/email/.htaccess similarity index 100% rename from inc/cache/_compiled/emails/.htaccess rename to inc/cache/_compiled/email/.htaccess diff --git a/inc/cache/_compiled/xml/.htaccess b/inc/cache/_compiled/xml/.htaccess new file mode 100644 index 0000000000..3a42882788 --- /dev/null +++ b/inc/cache/_compiled/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index ed6a26f2d0..fc973a3dcf 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.5.4'); +setThisExtensionVersion('0.5.5'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4')); +setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -198,6 +198,7 @@ INDEX (`stats_type`)", unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', true, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'update_referral_data', 'GENERIC_UPDATE_USER_REFERRAL', true, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'update_referral_data', 'UPDATE_USER_SUBID', true, isExtensionDryRun()); + unregisterFilter(__FILE__, __LINE__, 'member_admin_actions', 'ADD_USER_SUBID_MEMBER_ACTION', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -637,6 +638,14 @@ INDEX (`subid`)", // Update notes (these will be set as task text!) setExtensionUpdateNotes("Weitere Filter für Referral-Counter und Sub-Id hinzugefügt."); break; + + case '0.5.5': // SQL queries for v0.5.5 + // Register filter + registerFilter(__FILE__, __LINE__, 'member_admin_actions', 'ADD_USER_SUBID_MEMBER_ACTION', false, true, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Weiteren Filter für Mitglieder-Aktionen im Adminbereich hinzugefügt."); + break; } // END - switch break; diff --git a/inc/filter/user_filter.php b/inc/filter/user_filter.php index de3ce0efc2..27980937c2 100644 --- a/inc/filter/user_filter.php +++ b/inc/filter/user_filter.php @@ -227,5 +227,16 @@ function FILTER_UPDATE_USER_SUBID ($filterData) { return $filterData; } +// Filter for adding member action +function FILTER_ADD_USER_SUBID_MEMBER_ACTION ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + // Add entry + array_push($filterData, 'list_user_subid'); + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + // [EOF] ?> diff --git a/inc/filters.php b/inc/filters.php index fca3cf439a..634d0f1c00 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -993,10 +993,12 @@ function FILTER_FLUSH_TEMPLATE_CACHE () { // Is there cached eval() data? if ((isset($GLOBALS['template_eval'])) && (count($GLOBALS['template_eval']) > 0)) { // Now flush all - foreach ($GLOBALS['template_eval'] as $template => $eval) { - // Flush the cache (if not yet found) - flushTemplateCache($template, $eval); - } // END - if + foreach ($GLOBALS['template_eval'] as $prefix => $templateArray) { + foreach ($templateArray as $template => $eval) { + // Flush the cache (if not yet found) + flushTemplateCache($prefix, $template, $eval); + } // END - foreach + } // END - foreach } // END - if } diff --git a/inc/functions.php b/inc/functions.php index 5fb35afd9f..c37b570c97 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -64,7 +64,7 @@ function addFatalMessage ($F, $L, $message, $extra = '') { array_push($GLOBALS['fatal_messages'], $message); // Log fatal messages away - logDebugMessage($F, $L, 'Fatal error message: ' . $message); + logDebugMessage($F, $L, 'Fatal error message: ' . compileCode($message)); } // Getter for total fatal message count diff --git a/inc/language/user_de.php b/inc/language/user_de.php index 732ccf6fdb..ef6feb05ff 100644 --- a/inc/language/user_de.php +++ b/inc/language/user_de.php @@ -155,6 +155,10 @@ addMessages(array( 'MEMBER_EDIT_USER_SUBIDS_SUBJECT' => "Änderung Ihrer Sub-Id", 'MEMBER_DELETE_USER_SUBIDS_SUBJECT' => "Ihre Sub-Id ist gelöscht", + // Admin - sub ids - action link + 'ADMIN_USER_ACTION_LINK_LIST_USER_SUBID_TITLE' => "Sub-Ids des Mitgliedes auflisten und Statistik einsehen", + 'ADMIN_USER_ACTION_LINK_LIST_USER_SUBID' => "Sub-Ids auflisten", + // Generic - subids 'SUBID_VALUE' => "Sub-Id:", 'SUBID_ADDED' => "Hinzugefügt:", diff --git a/inc/modules/admin/what-list_ b/inc/modules/admin/what-list_ index e190b12960..4885a6a285 100644 --- a/inc/modules/admin/what-list_ +++ b/inc/modules/admin/what-list_ @@ -6,9 +6,9 @@ * -------------------------------------------------------------------- * * File : what-list_!!!s.php * * -------------------------------------------------------------------- * - * Short description : List all URLs in !!! and sync from mail pool * + * Short description : List all URLs in !!! * * -------------------------------------------------------------------- * - * Kurzbeschreibung : Alle URLs in !!! auflisten und syncen * + * Kurzbeschreibung : Alle URLs in !!! auflisten * * -------------------------------------------------------------------- * * $Revision:: $ * * $Date:: $ * @@ -100,7 +100,7 @@ if ($show === false) { return false; } // END - if -// List all URLs +// List all !!! showEntriesByXmlCallback('admin_list_!!!s'); // [EOF] diff --git a/inc/modules/admin/what-list_nickname.php b/inc/modules/admin/what-list_nickname.php index a52ef8323d..8d4cada317 100644 --- a/inc/modules/admin/what-list_nickname.php +++ b/inc/modules/admin/what-list_nickname.php @@ -46,7 +46,9 @@ addYouAreHereLink('admin', __FILE__); // Check if 'userid' is set if (isGetRequestElementSet('userid')) { // List all entries per user - showEntriesByXmlCallback('admin_list_nickname_history'); + showEntriesByXmlCallback('admin_list_nickname_history', array( + 'userid' => bigintval(getRequestElement('userid')) + )); } else { // Output selection form with all confirmed user accounts listed addMemberSelectionBox(); diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index 28f967faa1..d721f6f0f0 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -137,7 +137,6 @@ LIMIT 1", $content['joined'] = generateDateTime($content['joined'], '2'); $content['last_update'] = generateDateTime($content['last_update'], '2'); $content['last_profile_sent'] = generateDateTime($content['last_profile_sent'], '2'); - $content['total_points'] = getTotalPoints($content['userid']); $content['locked_points'] = countSumTotalData($content['userid'], 'user_points', 'locked_points') + countSumTotalData($content['userid'], 'user_points', 'locked_order_points'); // Prepare array for filter diff --git a/inc/modules/admin/what-list_user_subid.php b/inc/modules/admin/what-list_user_subid.php new file mode 100644 index 0000000000..b2bede3baf --- /dev/null +++ b/inc/modules/admin/what-list_user_subid.php @@ -0,0 +1,88 @@ + 0) && (!ifPostContainsSelections('id'))) { + // Not found so output message + displayMessage('{--ADMIN_USER_SUBID_NO_SELECTIONS--}'); + + // Abort here + return; +} // END - if + +// Edit or delete button hit? +if (isFormSent('delete')) { + // Show entries for deletion + showEntriesByXmlCallback('admin_delete_show_user_subid'); + + // Do not show the list of URLs after this template + $show = false; +} elseif (isFormSent('do_delete')) { + // Remove entries from database + showEntriesByXmlCallback('admin_delete_do_user_subid'); +} + +// Show entries? +if ($show === false) { + // No, a form has already been show + return false; +} // END - if + +// Is a user id sent? +if (isGetRequestElementSet('userid')) { + // List all sub ids + showEntriesByXmlCallback('admin_list_user_subid', array( + 'userid' => bigintval(getRequestElement('userid')) + )); +} else { + // Output selection form with all confirmed user accounts listed + addMemberSelectionBox(); +} + +// [EOF] +?> diff --git a/inc/template-functions.php b/inc/template-functions.php index e2b65de749..9c7192ab1a 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -298,16 +298,16 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC $GLOBALS['current_template'] = $template; // Is there cache? - if ((!isDebuggingTemplateCache()) && (isTemplateCached($template))) { + if ((!isDebuggingTemplateCache()) && (isTemplateCached('html', $template))) { // Evaluate the cache - eval(readTemplateCache($template)); - } elseif (!isset($GLOBALS['template_eval'][$template])) { + eval(readTemplateCache('html', $template)); + } elseif (!isset($GLOBALS['template_eval']['html'][$template])) { // Make all template names lowercase $template = strtolower($template); // Base directory $basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage()); - $extraPath = detectExtraTemplatePath($template); + $extraPath = detectExtraTemplatePath('html', $template); // Generate FQFN $FQFN = $basePath . $extraPath . $template . '.tpl'; @@ -325,31 +325,31 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC incrementConfigEntry('num_templates'); // The local file does exists so we load it. :) - $GLOBALS['tpl_content'][$template] = readFromFile($FQFN); + $GLOBALS['template_content']['html'][$template] = readFromFile($FQFN); // Is there to compile the code? - if ((isInString('$', $GLOBALS['tpl_content'][$template])) || (isInString('{--', $GLOBALS['tpl_content'][$template])) || (isInString('{?', $GLOBALS['tpl_content'][$template])) || (isInString('{%', $GLOBALS['tpl_content'][$template]))) { + if ((isInString('$', $GLOBALS['template_content']['html'][$template])) || (isInString('{--', $GLOBALS['template_content']['html'][$template])) || (isInString('{?', $GLOBALS['template_content']['html'][$template])) || (isInString('{%', $GLOBALS['template_content']['html'][$template]))) { // Normal HTML output? if ((isHtmlOutputMode()) && (substr($template, 0, 3) != 'js_')) { // Add surrounding HTML comments to help finding bugs faster - $code = '' . $GLOBALS['tpl_content'][$template] . ''; + $code = '' . $GLOBALS['template_content']['html'][$template] . ''; // Prepare eval() command - $GLOBALS['template_eval'][$template] = '$ret = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), false, true, true, $compileCode) . '";'; + $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), false, true, true, $compileCode) . '";'; } elseif (substr($template, 0, 3) == 'js_') { // JavaScripts don't like entities, dollar signs and timings - $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; + $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), false, true, true, $compileCode) . '");'; } else { // Prepare eval() command, other output doesn't like entities, maybe - $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; + $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['html'][$template]), false, true, true, $compileCode) . '");'; } } elseif (isHtmlOutputMode()) { // Add surrounding HTML comments to help finding bugs faster - $ret = '' . $GLOBALS['tpl_content'][$template] . ''; - $GLOBALS['template_eval'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), false, true, true, $compileCode) . '";'; + $ret = '' . $GLOBALS['template_content']['html'][$template] . ''; + $GLOBALS['template_eval']['html'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), false, true, true, $compileCode) . '";'; } else { // JavaScript again - $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; + $GLOBALS['template_eval']['html'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['template_content']['html'][$template]), false, true, true, $compileCode) . '");'; } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active @@ -365,16 +365,16 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC '; } else { // No file! - $GLOBALS['template_eval'][$template] = '404'; + $GLOBALS['template_eval']['html'][$template] = '404'; } } // Code set? - if ((isset($GLOBALS['template_eval'][$template])) && ($GLOBALS['template_eval'][$template] != '404')) { + if ((isset($GLOBALS['template_eval']['html'][$template])) && ($GLOBALS['template_eval']['html'][$template] != '404')) { // Eval the code //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - BEFORE EVAL'); - ///* DEBUG: */ print('
'.htmlentities($GLOBALS['template_eval'][$template]).'
'); - eval($GLOBALS['template_eval'][$template]); + ///* DEBUG: */ print('
'.htmlentities($GLOBALS['template_eval']['html'][$template]).'
'); + eval($GLOBALS['template_eval']['html'][$template]); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - AFTER EVAL'); } // END - if @@ -395,12 +395,12 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC } // Detects the extra template path from given template name -function detectExtraTemplatePath ($template) { +function detectExtraTemplatePath ($prefix, $template) { // Default is empty $extraPath = ''; // Is there cache? - if (!isset($GLOBALS['extra_path'][$template])) { + if (!isset($GLOBALS['extra_path'][$prefix][$template])) { // Check for admin/guest/member/etc. templates if (substr($template, 0, 6) == 'admin_') { // Admin template found @@ -441,11 +441,11 @@ function detectExtraTemplatePath ($template) { } // Store it in cache - $GLOBALS['extra_path'][$template] = $extraPath; + $GLOBALS['extra_path'][$prefix][$template] = $extraPath; } // END - if // Return result - return $GLOBALS['extra_path'][$template]; + return $GLOBALS['extra_path'][$prefix][$template]; } // Loads an email template and compiles it @@ -471,33 +471,37 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load } } // END - if - // Base directory - $basePath = sprintf("%stemplates/%s/emails/", getPath(), getLanguage()); + // Is there cache? + if ((!isDebuggingTemplateCache()) && (isTemplateCached('email', $template))) { + // Evaluate the cache + eval(readTemplateCache('email', $template)); + } elseif (!isset($GLOBALS['template_eval']['email'][$template])) { + // Base directory + $basePath = sprintf("%stemplates/%s/emails/", getPath(), getLanguage()); - // Detect extra path - $extraPath = detectExtraTemplatePath($template); + // Detect extra path + $extraPath = detectExtraTemplatePath('email', $template); - // Generate full FQFN - $FQFN = $basePath . $extraPath . $template . '.tpl'; + // Generate full FQFN + $FQFN = $basePath . $extraPath . $template . '.tpl'; - // Does the special template exists? - if (!isFileReadable($FQFN)) { - // Reset to default template - $FQFN = $basePath . $template . '.tpl'; - } // END - if + // Does the special template exists? + if (!isFileReadable($FQFN)) { + // Reset to default template + $FQFN = $basePath . $template . '.tpl'; + } // END - if - // Now does the final template exists? - $newContent = ''; - if (isFileReadable($FQFN)) { - // The local file does exists so we load it. :) - $GLOBALS['tpl_content'][$template] = readFromFile($FQFN); - - // Run code - $GLOBALS['tpl_content'][$template] = '$newContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'][$template])) . '");'; - eval($GLOBALS['tpl_content'][$template]); - } elseif (!empty($template)) { - // Template file not found - $newContent = '
+ // Now does the final template exists? + $newContent = ''; + if (isFileReadable($FQFN)) { + // The local file does exists so we load it. :) + $GLOBALS['template_content']['email'][$template] = readFromFile($FQFN); + + // Run code + $GLOBALS['template_eval']['email'][$template] = '$newContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['email'][$template])) . '");'; + } elseif (!empty($template)) { + // Template file not found + $newContent = '
{--TEMPLATE_404--}: ' . $template . '
@@ -505,25 +509,39 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load
' . print_r($content, true) . '
'; - // Debug mode not active? Then remove the HTML tags - if (!isDebugModeEnabled()) { - // Remove HTML tags - $newContent = secureString($newContent); - } // END - if - } else { - // No template name supplied! - $newContent = '{--NO_TEMPLATE_SUPPLIED--}'; + // Don't cache this, as there is no template to cache + $GLOBALS['template_eval']['email'][$template] = '404'; + + // Debug mode not active? Then remove the HTML tags + if (!isDebugModeEnabled()) { + // Remove HTML tags + $newContent = secureString($newContent); + } // END - if + } else { + // No template name supplied! + $newContent = '{--NO_TEMPLATE_SUPPLIED--}'; + $GLOBALS['template_eval']['email'][$template] = '404'; + } } + // Is there something to eval? + if ((isset($GLOBALS['template_eval']['email'][$template])) && ($GLOBALS['template_eval']['email'][$template] != '404')) { + // Eval the code + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - BEFORE EVAL'); + ///* DEBUG: */ print('
'.htmlentities($GLOBALS['template_eval']['email'][$template]).'
'); + eval($GLOBALS['template_eval']['email'][$template]); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template=' . $template . ' - AFTER EVAL'); + } // END - if + // Are there some content? if (empty($newContent)) { // Compiling failed - $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['tpl_content'][$template]; + $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['template_content']['email'][$template]; // Add last error if the required function exists if (function_exists('error_get_last')) { // Add last error and some lines for better overview - $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx."; + $newContent .= "\n--------------------------------------\nDebug:\n" . print_r(error_get_last(), true) . "--------------------------------------\nPlease don't alter these informations!\nThanx."; } // END - if } // END - if @@ -1568,26 +1586,32 @@ function determinePageTitle () { } // Checks whethere there is a cache file there. This function is cached. -function isTemplateCached ($template) { +function isTemplateCached ($prefix, $template) { // Is there cached this result? - if (!isset($GLOBALS['template_cache'][$template])) { + if (!isset($GLOBALS['template_cache'][$prefix][$template])) { // Generate FQFN - $FQFN = generateCacheFqfn($template); + $FQFN = generateCacheFqfn($prefix, $template); // Is it there? - $GLOBALS['template_cache'][$template] = isFileReadable($FQFN); + $GLOBALS['template_cache'][$prefix][$template] = isFileReadable($FQFN); } // END - if // Return it - return $GLOBALS['template_cache'][$template]; + return $GLOBALS['template_cache'][$prefix][$template]; } // Flushes non-flushed template cache to disk -function flushTemplateCache ($template, $eval) { +function flushTemplateCache ($prefix, $template, $eval) { // Is this cache flushed? - if ((isDebuggingTemplateCache() === false) && (isTemplateCached($template) === false) && ($eval != '404')) { + if ((isDebuggingTemplateCache() === false) && (isTemplateCached($prefix, $template) === false) && ($eval != '404')) { // Generate FQFN - $FQFN = generateCacheFqfn($template); + $FQFN = generateCacheFqfn($prefix, $template); + + // Is this a XML template? + if ($prefix == 'xml') { + // Compact only XML templates as emails needs new-line characters and HTML may contain required "comments" + $eval = compactContent($eval); + } // END - if // And flush it writeToFile($FQFN, $eval, true); @@ -1595,24 +1619,24 @@ function flushTemplateCache ($template, $eval) { } // Reads a template cache -function readTemplateCache ($template) { +function readTemplateCache ($prefix, $template) { // Check it again - if ((isDebuggingTemplateCache()) || (!isTemplateCached($template))) { + if ((isDebuggingTemplateCache()) || (!isTemplateCached($prefix, $template))) { // This should not happen reportBug('Wether debugging of template cache is enabled or template ' . $template . ' is not cached while expected.'); } // END - if // Is it cached? - if (!isset($GLOBALS['template_eval'][$template])) { + if (!isset($GLOBALS['template_eval'][$prefix][$template])) { // Generate FQFN - $FQFN = generateCacheFqfn($template); + $FQFN = generateCacheFqfn($prefix, $template); // And read from it - $GLOBALS['template_eval'][$template] = readFromFile($FQFN); + $GLOBALS['template_eval'][$prefix][$template] = readFromFile($FQFN); } // END - if // And return it - return $GLOBALS['template_eval'][$template]; + return $GLOBALS['template_eval'][$prefix][$template]; } // Escapes quotes (default is only double-quotes) @@ -1872,20 +1896,20 @@ function generateMetaDescriptionCode () { } // Generates an FQFN for template cache from the given template name -function generateCacheFqfn ($template, $mode = 'html') { +function generateCacheFqfn ($prefix, $template) { // Is this cached? - if (!isset($GLOBALS['template_cache_fqfn'][$template])) { + if (!isset($GLOBALS['template_cache_fqfn'][$prefix][$template])) { // Generate the FQFN - $GLOBALS['template_cache_fqfn'][$template] = sprintf( + $GLOBALS['template_cache_fqfn'][$prefix][$template] = sprintf( "%s_compiled/%s/%s.tpl.cache", getCachePath(), - $mode, + $prefix, $template ); } // END - if // Return it - return $GLOBALS['template_cache_fqfn'][$template]; + return $GLOBALS['template_cache_fqfn'][$prefix][$template]; } // "Fixes" null or empty string to count of dashes @@ -2242,5 +2266,34 @@ function anonymizeSensitiveData ($data) { return $data; } +/** + * Removes all commentd, tabs and new-line characters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ +function compactContent ($uncompactedContent) { + // First, remove all tab/new-line/revert characters + $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent))); + + // Then regex all comments like away + preg_match_all('//', $compactedContent, $matches); + + // Do we have entries? + if (isset($matches[0][0])) { + // Remove all + foreach ($matches[0] as $match) { + // Remove the match + $compactedContent = str_replace($match, '', $compactedContent); + } // END - foreach + } // END - if + + // Set the content again + // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent); + + // Return compacted content + return $compactedContent; +} + // [EOF] ?> diff --git a/inc/xml-functions.php b/inc/xml-functions.php index c3cfa51b0b..d0963f4b22 100644 --- a/inc/xml-functions.php +++ b/inc/xml-functions.php @@ -41,11 +41,11 @@ if (!defined('__SECURITY')) { } // END - if // Calls back a function based on given XML template data -function showEntriesByXmlCallback ($template) { +function showEntriesByXmlCallback ($template, $content = array(), $compileCode = true) { // Generate FQFN for with special path $FQFN = sprintf("%stemplates/xml/%s%s.xml", getPath(), - detectExtraTemplatePath($template), + detectExtraTemplatePath('xml', $template), $template ); @@ -60,8 +60,20 @@ function showEntriesByXmlCallback ($template) { // Is it again readable? if (isFileReadable($FQFN)) { - // Read it - $templateContent = readFromFile($FQFN); + // Is there cache? + if ((!isDebuggingTemplateCache()) && (isTemplateCached('xml', $template))) { + // Evaluate the cache + eval(readTemplateCache('xml', $template)); + } else { + // Read it + $templateContent = readFromFile($FQFN); + + // Prepare it for finaly eval() command + $GLOBALS['template_eval']['xml'][$template] = '$templateContent = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($templateContent), false, true, true, $compileCode) . '");'; + + // Eval the code, this does insert any array elements from $content + eval($GLOBALS['template_eval']['xml'][$template]); + } // Init main arrays $GLOBALS['__XML_CALLBACKS'] = array( @@ -87,7 +99,7 @@ function showEntriesByXmlCallback ($template) { // Adds special elements by calling back another template-depending function function addXmlSpecialElements ($template) { - // Generate the FQCN (Full-Qualified CallbackName) + // Generate the FQCN (Full-Qualified Callback Name) $FQCN = 'addXmlSpecial' . capitalizeUnderscoreString($template); // Is it there? diff --git a/templates/xml/admin/admin_list_nickname_history.xml b/templates/xml/admin/admin_list_nickname_history.xml index 7d74b2cf86..01f74798af 100644 --- a/templates/xml/admin/admin_list_nickname_history.xml +++ b/templates/xml/admin/admin_list_nickname_history.xml @@ -88,7 +88,7 @@ MA 02110-1301 USA - condition = look-up condition - look-for = What to look for //--> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin_list_data_template.xml b/templates/xml/admin_list_data_template.xml index 4a5311dffc..e0e63fb882 100644 --- a/templates/xml/admin_list_data_template.xml +++ b/templates/xml/admin_list_data_template.xml @@ -117,7 +117,7 @@ MA 02110-1301 USA - condition = look-up condition - look-for = What to look for //--> - + -- 2.30.2