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;
|
||||
}
|
||||
|
||||
function print_obj($array,$title="Object Information") {
|
||||
global $user, $page;
|
||||
// print_obj ($object, $title, $return)
|
||||
function print_obj($object,$title="Object Information", $return=false) {
|
||||
global $user;
|
||||
if(DEBUG && isset($_GET['debug']) && $user->is_admin()) {
|
||||
// big test:
|
||||
// $debug_active to be able to kill the function from the file system.
|
||||
// Look for ?debug (GET type data) to prevent the debug from appearing to regular browsing.
|
||||
// Finally an admin check, because variables may contain sensitive data.
|
||||
// once all that is cleared, make a block:
|
||||
$page->add_block(
|
||||
new Block(
|
||||
$title,
|
||||
str_replace(" ",
|
||||
"<span style='opacity:0; -moz-opacity:0; alpha:0;'>__</span>",
|
||||
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.
|
||||
}
|
||||
$pr = print_r($object,true);
|
||||
$count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25;
|
||||
$pr = "<textarea rows='".$count."' cols='80'>$pr</textarea>";
|
||||
|
||||
if($return) {
|
||||
return $pr;
|
||||
} else {
|
||||
global $page;
|
||||
$page->add_block(new Block($title,$pr,"main",1000));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// preset tests.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user