Skip to content

Commit cb0f1eb

Browse files
committed
Added php.ini support, minor fixes, removed some useless CSS
1 parent 99285fe commit cb0f1eb

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ To modify the global configuration call `ref::config()`:
6363
// example: initially expand first 3 levels
6464
ref::config('expLvl', 3);
6565

66+
You can also add configuration options in your `php.ini` file like this:
67+
68+
[ref]
69+
ref.expLvl = 3
70+
ref.maxDepth = 4
71+
6672
Currently available options and their default values:
6773

6874
| Option | Default | Description
@@ -78,7 +84,7 @@ Currently available options and their default values:
7884
| `'shortcutFunc'` | `array('r', 'rt')` | Shortcut functions used to detect the input expression. If they are namespaced, the namespace must be present as well (methods are not supported)
7985
| `'stylePath'` | `'{:dir}/ref.css'` | Local path to a custom stylesheet (HTML only); `FALSE` means that no CSS is included.
8086
| `'scriptPath'` | `'{:dir}/ref.js'` | Local path to a custom javascript (HTML only); `FALSE` means no javascript (tooltips / toggle / kbd shortcuts require JS)
81-
| `'showUrls'` | `TRUE` | Gets information about URLs. Setting to false can improve performance (requires showStringMatches to be TRUE)
87+
| `'showUrls'` | `FALSE` | Gets information about URLs. Setting to false can improve performance (requires showStringMatches to be TRUE)
8288

8389

8490
## Similar projects

ref.css

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656
border-radius: 4px;
5757
opacity: 0.90;
5858
box-shadow:0 0 4px rgba(0,0,0, 0.25);
59-
-webkit-transition: opacity .25s, margin .25s;
60-
-moz-transition: opacity .25s, margin .25s;
61-
-ms-transition: opacity .25s, margin .25s;
59+
-webkit-transition: opacity .25s, margin .25s;
6260
transition: opacity .25s, margin .25s;
6361
}
6462

@@ -136,9 +134,7 @@
136134
display: block;
137135
color: #ccc;
138136
background-color: #333;
139-
background-image: -webkit-linear-gradient(top, #444, #333);
140-
background-image: -moz-linear-gradient(top, #444, #333);
141-
background-image: -ms-linear-gradient(top, #444, #333);
137+
background-image: -webkit-linear-gradient(top, #444, #333);
142138
background-image: linear-gradient(top, #444, #333);
143139
border-radius: 4px 4px 0 0;
144140
border-bottom: 1px solid #fff;
@@ -171,16 +167,13 @@
171167
border-width: 7px 0 7px 10px;
172168
border-color: transparent transparent transparent #CC0033;
173169
cursor: pointer;
174-
-webkit-transition: all ease-in .15s;
175-
-moz-transition: all ease-in .15s;
176-
-ms-transition: all ease-in .15s;
170+
-webkit-transition: all ease-in .15s;
177171
transition: all ease-in .15s;
178172
}
179173

180174
/* collapse graphic */
181175
.ref [data-toggle][data-exp]{
182176
-webkit-transform: rotate(90deg);
183-
-moz-transform: rotate(90deg);
184177
-ms-transform: rotate(90deg);
185178
transform: rotate(90deg);
186179
}
@@ -249,8 +242,6 @@
249242
margin-right: 5px;
250243
background-color: #eee;
251244
background-image: -webkit-linear-gradient(top, rgba(255,255,255,0.1) 40%,rgba(0,0,0,0.1) 100%);
252-
background-image: -moz-linear-gradient(top, rgba(255,255,255,0.1) 40%, rgba(0,0,0,0.1) 100%);
253-
background-image: -ms-linear-gradient(top, rgba(255,255,255,0.1) 40%,rgba(0,0,0,0.1) 100%);
254245
background-image: linear-gradient(to bottom, rgba(255,255,255,0.1) 40%,rgba(0,0,0,0.1) 100%);
255246
}
256247

ref.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ window.addEventListener('load', function(){
4848
});
4949

5050
window.addEventListener('keydown', function(e){
51-
if((e.keyCode != 88) || (e.target.tagName.toLowerCase() == 'input') || (e.target.tagName.toLowerCase() == 'textarea'))
51+
var tt = e.target.tagName.toLowerCase();
52+
if((e.keyCode != 88) || (tt == 'input') || (tt == 'textarea') || (tt == 'select'))
5253
return;
5354

5455
var kbds = document.querySelectorAll('.ref [data-toggle]'),

ref.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function r(){
2727
$expressions = null;
2828

2929
// IE goes funky if there's no doctype
30-
if(!$capture && !headers_sent() && !ob_get_level())
30+
if(!$capture && !headers_sent() && (!ob_get_level() || ini_get('output_buffering')))
3131
print '<!DOCTYPE HTML><html><head><title>REF</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>';
3232

3333
if($capture)
@@ -156,7 +156,7 @@ class ref{
156156
'scriptPath' => '{:dir}/ref.js',
157157

158158
// display url info via cURL
159-
'showUrls' => true,
159+
'showUrls' => false,
160160
),
161161

162162
/**
@@ -186,6 +186,19 @@ class ref{
186186
*/
187187
public function __construct($format = 'html'){
188188

189+
static $didIni = false;
190+
191+
if(!$didIni){
192+
$didIni = true;
193+
foreach(array_keys(static::$config) as $key){
194+
$iniVal = get_cfg_var('ref.' . $key);
195+
print_r($iniVal);
196+
if($iniVal !== false)
197+
static::$config[$key] = $iniVal;
198+
}
199+
200+
}
201+
189202
if($format instanceof RFormatter){
190203
$this->fmt = $format;
191204

@@ -1381,7 +1394,7 @@ protected function evaluate(&$subject, $specialStr = false){
13811394
if(!$isNumeric && ($length > 4)){
13821395

13831396
// url
1384-
if(static::$config['showUrls'] &&static::$env['curlActive'] && filter_var($subject, FILTER_VALIDATE_URL)){
1397+
if(static::$config['showUrls'] && static::$env['curlActive'] && filter_var($subject, FILTER_VALIDATE_URL)){
13851398
$ch = curl_init($subject);
13861399
curl_setopt($ch, CURLOPT_NOBODY, true);
13871400
curl_exec($ch);
@@ -2374,8 +2387,8 @@ public function startExp(){
23742387
}
23752388

23762389
public function endExp(){
2377-
if (ref::config('showBacktrace')) {
2378-
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
2390+
if(ref::config('showBacktrace')) {
2391+
$traces = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
23792392
if (isset($traces[2])) {
23802393
$trace = $traces[2];
23812394
$this->out .= '<span data-backtrace>' . $trace['file'] . ':' . $trace['line'] . '</span>';
@@ -2663,8 +2676,8 @@ public function bubbles(array $items){
26632676
}
26642677

26652678
public function endExp(){
2666-
if (ref::config('showBacktrace')) {
2667-
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
2679+
if(ref::config('showBacktrace')) {
2680+
$traces = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
26682681
if (isset($traces[2])) {
26692682
$trace = $traces[2];
26702683
$this->out .= ' - ' . $trace['file'] . ':' . $trace['line'];

tests/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
ref::config('showPrivateMembers', true);
1111
ref::config('showIteratorContents', true);
12+
ref::config('showUrls', true);
1213

1314
/**
1415
* Test class

0 commit comments

Comments
 (0)