1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage HTML
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Extended Utility class for render debug information.
14 *
15 * @since 3.7.0
16 */
17 abstract class JHtmlDebug
18 {
19 /**
20 * xdebug.file_link_format from the php.ini.
21 *
22 * Make this property public to support test.
23 *
24 * @var string
25 *
26 * @since 3.7.0
27 */
28 public static $xdebugLinkFormat;
29
30 /**
31 * Replaces the Joomla! root with "JROOT" to improve readability.
32 * Formats a link with a special value xdebug.file_link_format
33 * from the php.ini file.
34 *
35 * @param string $file The full path to the file.
36 * @param string $line The line number.
37 *
38 * @return string
39 *
40 * @throws \InvalidArgumentException
41 *
42 * @since 3.7.0
43 */
44 public static function xdebuglink($file, $line = '')
45 {
46 if (static::$xdebugLinkFormat === null)
47 {
48 static::$xdebugLinkFormat = ini_get('xdebug.file_link_format');
49 }
50
51 $link = str_replace(JPATH_ROOT, 'JROOT', $file);
52 $link .= $line ? ':' . $line : '';
53
54 if (static::$xdebugLinkFormat)
55 {
56 $href = static::$xdebugLinkFormat;
57 $href = str_replace('%f', $file, $href);
58 $href = str_replace('%l', $line, $href);
59
60 $html = JHtml::_('link', $href, $link);
61 }
62 else
63 {
64 $html = $link;
65 }
66
67 return $html;
68 }
69 }
70