From 61234f4bdf7b153688f02a4af85c5cc54a7b010c Mon Sep 17 00:00:00 2001 From: quix0r Date: Thu, 14 Jul 2011 12:17:57 +0000 Subject: [PATCH] Fixes for compilation, more EL code: - More usage of EL code - Compilation will now compile {OPEN_TEMPLATE} and its brothers out - Compilation loop count will be added in HTML code and if debug-mode is enabled - TODOs.txt updated --- DOCS/TODOs.txt | 28 ++++++------ inc/extensions/ext-bonus.php | 1 - inc/extensions/ext-user.php | 18 +++++--- inc/functions.php | 24 ++++++++++ inc/language/de.php | 12 ++--- inc/language/order_de.php | 3 ++ inc/libs/user_functions.php | 4 +- inc/modules/admin/what-list_cats.php | 3 +- inc/modules/admin/what-list_links.php | 4 +- inc/modules/member/what-order.php | 6 +-- inc/template-functions.php | 20 ++++++--- .../de/html/admin/admin_list_beg_rows.tpl | 2 +- templates/de/html/admin/admin_list_links.tpl | 7 ++- .../html/admin/admin_list_rallye_usr_row.tpl | 3 +- .../de/html/admin/admin_list_rallyes_row2.tpl | 3 +- templates/de/html/admin/admin_list_refs.tpl | 2 +- templates/de/html/admin/admin_list_refs2.tpl | 2 +- .../de/html/admin/admin_list_user_cats.tpl | 4 +- .../html/admin/admin_list_user_cats_404.tpl | 4 +- .../de/html/admin/admin_send_bonus_select.tpl | 45 +++++++++++-------- 20 files changed, 119 insertions(+), 76 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 72475d7ffd..89adf4e7d6 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -54,9 +54,9 @@ ./inc/functions.php:2214: // @TODO Rename column data_type to e.g. mail_status ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); -./inc/language/de.php:1066: // @TODO Rewrite these two constants -./inc/language/de.php:1082: // @TODO Rewrite these three constants -./inc/language/de.php:758:// @TODO Are these constants longer used? +./inc/language/de.php:1062: // @TODO Rewrite these two constants +./inc/language/de.php:1078: // @TODO Rewrite these three constants +./inc/language/de.php:754:// @TODO Are these constants longer used? ./inc/language-functions.php:255: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * @@ -129,7 +129,7 @@ ./inc/modules/admin/what-list_autopurge.php:47:// @TODO Rewrite those lines to filter ./inc/modules/admin/what-list_bonus.php:133: // @TODO Can't this be moved into our expression language? ./inc/modules/admin/what-list_cats.php:54: // @TODO No longer needed? define('__CATEGORIES_BASE' , 'link_type ist nun kein ENUM mehr, um weitere Mailtypen zu erlauben."); break; } // END - switch break; diff --git a/inc/functions.php b/inc/functions.php index c9713ce1d5..fdf4b97ecf 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2457,6 +2457,30 @@ function convertStringToBoolean ($str) { return (($str == 'true') ? true : false); } +/** + * "Makes" a variable in given string parseable, this function will throw an + * error if the first character is not a dollar sign. + * + * @param $varString String which contains a variable + * @return $return String with added single quotes for better parsing + */ +function makeParseableVariable ($varString) { + // The first character must be a dollar sign + if (substr($varString, 0, 1) != '$') { + // Please report this + debug_report_bug(__FUNCTION__, __LINE__, 'varString=' . $varString . ' - No dollar sign detected, will not parse it.'); + } // END - if + + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$varString])) { + // Snap them in, if [,] are there + $GLOBALS[__FUNCTION__][$varString] = str_replace('[', "['", str_replace(']', "']", $varString)); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$varString]; +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //----------------------------------------------------------------------------- diff --git a/inc/language/de.php b/inc/language/de.php index afae893963..f1bd5228b9 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -340,8 +340,6 @@ addMessages(array( 'REFERAL_VIEWS' => "Views", 'REFERAL_IS_ACTIVE' => "Aktiv?", 'POINTS_USED' => "Verbrauchte {?POINTS?}", - 'MEMBER_NO_POINTS' => "Sie haben keine {?POINTS?} mehr zum Versenden übrig.", - 'MEMBER_NO_PAYMENTS' => "Der Admin dieses {?mt_word3?} hat noch keine Mailarten definiert.", 'MEMBER_POINTS_LEFT' => "{?POINTS?}-Guthaben zum Mailversand übrig", 'SELECT_MAIL_TYPE' => "Mailart auswählen", 'PLEASE_SELECT' => "Bitte auswählen", @@ -563,16 +561,14 @@ addMessages(array( 'KBYTES' => "KBytes", 'DEFAULT_SUBJECT_LINE' => "Klick-Mail von {?MAIN_TITLE?}", 'MEBER_UPDATE_PWD_WRONG' => "Sie haben das falsche Passwort eingegeben! Bitte nochmal versuchen.", - 'ADMIN_MEMBER_NO_CATEGORIES_1' => "Das Mitglied ", - 'ADMIN_MEMBER_NO_CATEGORIES_2' => " hat keine Kategorien ausgewählt.", + 'ADMIN_MEMBER_NO_CATEGORIES' => "Das Mitglied {%%pipe,generateUserProfileLink=%s%%} hat keine Kategorien ausgewählt.", 'USER_ID' => "Mitglied", 'UNCONFIRMED_LINKS' => "Unbestätigte Mails", - 'ADMIN_MEMBER_LINKS' => "Das Mitglied %s hat alle seine Mails bestätigt.", - 'MEMBER_TOTAL_LINKS' => "Es müssen noch %s Mails von diesem Mitglied bestätigt werden.", + 'ADMIN_NO_UNCONFIRMED_MAILS_LEFT' => "Das Mitglied %s hat alle seine Mails bestätigt.", + 'ADMIN_TOTAL_LINKS_LEFT' => "Es müssen noch %s Mails von diesem Mitglied bestätigt werden.", 'ADMIN_DELETE_UNCONFIRMED_LINKS' => "Alle unbestätigten Mails löschen", 'ADMIN_LINKS_DELETED' => "Links für unbestätigte Mails wurden gelöscht.", 'ADMIN_DELETE_LINK_SUBJECT' => "Ihr unbestätigen Mails wurden gelöscht.", - 'MEMBER_LINKS_LEFT' => "Sie haben %s unbestätigte Mails. Bitte bestätigen Sie diese zuerst. Wenn Sie weniger als {?unconfirmed?} Mails im Account haben, können Sie auch wieder buchen.", 'TODAY' => "Heute", 'MEMBER_PROFILE_LOCKED' => "Sie können Ihren Account erst am %s wieder ändern.", 'MEMBER_HAS_ZERO_MMAILS' => "Sie haben Ihren Empfang auf Urlaub stehen! Bitte stellen Sie unter "Profildaten ändern" den Empfang höher ein.", @@ -874,7 +870,7 @@ addMessages(array( 'ADMIN_ENTER_REFERAL_BANNER_URL' => "Banner-URL", 'ADMIN_ENTER_ALTERNATE_REFERAL_BANNER_TEXT' => "Alternativen Text", 'ADMIN_SELECT_REFERAL_BANNER_ACTIVE' => "Ist der Werbebanner aktiv?", - 'ADMIN_LIST_REFERALS' => "Referal-Übersicht des Mitgliedes %s in allen Ebenen:", + 'ADMIN_LIST_REFERALS' => "Referal-Übersicht des Mitgliedes {%%pipe,generateUserProfileLink=%s%%} in allen Ebenen:", 'ADMIN_LIST_REFERALS_LEVEL' => "Referals in Ebene %s:", 'ADMIN_LIST_REFERALS_NOTE' => "Änderung: Klicken Sie die Mitglieder-Id an und gelangen Sie zum Mitgliederprofil. Klicken Sie Anzahl Referals an, werden die Referals des jeweiligen Mitgliedes aufgelistet.", 'ADMIN_NORMAL_MAIL_ALREADY_DELETED' => "Mitglieder-Mail bereits gelöscht.", diff --git a/inc/language/order_de.php b/inc/language/order_de.php index f6f8db3ccc..97728d971e 100644 --- a/inc/language/order_de.php +++ b/inc/language/order_de.php @@ -64,6 +64,9 @@ addMessages(array( 'MEMBER_ORDER_ALLOWED_EXHAUSTED' => "Sie können keine weiteren Mails mehr versenden, oder stellen Sie bitte den Empfang höher ein.", 'MEMBER_ENTER_INVALID_URL' => "Ungütige URL eingegeben.", 'MEMBER_NO_MAIL_TYPE_SELECTED' => "Bitte wählen Sie eine Mailart aus.", + 'MEMBER_ORDER_NO_POINTS' => "Sie haben keine {?POINTS?} mehr zum Versenden übrig.", + 'MEMBER_ORDER_NO_PAYMENTS' => "Der Admin dieses {?mt_word3?} hat noch keine Mailarten definiert.", + 'MEMBER_ORDER_LINKS_LEFT' => "Sie haben %s unbestätigte Mails. Bitte bestätigen Sie diese zuerst. Wenn Sie weniger als {?unconfirmed?} Mails im Account haben, können Sie auch wieder buchen.", 'ADMIN_ORDER_SELECT_COLUMN_USERID' => "Mitgliedsnummer", 'ADMIN_ORDER_SELECT_COLUMN_ZIP' => "Postleitzahl", diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index bd678e4278..b7d06247d8 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -741,9 +741,9 @@ function doExpressionUser ($data) { // User-related data, so is there a userid? if (!empty($data['matches'][4][$data['key']])) { // Do we have a userid or $userid? - if ($data['matches'][4][$data['key']] == '$userid') { + if (substr($data['matches'][4][$data['key']], 0, 1) == '$') { // Use dynamic call - $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')"; + $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')"; } elseif (!empty($data['matches'][4][$data['key']])) { // Do we have a number or a dollar sign in front of it? if (preg_replace('/[^0123456789]/', '', $data['matches'][4][$data['key']]) != $data['matches'][4][$data['key']]) { diff --git a/inc/modules/admin/what-list_cats.php b/inc/modules/admin/what-list_cats.php index 8ea0db4b69..73282a1564 100644 --- a/inc/modules/admin/what-list_cats.php +++ b/inc/modules/admin/what-list_cats.php @@ -52,8 +52,7 @@ if (isGetRequestParameterSet('userid')) { // Prepare constants // @TODO No longer needed? define('__CATEGORIES_BASE' , '' . $content['surname'] . ' ' . $content['family'] . ''; + $content['email'] = '{%pipe,translateGender=' . $content['gender'] . '%} ' . $content['surname'] . ' ' . $content['family'] . ''; // Ok, list categories of this user $result_cats = SQL_QUERY("SELECT `id`, `cat` FROM `{?_MYSQL_PREFIX?}_cats` ORDER BY `sort` ASC", __FILE__, __LINE__); diff --git a/inc/modules/admin/what-list_links.php b/inc/modules/admin/what-list_links.php index c337642ab1..d5388fb560 100644 --- a/inc/modules/admin/what-list_links.php +++ b/inc/modules/admin/what-list_links.php @@ -145,8 +145,6 @@ if (isGetRequestParameterSet('userid')) { } // END - while // Remember list in constant for the template - $content['surname'] = getUserData('surname'); - $content['family'] = getUserData('family'); $content['email'] = '' . getUserData('email') . ''; $content['rows'] = $OUT; $content['nums'] = SQL_NUMROWS($result); @@ -160,7 +158,7 @@ if (isGetRequestParameterSet('userid')) { } } else { // No mails left to confirm - displayMessage('{%message,ADMIN_MEMBER_LINKS=' . bigintval(getRequestParameter('userid')) . '%}'); + displayMessage('{%message,ADMIN_NO_UNCONFIRMED_MAILS_LEFT=' . bigintval(getRequestParameter('userid')) . '%}'); } } else { // User not found diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 95a1e0d9e5..de7899c8f2 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -723,11 +723,11 @@ LIMIT 1", } } else { // No mail types defined - displayMessage('{--MEMBER_NO_PAYMENTS--}'); + displayMessage('{--MEMBER_ORDER_NO_PAYMENTS--}'); } } else { // No points left - displayMessage('{--MEMBER_NO_POINTS--}'); + displayMessage('{--MEMBER_ORDER_NO_POINTS--}'); } } else { // No cateogries are defined yet @@ -735,7 +735,7 @@ LIMIT 1", } } else { // Please confirm some mails first - displayMessage('{%message,MEMBER_LINKS_LEFT=' . $links . '%}', $links); + displayMessage('{%message,MEMBER_ORDER_LINKS_LEFT=' . $links . '%}', $links); } if (!empty($url)) { diff --git a/inc/template-functions.php b/inc/template-functions.php index 29e3e092db..25e899ee11 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -217,9 +217,6 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true) // Init counter $count = 0; - // Compile the raw code - $code = compileRawCode($code); - // Compile all out while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) { // Init common variables @@ -243,10 +240,19 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true) // Use it again $code = $newContent; + // Compile the final code + $code = compileRawCode($code); + // Count round $count++; } // END - while + // Add debugging data in HTML code, if mode is enabled + if ((isDebugModeEnabled()) && ($insertComments === true)) { + // Add loop count + $code .= ''; + } // END - if + // Return the compiled code return $code; } @@ -659,12 +665,15 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $newMatch = str_replace('[', "['", str_replace(']', "']", $match)); $code = str_replace($match, '".' . $newMatch . '."', $code); $matchesFound[$key . '_' . $matches[4][$key]] = 1; - $matchesFound[$match] = 1; + $matchesFound[$match] = true; } elseif (!isset($matchesFound[$match])) { // Not yet replaced! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match); $code = str_replace($match, '".' . $match . '."', $code); $matchesFound[$match] = 1; + } else { + // Everthing else should be a least logged + logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match . ',key=' . $key); } } // END - foreach } // END - if @@ -1119,9 +1128,6 @@ function generateEmailLink ($email, $table = 'admins') { $EMAIL = generateSponsorEmailLink($email); } - // Shall I close the link when there is no admin? - if ((!isAdmin()) && ($EMAIL == $email)) $EMAIL = '#'; // Closed! - // Return email link return $EMAIL; } diff --git a/templates/de/html/admin/admin_list_beg_rows.tpl b/templates/de/html/admin/admin_list_beg_rows.tpl index 261ae7759b..a6b1c0411d 100644 --- a/templates/de/html/admin/admin_list_beg_rows.tpl +++ b/templates/de/html/admin/admin_list_beg_rows.tpl @@ -1,6 +1,6 @@ $content[win1]$content[cnt]$content[win2] - $content[win1]$content[userid]$content[win2] + $content[win1]{%pipe,generateUserProfileLink=$content[userid]%}$content[win2] $content[win1]{%pipe,translateGender=$content[gender]%} $content[surname] $content[family]$content[win2] {%pipe,translateComma=$content[beg_points]%} {?POINTS?} $content[last_online] diff --git a/templates/de/html/admin/admin_list_links.tpl b/templates/de/html/admin/admin_list_links.tpl index a58b56b7c6..31dfe3d04a 100644 --- a/templates/de/html/admin/admin_list_links.tpl +++ b/templates/de/html/admin/admin_list_links.tpl @@ -2,13 +2,16 @@ $content[rows] diff --git a/templates/de/html/admin/admin_list_rallye_usr_row.tpl b/templates/de/html/admin/admin_list_rallye_usr_row.tpl index 1aa2935b39..71951c5a82 100644 --- a/templates/de/html/admin/admin_list_rallye_usr_row.tpl +++ b/templates/de/html/admin/admin_list_rallye_usr_row.tpl @@ -1,7 +1,6 @@
- $content[surname] $content[family] ($content[email]): + {%user,gender,translateGender=$content[userid]%} + {%user,surname=$content[userid]%} + {%user,family=$content[userid]%} + {%pipe,generateUserProfileLink=$content[userid]%}:
- $content[bold_l]$content[userid]$content[bold_r] + $content[bold_l]{%pipe,generateUserProfileLink=$content[userid]%}$content[bold_r] $content[bold_l]$content[refs]$content[bold_r] diff --git a/templates/de/html/admin/admin_list_rallyes_row2.tpl b/templates/de/html/admin/admin_list_rallyes_row2.tpl index d7ba771963..555c1fb9c0 100644 --- a/templates/de/html/admin/admin_list_rallyes_row2.tpl +++ b/templates/de/html/admin/admin_list_rallyes_row2.tpl @@ -1,7 +1,6 @@
- $content[bold_l]$content[userid]$content[bold_r] + $content[bold_l]{%pipe,generateUserProfileLink=$content[userid]%}$content[bold_r] $content[bold_l]$content[old]$content[bold_r] diff --git a/templates/de/html/admin/admin_list_refs.tpl b/templates/de/html/admin/admin_list_refs.tpl index fa2ed988d3..8cd32d5aa1 100644 --- a/templates/de/html/admin/admin_list_refs.tpl +++ b/templates/de/html/admin/admin_list_refs.tpl @@ -2,7 +2,7 @@ diff --git a/templates/de/html/admin/admin_list_refs2.tpl b/templates/de/html/admin/admin_list_refs2.tpl index db883bb9ab..064c22b5b7 100644 --- a/templates/de/html/admin/admin_list_refs2.tpl +++ b/templates/de/html/admin/admin_list_refs2.tpl @@ -2,7 +2,7 @@
- {%message,ADMIN_LIST_REFERALS={%pipe,generateUserProfileLink=$content[userid]%}%} + {%message,ADMIN_LIST_REFERALS=$content[userid]%}
$content[rows] diff --git a/templates/de/html/admin/admin_list_user_cats.tpl b/templates/de/html/admin/admin_list_user_cats.tpl index 52e6650b0b..67335c0f1f 100644 --- a/templates/de/html/admin/admin_list_user_cats.tpl +++ b/templates/de/html/admin/admin_list_user_cats.tpl @@ -2,7 +2,7 @@
- {%message,ADMIN_LIST_REFERALS={%pipe,generateUserProfileLink=$content[userid]%}%} + {%message,ADMIN_LIST_REFERALS=$content[userid]%}
@@ -10,7 +10,7 @@
- {--USER_ID--}: $content[userid] + {--USER_ID--}: {%pipe,generateUserProfileLink=$content[userid]%} ($content[email])