Ejemplo n.º 1
0
 private function renderHtml()
 {
     $res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
     foreach ($this->list as $item) {
         $res .= Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "<br>\n";
     }
     return $res . '</code>';
 }
Ejemplo n.º 2
0
 /**
  * @return string
  */
 public function getPanel()
 {
     if (!$this->calls) {
         return NULL;
     }
     ob_start();
     $esc = callback('Nette\\Templating\\Helpers::escapeHtml');
     $click = class_exists('Nette\\Diagnostics\\Dumper') ? function ($o, $c = FALSE) {
         return Nette\Diagnostics\Dumper::toHtml($o, array('collapse' => $c));
     } : callback('Nette\\Diagnostics\\Helpers::clickableDump');
     $totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
Ejemplo n.º 3
0
 public function getPanel()
 {
     $template = parent::getTemplate();
     $template->setFile(__DIR__ . '/templates/panel.latte');
     $template->identity = $this->identity;
     $template->user = $this->user;
     $template->dumper = function ($variable, $collapsed = false) {
         if (class_exists('Nette\\Diagnostics\\Dumper')) {
             return Dumper::toHtml($variable, [Dumper::COLLAPSE => $collapsed]);
         }
         // Nette 2.0 back compatibility
         return \Nette\Diagnostics\Helpers::clickableDump($variable, $collapsed);
     };
     ob_start();
     if ($this->parent) {
         $template->render();
     }
     return ob_get_clean();
 }
Ejemplo n.º 4
0
 /**
  * Returns syntax highlighted source code.
  * @param  string
  * @param  int
  * @param  int
  * @return string
  */
 public static function highlightPhp($source, $line, $lines = 15, $vars = array())
 {
     if (function_exists('ini_set')) {
         ini_set('highlight.comment', '#998; font-style: italic');
         ini_set('highlight.default', '#000');
         ini_set('highlight.html', '#06B');
         ini_set('highlight.keyword', '#D24; font-weight: bold');
         ini_set('highlight.string', '#080');
     }
     $source = str_replace(array("\r\n", "\r"), "\n", $source);
     $source = explode("\n", highlight_string($source, TRUE));
     $out = $source[0];
     // <code><span color=highlight.html>
     $source = str_replace('<br />', "\n", $source[1]);
     $out .= static::highlightLine($source, $line, $lines);
     $out = preg_replace_callback('#">\\$(\\w+)(&nbsp;)?</span>#', function ($m) use($vars) {
         return isset($vars[$m[1]]) ? '" title="' . str_replace('"', '&quot;', strip_tags(Dumper::toHtml($vars[$m[1]]))) . $m[0] : $m[0];
     }, $out);
     return "<pre class='php'><div>{$out}</div></pre>";
 }
Ejemplo n.º 5
0
 /** @deprecated */
 public static function clickableDump($var)
 {
     trigger_error(__METHOD__ . '() is deprecated; use Nette\\Diagnostics\\Dumper::toHtml() instead.', E_USER_DEPRECATED);
     return Dumper::toHtml($var);
 }
Ejemplo n.º 6
0
 /**
  * Dumps information about a variable in Nette Debug Bar.
  * @param  mixed  variable to dump
  * @param  string optional title
  * @param  array  dumper options
  * @return mixed  variable itself
  */
 public static function barDump($var, $title = NULL, array $options = NULL)
 {
     if (!self::$productionMode) {
         self::getBar()->getPanel(__CLASS__ . ':dumps')->data[] = array('title' => $title, 'dump' => Dumper::toHtml($var, (array) $options + array(Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLen, Dumper::LOCATION => self::$showLocation)));
     }
     return $var;
 }
Ejemplo n.º 7
0
 public static function initializePanel(Nette\Application\Application $application)
 {
     Nette\Diagnostics\Debugger::getBlueScreen()->addPanel(function ($e) use($application) {
         return $e ? NULL : array('tab' => 'Nette Application', 'panel' => '<h3>Requests</h3>' . Dumper::toHtml($application->getRequests()) . '<h3>Presenter</h3>' . Dumper::toHtml($application->getPresenter()));
     });
 }
Ejemplo n.º 8
0
 /**
  * Returns syntax highlighted source code.
  * @param  string
  * @param  int
  * @param  int
  * @return string
  */
 public static function highlightPhp($source, $line, $lines = 15, $vars = array())
 {
     if (function_exists('ini_set')) {
         ini_set('highlight.comment', '#998; font-style: italic');
         ini_set('highlight.default', '#000');
         ini_set('highlight.html', '#06B');
         ini_set('highlight.keyword', '#D24; font-weight: bold');
         ini_set('highlight.string', '#080');
     }
     $source = str_replace(array("\r\n", "\r"), "\n", $source);
     $source = explode("\n", highlight_string($source, TRUE));
     $spans = 1;
     $out = $source[0];
     // <code><span color=highlight.html>
     $source = explode('<br />', $source[1]);
     array_unshift($source, NULL);
     $start = $i = max(1, $line - floor($lines * 2 / 3));
     while (--$i >= 1) {
         // find last highlighted block
         if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
             if ($m[1] !== '</span>') {
                 $spans++;
                 $out .= $m[1];
             }
             break;
         }
     }
     $source = array_slice($source, $start, $lines, TRUE);
     end($source);
     $numWidth = strlen((string) key($source));
     foreach ($source as $n => $s) {
         $spans += substr_count($s, '<span') - substr_count($s, '</span');
         $s = str_replace(array("\r", "\n"), array('', ''), $s);
         preg_match_all('#<[^>]+>#', $s, $tags);
         if ($n == $line) {
             $out .= sprintf("<span class='highlight'>%{$numWidth}s:    %s\n</span>%s", $n, strip_tags($s), implode('', $tags[0]));
         } else {
             $out .= sprintf("<span class='line'>%{$numWidth}s:</span>    %s\n", $n, $s);
         }
     }
     $out .= str_repeat('</span>', $spans) . '</code>';
     $out = preg_replace_callback('#">\\$(\\w+)(&nbsp;)?</span>#', function ($m) use($vars) {
         return isset($vars[$m[1]]) ? '" title="' . str_replace('"', '&quot;', strip_tags(Dumper::toHtml($vars[$m[1]]))) . $m[0] : $m[0];
     }, $out);
     return "<pre class='php'><div>{$out}</div></pre>";
 }
Ejemplo n.º 9
0
 public static function dump($variable, $collapsed = false)
 {
     if (class_exists('Nette\\Diagnostics\\Dumper')) {
         return \Nette\Diagnostics\Dumper::toHtml($variable, [\Nette\Diagnostics\Dumper::COLLAPSE => $collapsed]);
     }
     // Nette 2.0 back compatibility
     return \Nette\Diagnostics\Helpers::clickableDump($variable, $collapsed);
 }
Ejemplo n.º 10
0
 /**
  * @param  mixed
  * @return string
  */
 private function dumpHtml($var)
 {
     if (class_exists('Tracy\\Dumper')) {
         return Tracy\Dumper::toHtml($var, [Tracy\Dumper::COLLAPSE => TRUE]);
     } elseif (class_exists('Nette\\Diagnostics\\Dumper')) {
         return Nette\Diagnostics\Dumper::toHtml($var, [Nette\Diagnostics\Dumper::COLLAPSE => TRUE]);
     } else {
         return Nette\Diagnostics\Debugger::dump($var, TRUE);
     }
 }