new print_obj function from artanis
git-svn-id: file:///home/shish/svn/shimmie2/trunk@607 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
637712d72c
commit
7af10fe562
@ -249,33 +249,23 @@ function get_debug_info() {
|
|||||||
return $debug;
|
return $debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_obj($array,$title="Object Information") {
|
// print_obj ($object, $title, $return)
|
||||||
global $user, $page;
|
function print_obj($object,$title="Object Information", $return=false) {
|
||||||
|
global $user;
|
||||||
if(DEBUG && isset($_GET['debug']) && $user->is_admin()) {
|
if(DEBUG && isset($_GET['debug']) && $user->is_admin()) {
|
||||||
// big test:
|
$pr = print_r($object,true);
|
||||||
// $debug_active to be able to kill the function from the file system.
|
$count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25;
|
||||||
// Look for ?debug (GET type data) to prevent the debug from appearing to regular browsing.
|
$pr = "<textarea rows='".$count."' cols='80'>$pr</textarea>";
|
||||||
// Finally an admin check, because variables may contain sensitive data.
|
|
||||||
// once all that is cleared, make a block:
|
if($return) {
|
||||||
$page->add_block(
|
return $pr;
|
||||||
new Block(
|
} else {
|
||||||
$title,
|
global $page;
|
||||||
str_replace(" ",
|
$page->add_block(new Block($title,$pr,"main",1000));
|
||||||
"<span style='opacity:0; -moz-opacity:0; alpha:0;'>__</span>",
|
return true;
|
||||||
str_replace("\n","<br/>",html_escape(print_r($array,true)))),
|
}
|
||||||
"main",1000
|
}
|
||||||
)
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
// print_r is called with the return option (not echo-style) to get a string
|
|
||||||
// output to work with.
|
|
||||||
|
|
||||||
// Then two str_replaces turn newlines into <br/> tags and indent spaces into
|
|
||||||
// rendered underscores (which are then hidden.)
|
|
||||||
|
|
||||||
// Finally the entire thing is packaged into a block and mailed to the main
|
|
||||||
// section at the bottom of the pile.
|
|
||||||
}
|
|
||||||
|
|
||||||
// preset tests.
|
// preset tests.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user