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
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Tracy (http://tracy.nette.org)
  5:  * Copyright (c) 2004 David Grudl (http://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)
 26:     {
 27:         if ($editor = self::editorUri($file, $line)) {
 28:             $dir = dirname(strtr($file, '/', DIRECTORY_SEPARATOR));
 29:             $base = isset($_SERVER['SCRIPT_FILENAME']) ? dirname(dirname(strtr($_SERVER['SCRIPT_FILENAME'], '/', DIRECTORY_SEPARATOR))) : dirname($dir);
 30:             if (substr($dir, 0, strlen($base)) === $base) {
 31:                 $dir = '...' . substr($dir, strlen($base));
 32:             }
 33:             return self::createHtml('<a href="%" title="%">%<b>%</b>%</a>',
 34:                 $editor,
 35:                 "$file:$line",
 36:                 rtrim($dir, 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)
 51:     {
 52:         if (Debugger::$editor && $file && is_file($file)) {
 53:             return strtr(Debugger::$editor, array('%file' => rawurlencode($file), '%line' => (int) $line));
 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);
 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:     public static function fixStack($exception)
 83:     {
 84:         if (function_exists('xdebug_get_function_stack')) {
 85:             $stack = array();
 86:             foreach (array_slice(array_reverse(xdebug_get_function_stack()), 2, -1) as $row) {
 87:                 $frame = array(
 88:                     'file' => $row['file'],
 89:                     'line' => $row['line'],
 90:                     'function' => isset($row['function']) ? $row['function'] : '*unknown*',
 91:                     'args' => array(),
 92:                 );
 93:                 if (!empty($row['class'])) {
 94:                     $frame['type'] = isset($row['type']) && $row['type'] === 'dynamic' ? '->' : '::';
 95:                     $frame['class'] = $row['class'];
 96:                 }
 97:                 $stack[] = $frame;
 98:             }
 99:             $ref = new \ReflectionProperty('Exception', 'trace');
100:             $ref->setAccessible(TRUE);
101:             $ref->setValue($exception, $stack);
102:         }
103:         return $exception;
104:     }
105: 
106: 
107:     /**
108:      * Returns correctly UTF-8 encoded string.
109:      * @param  string  byte stream to fix
110:      * @return string
111:      */
112:     public static function fixEncoding($s)
113:     {
114:         if (PHP_VERSION_ID < 50400) {
115:             return @iconv('UTF-16', 'UTF-8//IGNORE', iconv('UTF-8', 'UTF-16//IGNORE', $s)); // intentionally @
116:         } else {
117:             return htmlspecialchars_decode(htmlspecialchars($s, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8'), ENT_NOQUOTES);
118:         }
119:     }
120: 
121: }
122: 
Nette 2.2.2 API API documentation generated by ApiGen 2.8.0