12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316 |
- <?php
- /**
- * Krumo: Structured information display solution
- *
- * Krumo is a debugging tool (PHP5 only), which displays structured information
- * about any PHP variable. It is a nice replacement for print_r() or var_dump()
- * which are used by a lot of PHP developers.
- *
- * @author Kaloyan K. Tsvetkov <kaloyan@kaloyan.info>
- * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License Version 2.1
- *
- * @package Krumo
- */
- //////////////////////////////////////////////////////////////////////////////
- /**
- * 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
- */
- Public Static Function version() {
- return '0.2.1a';
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Prints a debug backtrace
- *
- * @access public
- * @static
- */
- 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
- */
- Public Static Function classes() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently declared classes.
- </div>
- <?php
- return krumo::dump(get_declared_classes());
- }
- /**
- * Prints a list of all currently declared interfaces (PHP5 only).
- *
- * @access public
- * @static
- */
- Public Static Function interfaces() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently declared interfaces.
- </div>
- <?php
- return krumo::dump(get_declared_interfaces());
- }
- /**
- * Prints a list of all currently included (or required) files.
- *
- * @access public
- * @static
- */
- Public Static Function includes() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently included (or required) files.
- </div>
- <?php
- return krumo::dump(get_included_files());
- }
- /**
- * Prints a list of all currently declared functions.
- *
- * @access public
- * @static
- */
- Public Static Function functions() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently declared functions.
- </div>
- <?php
- return krumo::dump(get_defined_functions());
- }
- /**
- * Prints a list of all currently declared constants.
- *
- * @access public
- * @static
- */
- Public Static Function defines() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently declared constants (defines).
- </div>
- <?php
- return krumo::dump(get_defined_constants());
- }
- /**
- * Prints a list of all currently loaded PHP extensions.
- *
- * @access public
- * @static
- */
- Public Static Function extensions() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all currently loaded PHP extensions.
- </div>
- <?php
- return krumo::dump(get_loaded_extensions());
- }
- /**
- * Prints a list of all HTTP request headers.
- *
- * @access public
- * @static
- */
- Public Static Function headers() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all HTTP request headers.
- </div>
- <?php
- return krumo::dump(getAllHeaders());
- }
- /**
- * Prints a list of the configuration settings read from <i>php.ini</i>
- *
- * @access public
- * @static
- */
- Public Static Function phpini() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- if (!readable(get_cfg_var('cfg_file_path'))) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of the configuration settings read from <code><b><?php echo get_cfg_var('cfg_file_path');?></b></code>.
- </div>
- <?php
- return krumo::dump(parse_ini_file(get_cfg_var('cfg_file_path'), true));
- }
- /**
- * Prints a list of all your configuration settings.
- *
- * @access public
- * @static
- */
- Public Static Function conf() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all your configuration settings.
- </div>
- <?php
- return krumo::dump(ini_get_all());
- }
- /**
- * Prints a list of the specified directories under your <i>include_path</i> option.
- *
- * @access public
- * @static
- */
- Public Static Function path() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of the specified directories under your <code><b>include_path</b></code> option.
- </div>
- <?php
- return krumo::dump(explode(PATH_SEPARATOR, ini_get('include_path')));
- }
- /**
- * Prints a list of all the values from the <i>$_REQUEST</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function request() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_REQUEST</b></code> array.
- </div>
- <?php
- return krumo::dump($_REQUEST);
- }
- /**
- * Prints a list of all the values from the <i>$_GET</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function get() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_GET</b></code> array.
- </div>
- <?php
- return krumo::dump($_GET);
- }
- /**
- * Prints a list of all the values from the <i>$_POST</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function post() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_POST</b></code> array.
- </div>
- <?php
- return krumo::dump($_POST);
- }
- /**
- * Prints a list of all the values from the <i>$_SERVER</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function server() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_SERVER</b></code> array.
- </div>
- <?php
- return krumo::dump($_SERVER);
- }
- /**
- * Prints a list of all the values from the <i>$_COOKIE</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function cookie() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_COOKIE</b></code> array.
- </div>
- <?php
- return krumo::dump($_COOKIE);
- }
- /**
- * Prints a list of all the values from the <i>$_ENV</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function env() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_ENV</b></code> array.
- </div>
- <?php
- return krumo::dump($_ENV);
- }
- /**
- * Prints a list of all the values from the <i>$_SESSION</i> array.
- *
- * @access public
- * @static
- */
- Public Static Function session() {
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
- // render it
- //
- ?>
- <div class="krumo-title">
- This is a list of all the values from the <code><b>$_SESSION</b></code> array.
- </div>
- <?php
- return krumo::dump($_SESSION);
- }
- /**
- * 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) {
- // 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
- // DEVEL: we add an ltr here.
- ?>
- <div class="krumo-root" dir="ltr">
- <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);
- // DEVEL: changed 'else' to 'elseif' below
- } elseif (is_array($bee)) {
- 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()]);
- }
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Returns values from Krumo's configuration
- *
- * @param string $group
- * @param string $name
- * @param mixed $fallback
- * @return mixed
- *
- * @access private
- * @static
- */
- Private Static Function _config($group, $name, $fallback=null) {
- static $_config = array();
- // not loaded ?
- //
- if (empty($_config)) {
- $_config = (array) @parse_ini_file(
- KRUMO_DIR . 'krumo.ini',
- true);
- }
- // exists ?
- //
- return (isset($_config[$group][$name]))
- ? $_config[$group][$name]
- : $fallback;
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Print the skin (CSS)
- *
- * @return boolean
- * @access private
- * @static
- */
- 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 = file_create_url(drupal_get_path('module', 'devel') . "/krumo/skins/{$skin}/");
- $css = preg_replace('~%url%~Uis', $css_url, $css);
- // the CSS
- //
- ?>
- <!-- Using Krumo Skin: <?php echo preg_replace('~^' . preg_quote(realpath(KRUMO_DIR) . DIRECTORY_SEPARATOR) . '~Uis', '', realpath($_));?> -->
- <style type="text/css">
- <!--/**/
- <?php echo $css?>
- /**/-->
- </style>
- <?php
- // the JS
- //
- ?>
- <script type="text/javascript">
- <!--//
- <?php echo join(file(KRUMO_DIR . "krumo.js"));?>
- //-->
- </script>
- <?php
- }
- return $_css;
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Enable Krumo
- *
- * @return boolean
- * @access public
- * @static
- */
- Public Static Function enable() {
- return true === krumo::_debug(true);
- }
- /**
- * Disable Krumo
- *
- * @return boolean
- * @access public
- * @static
- */
- Public Static Function disable() {
- return false === krumo::_debug(false);
- }
- /**
- * Get\Set Krumo state: whether it is enabled or disabled
- *
- * @param boolean $state
- * @return boolean
- * @access private
- * @static
- */
- Private Static Function _debug($state=null) {
- static $_ = true;
- // set
- //
- if (isset($state)) {
- $_ = (boolean) $state;
- }
- // get
- //
- return $_;
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Dump information about a variable
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _dump(&$data, $name='...') {
- // object ?
- //
- if (is_object($data)) {
- return krumo::_object($data, $name);
- }
- // array ?
- //
- if (is_array($data)) {
- // PHP 4.x.x array reference bug...
- //
- if (version_compare(PHP_VERSION, "5", "<")) {
- // prepare the GLOBAL reference list...
- //
- if (!isset($GLOBALS[krumo::_marker()])) {
- $GLOBALS[krumo::_marker()] = array();
- }
- if (!is_array($GLOBALS[krumo::_marker()])) {
- $GLOBALS[krumo::_marker()] = (array) $GLOBALS[krumo::_marker()];
- }
- // extract ?
- //
- if (!empty($GLOBALS[krumo::_marker()])) {
- $d = array_shift($GLOBALS[krumo::_marker()]);
- if (is_array($d)) {
- $data = $d;
- }
- }
- }
- return krumo::_array($data, $name);
- }
- // resource ?
- //
- if (is_resource($data)) {
- return krumo::_resource($data, $name);
- }
- // scalar ?
- //
- if (is_string($data)) {
- return krumo::_string($data, $name);
- }
- if (is_float($data)) {
- return krumo::_float($data, $name);
- }
- if (is_integer($data)) {
- return krumo::_integer($data, $name);
- }
- if (is_bool($data)) {
- return krumo::_boolean($data, $name);
- }
- // null ?
- //
- if (is_null($data)) {
- return krumo::_null($name);
- }
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a NULL value
- *
- * @param string $name
- * @return string
- * @access private
- * @static
- */
- Private Static Function _null($name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type krumo-null">NULL</em>)
- </div>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Return the marked used to stain arrays
- * and objects in order to detect recursions
- *
- * @return string
- * @access private
- * @static
- */
- Private Static Function _marker() {
- static $_recursion_marker;
- if (!isset($_recursion_marker)) {
- $_recursion_marker = uniqid('krumo');
- }
- return $_recursion_marker;
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Adds a variable to the hive of arrays and objects which
- * are tracked for whether they have recursive entries
- *
- * @param mixed &$bee either array or object, not a scallar vale
- * @return array all the bees
- *
- * @access private
- * @static
- */
- Private Static Function &_hive(&$bee) {
- static $_ = array();
- // new bee ?
- //
- if (!is_null($bee)) {
- // stain it
- //
- $_recursion_marker = krumo::_marker();
- (is_object($bee))
- ? @($bee->$_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
- */
- 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
- //
- ?>
- <div class="krumo-nest" style="display:none;">
- <ul class="krumo-node">
- <?php
- // keys ?
- //
- $keys = ($_is_object)
- ? array_keys(get_object_vars($data))
- : array_keys($data);
- // itterate
- //
- foreach($keys as $k) {
- // skip marker
- //
- if ($k === $_recursion_marker) {
- continue;
- }
- // get real value
- //
- if ($_is_object) {
- $v =& $data->$k;
- } else {
- $v =& $data[$k];
- }
- krumo::_dump($v,$k);
- } ?>
- </ul>
- </div>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a block that detected recursion
- *
- * @access private
- * @static
- */
- Private Static Function _recursion() {
- ?>
- <div class="krumo-nest" style="display:none;">
- <ul class="krumo-node">
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <a class="krumo-name"><big>∞</big></a>
- (<em class="krumo-type">Recursion</em>)
- </div>
- </li>
- </ul>
- </div>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for an array
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _array(&$data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
- <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Array, <strong class="krumo-array-length"><?php echo
- (count($data)==1)
- ?("1 element")
- :(count($data)." elements");
- ?></strong></em>)
- <?php
- // callback ?
- //
- if (is_callable($data)) {
- $_ = array_values($data);
- ?>
- <span class="krumo-callback"> |
- (<em class="krumo-type">Callback</em>)
- <strong class="krumo-string"><?php
- echo htmlSpecialChars($_[0]);?>::<?php
- echo htmlSpecialChars($_[1]);?>();</strong></span>
- <?php
- }
- ?>
- </div>
- <?php if (count($data)) {
- krumo::_vars($data);
- } ?>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for an object
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _object(&$data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
- <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Object</em>)
- <strong class="krumo-class"><?php echo get_class($data);?></strong>
- </div>
- <?php if (count($data)) {
- krumo::_vars($data);
- } ?>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a resource
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _resource($data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Resource</em>)
- <strong class="krumo-resource"><?php echo get_resource_type($data);?></strong>
- </div>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a boolean value
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _boolean($data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Boolean</em>)
- <strong class="krumo-boolean"><?php echo $data?'TRUE':'FALSE'?></strong>
- </div>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a integer value
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _integer($data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Integer</em>)
- <strong class="krumo-integer"><?php echo $data;?></strong>
- </div>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a float value
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _float($data, $name) {
- ?>
- <li class="krumo-child">
- <div class="krumo-element"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">Float</em>)
- <strong class="krumo-float"><?php echo $data;?></strong>
- </div>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- /**
- * Render a dump for a string value
- *
- * @param mixed $data
- * @param string $name
- * @access private
- * @static
- */
- Private Static Function _string($data, $name) {
- // extra ?
- //
- $_extra = false;
- $_ = $data;
- if (strLen($data) > KRUMO_TRUNCATE_LENGTH) {
- $_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...';
- $_extra = true;
- }
- ?>
- <li class="krumo-child">
- <div class="krumo-element<?php echo $_extra ? ' krumo-expand' : '';?>"
- <?php if ($_extra) {?> onClick="krumo.toggle(this);"<?php } ?>
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
- <?php /* DEVEL: added htmlSpecialChars */ ?>
- <a class="krumo-name"><?php echo htmlSpecialChars($name);?></a>
- (<em class="krumo-type">String,
- <strong class="krumo-string-length"><?php
- echo strlen($data) ?> characters</strong> </em>)
- <strong class="krumo-string"><?php echo htmlSpecialChars($_);?></strong>
- <?php
- // callback ?
- //
- if (is_callable($data)) {
- ?>
- <span class="krumo-callback"> |
- (<em class="krumo-type">Callback</em>)
- <strong class="krumo-string"><?php echo htmlSpecialChars($_);?>();</strong></span>
- <?php
- }
- ?>
- </div>
- <?php if ($_extra) { ?>
- <div class="krumo-nest" style="display:none;">
- <ul class="krumo-node">
- <li class="krumo-child">
- <div class="krumo-preview"><?php echo htmlSpecialChars($data);?></div>
- </li>
- </ul>
- </div>
- <?php } ?>
- </li>
- <?php
- }
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- //--end-of-class--
- }
- //////////////////////////////////////////////////////////////////////////////
- /**
- * Alias of {@link krumo::dump()}
- *
- * @param mixed $data,...
- *
- * @see krumo::dump()
- */
- Function krumo() {
- $_ = func_get_args();
- return call_user_func_array(
- array('krumo', 'dump'), $_
- );
- }
- //////////////////////////////////////////////////////////////////////////////
- ?>
|