]> git.mxchange.org Git - mailer.git/blobdiff - inc/expression-functions.php
Fix for missing array elements
[mailer.git] / inc / expression-functions.php
index e74d3784635e456d0cbcfe825bb1acb7875f0179..c77eb0c92aec2bfca0887f262e79bc34119f92c6 100644 (file)
@@ -138,14 +138,29 @@ function doExpressionConfig ($data) {
        // Read configuration
        $configValue = getConfig($data['matches'][4][$data['key']]);
 
-       // Do we have a call-back?
+       // Construct a new expression
+       $replacer = '{%pipe,' . $data['callback'] . ',' . $configValue . '%}';
+
+       // Replace the config entry
+       $code = str_replace($data['matches'][0][$data['key']], $replacer, $data['code']);
+
+       // Return replaced code
+       return $code;
+}
+
+// Expression call-back function for piping data through functions
+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'];
+
+       // Do we have a call-back? Should always be there!
        if (!empty($data['callback'])) {
                // Parse it through this function
-               $configValue = call_user_func_array($data['callback'], array($configValue));
+               $replacer = "\" . " . $data['callback'] . "('" . $replacer . "') . \"";
        } // END - if
 
        // Replace the config entry
-       $code = str_replace($data['matches'][0][$data['key']], $configValue, $data['code']);
+       $code = str_replace($data['matches'][0][$data['key']], $replacer, $data['code']);
 
        // Return replaced code
        return $code;
@@ -186,7 +201,21 @@ function doExpressionValidatorLinks ($data) {
 
 // Expression call-back for dynamic messages
 function doExpressionMessage ($data) {
-       die('<pre>'.htmlentities(print_r($data, true)).'</pre>');
+       // Message string replacement depends on if message is masked
+       if (isMessageMasked($data['callback'])) {
+               // Message should be masked
+               $replacer = "\" . getMaskedMessage('" . $data['callback'] . "', '" . $data['extra_func'] . "') . \"";
+       } else {
+               // Regular message
+               $replacer = "\" . getMessage('" . $data['callback'] . "') . \"";
+       }
+
+       // Replace the code
+       // @TODO is escapeQuotes enougth for strings with single/double quotes?
+       $code = str_replace($data['matches'][0][$data['key']], $replacer, escapeQuotes($data['code']));
+
+       // Return the (maybe) replaced code
+       return $code;
 }
 
 // [EOF]