Skip to content

Commit 97957f8

Browse files
authored
Merge pull request #9 from Ilya-Zhulin/patch-3
Update jbdump.php
2 parents a4adb4c + 1013657 commit 97957f8

File tree

1 file changed

+102
-99
lines changed

1 file changed

+102
-99
lines changed

joomla/jbdump.php

Lines changed: 102 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Library for dump variables and profiling PHP code
45
* The idea and the look was taken from http://krumo.sourceforge.net/
@@ -10,126 +11,128 @@
1011
* @copyright Copyright (c) 2009-2011 Joomla-book.ru
1112
* @license GNU General Public License version 2 or later; see LICENSE
1213
*/
13-
1414
defined('_JEXEC') or die('Restricted access');
1515

1616
jimport('joomla.event.helper');
1717

1818
if (!class_exists('jbdump')) {
19-
require_once(dirname(__FILE__) . DS . 'class.jbdump.php');
19+
require_once(dirname(__FILE__) . '/class.jbdump.php');
2020
}
2121

22-
class plgSystemJBDump extends JPlugin
23-
{
24-
25-
/**
26-
* Plugin init
27-
*/
28-
function plgSystemJBDump($subject, $params)
29-
{
30-
parent::__construct($subject, $params);
31-
}
32-
33-
34-
/**
35-
* JBDump init
36-
*/
37-
function onAfterInitialise()
38-
{
39-
40-
$logPath = $this->params->get('logPath', JPATH_ROOT . DS . 'logs');
41-
if (empty($logPath)) {
42-
$logPath = JPATH_ROOT . DS . 'logs';
43-
}
44-
45-
$logFile = $this->params->get('logFile', false);
46-
if (empty($logFile)) {
47-
$logFile = false;
48-
}
49-
50-
// init and configuration JBDump library
51-
$params = array(
52-
53-
'root' => JPATH_SITE,
54-
55-
// file logger
56-
'logPath' => $logPath,
57-
'logFile' => $logFile,
58-
'serialize' => $this->params->get('serialize', 'print_r'),
59-
'logFormat' => "{DATETIME}\t{CLIENT_IP}\t\t{FILE}\t\t{NAME}\t\t{TEXT}",
60-
61-
// profiler
62-
'autoProfile' => (int)$this->params->get('autoProfile', true),
63-
'profileToFile' => (int)$this->params->get('profileToFile', false),
64-
65-
// sorting (ASC)
66-
'sort' => array(
67-
'array' => (int)$this->params->get('sort_array', false),
68-
'object' => (int)$this->params->get('sort_object', true),
69-
'methods' => (int)$this->params->get('sort_methods', true),
70-
),
71-
72-
// handlers
73-
'handler' => array(
74-
'error' => (int)$this->params->get('handler_error', true),
75-
'exception' => (int)$this->params->get('handler_exception', true),
76-
'context' => (int)$this->params->get('handler_context', false),
77-
),
78-
79-
// personal dump
80-
'ip' => $this->params->get('ip', false),
81-
'requestParam' => $this->params->get('requestParam', false),
82-
'requestValue' => $this->params->get('requestValue', false),
83-
84-
// others
85-
'lite_mode' => (int)$this->params->get('lite_mode', false),
86-
'stringLength' => $this->params->get('stringLength', 50),
87-
'maxDepth' => $this->params->get('maxDepth', 3),
88-
'showMethods' => (int)$this->params->get('showMethods', true),
89-
'allToLog' => (int)$this->params->get('allToLog', false),
90-
'showArgs' => (int)$this->params->get('showMethods', false),
91-
);
92-
93-
// init jbdump
94-
JBDump::i('jbdump', $params);
95-
}
22+
class plgSystemJBDump extends JPlugin {
23+
24+
/**
25+
* Constructor.
26+
*
27+
* @param object &$subject The object to observe -- event dispatcher.
28+
* @param object $config An optional associative array of configuration settings.
29+
*
30+
* @since 1.6
31+
*/
32+
public function __construct(& $subject, $config) {
33+
parent::__construct($subject, $config);
34+
}
35+
36+
/**
37+
* Plugin init
38+
*/
39+
// function plgSystemJBDump($subject, $params) {
40+
// parent::__construct($subject, $params);
41+
// }
42+
43+
/**
44+
* JBDump init
45+
*/
46+
function onAfterInitialise() {
47+
48+
$logPath = $this->params->get('logPath', JPATH_ROOT . '/logs');
49+
if (empty($logPath)) {
50+
$logPath = JPATH_ROOT . '/logs';
51+
}
52+
53+
$logFile = $this->params->get('logFile', false);
54+
if (empty($logFile)) {
55+
$logFile = false;
56+
}
57+
58+
// init and configuration JBDump library
59+
$params = array(
60+
'root' => JPATH_SITE,
61+
// file logger
62+
'logPath' => $logPath,
63+
'logFile' => $logFile,
64+
'serialize' => $this->params->get('serialize', 'print_r'),
65+
'logFormat' => "{DATETIME}\t{CLIENT_IP}\t\t{FILE}\t\t{NAME}\t\t{TEXT}",
66+
// profiler
67+
'autoProfile' => (int) $this->params->get('autoProfile', true),
68+
'profileToFile' => (int) $this->params->get('profileToFile', false),
69+
// sorting (ASC)
70+
'sort' => array(
71+
'array' => (int) $this->params->get('sort_array', false),
72+
'object' => (int) $this->params->get('sort_object', true),
73+
'methods' => (int) $this->params->get('sort_methods', true),
74+
),
75+
// handlers
76+
'handler' => array(
77+
'error' => (int) $this->params->get('handler_error', true),
78+
'exception' => (int) $this->params->get('handler_exception', true),
79+
'context' => (int) $this->params->get('handler_context', false),
80+
),
81+
// personal dump
82+
'ip' => $this->params->get('ip', false),
83+
'requestParam' => $this->params->get('requestParam', false),
84+
'requestValue' => $this->params->get('requestValue', false),
85+
// others
86+
'lite_mode' => (int) $this->params->get('lite_mode', false),
87+
'stringLength' => $this->params->get('stringLength', 50),
88+
'maxDepth' => $this->params->get('maxDepth', 3),
89+
'showMethods' => (int) $this->params->get('showMethods', true),
90+
'allToLog' => (int) $this->params->get('allToLog', false),
91+
'showArgs' => (int) $this->params->get('showMethods', false),
92+
);
93+
94+
// init jbdump
95+
JBDump::i(array('jbdump'), $params);
96+
}
9697

9798
}
9899

99100
// usability methods
100101
if (!function_exists('d')) {
101-
function d($var = 'JBDump::variable no set', $isDie = true, $name = '...')
102-
{
103-
$_this = JBDump::i();
104102

105-
if ($var !== 'JBDump::variable no set') {
106-
if ($_this->isDebug()) {
103+
function d($var = 'JBDump::variable no set', $isDie = true, $name = '...') {
104+
$_this = JBDump::i();
107105

108-
$params = array('trace' => debug_backtrace());
109-
$_this->dump($var, $name, $params);
106+
if ($var !== 'JBDump::variable no set') {
107+
if ($_this->isDebug()) {
110108

111-
if ($isDie) {
112-
die('JBDump_die');
113-
}
114-
}
115-
}
109+
$params = array('trace' => debug_backtrace());
110+
$_this->dump($var, $name, $params);
116111

117-
return $_this;
118-
}
112+
if ($isDie) {
113+
die('JBDump_die');
114+
}
115+
}
116+
}
117+
118+
return $_this;
119+
}
119120

120121
}
121122

122123
if (!function_exists('l')) {
123-
function l($entry, $mark = '...')
124-
{
125-
$params = array('trace' => debug_backtrace());
126-
return JBDump::log($entry, $mark, $params);
127-
}
124+
125+
function l($entry, $mark = '...') {
126+
$params = array('trace' => debug_backtrace());
127+
return JBDump::log($entry, $mark, $params);
128+
}
129+
128130
}
129131

130132
if (!function_exists('m')) {
131-
function m($text)
132-
{
133-
return JBDump::mark($text);
134-
}
133+
134+
function m($text) {
135+
return JBDump::mark($text);
136+
}
137+
135138
}

0 commit comments

Comments
 (0)