]> git.mxchange.org Git - mailer.git/blobdiff - inc/filters.php
Deprecated variables for templates removed, mor EL-rewrites, getMessage() rewritten:
[mailer.git] / inc / filters.php
index fa28dba40068e882bdf918aab32727d3806a4327..1d96aa316c814c10171bb7fa0324e03afe017154 100644 (file)
@@ -79,15 +79,15 @@ function FILTER_FLUSH_FILTERS () {
                // Walk through all filters
                foreach ($filterArray as $filterFunction => $active) {
                        // Is this filter loaded?
-                       //* DEBUG: */ print 'FOUND:'.$filterName.'/'.$filterFunction.'='.$active.'<br />';
+                       //* DEBUG: */ debugOutput('FOUND:'.$filterName.'/'.$filterFunction.'='.$active);
                        if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) {
                                // Add this filter (all filters are active by default)
-                               //* DEBUG: */ print 'ADD:'.$filterName.'/'.$filterFunction.'<br />';
+                               //* DEBUG: */ debugOutput('ADD:'.$filterName.'/'.$filterFunction);
                                $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction);
                                $inserted++;
                        } elseif ($active == 'R') {
                                // Remove this filter
-                               //* DEBUG: */ print 'REMOVE:'.$filterName.'/'.$filterFunction.'<br />';
+                               //* DEBUG: */ debugOutput('REMOVE:'.$filterName.'/'.$filterFunction);
                                $removeSQL .= sprintf(" (`filter_name`='%s' AND `filter_function`='%s') OR", $filterName, $filterFunction);
                                $removed++;
                        }
@@ -435,8 +435,8 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) {
        // Should we compile it?
        if ($compiled === true) {
                // Run the code
-               $eval = "\$GLOBALS['compiled_config'][\$uncompiled] = \"" . $GLOBALS['compiled_config'][$uncompiled] . "\";";
-               //* DEBUG: */ print(__FUNCTION__.'['.__LINE__.']:<pre>' . str_replace('$', '&#36;', htmlentities($eval)) . '</pre>');
+               $eval = "\$GLOBALS['compiled_config'][\$uncompiled] = \"" . $GLOBALS['compiled_config'][$uncompiled] . '";';
+               //* DEBUG: */ debugOutput(__FUNCTION__.'['.__LINE__.']:<pre>' . str_replace('$', '&#36;', htmlentities($eval)) . '</pre>');
                eval($eval);
        } // END - if
 
@@ -449,7 +449,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) {
        // Compile {%cmd,callback,extraFunction=some_value%} to get expression code snippets
        // See switch() command below for supported commands
        preg_match_all('/\{%(([a-zA-Z0-9-_,]+)(=([^\}]+)){0,1})*%\}/', $code, $matches);
-       //* DEBUG: */ print(__FUNCTION__.'['.__LINE__.']:<pre>'.print_r($matches, true).'</pre>');
+       //* DEBUG: */ debugOutput(__FUNCTION__.'['.__LINE__.']:<pre>'.print_r($matches, true).'</pre>');
 
        // Default is from outputHtml()
        $outputMode = getOutputMode();
@@ -459,15 +459,29 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) {
                // Replace all matches
                foreach ($matches[2] as $key => $cmd) {
                        // Init replacer/call-back variable
-                       $replacer = '';
-                       $callback = '';
+                       $replacer      = '';
+                       $callback      = '';
                        $extraFunction = '';
+                       $value         = '';
 
                        // Extract command and call-back
                        $cmdArray = explode(',', $cmd);
                        $cmd = $cmdArray[0];
-                       if (isset($cmdArray[1])) $callback      = $cmdArray[1];
-                       if (isset($cmdArray[2])) $extraFunction = $cmdArray[2];
+
+                       // Detect call-back function
+                       if (isset($cmdArray[1])) {
+                               // Call-back function detected
+                               $callback = $cmdArray[1];
+                       } // END - if
+
+                       // Detect extra function
+                       if (isset($cmdArray[2])) {
+                               // Also detected
+                               $extraFunction = $cmdArray[2];
+                       } elseif (isset($matches[4][$key])) {
+                               // Use this as value
+                               $value = $matches[4][$key];
+                       }
 
                        // Construct call-back function name for the command
                        $commandFunction = 'doExpression' . ucfirst(strtolower($cmd));
@@ -481,11 +495,12 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) {
                                        'mode'       => $outputMode,
                                        'code'       => $code,
                                        'callback'   => $callback,
-                                       'extra_func' => $extraFunction
+                                       'extra_func' => $extraFunction,
+                                       'value'      => $value
                                );
 
                                // Call it
-                               //* DEBUG: */ print __FUNCTION__ . '[' . __LINE__ . ']: function=' . $commandFunction . "<br />\n";
+                               //* DEBUG: */ debugOutput(__FUNCTION__ . '[' . __LINE__ . ']: function=' . $commandFunction);
                                $code = call_user_func($commandFunction, $data);
                        } else {
                                // Unsupported command detected
@@ -498,7 +513,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) {
        if ((getOutputMode() != '0') || ($outputMode != '0')) $code = decodeEntities($code);
 
        // Return compiled code
-       //* DEBUG: */ print(__FUNCTION__.'['.__LINE__.']:<pre>'.($code).'</pre>');
+       //* DEBUG: */ debugOutput(__FUNCTION__.'['.__LINE__.']:<pre>'.($code).'</pre>');
        return $code;
 }
 
@@ -637,7 +652,7 @@ function FILTER_DETERMINE_WHAT_ACTION () {
        }
 
        // Set default 'what' value
-       //* DEBUG: */ outputHtml('-'.getModule().'/'.getWhat()."-<br />");
+       //* DEBUG: */ debugOutput('-' . getModule() . '/' . getWhat() . '-');
        if ((!isWhatSet()) && (!isActionSet()) && (getOutputMode() != 1) && (getOutputMode() != -1)) {
                if (getModule() == 'admin') {
                        // Set 'action' value to 'login' in admin menu