diff options
author | Urban Müller | 2014-10-03 14:48:30 +0200 |
---|---|---|
committer | Urban Müller | 2014-10-03 14:48:30 +0200 |
commit | 7319211524a47bafcc609ddc8cd9946946ac7b56 (patch) | |
tree | 36b7cbcd10c40ddee7c47e5bfb632f8a58dc1eae /it_debug.class | |
parent | 95bb09069f31e99f5598cbceb3197f17c70ae919 (diff) | |
download | itools-7319211524a47bafcc609ddc8cd9946946ac7b56.tar.gz itools-7319211524a47bafcc609ddc8cd9946946ac7b56.tar.bz2 itools-7319211524a47bafcc609ddc8cd9946946ac7b56.zip |
simplify ED(), mark debug output with unicode block chars in text output
Diffstat (limited to 'it_debug.class')
-rw-r--r-- | it_debug.class | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/it_debug.class b/it_debug.class index b7df95b..89258fd 100644 --- a/it_debug.class +++ b/it_debug.class @@ -79,11 +79,11 @@ static function srcline($stackoffs = 0) static function dump($args) { if ((preg_match('/csv|txt|gif|jpg/', $_SERVER['PHP_SELF']) || preg_grep('#text/(calendar|css|javascript|json|plain|rfc822|xml)|application/#', headers_list()) || $GLOBALS['debug_edplain']) && !$GLOBALS['debug_edhtml']) - $plain = 1; + ; else if ($_SERVER['REMOTE_ADDR']) list($blue, $noblue, $htmlok) = array("<span style='color:#00c'>", "</span>", 1); else if (posix_isatty(STDOUT)) - list($blue, $noblue, $red, $nored) = getenv('IT_ED_BRIGHT') ? array("\033[34m", "\033[m", "\033[33m", "\033[m") : array("\033[34m", "\033[m", "\033[31m", "\033[m"); + list($blue, $noblue, $red, $nored, $ansiok) = getenv('IT_ED_BRIGHT') ? array("\033[34m", "\033[m", "\033[33m", "\033[m", 1) : array("\033[34m", "\033[m", "\033[31m", "\033[m", 1); @fseek(STDOUT, 0, SEEK_END); # Work around PHP bug 49819: posix_isatty seeks to start $src = it_debug::srcline(1); @@ -140,11 +140,8 @@ static function dump($args) #$item = preg_replace('#\s+var \$_(.|\n)*?;\s*\n#', "", $item); $item = "$red$item$nored"; - if (isset($_SERVER['REMOTE_ADDR']) && !$plain) # html encode content and link any urls - $item = htmlspecialchars($item, ENT_COMPAT, "ISO-8859-1"); - if ($htmlok) - $item = preg_replace("#http://[^ ']*#", "<a href='\$0'>\$0</a>", $item); + $item = preg_replace("#http://[^ ']*#", "<a href='\$0'>\$0</a>", htmlspecialchars($item)); if (preg_match('/^[\'"]/', $var)) $r .= "$item "; @@ -161,10 +158,10 @@ static function dump($args) # not it_html::Q(); we dont wanna load it_html in ultraclassloader debugging $title = htmlspecialchars(it_debug::backtrace(array('skiplevels' => 1)), ENT_COMPAT, "ISO-8859-1"); - if (isset($_SERVER['REMOTE_ADDR']) && !$plain) - return "<pre title='$title' style='color:#c00; text-align:left; background-color:white; margin:0 0 0.4em; padding:0 0 0.4em 0; border-bottom:1px solid #ddd;z-index:10000; position:relative'>$r</pre>\n"; + if ($htmlok) + return "<pre title='$title' style='color:#c00; text-align:left; background:white; margin:0 0 0.8em; border-bottom:1px solid #ddd; z-index:9999; position:relative'>$r</pre>\n"; else - return "$r\n"; + return $ansiok ? "$r\n" : "\xe2\x96\x88 " . it::replace("\n" => "\n\xe2\x96\x88 ", "$r") . "\n"; } /** |