first commit
[step2_drupal.git] / devel / krumo / class.krumo.php
blobbc80031eda065ced9076e513ec9216371894b5a6
1 <?php
2 /**
3 * Krumo: Structured information display solution
5 * Krumo is a debugging tool (PHP4/PHP5), which displays structured information
6 * about any PHP variable. It is a nice replacement for print_r() or var_dump()
7 * which are used by a lot of PHP developers.
9 * @author Kaloyan K. Tsvetkov <kaloyan@kaloyan.info>
10 * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License Version 2.1
12 * @package Krumo
13 * @version $Id: class.krumo.php,v 1.1.2.4 2009/02/11 04:01:01 weitzman Exp $
16 //////////////////////////////////////////////////////////////////////////////
18 /**
19 * backward compatibility: the DIR_SEP constant isn't used anymore
21 if(!defined('DIR_SEP')) {
22 define('DIR_SEP', DIRECTORY_SEPARATOR);
24 /**
25 * backward compatibility: the PATH_SEPARATOR constant is availble since 4.3.0RC2
27 if (!defined('PATH_SEPARATOR')) {
28 define('PATH_SEPARATOR', OS_WINDOWS ? ';' : ':');
31 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
33 /**
34 * Set the KRUMO_DIR constant up with the absolute path to Krumo files. If it is
35 * not defined, include_path will be used. Set KRUMO_DIR only if any other module
36 * or application has not already set it up.
38 if (!defined('KRUMO_DIR')) {
39 define('KRUMO_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
42 /**
43 * This constant sets the maximum strings of strings that will be shown
44 * as they are. Longer strings will be truncated with this length, and
45 * their `full form` will be shown in a child node.
47 if (!defined('KRUMO_TRUNCATE_LENGTH')) {
48 define('KRUMO_TRUNCATE_LENGTH', 50);
51 //////////////////////////////////////////////////////////////////////////////
53 /**
54 * Krumo API
56 * This class stores the Krumo API for rendering and
57 * displaying the structured information it is reporting
59 * @package Krumo
61 Class krumo {
63 /**
64 * Return Krumo version
66 * @return string
67 * @access public
68 * @static
70 Function version() {
71 return '0.2a';
74 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
76 /**
77 * Prints a debug backtrace
79 * @access public
80 * @static
82 Function backtrace() {
84 // disabled ?
86 if (!krumo::_debug()) {
87 return false;
90 // render it
92 return krumo::dump(debug_backtrace());
95 /**
96 * Prints a list of all currently declared classes.
98 * @access public
99 * @static
101 Function classes() {
103 // disabled ?
105 if (!krumo::_debug()) {
106 return false;
109 // render it
112 <div class="krumo-title">
113 This is a list of all currently declared classes.
114 </div>
115 <?php
116 return krumo::dump(get_declared_classes());
120 * Prints a list of all currently declared interfaces (PHP5 only).
122 * @access public
123 * @static
125 Function interfaces() {
127 // disabled ?
129 if (!krumo::_debug()) {
130 return false;
133 // render it
136 <div class="krumo-title">
137 This is a list of all currently declared interfaces.
138 </div>
139 <?php
140 return krumo::dump(get_declared_interfaces());
144 * Prints a list of all currently included (or required) files.
146 * @access public
147 * @static
149 Function includes() {
151 // disabled ?
153 if (!krumo::_debug()) {
154 return false;
157 // render it
160 <div class="krumo-title">
161 This is a list of all currently included (or required) files.
162 </div>
163 <?php
164 return krumo::dump(get_included_files());
168 * Prints a list of all currently declared functions.
170 * @access public
171 * @static
173 Function functions() {
175 // disabled ?
177 if (!krumo::_debug()) {
178 return false;
181 // render it
184 <div class="krumo-title">
185 This is a list of all currently declared functions.
186 </div>
187 <?php
188 return krumo::dump(get_defined_functions());
192 * Prints a list of all currently declared constants.
194 * @access public
195 * @static
197 Function defines() {
199 // disabled ?
201 if (!krumo::_debug()) {
202 return false;
205 // render it
208 <div class="krumo-title">
209 This is a list of all currently declared constants (defines).
210 </div>
211 <?php
212 return krumo::dump(get_defined_constants());
216 * Prints a list of all currently loaded PHP extensions.
218 * @access public
219 * @static
221 Function extensions() {
223 // disabled ?
225 if (!krumo::_debug()) {
226 return false;
229 // render it
232 <div class="krumo-title">
233 This is a list of all currently loaded PHP extensions.
234 </div>
235 <?php
236 return krumo::dump(get_loaded_extensions());
240 * Prints a list of all HTTP request headers.
242 * @access public
243 * @static
245 Function headers() {
247 // disabled ?
249 if (!krumo::_debug()) {
250 return false;
253 // render it
256 <div class="krumo-title">
257 This is a list of all HTTP request headers.
258 </div>
259 <?php
260 return krumo::dump(getAllHeaders());
264 * Prints a list of the configuration settings read from <i>php.ini</i>
266 * @access public
267 * @static
269 Function phpini() {
271 // disabled ?
273 if (!krumo::_debug()) {
274 return false;
277 // render it
280 <div class="krumo-title">
281 This is a list of the configuration settings read from <code><b><?php echo get_cfg_var('cfg_file_path');?></b></code>.
282 </div>
283 <?php
284 return krumo::dump(parse_ini_file(get_cfg_var('cfg_file_path'), true));
288 * Prints a list of all your configuration settings.
290 * @access public
291 * @static
293 Function conf() {
295 // disabled ?
297 if (!krumo::_debug()) {
298 return false;
301 // render it
304 <div class="krumo-title">
305 This is a list of all your configuration settings.
306 </div>
307 <?php
308 return krumo::dump(ini_get_all());
312 * Prints a list of the specified directories under your <i>include_path</i> option.
314 * @access public
315 * @static
317 Function path() {
319 // disabled ?
321 if (!krumo::_debug()) {
322 return false;
325 // render it
328 <div class="krumo-title">
329 This is a list of the specified directories under your <code><b>include_path</b></code> option.
330 </div>
331 <?php
332 return krumo::dump(explode(PATH_SEPARATOR, ini_get('include_path')));
336 * Prints a list of all the values from the <i>$_REQUEST</i> array.
338 * @access public
339 * @static
341 Function request() {
343 // disabled ?
345 if (!krumo::_debug()) {
346 return false;
349 // render it
352 <div class="krumo-title">
353 This is a list of all the values from the <code><b>$_REQUEST</b></code> array.
354 </div>
355 <?php
356 return krumo::dump($_REQUEST);
360 * Prints a list of all the values from the <i>$_GET</i> array.
362 * @access public
363 * @static
365 Function get() {
367 // disabled ?
369 if (!krumo::_debug()) {
370 return false;
373 // render it
376 <div class="krumo-title">
377 This is a list of all the values from the <code><b>$_GET</b></code> array.
378 </div>
379 <?php
380 return krumo::dump($_GET);
384 * Prints a list of all the values from the <i>$_POST</i> array.
386 * @access public
387 * @static
389 Function post() {
391 // disabled ?
393 if (!krumo::_debug()) {
394 return false;
397 // render it
400 <div class="krumo-title">
401 This is a list of all the values from the <code><b>$_POST</b></code> array.
402 </div>
403 <?php
404 return krumo::dump($_POST);
408 * Prints a list of all the values from the <i>$_SERVER</i> array.
410 * @access public
411 * @static
413 Function server() {
415 // disabled ?
417 if (!krumo::_debug()) {
418 return false;
421 // render it
424 <div class="krumo-title">
425 This is a list of all the values from the <code><b>$_SERVER</b></code> array.
426 </div>
427 <?php
428 return krumo::dump($_SERVER);
432 * Prints a list of all the values from the <i>$_COOKIE</i> array.
434 * @access public
435 * @static
437 Function cookie() {
439 // disabled ?
441 if (!krumo::_debug()) {
442 return false;
445 // render it
448 <div class="krumo-title">
449 This is a list of all the values from the <code><b>$_COOKIE</b></code> array.
450 </div>
451 <?php
452 return krumo::dump($_COOKIE);
456 * Prints a list of all the values from the <i>$_ENV</i> array.
458 * @access public
459 * @static
461 Function env() {
463 // disabled ?
465 if (!krumo::_debug()) {
466 return false;
469 // render it
472 <div class="krumo-title">
473 This is a list of all the values from the <code><b>$_ENV</b></code> array.
474 </div>
475 <?php
476 return krumo::dump($_ENV);
480 * Prints a list of all the values from the <i>$_SESSION</i> array.
482 * @access public
483 * @static
485 Function session() {
487 // disabled ?
489 if (!krumo::_debug()) {
490 return false;
493 // render it
496 <div class="krumo-title">
497 This is a list of all the values from the <code><b>$_SESSION</b></code> array.
498 </div>
499 <?php
500 return krumo::dump($_SESSION);
504 * Prints a list of all the values from an INI file.
506 * @param string $ini_file
508 * @access public
509 * @static
511 Function ini($ini_file) {
513 // disabled ?
515 if (!krumo::_debug()) {
516 return false;
519 // read it
521 if (!$_ = @parse_ini_file($ini_file, 1)) {
522 return false;
525 // render it
528 <div class="krumo-title">
529 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.
530 </div>
531 <?php
532 return krumo::dump($_);
535 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
538 * Dump information about a variable
540 * @param mixed $data,...
541 * @access public
542 * @static
544 Function dump($data) {
546 // disabled ?
548 if (!krumo::_debug()) {
549 return false;
552 // more arguments ?
554 if (func_num_args() > 1) {
555 $_ = func_get_args();
556 foreach($_ as $d) {
557 krumo::dump($d);
559 return;
562 // the css ?
564 krumo::_css();
566 // find caller
568 // DEVEL: we added array_reverse() so the proper file+line number is found.
569 $_ = array_reverse(debug_backtrace());
570 while($d = array_pop($_)) {
571 // DEVEL: changed if() condition below
572 if ((strpos(@$d['file'], 'devel') === FALSE) && (strpos(@$d['file'], 'krumo') === FALSE) && @$d['class'] != 'krumo') {
573 break;
577 // the content
580 <div class="krumo-root" dir="ltr">
581 <ul class="krumo-node krumo-first">
582 <?php echo krumo::_dump($data);?>
583 <li class="krumo-footnote">
584 <div class="krumo-version" style="white-space:nowrap;">
585 <h6>Krumo version <?php echo krumo::version();?></h6> | <a
586 href="http://krumo.sourceforge.net"
587 target="_blank">http://krumo.sourceforge.net</a>
588 </div>
590 <?php if (@$d['file']) { ?>
591 <span class="krumo-call" style="white-space:nowrap;">
592 Called from <code><?php echo $d['file']?></code>,
593 line <code><?php echo $d['line']?></code></span>
594 <?php } ?>
595 &nbsp;
596 </li>
597 </ul>
598 </div>
599 <?php
600 // flee the hive
602 $_recursion_marker = krumo::_marker();
603 if ($hive =& krumo::_hive($dummy)) {
604 foreach($hive as $i=>$bee){
605 if (is_object($bee)) {
606 unset($hive[$i]->$_recursion_marker);
607 } else {
608 unset($hive[$i][$_recursion_marker]);
613 // PHP 4.x.x array reference bug...
615 if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
616 unset($GLOBALS[krumo::_marker()]);
620 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
623 * Print the skin (CSS)
625 * @return boolean
626 * @access private
627 * @static
629 Function _css() {
631 static $_css = false;
633 // already set ?
635 if ($_css) {
636 return true;
639 $css = '';
641 // DEVEL: changed for Drupal variables system
642 $skin = variable_get('devel_krumo_skin', 'orange');
644 // custom selected skin ?
646 $_ = KRUMO_DIR . "skins/{$skin}/skin.css";
647 if ($fp = @fopen($_, 'r', 1)) {
648 $css = fread($fp, filesize($_));
649 fclose($fp);
652 // defautl skin ?
654 if (!$css && ($skin != 'default')) {
655 $skin = 'default';
656 $_ = KRUMO_DIR . "skins/default/skin.css";
657 $css = join('', @file($_));
660 // print ?
662 if ($_css = $css != '') {
664 // fix the urls
667 // DEVEL: changed for Drupal path system.
668 $css_url = url(drupal_get_path('module', 'devel')) . "/krumo/skins/{$skin}/";
670 $css = preg_replace('~%url%~Uis', $css_url, $css);
672 // the CSS
675 <!-- Using Krumo Skin: <?php echo preg_replace('~^' . preg_quote(realpath(KRUMO_DIR) . DIRECTORY_SEPARATOR) . '~Uis', '', realpath($_));?> -->
676 <style type="text/css">
677 <!--/**/
678 <?php echo $css?>
680 /**/-->
681 </style>
682 <?php
683 // the JS
686 <script type="text/javascript">
687 <!--//
688 <?php echo join(file(KRUMO_DIR . "krumo.js"));?>
690 //-->
691 </script>
692 <?php
695 return $_css;
698 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
701 * Enable Krumo
703 * @return boolean
704 * @access public
705 * @static
707 Function enable() {
708 return true === krumo::_debug(true);
712 * Disable Krumo
714 * @return boolean
715 * @access public
716 * @static
718 Function disable() {
719 return false === krumo::_debug(false);
723 * Get\Set Krumo state: whether it is enabled or disabled
725 * @param boolean $state
726 * @return boolean
727 * @access private
728 * @static
730 Function _debug($state=null) {
732 static $_ = true;
734 // set
736 if (isset($state)) {
737 $_ = (boolean) $state;
740 // get
742 return $_;
745 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
748 * Dump information about a variable
750 * @param mixed $data
751 * @param string $name
752 * @access private
753 * @static
755 Function _dump(&$data, $name='...') {
757 // object ?
759 if (is_object($data)) {
760 return krumo::_object($data, $name);
763 // array ?
765 if (is_array($data)) {
767 // PHP 4.x.x array reference bug...
769 if (version_compare(PHP_VERSION, "5", "<")) {
771 // prepare the GLOBAL reference list...
773 if (!isset($GLOBALS[krumo::_marker()])) {
774 $GLOBALS[krumo::_marker()] = array();
776 if (!is_array($GLOBALS[krumo::_marker()])) {
777 $GLOBALS[krumo::_marker()] = (array) $GLOBALS[krumo::_marker()];
780 // extract ?
782 if (!empty($GLOBALS[krumo::_marker()])) {
783 $d = array_shift($GLOBALS[krumo::_marker()]);
784 if (is_array($d)) {
785 $data = $d;
790 return krumo::_array($data, $name);
793 // resource ?
795 if (is_resource($data)) {
796 return krumo::_resource($data, $name);
799 // scalar ?
801 if (is_string($data)) {
802 return krumo::_string($data, $name);
805 if (is_float($data)) {
806 return krumo::_float($data, $name);
809 if (is_integer($data)) {
810 return krumo::_integer($data, $name);
813 if (is_bool($data)) {
814 return krumo::_boolean($data, $name);
817 // null ?
819 if (is_null($data)) {
820 return krumo::_null($name);
824 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
827 * Render a dump for a NULL value
829 * @param string $name
830 * @return string
831 * @access private
832 * @static
834 Function _null($name) {
836 <li class="krumo-child">
837 <div class="krumo-element"
838 onMouseOver="krumo.over(this);"
839 onMouseOut="krumo.out(this);">
841 <a class="krumo-name"><?php echo $name;?></a>
842 (<em class="krumo-type krumo-null">NULL</em>)
843 </div>
844 </li>
845 <?php
848 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
851 * Return the marked used to stain arrays
852 * and objects in order to detect recursions
854 * @return string
855 * @access private
856 * @static
858 Function _marker() {
860 static $_recursion_marker;
861 if (!isset($_recursion_marker)) {
862 $_recursion_marker = uniqid('krumo');
865 return $_recursion_marker;
868 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
871 * Adds a variable to the hive of arrays and objects which
872 * are tracked for whether they have recursive entries
874 * @param mixed &$bee either array or object, not a scallar vale
875 * @return array all the bees
877 * @access private
878 * @static
880 Function &_hive(&$bee) {
882 static $_ = array();
884 // new bee ?
886 if (!is_null($bee)) {
888 // stain it
890 $_recursion_marker = krumo::_marker();
891 (is_object($bee))
892 ? @($bee->$_recursion_marker++)
893 : @($bee[$_recursion_marker]++);
895 $_[0][] =& $bee;
898 // return all bees
900 return $_[0];
903 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
906 * Render a dump for the properties of an array or objeect
908 * @param mixed &$data
909 * @access private
910 * @static
912 Function _vars(&$data) {
914 $_is_object = is_object($data);
916 // test for references in order to
917 // prevent endless recursion loops
919 $_recursion_marker = krumo::_marker();
920 $_r = ($_is_object)
921 ? @$data->$_recursion_marker
922 : @$data[$_recursion_marker] ;
923 $_r = (integer) $_r;
925 // recursion detected
927 if ($_r > 0) {
928 return krumo::_recursion();
931 // stain it
933 krumo::_hive($data);
935 // render it
938 <div class="krumo-nest" style="display:none;">
939 <ul class="krumo-node">
940 <?php
942 // keys ?
944 $keys = ($_is_object)
945 ? array_keys(get_object_vars($data))
946 : array_keys($data);
948 // itterate
950 foreach($keys as $k) {
952 // skip marker
954 if ($k === $_recursion_marker) {
955 continue;
958 // get real value
960 if ($_is_object) {
961 $v =& $data->$k;
962 } else {
963 $v =& $data[$k];
966 // PHP 4.x.x array reference bug...
968 if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
969 $GLOBALS[krumo::_marker()][] =& $v;
972 krumo::_dump($v,$k);
973 } ?>
974 </ul>
975 </div>
976 <?php
979 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
982 * Render a block that detected recursion
984 * @access private
985 * @static
987 Function _recursion() {
989 <div class="krumo-nest" style="display:none;">
990 <ul class="krumo-node">
991 <li class="krumo-child">
992 <div class="krumo-element"
993 onMouseOver="krumo.over(this);"
994 onMouseOut="krumo.out(this);">
995 <a class="krumo-name"><big>&#8734;</big></a>
996 (<em class="krumo-type">Recursion</em>)
997 </div>
999 </li>
1000 </ul>
1001 </div>
1002 <?php
1005 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1008 * Render a dump for an array
1010 * @param mixed $data
1011 * @param string $name
1012 * @access private
1013 * @static
1015 Function _array(&$data, $name) {
1017 <li class="krumo-child">
1019 <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
1020 <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
1021 onMouseOver="krumo.over(this);"
1022 onMouseOut="krumo.out(this);">
1024 <a class="krumo-name"><?php echo $name;?></a>
1025 (<em class="krumo-type">Array, <strong class="krumo-array-length"><?php echo
1026 (count($data)==1)
1027 ?("1 element")
1028 :(count($data)." elements");
1029 ?></strong></em>)
1032 <?php
1033 // callback ?
1035 if (is_callable($data)) {
1036 $_ = array_values($data);
1038 <span class="krumo-callback"> |
1039 (<em class="krumo-type">Callback</em>)
1040 <strong class="krumo-string"><?php
1041 echo htmlSpecialChars($_[0]);?>::<?php
1042 echo htmlSpecialChars($_[1]);?>();</strong></span>
1043 <?php
1047 </div>
1049 <?php if (count($data)) {
1050 krumo::_vars($data);
1051 } ?>
1052 </li>
1053 <?php
1056 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1059 * Render a dump for an object
1061 * @param mixed $data
1062 * @param string $name
1063 * @access private
1064 * @static
1066 Function _object(&$data, $name) {
1068 <li class="krumo-child">
1070 <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
1071 <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
1072 onMouseOver="krumo.over(this);"
1073 onMouseOut="krumo.out(this);">
1075 <a class="krumo-name"><?php echo $name;?></a>
1076 (<em class="krumo-type">Object</em>)
1077 <strong class="krumo-class"><?php echo get_class($data);?></strong>
1078 </div>
1080 <?php if (count($data)) {
1081 krumo::_vars($data);
1082 } ?>
1083 </li>
1084 <?php
1087 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1090 * Render a dump for a resource
1092 * @param mixed $data
1093 * @param string $name
1094 * @access private
1095 * @static
1097 Function _resource($data, $name) {
1099 <li class="krumo-child">
1101 <div class="krumo-element"
1102 onMouseOver="krumo.over(this);"
1103 onMouseOut="krumo.out(this);">
1105 <a class="krumo-name"><?php echo $name;?></a>
1106 (<em class="krumo-type">Resource</em>)
1107 <strong class="krumo-resource"><?php echo get_resource_type($data);?></strong>
1108 </div>
1110 </li>
1111 <?php
1114 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1117 * Render a dump for a boolean value
1119 * @param mixed $data
1120 * @param string $name
1121 * @access private
1122 * @static
1124 Function _boolean($data, $name) {
1126 <li class="krumo-child">
1128 <div class="krumo-element"
1129 onMouseOver="krumo.over(this);"
1130 onMouseOut="krumo.out(this);">
1132 <a class="krumo-name"><?php echo $name;?></a>
1133 (<em class="krumo-type">Boolean</em>)
1134 <strong class="krumo-boolean"><?php echo $data?'TRUE':'FALSE'?></strong>
1135 </div>
1137 </li>
1138 <?php
1141 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1144 * Render a dump for a integer value
1146 * @param mixed $data
1147 * @param string $name
1148 * @access private
1149 * @static
1151 Function _integer($data, $name) {
1153 <li class="krumo-child">
1155 <div class="krumo-element"
1156 onMouseOver="krumo.over(this);"
1157 onMouseOut="krumo.out(this);">
1159 <a class="krumo-name"><?php echo $name;?></a>
1160 (<em class="krumo-type">Integer</em>)
1161 <strong class="krumo-integer"><?php echo $data;?></strong>
1162 </div>
1164 </li>
1165 <?php
1168 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1171 * Render a dump for a float value
1173 * @param mixed $data
1174 * @param string $name
1175 * @access private
1176 * @static
1178 Function _float($data, $name) {
1180 <li class="krumo-child">
1182 <div class="krumo-element"
1183 onMouseOver="krumo.over(this);"
1184 onMouseOut="krumo.out(this);">
1186 <a class="krumo-name"><?php echo $name;?></a>
1187 (<em class="krumo-type">Float</em>)
1188 <strong class="krumo-float"><?php echo $data;?></strong>
1189 </div>
1191 </li>
1192 <?php
1195 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1198 * Render a dump for a string value
1200 * @param mixed $data
1201 * @param string $name
1202 * @access private
1203 * @static
1205 Function _string($data, $name) {
1207 // extra ?
1209 $_extra = false;
1210 $_ = $data;
1211 if (strLen($data) > KRUMO_TRUNCATE_LENGTH) {
1212 $_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...';
1213 $_extra = true;
1216 <li class="krumo-child">
1218 <div class="krumo-element<?php echo $_extra ? ' krumo-expand' : '';?>"
1219 <?php if ($_extra) {?> onClick="krumo.toggle(this);"<?php } ?>
1220 onMouseOver="krumo.over(this);"
1221 onMouseOut="krumo.out(this);">
1223 <a class="krumo-name"><?php echo $name;?></a>
1224 (<em class="krumo-type">String,
1225 <strong class="krumo-string-length"><?php
1226 echo strlen($data) ?> characters</strong> </em>)
1227 <strong class="krumo-string"><?php echo htmlSpecialChars($_);?></strong>
1229 <?php
1230 // callback ?
1232 if (is_callable($data)) {
1234 <span class="krumo-callback"> |
1235 (<em class="krumo-type">Callback</em>)
1236 <strong class="krumo-string"><?php echo htmlSpecialChars($_);?>();</strong></span>
1237 <?php
1241 </div>
1243 <?php if ($_extra) { ?>
1244 <div class="krumo-nest" style="display:none;">
1245 <ul class="krumo-node">
1247 <li class="krumo-child">
1248 <div class="krumo-preview"><?php echo htmlSpecialChars($data);?></div>
1249 </li>
1251 </ul>
1252 </div>
1253 <?php } ?>
1254 </li>
1255 <?php
1258 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1260 //--end-of-class--
1263 //////////////////////////////////////////////////////////////////////////////
1266 * Alias of {@link krumo::dump()}
1268 * @param mixed $data,...
1270 * @see krumo::dump()
1272 Function krumo() {
1273 $_ = func_get_args();
1274 return call_user_func_array(
1275 array('krumo', 'dump'), $_
1279 //////////////////////////////////////////////////////////////////////////////