// 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;
// 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]