| 10 |
* |
* |
| 11 |
*/ |
*/ |
| 12 |
|
|
|
// global var to hold ALL debug messages (each message should be an array) |
|
|
$debug = array(); |
|
|
|
|
| 13 |
// global var for default parmaters of debug window |
// global var for default parmaters of debug window |
| 14 |
$default_params = array( |
$default_params = array( |
| 15 |
"opacity" => '9', |
"opacity" => '9', |
| 26 |
* ex. debug("var1",$var1,"var6",$var6,...) |
* ex. debug("var1",$var1,"var6",$var6,...) |
| 27 |
*/ |
*/ |
| 28 |
function debug(){ |
function debug(){ |
| 29 |
$arg_list = func_get_args(); |
// set a static array to handle all debug messages |
| 30 |
|
static $_debug = array(); |
| 31 |
|
|
| 32 |
// check for no arguments |
// grab passed in args |
| 33 |
if(empty($arg_list)){ return(false); } |
$arg_list = func_get_args(); |
| 34 |
|
|
| 35 |
|
// check for no arguments; if none, return debug array |
| 36 |
|
if(empty($arg_list)){ return($_debug); } |
| 37 |
|
|
| 38 |
$args = array(); |
$args = array(); |
| 39 |
$arg_count = func_num_args(); |
$arg_count = func_num_args(); |
| 47 |
} |
} |
| 48 |
|
|
| 49 |
// add the debug message to the global debug array |
// add the debug message to the global debug array |
| 50 |
debug_set(theme('debug',$args)); |
$_debug[] = theme('debug',$args); |
| 51 |
|
|
| 52 |
} |
} |
| 53 |
|
|
| 54 |
/** |
/** |
| 136 |
return system_settings_form($form); |
return system_settings_form($form); |
| 137 |
} |
} |
| 138 |
|
|
|
|
|
|
/** |
|
|
* adds debug statement to the global debug array |
|
|
* |
|
|
* @param debug_msg: themed individual debug message (one lbl & one var) |
|
|
*/ |
|
|
function debug_set($debug_msg){ |
|
|
global $debug; |
|
|
|
|
|
// create the debug gloabl array if needed |
|
|
if (!isset($debug)) { $debug = array(); } |
|
|
|
|
|
// add debug statement to session |
|
|
$debug[] = $debug_msg; |
|
|
} |
|
|
|
|
|
/** |
|
|
* returns an array of debug statements |
|
|
* |
|
|
* @param clear: if clear is true, all messages are purged from global debug array |
|
|
* @return array of themed debug messages |
|
|
*/ |
|
|
function debug_get($clear = TRUE){ |
|
|
global $debug; |
|
|
|
|
|
// grab messages |
|
|
if ($debug_msgs = $debug) { |
|
|
// clear out queuue if necessary |
|
|
if ($clear) { unset($debug); } |
|
|
return $debug_msgs; |
|
|
} |
|
|
return array(); |
|
|
} |
|
|
|
|
| 139 |
/** |
/** |
| 140 |
* called by $.get; |
* called by $.get; |
| 141 |
* uses variable_set to remember the x,y position & width of the debug window |
* uses variable_set to remember the x,y position & width of the debug window |
| 166 |
* |
* |
| 167 |
*/ |
*/ |
| 168 |
function debug_output(){ |
function debug_output(){ |
| 169 |
global $debug, $default_params; |
global $default_params; |
| 170 |
|
|
| 171 |
$params = array(); |
$params = array(); |
| 172 |
$params['opacity'] = variable_get('debug_opacity',$default_params['opacity']) * 10; |
$params['opacity'] = variable_get('debug_opacity',$default_params['opacity']) * 10; |
| 174 |
$params['remember'] = variable_get('debug_remember',$default_params['remember']); |
$params['remember'] = variable_get('debug_remember',$default_params['remember']); |
| 175 |
$params = array_merge($params,variable_get('debug_window_params',array("x"=>$default_params['x'],"y"=>$default_params['y'],"w"=>$default_params['w']))); |
$params = array_merge($params,variable_get('debug_window_params',array("x"=>$default_params['x'],"y"=>$default_params['y'],"w"=>$default_params['w']))); |
| 176 |
|
|
| 177 |
if(!empty($debug)){ |
$_debug = debug(); |
| 178 |
return theme('debug_msgs',debug_get(),$params); |
|
| 179 |
|
if(!empty($_debug)){ |
| 180 |
|
return theme('debug_msgs',debug(),$params); |
| 181 |
} |
} |
| 182 |
} |
} |
| 183 |
|
|
| 252 |
$output .= "</div>"; |
$output .= "</div>"; |
| 253 |
|
|
| 254 |
$output .= "<div>"; |
$output .= "<div>"; |
| 255 |
$output .= theme('debug_val',$arg); |
$output .= theme('debug_val',$arg['val']); |
| 256 |
$output .= "</div>"; |
$output .= "</div>"; |
| 257 |
} |
} |
| 258 |
$output .= "</div>"; |
$output .= "</div>"; |
| 263 |
/** |
/** |
| 264 |
* Theme function for individual debug values (called recursivly for arrays & objects) |
* Theme function for individual debug values (called recursivly for arrays & objects) |
| 265 |
* |
* |
| 266 |
* @param arg: array(val,ilk) |
* @param val: mixed |
| 267 |
* @return themed string of individual value depending on ilk |
* @return themed string of individual value depending on ilk |
| 268 |
*/ |
*/ |
| 269 |
function theme_debug_val($arg){ |
function theme_debug_val($val){ |
| 270 |
|
$ilk = gettype($val); |
| 271 |
|
|
| 272 |
// display val based on the type |
// display val based on the type |
| 273 |
switch($arg['ilk']){ |
switch($ilk){ |
| 274 |
case("NULL"): |
case("NULL"): |
| 275 |
$output .= "{null}"; |
$output .= "{null}"; |
| 276 |
break; |
break; |
| 277 |
case("resource"): |
case("resource"): |
| 278 |
$output .= "resource ".$arg['val'].": ".get_resource_type($arg['val']); |
$output .= "resource ".$val.": ".get_resource_type($val); |
| 279 |
break; |
break; |
| 280 |
case("object"): |
case("object"): |
| 281 |
case("array"): |
case("array"): |
| 282 |
$output .= "("; |
$output .= "("; |
| 283 |
foreach($arg['val'] as $key => $val){ |
foreach($val as $k => $v){ |
| 284 |
$output .= "<div>[".$key."] => ".theme('debug_val',array('val'=>$val,'ilk'=>gettype($val)))."</div>"; |
$output .= "<div>[".$k."] => ".theme('debug_val',$v)."</div>"; |
| 285 |
} |
} |
| 286 |
$output .= ")"; |
$output .= ")"; |
| 287 |
break; |
break; |
| 288 |
case("string"): |
case("string"): |
| 289 |
if($arg['val'] == ''){ |
if($val == ''){ |
| 290 |
$output .= "{empty string}"; |
$output .= "{empty string}"; |
| 291 |
} elseif($arg['val'] === ' '){ |
} elseif($val === ' '){ |
| 292 |
$output .= "{space}"; |
$output .= "{space}"; |
| 293 |
} else { |
} else { |
| 294 |
$output .= htmlentities($arg['val']); |
$output .= htmlentities($val); |
| 295 |
} |
} |
| 296 |
break; |
break; |
| 297 |
case("boolean"): |
case("boolean"): |
| 298 |
$output .= ($arg['val'] ? "{true}" : "{false}"); |
$output .= ($val ? "{true}" : "{false}"); |
| 299 |
break; |
break; |
| 300 |
default: |
default: |
| 301 |
$output .= $arg['val']; |
$output .= $val; |
| 302 |
} // end switch |
} // end switch |
| 303 |
|
|
| 304 |
return $output; |
return $output; |