s: * .type_unset Unset PHP variables * .type_null NULL values from databases * .type_resource PHP resources (file handles etc.) * .type_syntax parentheses, commas etc. * .type_bool boolean values * .type_scalar numbers and strings * .type_controlcode nonprintable characters in strings * .type_unkown other type (probably the effect of a bug) */ if(!isset($what)) { return 'Unset'; } elseif(is_null($what)) { return 'NULL'; } elseif(is_resource($what)) { return '' . htmlentities(get_resource_type($what), ENT_QUOTES) . ''; } elseif(is_array($what) || is_object($what)) { $a = array(); foreach($what as $id=>$v) { $a[] = RuleTableHtmlDump($id) . ' => ' . RuleTableHtmlDump($v); } return implode(',
', $a); } elseif(is_bool($what)) { return '' . ($what ? 'True' : 'False') . ''; } elseif(is_scalar($what)) { global $Charset, $KeepToken; $ktchar = $KeepToken[0]; # add $KeepToken character to list for old pmwiki versions - cgg $ktrepl = '\\x' . bin2hex($ktchar); return '' . str_replace( array( "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", $ktchar), array( '\\x00', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\x07', '\\x08', '\\t', '\\n', '\\x0b', '\\x0c', '\\r', '\\x0e', '\\x0f', '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', '\\x18', '\\x19', '\\x1a', '\\x1b', '\\x1c', '\\x1d', '\\x1e', '\\x1f', ''.$ktrepl.''), htmlentities($what, ENT_QUOTES, $Charset)) # add char set for new php versions - cgg . ''; } else { return 'Unknown datatype'; } } function RuleTableColsCB($columns, $rule) { #SDV ($columns, array()); #SDV ($rule, array()); return array_merge($columns, $rule); } function RuleTableEPatCB($m) { return '^' . preg_quote($m[1],'/') . '(.*)' . preg_quote($m[2],'/') . '$'; } function RuleTableHandler($pagename) { global $ScriptUrl; global $MarkupTable; BuildMarkupRules(); $out = array(); # Collect available columns $RuleTableColumns = array_keys( array_reduce( $MarkupTable, 'RuleTableColsCB', array() ) ); # Further restrict to those listed in ?columns=... if(isset($_REQUEST['columns'])) { $RuleTableColumns = array_intersect( explode(',', $_REQUEST['columns']), $RuleTableColumns); } $out[] = ''; $out[] = ''; $out[] = ''; $out[] = ' '; $out[] = ' Rule Table'; $out[] = ' '; $out[] = ''; $out[] = ''; $out[] = ' '; #$out[] = ' '; #$out[] = '
Markup Ruleset Debugging recipe is here.
'; $out[] = '
Markup Ruleset Debugging recipe is here.
'; $out[] = '

Markup rules, in order of application (duplicate patterns and patterns using the deprecated /e flag are highlighted):

'; $out[] = ' '; $out[] = ' '; $out[] = ' '; foreach($RuleTableColumns as $m) { $out[] = " "; } $out[] = ' '; # Setup to retrieve replacement code from callback function cache -cgg global $CallbackFunctions, $CallbackFnTemplates; global $RuleTableBaseFilePat; $patterns = array(); $lambdas = array(); $trfunc = function ($m) { return sprintf('\\x%02x', ord($m[1])); }; if ($CallbackFunctions) { foreach ($CallbackFunctions as $k=>$v) { #if (preg_match('/^.(lambda_\\d+)$/', (string)$v, $matches)) { # $lambdas[$matches[1]] = $k; if (preg_match('/^(.*?lambda_\\d+)$/', (string)$v, $matches)) { $lambdas[preg_replace_callback('/([\x00-\x2f\x7f-\xff])/',$trfunc,$matches[1])] = $k; } } } $markupEPat = preg_replace_callback( '/^(.*?)%s(.*)$/', 'RuleTableEPatCB', $CallbackFnTemplates["markup_e"] ); foreach($MarkupTable as $id=>$m) { $out[] = ' '; $out[] = ' '; foreach($RuleTableColumns as $n) { $cellattr = ''; #cgg $prefix = ''; #cgg # $comment = ''; #cgg $comments = array(); #cgg $val = @$m[@$n]; if ($n == 'rep') { if (is_callable($val)) { if (is_a($val, 'Closure')) { $val = ''; $prefix = 'Closure Object'; } elseif (preg_match('/^((.*?)lambda_\\d+)$/', (string)$val, $matches)) { # Retrieve replacement code from callback function cache -cgg $lambda = preg_replace_callback('/([\x00-\x2f\x7f-\xff])/',$trfunc,$matches[1]); if (isset($lambdas[$lambda])) { $val = $lambdas[$lambda]; $val2 = preg_replace("/$markupEPat/s", '$1', $val, 1); if ($val2 !== $val) { $val = $val2; $color = ($matches[2] != "\x00") ? '#f00' : 'blue'; $prefix = 'Markup_e: '; } } else { $val = $lambda; } } } } elseif ($n == 'pat') { # Highlight pattern if /e flag present -cgg if (preg_match('!^/(?>.*/)(?=[a-z]*$).*?e!is', strval($val))) { $cellattr = ' class="patbad"'; } if (@$patterns[$val] && $val != '' && $val != 'Unset') { $comments[] = '
Warning: Duplicate pattern will not work as expected.
'; $cellattr = ' class="patbad"'; ++$patterns[$val]; } else { $patterns[$val] = 1; } if (isset($m['dbg'])) { $dbg = $m['dbg']; if (preg_match('/^(.*?file:\\s*)(.*?)(,\\s*line:.*?),/i', $dbg, $dbgmatches)) { $file = $dbgmatches[2]; if (isset($RuleTableBaseFilePat)) { $file = preg_replace($RuleTableBaseFilePat, '$1', $file); } $dbg = $dbgmatches[1] . $file . $dbgmatches[3]; } # $comment = '
' . htmlentities($dbg, ENT_QUOTES) . '
'; $comments[] = '
' . htmlentities($dbg, ENT_QUOTES) . '
'; } } $out[] = " "; $divclass = (preg_match('/^(?:seq|dep|cmd)$/', $n) ? '' : ' class="wide"'); $out[] = " " . $prefix . RuleTableHtmlDump($val) . ''; # if ($comment !== '') { # $out[] = " " . $comment; # } if ($comments) { $out = array_merge($out, $comments); } $out[] = ' '; } $out[] = ' '; } $out[] = '
id$m
' . htmlentities($id, ENT_QUOTES) . '
'; $out[] = ''; $out[] = ''; print implode("\n",$out); } SDV($HandleActions['ruletable'], 'RuleTableHandler');