/** * Dump a variable * * @param mixed $var variable which will be dumped * @param bool $inline force inline display if true, otherwise will attempt to * use debug.log event * * @return void */ public static function dump($var, $inline = false) { $events = \Xoops::getInstance()->events(); $eventName = 'debug.log'; if (!$inline && $events->hasListeners($eventName)) { $events->triggerEvent($eventName, $var); //\Kint::dump(func_get_arg(0)); } else { $config = array('skin' => array('selected' => 'modern'), 'css' => array('url' => \XoopsBaseConfig::get('url') . '/modules/xmf/css/krumo/'), 'display' => array('show_version' => false, 'show_call_info' => false, 'sort_arrays' => false)); \krumo::setConfig($config); $msg = \krumo::dump($var); echo $msg; } }
/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ function dump($data) { // disabled ? // if (!krumo::_debug()) { return false; } // more arguments ? // if (func_num_args() > 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 // ?> <div class="krumo-root"> <ul class="krumo-node krumo-first"> <?php echo krumo::_dump($data); ?> <li class="krumo-footnote"> <div class="krumo-version" style="white-space:nowrap;"> <h6>Krumo version <?php echo krumo::version(); ?> </h6> | <a href="http://krumo.sourceforge.net" target="_blank">http://krumo.sourceforge.net</a> </div> <?php if (@$d['file']) { ?> <span class="krumo-call" style="white-space:nowrap;"> Called from <code><?php echo $d['file']; ?> </code>, line <code><?php echo $d['line']; ?> </code></span> <?php } ?> </li> </ul> </div> <?php // flee the hive // $_recursion_marker = krumo::_marker(); if ($hive =& krumo::_hive($dummy)) { foreach ($hive as $i => $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()]); } }
/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ public static function dump($data) { // disabled ? // if (!krumo::_debug()) { return false; } // more arguments ? // if (func_num_args() > 1) { $_ = func_get_args(); foreach ($_ as $d) { krumo::dump($d); } return; } // the css ? // krumo::_css(); // find caller // $_ = debug_backtrace(); while ($d = array_pop($_)) { if (strToLower($d['function']) == 'krumo' || strToLower(@$d['class']) == 'krumo') { break; } } // the content // ?> <div class="krumo-root"> <ul class="krumo-node krumo-first"> <?php echo krumo::_dump($data); ?> <li class="krumo-footnote"> <div class="krumo-version" style="white-space:nowrap;"> <h6>腾迅微博API,PHP SDK <?php echo krumo::version(); ?> </h6> | <a href="http://t.177wan.com/qq" target="_blank">http://t.177wan.com</a> </div> <?php if (@$d['file']) { ?> <span class="krumo-call" style="white-space:nowrap;"> Called from <code><?php echo $_SERVER['PHP_SELF']; ?> </code>, line <code><?php echo $d['line']; ?> </code></span> <?php } ?> </li> </ul> </div> <?php // flee the hive // $_recursion_marker = krumo::_marker(); if ($hive =& krumo::_hive($dummy)) { foreach ($hive as $i => $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()]); } }
/** * Prints a list of all the values from an INI file. * * @param string $ini_file * * @access public * @static */ public static function ini($ini_file) { // disabled ? // if (!krumo::_debug()) { return false; } // read it // if (!($_ = @parse_ini_file($ini_file, 1))) { return false; } // render it // ?> <div class="krumo-title"> This is a list of all the values from the <code><b><?php echo realpath($ini_file) ? realpath($ini_file) : $ini_file; ?> </b></code> INI file. </div> <?php return krumo::dump($_); }
/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ public static function dump($data, $capture = '') { // If we're capturing call dump() with just data and capture the output if ($capture === KRUMO_CAPTURE) { ob_start(); krumo::dump($data); $str = ob_get_clean(); return $str; } $clearObjectRecursionProtection = false; if (self::$objectRecursionProtection === NULL) { self::$objectRecursionProtection = array(); $clearObjectRecursionProtection = true; } // disabled if (!krumo::_debug()) { return false; } // more arguments if (func_num_args() > 1) { $_ = func_get_args(); foreach ($_ as $d) { krumo::dump($d); } return; } // the css krumo::_css(); // find caller $_ = debug_backtrace(); while ($d = array_pop($_)) { $callback = self::$lineNumberTestCallback; $function = strToLower($d['function']); if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && $callback($d)) { break; } } $showVersion = krumo::_config('display', 'show_version', TRUE); $showCallInfo = krumo::_config('display', 'show_call_info', TRUE); $krumoUrl = 'https://github.com/oodle/krumo'; ////////////////////// // Start HTML header// ////////////////////// print "<div class=\"krumo-root\">\n"; print "\t<ul class=\"krumo-node krumo-first\">\n"; // The actual item itself print krumo::_dump($data); if ($showVersion || $showCallInfo) { print "\t\t<li class=\"krumo-footnote\">\n"; if ($showVersion) { $version = krumo::version(); print "<div class=\"krumo-version\" style=\"white-space:nowrap;\">\n"; print "<h6>Krumo version {$version}</h6> | <a href=\"{$krumoUrl}\"\ttarget=\"_blank\">{$krumoUrl}</a>\n"; print "</div>\n"; } if ($showCallInfo && isset($d['file']) && $d['file']) { print "<span class=\"krumo-call\" style=\"white-space:nowrap;\">"; print "Called from <code>" . $d['file'] . "</code>, "; print "line <code>" . $d['line'] . "</code></span>"; } print "</li>"; } print "</ul></div>\n"; print "<!-- Krumo - HTML -->\n\n"; //////////////////// // End HTML header// //////////////////// // flee the hive $_recursion_marker = krumo::_marker(); if ($hive =& krumo::_hive($dummy)) { foreach ($hive as $i => $bee) { if (is_object($bee)) { if (($hash = spl_object_hash($bee)) && isset(self::$objectRecursionProtection[$hash])) { unset(self::$objectRecursionProtection[$hash]); } } elseif (isset($hive[$i]->{$_recursion_marker})) { unset($hive[$i][$_recursion_marker]); } } } if ($clearObjectRecursionProtection) { self::$objectRecursionProtection = NULL; } // End of dump() }
/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ public static function dump($data) { // disabled ? // if (!krumo::_debug()) { return false; } // more arguments ? // if (func_num_args() > 1) { $_ = func_get_args(); foreach ($_ as $d) { krumo::dump($d); } return; } // the css ? // krumo::_css(); // find caller // $_ = debug_backtrace(); while ($d = array_pop($_)) { if (strToLower($d['function']) == 'krumo' || strToLower(@$d['class']) == 'krumo') { break; } } // the content // ?> <div class="krumo-root"> <ul class="krumo-node krumo-first"> <?php echo krumo::_dump($data); ?> </ul> </div> <?php // flee the hive // $_recursion_marker = krumo::_marker(); if ($hive =& krumo::_hive($dummy)) { foreach ($hive as $i => $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()]); } }
public static function dump($data, $label = NULL, $backtrace = TRUE) { ob_start(); krumo::dump($data, $label, $backtrace); return ob_get_clean(); }
/** * Dumps a var with PEAR::Var_Dump. * * @param mixed $var The variable to dump * @param string $title An optional title * * @return void */ public static function varDump($var, $title = '') { echo $title ? '<h3><tt>' . $title . '</tt></h3>' : ''; $debug_type = JComponentHelper::getParams('com_easycreator')->get('ecr_debug_type', 'easy'); if ($debug_type == 'krumo') { ecrLoadHelper('krumo_0_2.krumo'); krumo::dump($var); return; } include_once 'Var_Dump.php'; if (class_exists('Var_Dump')) { Var_Dump::displayInit(array('display_mode' => 'HTML4_Table'), array('show_caption' => FALSE, 'bordercolor' => '#ccc', 'bordersize' => '2', 'captioncolor' => 'black', 'cellpadding' => '8', 'cellspacing' => '5', 'color1' => '#000', 'color2' => '#000', 'before_num_key' => '<span style="color: #fff; font-weight: bold;">', 'after_num_key' => '</span>', 'before_str_key' => '<span style="color: #5450cc; font-weight: bold;">', 'after_str_key' => '</span>', 'before_value' => '<span style="color: #5450cc;">', 'after_value' => '</span>')); Var_Dump::display($var); } else { echo '<pre>' . print_r($var, true) . '</pre>'; } }
/** * A more ajax and user friendly way to var_dump. * Use instead of pr() * * @param mixed $var * @param bool $useFireCakeOutsideViews */ static function krumo($var, $options = array()) { $options = array('fireCake' => true, 'debug' => true); if ($options['debug'] && !Configure::read()) { return; } if ($options['fireCake'] && empty(Sl::getInstance()->view) && class_exists('FireCake')) { return FireCake::fb($var); } // force Pheme to keep the whitespace and line breaks echo "<!--{!preserveWhitespace}-->"; App::import('vendor', 'krumo', array('file' => 'krumo/class.krumo.php')); return krumo::dump($var); }