@@ -59,6 +59,7 @@ public function __construct($output = null, $charset = null, $flags = 0)
59
59
{
60
60
AbstractDumper::__construct ($ output , $ charset , $ flags );
61
61
$ this ->dumpId = 'sf-dump- ' .mt_rand ();
62
+ $ this ->displayOptions ['fileLinkFormat ' ] = ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
62
63
}
63
64
64
65
/**
@@ -189,18 +190,14 @@ function toggle(a, recursive) {
189
190
options = {$options},
190
191
elt = root.getElementsByTagName('A'),
191
192
len = elt.length,
192
- i = 0, s, h, fmt,
193
+ i = 0, s, h,
193
194
t = [];
194
195
195
196
while (i < len) t.push(elt[i++]);
196
197
197
198
for (i in x) {
198
199
options[i] = x[i];
199
200
}
200
- fmt = options.fileLinkFormat;
201
- if (fmt && 'string' == typeof fmt) {
202
- fmt = [fmt];
203
- }
204
201
205
202
function a(e, f) {
206
203
addEventListener(root, e, function (e) {
@@ -221,8 +218,10 @@ function isCtrlKey(e) {
221
218
refStyle.innerHTML = '';
222
219
}
223
220
});
224
- a('mouseover', function (a) {
225
- if (a = idRx.exec(a.className)) {
221
+ a('mouseover', function (a, e, c) {
222
+ if (c) {
223
+ e.target.style.cursor = "pointer";
224
+ } else if (a = idRx.exec(a.className)) {
226
225
try {
227
226
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
228
227
} catch (e) {
@@ -321,16 +320,6 @@ function isCtrlKey(e) {
321
320
}
322
321
}
323
322
}
324
- } else if (fmt && (a = elt.getAttribute('data-file'))) {
325
- if (fmt[1]) {
326
- for (x in fmt[1]) {
327
- if (0 === a.indexOf(x)) {
328
- a = fmt[1][x] + a.substr(x.length);
329
- break;
330
- }
331
- }
332
- }
333
- elt.href = fmt[0].replace('%l', elt.getAttribute('data-line')).replace('%f', a);
334
323
}
335
324
}
336
325
@@ -391,7 +380,7 @@ function isCtrlKey(e) {
391
380
display: inline-block;
392
381
overflow: visible;
393
382
text-overflow: ellipsis;
394
- width: 50px ;
383
+ width: 5em ;
395
384
white-space: nowrap;
396
385
overflow: hidden;
397
386
vertical-align: top;
@@ -411,7 +400,7 @@ function isCtrlKey(e) {
411
400
);
412
401
413
402
foreach ($ this ->styles as $ class => $ style ) {
414
- $ line .= 'pre.sf-dump ' .('default ' !== $ class ? ' .sf-dump- ' . $ class : '' ).'{ ' .$ style .'} ' ;
403
+ $ line .= 'pre.sf-dump ' .('default ' === $ class ? ', pre .sf-dump' : '' ). ' .sf-dump- ' . $ class .'{ ' .$ style .'} ' ;
415
404
}
416
405
417
406
return $ this ->dumpHeader = preg_replace ('/\s+/ ' , ' ' , $ line ).'</style> ' .$ this ->dumpHeader ;
@@ -485,37 +474,27 @@ protected function style($style, $value, $attr = array())
485
474
$ style .= sprintf (' title="Private property defined in class: `%s`" ' , esc ($ this ->utf8Encode ($ attr ['class ' ])));
486
475
}
487
476
$ map = static ::$ controlCharsMap ;
488
- $ style = "<span class=sf-dump- {$ style }> " ;
489
477
490
478
if (isset ($ attr ['ellipsis ' ])) {
491
479
$ label = esc (substr ($ value , -$ attr ['ellipsis ' ]));
492
-
493
- $ v = sprintf ('</ span>%s<abbr title="%s" class=sf-dump-ellipsis>%2$ s</abbr>%s</ span>%1$s ' , $ style , substr ($ v , 0 , -strlen ($ label )), $ label );
480
+ $ style = str_replace ( ' title=" ' , " title= \" $ v \n" , $ style );
481
+ $ v = sprintf ('<span class=sf-dump-ellipsis>%s</span>%s ' , substr ($ v , 0 , -strlen ($ label )), $ label );
494
482
}
495
483
496
- $ v = preg_replace_callback (static ::$ controlCharsRx , function ($ c ) use ($ map, $ style ) {
497
- $ s = '</ span> ' ;
484
+ $ v = " <span class=sf-dump- { $ style } > " . preg_replace_callback (static ::$ controlCharsRx , function ($ c ) use ($ map ) {
485
+ $ s = '<span class=sf-dump-default > ' ;
498
486
$ c = $ c [$ i = 0 ];
499
487
do {
500
488
$ s .= isset ($ map [$ c [$ i ]]) ? $ map [$ c [$ i ]] : sprintf ('\x%02X ' , ord ($ c [$ i ]));
501
489
} while (isset ($ c [++$ i ]));
502
490
503
- return $ s .$ style ;
504
- }, $ v, - 1 , $ cchrCount ) ;
491
+ return $ s .' </span> ' ;
492
+ }, $ v). ' </span> ' ;
505
493
506
- if ('< ' === $ v [0 ]) {
507
- $ v = substr ($ v , 7 );
508
- } else {
509
- $ v = $ style .$ v ;
510
- }
511
- if ('> ' === substr ($ v , -1 )) {
512
- $ v = substr ($ v , 0 , -strlen ($ style ));
513
- } else {
514
- $ v .= '</span> ' ;
494
+ if (isset ($ attr ['file ' ]) && $ href = $ this ->getSourceLink ($ attr ['file ' ], isset ($ attr ['line ' ]) ? $ attr ['line ' ] : 0 )) {
495
+ $ attr ['href ' ] = $ href ;
515
496
}
516
- if (isset ($ attr ['file ' ])) {
517
- $ v = sprintf ('<a data-file="%s" data-line="%d">%s</a> ' , esc ($ this ->utf8Encode ($ attr ['file ' ])), isset ($ attr ['line ' ]) ? $ attr ['line ' ] : 1 , $ v );
518
- } elseif (isset ($ attr ['href ' ])) {
497
+ if (isset ($ attr ['href ' ])) {
519
498
$ v = sprintf ('<a href="%s">%s</a> ' , esc ($ this ->utf8Encode ($ attr ['href ' ])), $ v );
520
499
}
521
500
if (isset ($ attr ['lang ' ])) {
@@ -554,6 +533,31 @@ protected function dumpLine($depth, $endOfValue = false)
554
533
}
555
534
AbstractDumper::dumpLine ($ depth );
556
535
}
536
+
537
+ private function getSourceLink ($ file , $ line )
538
+ {
539
+ $ fileLinkFormat = $ this ->extraDisplayOptions + $ this ->displayOptions ;
540
+
541
+ if (!$ fileLinkFormat = $ fileLinkFormat ['fileLinkFormat ' ]) {
542
+ return false ;
543
+ }
544
+ if (!is_array ($ fileLinkFormat )) {
545
+ $ i = max (strpos ($ fileLinkFormat , '%f ' ), strpos ($ fileLinkFormat , '%l ' ));
546
+ $ i = strpos ($ fileLinkFormat , '#" ' , $ i ) ?: strlen ($ fileLinkFormat );
547
+ $ fileLinkFormat = array (substr ($ fileLinkFormat , 0 , $ i ), substr ($ fileLinkFormat , $ i + 1 ));
548
+ $ fileLinkFormat [1 ] = @json_decode ('{ ' .$ fileLinkFormat [1 ].'} ' , true ) ?: array ();
549
+ $ this ->extraDisplayOptions ['fileLinkFormat ' ] = $ fileLinkFormat ;
550
+ }
551
+
552
+ foreach ($ fileLinkFormat [1 ] as $ k => $ v ) {
553
+ if (0 === strpos ($ file , $ k )) {
554
+ $ file = substr_replace ($ file , $ v , 0 , strlen ($ k ));
555
+ break ;
556
+ }
557
+ }
558
+
559
+ return strtr ($ fileLinkFormat [0 ], array ('%f ' => $ file , '%l ' => $ line ));
560
+ }
557
561
}
558
562
559
563
function esc ($ str )
0 commit comments