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)) {
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"),
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'),
htmlentities($what, ENT_QUOTES))
. '';
} else {
return 'Unknown datatype';
}
}
function RuleTableHandler($pagename) {
global $MarkupTable;
BuildMarkupRules();
$out = array();
# Collect available columns
$RuleTableColumns =
array_keys(
array_reduce(
$MarkupTable,
create_function(
'$columns,$rule',
'SDV ($columns, array()); SDV ($rule, array()); return array_merge($columns,$rule);')));
# Further restrict to those listed in ?columns=...
if(isset($_REQUEST['columns'])) {
$RuleTableColumns =
array_intersect(
explode(',', $_REQUEST['columns']),
$RuleTableColumns);
}
$out[] = '';
$out[] = '
Markup rules, in order of application:
'; $out[] = 'id | '; foreach($RuleTableColumns as $m) { $out[] = "$m | "; } $out[] = '
---|---|
' . htmlentities($id, ENT_QUOTES) . ' | '; foreach($RuleTableColumns as $n) { $out[] = '' . RuleTableHtmlDump(@$m[@$n]) . ' | ';
}
$out[] = '