From 7af10fe56229a78fe2719aaee84758ff30c48444 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 3 Nov 2007 05:26:59 +0000 Subject: [PATCH] new print_obj function from artanis git-svn-id: file:///home/shish/svn/shimmie2/trunk@607 7f39781d-f577-437e-ae19-be835c7a54ca --- core/util.inc.php | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index d3a91fa0..ccc42070 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -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(" ", - "__", - str_replace("\n","
",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
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 = ""; + + if($return) { + return $pr; + } else { + global $page; + $page->add_block(new Block($title,$pr,"main",1000)); + return true; + } + } +} // preset tests.