Commit 01a60006 authored by Tomáš Pospíšil's avatar Tomáš Pospíšil
Browse files

Dumper fixes

parent 70965278
......@@ -12,6 +12,7 @@ use Smarty_Internal_Template;
use Smarty_Internal_TemplateBase;
use Smarty_Template_Compiled;
use Smarty_Template_Resource_Base;
use Tracy\Debugger;
use Tracy\Helpers;
final class Dumper
......@@ -98,7 +99,25 @@ final class Dumper
$file = Strings::replace($file, '#' . preg_quote(self::getDirectory(), '#') . '#', self::$projectPath);
}
return Helpers::editorLink($file, $line);
$file = strtr($origFile = $file, Debugger::$editorMapping);
if ($editor = self::editorUri($origFile, $line)) {
$file = str_replace('\\', '/', $file);
if (preg_match('#(^[a-z]:)?/.{1,40}$#i', $file, $m) && strlen($file) > strlen($m[0])) {
$file = '...' . $m[0];
}
$file = str_replace('/', DIRECTORY_SEPARATOR, $file);
return Helpers::formatHtml(
'<a href="%" title="%">%<b>%</b>%</a>',
$editor,
$origFile . ($line ? ":$line" : ''),
rtrim(dirname($file), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR,
basename($file),
$line ? ":$line" : ''
);
}
return Helpers::formatHtml('<span>%</span>', $file . ($line ? ":$line" : ''));
}
public static function getDirectory(): string
......@@ -107,10 +126,15 @@ final class Dumper
$scriptPath = filter_input(INPUT_SERVER, 'SCRIPT_FILENAME');
$dir = realpath(dirname($scriptPath));
while (false !== $dir && !is_dir($dir . '/.git')) {
while (false !== $dir && !is_dir($dir . '/vendor')) {
$currentDir = $dir;
$dir .= '/..';
$dir = realpath($dir);
$dir = @realpath($dir);
if ($dir === false) {
$dir = $currentDir;
}
if ($dir === $currentDir) {
break;
......@@ -120,9 +144,37 @@ final class Dumper
self::$rootDir = $dir;
}
if (!is_string(self::$rootDir)) {
return '';
}
return self::$rootDir;
}
/**
* Returns link to editor.
*/
public static function editorUri(string $file, int $line = null, string $action = 'open', string $search = '', string $replace = ''): ?string
{
if (Debugger::$editor && $file) {
$file = str_replace('/', DIRECTORY_SEPARATOR, $file);
$file = strtr($file, Debugger::$editorMapping);
return strtr(
Debugger::$editor,
[
'%action' => $action,
'%file' => rawurlencode($file),
'%line' => $line ?: 1,
'%search' => rawurlencode($search),
'%replace' => rawurlencode($replace),
]
);
}
return null;
}
/**
* @param mixed $value
* @return string
......
<script>
document.addEventListener("DOMContentLoaded", function () {
function filterTable(input, table, column = 0) {
let filter, tr, td, i, txtValue;
filter = input.value.toUpperCase();
tr = table.getElementsByTagName("tr");
for (i = 1; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[column];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
function filterTable(input, table, column = 0) {
let filter, tr, td, i, txtValue;
filter = input.value.toUpperCase();
tr = table.getElementsByTagName("tr");
for (i = 1; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[column];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment