Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

Classes

  • Bar
  • BlueScreen
  • Debugger
  • Dumper
  • FireLogger
  • Helpers
  • Logger
  • OutputDebugger

Interfaces

  • IBarPanel
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Tracy (https://tracy.nette.org)
  5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Tracy;
  9: 
 10: use Tracy;
 11: 
 12: 
 13: /**
 14:  * Rendering helpers for Debugger.
 15:  *
 16:  * @author     David Grudl
 17:  */
 18: class Helpers
 19: {
 20: 
 21:     /**
 22:      * Returns HTML link to editor.
 23:      * @return string
 24:      */
 25:     public static function editorLink($file, $line = NULL)
 26:     {
 27:         if ($editor = self::editorUri($file, $line)) {
 28:             $file = strtr($file, '\\', '/');
 29:             if (preg_match('#(^[a-z]:)?/.{1,50}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
 30:                 $file = '...' . $m[0];
 31:             }
 32:             $file = strtr($file, '/', DIRECTORY_SEPARATOR);
 33:             return self::createHtml('<a href="%" title="%">%<b>%</b>%</a>',
 34:                 $editor,
 35:                 $file . ($line ? ":$line" : ''),
 36:                 rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
 37:                 basename($file),
 38:                 $line ? ":$line" : ''
 39:             );
 40:         } else {
 41:             return self::createHtml('<span>%</span>', $file . ($line ? ":$line" : ''));
 42:         }
 43:     }
 44: 
 45: 
 46:     /**
 47:      * Returns link to editor.
 48:      * @return string
 49:      */
 50:     public static function editorUri($file, $line = NULL)
 51:     {
 52:         if (Debugger::$editor && $file && is_file($file)) {
 53:             return strtr(Debugger::$editor, array('%file' => rawurlencode($file), '%line' => $line ? (int) $line : 1));
 54:         }
 55:     }
 56: 
 57: 
 58:     public static function createHtml($mask)
 59:     {
 60:         $args = func_get_args();
 61:         return preg_replace_callback('#%#', function () use (& $args, & $count) {
 62:             return htmlspecialchars($args[++$count], ENT_IGNORE | ENT_QUOTES, 'UTF-8');
 63:         }, $mask);
 64:     }
 65: 
 66: 
 67:     public static function findTrace(array $trace, $method, & $index = NULL)
 68:     {
 69:         $m = explode('::', $method);
 70:         foreach ($trace as $i => $item) {
 71:             if (isset($item['function']) && $item['function'] === end($m)
 72:                 && isset($item['class']) === isset($m[1])
 73:                 && (!isset($item['class']) || $item['class'] === $m[0] || $m[0] === '*' || is_subclass_of($item['class'], $m[0]))
 74:             ) {
 75:                 $index = $i;
 76:                 return $item;
 77:             }
 78:         }
 79:     }
 80: 
 81: 
 82:     /**
 83:      * @return string
 84:      */
 85:     public static function getClass($obj)
 86:     {
 87:         return current(explode("\x00", get_class($obj)));
 88:     }
 89: 
 90: 
 91:     /** @internal */
 92:     public static function fixStack($exception)
 93:     {
 94:         if (function_exists('xdebug_get_function_stack')) {
 95:             $stack = array();
 96:             foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) {
 97:                 $frame = array(
 98:                     'file' => $row['file'],
 99:                     'line' => $row['line'],
100:                     'function' => isset($row['function']) ? $row['function'] : '*unknown*',
101:                     'args' => array(),
102:                 );
103:                 if (!empty($row['class'])) {
104:                     $frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
105:                     $frame['class'] = $row['class'];
106:                 }
107:                 $stack[] = $frame;
108:             }
109:             $ref = new \ReflectionProperty('Exception', 'trace');
110:             $ref->setAccessible(TRUE);
111:             $ref->setValue($exception, $stack);
112:         }
113:         return $exception;
114:     }
115: 
116: 
117:     /** @internal */
118:     public static function fixEncoding($s)
119:     {
120:         if (PHP_VERSION_ID < 50400) {
121:             return @iconv('UTF-16', 'UTF-8//IGNORE', iconv('UTF-8', 'UTF-16//IGNORE', $s)); // intentionally @
122:         } else {
123:             return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES);
124:         }
125:     }
126: 
127: }
128: 
Nette 2.2 API documentation generated by ApiGen 2.8.0