示例#1
0
 public static function dump($variable, $profundidad = 10, $color = true)
 {
     $dump = TVarDumper::dump($variable, $profundidad, $color);
     $dump = str_replace(")", "</span></span><span style=\"color: #007700\">)</span>", $dump);
     $dump = str_replace("(", "</span><span onclick=\"if(cerrar){this.childNodes[1].style.display == 'none' ? this.childNodes[1].style.display = 'inline' : this.childNodes[1].style.display = 'none'; cerrar = false}\"><span style=\"color: #007700\">(</span><span><span style=\"color: #007700\">", $dump);
     return $dump;
 }
示例#2
0
 /**
  * Converts a variable into a string representation.
  * This method achieves the similar functionality as var_dump and print_r
  * but is more robust when handling complex objects such as PRADO controls.
  * @param mixed variable to be dumped
  * @param integer maximum depth that the dumper should go into the variable. Defaults to 10.
  * @return string the string representation of the variable
  */
 public static function dump($var, $depth = 10, $highlight = false)
 {
     self::$_output = '';
     self::$_objects = array();
     self::$_depth = $depth;
     self::dumpInternal($var, 0);
     if ($highlight) {
         $result = highlight_string("<?php\n" . self::$_output, true);
         return preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
     } else {
         return self::$_output;
     }
 }
示例#3
0
 public static function varDump($var, $depth = 10, $highlight = false)
 {
     Prado::using('System.Util.TVarDumper');
     return TVarDumper::dump($var, $depth, $highlight);
 }
        public static function error_php_custom($type, $code, $message, $file, $line, $trace)
        {
            $error_id = uniqid('error');
            $title = defined("ENV_TITLE") ? ENV_TITLE : "Unknown Project";
            $class = "Brunodebarros\\StandaloneErrorCatcher\\Exceptions";
            $source = $class::debug_source($file, $line);
            $processed_trace = $class::trace($trace);
            $error = <<<error
<style type="text/css">
#exception_error {
\tbackground: #ddd;
\tfont-size: 1em;
\tfont-family:sans-serif;
\ttext-align: left;
\tcolor: #333333;
}
#exception_error h1,
#exception_error h2 {
\tmargin: 0;
\tpadding: 1em;
\tfont-size: 1em;
\tfont-weight: normal;
\tbackground: #911911;
\tcolor: #FFFFFF;
}
#exception_error h1 a,
#exception_error h2 a {
\tcolor: #FFFFFF;
}
#exception_error h2 {
\tbackground: #666666;
}
#exception_error h3 {
\tmargin: 0;
\tpadding: 0.4em 0 0;
\tfont-size: 1em;
\tfont-weight: normal;
}
#exception_error p {
\tmargin: 0;
\tpadding: 0.2em 0;
}
#exception_error a {
\tcolor: #1b323b;
}
#exception_error pre {
\toverflow: auto;
\twhite-space: pre-wrap;
}
#exception_error table {
\twidth: 100%;
\tdisplay: block;
\tmargin: 0 0 0.4em;
\tpadding: 0;
\tborder-collapse: collapse;
\tbackground: #fff;
}
#exception_error table td {
\tborder: solid 1px #ddd;
\ttext-align: left;
\tvertical-align: top;
\tpadding: 0.4em;
}
#exception_error div.content {
\tpadding: 0.4em 1em 1em;
\toverflow: hidden;
}
#exception_error pre.source {
\tmargin: 0 0 1em;
\tpadding: 0.4em;
\tbackground: #fff;
\tborder: dotted 1px #b7c680;
\tline-height: 1.2em;
}
#exception_error pre.source span.line {
\tdisplay: block;
}
#exception_error pre.source span.highlight {
\tbackground: #f0eb96;
}
#exception_error pre.source span.line span.number {
\tcolor: #666;
}
#exception_error ol.trace {
\tdisplay: block;
\tmargin: 0 0 0 2em;
\tpadding: 0;
\tlist-style: decimal;
}
#exception_error ol.trace li {
\tmargin: 0;
\tpadding: 0;
}
.js .collapsed {
\tdisplay: none;
}
</style>
<script type="text/javascript">
\tdocument.documentElement.className = 'js';
function koggle(elem)
{
\telem = document.getElementById(elem);

\tif (elem.style && elem.style['display'])
\t\t// Only works with the "style" attr
\tvar disp = elem.style['display'];
\telse if (elem.currentStyle)
\t\t// For MSIE, naturally
\tvar disp = elem.currentStyle['display'];
\telse if (window.getComputedStyle)
\t\t// For most other browsers
\tvar disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');

\t// Toggle the state of the "display" style
\telem.style.display = disp == 'block' ? 'none' : 'block';
\treturn false;
}
</script>

<div id="exception_error">
\t<h1><span class="type">[{$title}] {$type} [{$code}]:</span> <span class="message">{$message}<br />{$file}:{$line}</span></h1>
\t<div id="{$error_id}" class="content">

\t\t{$source}

\t\t<ol class="trace">
error;
            foreach ($processed_trace as $i => $step) {
                $error .= "<li>";
                $error .= "<p>";
                $error .= "<span class='file'>";
                if ($step['file']) {
                    $source_id = $error_id . 'source' . $i;
                    $error .= "<a href='#{$source_id}' onclick=\"return koggle('{$source_id}')\">" . $step['file'] . " [ {$step['line']} ]</a>";
                } else {
                    $error .= 'PHP internal call';
                }
                $error .= "</span> &raquo; {$step['function']} (";
                if ($step['args']) {
                    $args_id = $error_id . 'args' . $i;
                    $error .= "<a href='#{$args_id}' onclick=\"return koggle('{$args_id}')\">arguments</a>";
                }
                $error .= ")</p>";
                if ($step['args']) {
                    $error .= "<div id='{$args_id}' class='collapsed'>";
                    $error .= "<table cellspacing='0'>";
                    foreach ($step['args'] as $name => $arg) {
                        $error .= "<tr>";
                        $error .= "<td><code>{$name}</code></td>";
                        $error .= "<td><pre>" . TVarDumper::dump($arg) . "</pre></td>";
                        $error .= "</tr>";
                    }
                    $error .= "</table>";
                    $error .= "</div>";
                }
                if (isset($source_id)) {
                    $error .= "<pre id='{$source_id}' class='source collapsed'><code>{$step['source']}</code></pre>";
                }
                $error .= "</li>";
            }
            $error .= "</ol>";
            $error .= "</div>";
            $error .= "<div class='content'>";
            foreach (array('_GET', '_CLEAN_SERVER', '_POST', '_REQUEST') as $var) {
                if (empty($GLOBALS[$var]) || !is_array($GLOBALS[$var])) {
                    continue;
                }
                $env_id = $error_id . 'environment' . strtolower($var);
                $error .= '<h3><a href="#' . $env_id . '" onclick="return koggle(\'' . $env_id . '\')">$' . $var . '</a></h3>';
                $error .= '<div id="' . $env_id . '">';
                $error .= '<table cellspacing="0">';
                foreach ($GLOBALS[$var] as $key => $value) {
                    $error .= "<tr>";
                    $error .= "<td><code>{$key}</code></td>";
                    $error .= "<td><pre>" . TVarDumper::dump($value) . "</pre></td>";
                    $error .= "</tr>";
                }
                $error .= "</table>";
                $error .= "</div>";
            }
            $error .= "</div>";
            return $error;
        }