X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fexpression-functions.php;h=458dd1792c3a244f790bc723f3aca25b71d662a4;hb=8d4176053d397a86baca20b4d7ab7ed526355be8;hp=c3d1f57f8b9d015880d86593df7a0a472b1f01d1;hpb=22ba0c36c75ff989a6f48197c5a71524fb891b87;p=mailer.git diff --git a/inc/expression-functions.php b/inc/expression-functions.php index c3d1f57f8b..458dd1792c 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -99,9 +99,9 @@ function doExpressionUser ($data) { if ($data['matches'][4][$data['key']] == '$userid') { // Use dynamic call $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')"; - } elseif ($data['matches'][4][$data['key']] > 0) { + } elseif (!empty($data['matches'][4][$data['key']])) { // User data found - $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", " . $data['callback'] . "')"; + $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')"; } } elseif ((!empty($data['callback'])) && (isUserDataValid())) { // "Call-back" alias column for current logged in user's data @@ -115,7 +115,7 @@ function doExpressionUser ($data) { } // END - if // Generate replacer - $replacer = '{DQUOTE} . ' . $functionName . ' . "'; + $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}'; // Now replace the code $code = replaceExpressionCode($data, $replacer); @@ -151,17 +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; - - // Is there a call-back function provided? - if (!empty($data['callback'])) { - // Construct a new expression - $replacer = '{%pipe,' . $data['callback'] . ',' . $configValue . '%}'; - } // END - if + $replacer = '{DQUOTE} . ' . $data['callback'] . '(getConfig(' . "'" . $data['matches'][4][$data['key']] . "'" . ')) . {DQUOTE}'; // Replace the config entry $code = replaceExpressionCode($data, $replacer); @@ -175,6 +166,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 @@ -223,10 +220,16 @@ function doExpressionValidatorLinks ($data) { // Expression call-back for dynamic messages function doExpressionMessage ($data) { + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callback=' . $data['callback'] . ',extra_func=' . $data['extra_func'] . ',value=' . $data['value']); + // Message string replacement depends on if message is masked - if (isMessageMasked($data['callback'])) { + if ((isMessageMasked($data['callback'])) && ((!empty($data['extra_func'])) || ($data['extra_func'] == '0'))) { // Message should be masked $replacer = "{DQUOTE} . getMaskedMessage('" . $data['callback'] . "', '" . $data['extra_func'] . "') . {DQUOTE}"; + } elseif (!empty($data['value'])) { + // value is set, so it is masked message + $replacer = "{DQUOTE} . getMaskedMessage('" . $data['callback'] . "', '" . $data['value'] . "') . {DQUOTE}"; } else { // Regular message $replacer = "{DQUOTE} . getMessage('" . $data['callback'] . "') . {DQUOTE}"; @@ -239,5 +242,18 @@ function doExpressionMessage ($data) { return $code; } +// Expression call-back for template functions +function doExpressionTemplate ($data) { + // Do the replacement + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'template='.$GLOBALS['current_template']); + $replacer = '{DQUOTE} . doTemplate' . $data['callback'] . "('" . $GLOBALS['current_template'] . "', true) . {DQUOTE}"; + + // Replace the code + $code = replaceExpressionCode($data, $replacer); + + // Return the (maybe) replaced code + return $code; +} + // [EOF] ?>