* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License Version 2.1
*
* @package Krumo
* @version $Id: class.krumo.php,v 1.1.2.5 2009-09-23 18:14:19 davereid Exp $
*/
//////////////////////////////////////////////////////////////////////////////
/**
* backward compatibility: the DIR_SEP constant isn't used anymore
*/
if(!defined('DIR_SEP')) {
	define('DIR_SEP', DIRECTORY_SEPARATOR);
	}
/**
* backward compatibility: the PATH_SEPARATOR constant is availble since 4.3.0RC2
*/
if (!defined('PATH_SEPARATOR')) {
	define('PATH_SEPARATOR', OS_WINDOWS ? ';' : ':');
        }
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
/**
* Set the KRUMO_DIR constant up with the absolute path to Krumo files. If it is 
* not defined, include_path will be used. Set KRUMO_DIR only if any other module 
* or application has not already set it up.
*/
if (!defined('KRUMO_DIR')) {
	define('KRUMO_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
	}
/**
* This constant sets the maximum strings of strings that will be shown 
* as they are. Longer strings will be truncated with this length, and 
* their `full form` will be shown in a child node.
*/
if (!defined('KRUMO_TRUNCATE_LENGTH')) {
	define('KRUMO_TRUNCATE_LENGTH', 50);
	}
//////////////////////////////////////////////////////////////////////////////
/**
* Krumo API
*
* This class stores the Krumo API for rendering and
* displaying the structured information it is reporting
*
* @package Krumo
*/
Class krumo {
	/**
	* Return Krumo version
	*
	* @return string
	* @access public
	* @static
	*/
	Function version() {
		return '0.2a';
		}
	// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	
	/**
	* Prints a debug backtrace
	*
	* @access public
	* @static
	*/
	Function backtrace() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		return krumo::dump(debug_backtrace());
		}
	
	/**
	* Prints a list of all currently declared classes.
	*
	* @access public
	* @static
	*/
	Function classes() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all currently declared classes.
		
This is a list of all currently declared interfaces.
		
This is a list of all currently included (or required) files.
		
This is a list of all currently declared functions.
		
This is a list of all currently declared constants (defines).
		
This is a list of all currently loaded PHP extensions.
		
This is a list of all HTTP request headers.
		php.ini
	*
	* @access public
	* @static
	*/
	Function phpini() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of the configuration settings read from .
		
This is a list of all your configuration settings.
		include_path option.
	*
	* @access public
	* @static
	*/
	Function path() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of the specified directories under your include_path option.
		$_REQUEST array.
	*
	* @access public
	* @static
	*/
	Function request() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_REQUEST array.
		$_GET array.
	*
	* @access public
	* @static
	*/
	Function get() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_GET array.
		$_POST array.
	*
	* @access public
	* @static
	*/
	Function post() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_POST array.
		$_SERVER array.
	*
	* @access public
	* @static
	*/
	Function server() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_SERVER array.
		$_COOKIE array.
	*
	* @access public
	* @static
	*/
	Function cookie() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_COOKIE array.
		$_ENV array.
	*
	* @access public
	* @static
	*/
	Function env() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_ENV array.
		$_SESSION array.
	*
	* @access public
	* @static
	*/
	Function session() {
		// disabled ?
		//
		if (!krumo::_debug()) {
			return false;
			}
		// render it
		//
		?>
This is a list of all the values from the $_SESSION array.
		
This is a list of all the values from the  INI file.
		 1) {
			$_ = func_get_args();
			foreach($_ as $d) {
				krumo::dump($d);
				}
			return;
			}
		
		// the css ?
		//
		krumo::_css();
		// find caller
		
		// DEVEL: we added array_reverse() so the proper file+line number is found.
		$_ = array_reverse(debug_backtrace());
		while($d = array_pop($_)) {
			// DEVEL: changed if() condition below
			if ((strpos(@$d['file'], 'devel') === FALSE) && (strpos(@$d['file'], 'krumo') === FALSE) && @$d['class'] != 'krumo') {
				break;
			}
		}
		// the content
		//
		?>
$bee){
			  if (is_object($bee)) {
				  unset($hive[$i]->$_recursion_marker);
				} else {
				  unset($hive[$i][$_recursion_marker]);
				}
			}
    }
		// PHP 4.x.x array reference bug...
		//
		if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
			unset($GLOBALS[krumo::_marker()]); 
			}
		}
	// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	/**
	* Print the skin (CSS)
	*
	* @return boolean
	* @access private
	* @static
	*/
	Function _css() {
		
		static $_css = false;
		
		// already set ?
		//
		if ($_css) {
			return true;
			}
		
		$css = '';
		
		// DEVEL: changed for Drupal variables system
		$skin = variable_get('devel_krumo_skin', 'orange');
		
		// custom selected skin ?
		//
		$_ = KRUMO_DIR . "skins/{$skin}/skin.css";
		if ($fp = @fopen($_, 'r', 1)) {
			$css = fread($fp, filesize($_));
			fclose($fp);
			}
		
		// defautl skin ?
		//
		if (!$css && ($skin != 'default')) {
			$skin = 'default';
			$_ = KRUMO_DIR . "skins/default/skin.css";
			$css = join('', @file($_));
			}
		
		// print ?
		//
		if ($_css = $css != '') {
			
			// fix the urls
			//
			
			// DEVEL: changed for Drupal path system.
			$css_url = base_path() . drupal_get_path('module', 'devel') . "/krumo/skins/{$skin}/";
			
			$css = preg_replace('~%url%~Uis', $css_url, $css);
			
			// the CSS
			//
			?>
	
$_recursion_marker++)
				: @($bee[$_recursion_marker]++);
			
			$_[0][] =& $bee;
			}
		// return all bees
		//
		return $_[0];
		}
	
	// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	/**
	* Render a dump for the properties of an array or objeect
	*
	* @param mixed &$data
	* @access private
	* @static
	*/
	Function _vars(&$data) {
		$_is_object = is_object($data);
		
		// test for references in order to
		// prevent endless recursion loops
		//
		$_recursion_marker = krumo::_marker();
		$_r = ($_is_object)
			? @$data->$_recursion_marker
			: @$data[$_recursion_marker] ;
		$_r = (integer) $_r;
		// recursion detected
		//
		if ($_r > 0) {
			return krumo::_recursion();
			}
		// stain it
		//
		krumo::_hive($data);
		// render it
		//
		?>
	
	$k;
			} else {
			$v =& $data[$k];
			}
		// PHP 4.x.x array reference bug...
		//
		if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
			$GLOBALS[krumo::_marker()][] =& $v; 
			}
		krumo::_dump($v,$k);
		} ?>
	
 
	
	 0) {?> onClick="krumo.toggle(this);"
		onMouseOver="krumo.over(this);"
		onMouseOut="krumo.out(this);">
		
			
			(
Array, ) 
			
				
			
				
 |
					(Callback)
					::();
				
				
	 
	
	 0) {?> onClick="krumo.toggle(this);"
		onMouseOver="krumo.over(this);"
		onMouseOut="krumo.out(this);">
			
			(
Object) 
			
	 
	
	
	
	
	
 KRUMO_TRUNCATE_LENGTH) {
			$_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...';
			$_extra = true;
			}
?>
	 onClick="krumo.toggle(this);"
		onMouseOver="krumo.over(this);"
		onMouseOut="krumo.out(this);">
			
			(
String,
				 characters )
			
			
			
				 |
					(Callback)
					();