| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Krumo: Structured information display solution 4 * 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. 8 * 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 11 * 12 * @package Krumo 13 * @version $Id: class.krumo.php,v 1.1.2.5 2009/09/23 18:14:19 davereid Exp $ 14 */ 15 16 ////////////////////////////////////////////////////////////////////////////// 17 18 /** 19 * backward compatibility: the DIR_SEP constant isn't used anymore 20 */ 21 if(!defined('DIR_SEP')) { 22 define('DIR_SEP', DIRECTORY_SEPARATOR); 23 } 24 /** 25 * backward compatibility: the PATH_SEPARATOR constant is availble since 4.3.0RC2 26 */ 27 if (!defined('PATH_SEPARATOR')) { 28 define('PATH_SEPARATOR', OS_WINDOWS ? ';' : ':'); 29 } 30 31 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 32 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. 37 */ 38 if (!defined('KRUMO_DIR')) { 39 define('KRUMO_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); 40 } 41 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. 46 */ 47 if (!defined('KRUMO_TRUNCATE_LENGTH')) { 48 define('KRUMO_TRUNCATE_LENGTH', 50); 49 } 50 51 ////////////////////////////////////////////////////////////////////////////// 52 53 /** 54 * Krumo API 55 * 56 * This class stores the Krumo API for rendering and 57 * displaying the structured information it is reporting 58 * 59 * @package Krumo 60 */ 61 Class krumo { 62 63 /** 64 * Return Krumo version 65 * 66 * @return string 67 * @access public 68 * @static 69 */ 70 Function version() { 71 return '0.2a'; 72 } 73 74 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 75 76 /** 77 * Prints a debug backtrace 78 * 79 * @access public 80 * @static 81 */ 82 Function backtrace() { 83 84 // disabled ? 85 // 86 if (!krumo::_debug()) { 87 return false; 88 } 89 90 // render it 91 // 92 return krumo::dump(debug_backtrace()); 93 } 94 95 /** 96 * Prints a list of all currently declared classes. 97 * 98 * @access public 99 * @static 100 */ 101 Function classes() { 102 103 // disabled ? 104 // 105 if (!krumo::_debug()) { 106 return false; 107 } 108 109 // render it 110 // 111 ?> 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()); 117 } 118 119 /** 120 * Prints a list of all currently declared interfaces (PHP5 only). 121 * 122 * @access public 123 * @static 124 */ 125 Function interfaces() { 126 127 // disabled ? 128 // 129 if (!krumo::_debug()) { 130 return false; 131 } 132 133 // render it 134 // 135 ?> 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()); 141 } 142 143 /** 144 * Prints a list of all currently included (or required) files. 145 * 146 * @access public 147 * @static 148 */ 149 Function includes() { 150 151 // disabled ? 152 // 153 if (!krumo::_debug()) { 154 return false; 155 } 156 157 // render it 158 // 159 ?> 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()); 165 } 166 167 /** 168 * Prints a list of all currently declared functions. 169 * 170 * @access public 171 * @static 172 */ 173 Function functions() { 174 175 // disabled ? 176 // 177 if (!krumo::_debug()) { 178 return false; 179 } 180 181 // render it 182 // 183 ?> 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()); 189 } 190 191 /** 192 * Prints a list of all currently declared constants. 193 * 194 * @access public 195 * @static 196 */ 197 Function defines() { 198 199 // disabled ? 200 // 201 if (!krumo::_debug()) { 202 return false; 203 } 204 205 // render it 206 // 207 ?> 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()); 213 } 214 215 /** 216 * Prints a list of all currently loaded PHP extensions. 217 * 218 * @access public 219 * @static 220 */ 221 Function extensions() { 222 223 // disabled ? 224 // 225 if (!krumo::_debug()) { 226 return false; 227 } 228 229 // render it 230 // 231 ?> 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()); 237 } 238 239 /** 240 * Prints a list of all HTTP request headers. 241 * 242 * @access public 243 * @static 244 */ 245 Function headers() { 246 247 // disabled ? 248 // 249 if (!krumo::_debug()) { 250 return false; 251 } 252 253 // render it 254 // 255 ?> 256 <div class="krumo-title"> 257 This is a list of all HTTP request headers. 258 </div> 259 <?php 260 return krumo::dump(getAllHeaders()); 261 } 262 263 /** 264 * Prints a list of the configuration settings read from <i>php.ini</i> 265 * 266 * @access public 267 * @static 268 */ 269 Function phpini() { 270 271 // disabled ? 272 // 273 if (!krumo::_debug()) { 274 return false; 275 } 276 277 // render it 278 // 279 ?> 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)); 285 } 286 287 /** 288 * Prints a list of all your configuration settings. 289 * 290 * @access public 291 * @static 292 */ 293 Function conf() { 294 295 // disabled ? 296 // 297 if (!krumo::_debug()) { 298 return false; 299 } 300 301 // render it 302 // 303 ?> 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()); 309 } 310 311 /** 312 * Prints a list of the specified directories under your <i>include_path</i> option. 313 * 314 * @access public 315 * @static 316 */ 317 Function path() { 318 319 // disabled ? 320 // 321 if (!krumo::_debug()) { 322 return false; 323 } 324 325 // render it 326 // 327 ?> 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'))); 333 } 334 335 /** 336 * Prints a list of all the values from the <i>$_REQUEST</i> array. 337 * 338 * @access public 339 * @static 340 */ 341 Function request() { 342 343 // disabled ? 344 // 345 if (!krumo::_debug()) { 346 return false; 347 } 348 349 // render it 350 // 351 ?> 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); 357 } 358 359 /** 360 * Prints a list of all the values from the <i>$_GET</i> array. 361 * 362 * @access public 363 * @static 364 */ 365 Function get() { 366 367 // disabled ? 368 // 369 if (!krumo::_debug()) { 370 return false; 371 } 372 373 // render it 374 // 375 ?> 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); 381 } 382 383 /** 384 * Prints a list of all the values from the <i>$_POST</i> array. 385 * 386 * @access public 387 * @static 388 */ 389 Function post() { 390 391 // disabled ? 392 // 393 if (!krumo::_debug()) { 394 return false; 395 } 396 397 // render it 398 // 399 ?> 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); 405 } 406 407 /** 408 * Prints a list of all the values from the <i>$_SERVER</i> array. 409 * 410 * @access public 411 * @static 412 */ 413 Function server() { 414 415 // disabled ? 416 // 417 if (!krumo::_debug()) { 418 return false; 419 } 420 421 // render it 422 // 423 ?> 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); 429 } 430 431 /** 432 * Prints a list of all the values from the <i>$_COOKIE</i> array. 433 * 434 * @access public 435 * @static 436 */ 437 Function cookie() { 438 439 // disabled ? 440 // 441 if (!krumo::_debug()) { 442 return false; 443 } 444 445 // render it 446 // 447 ?> 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); 453 } 454 455 /** 456 * Prints a list of all the values from the <i>$_ENV</i> array. 457 * 458 * @access public 459 * @static 460 */ 461 Function env() { 462 463 // disabled ? 464 // 465 if (!krumo::_debug()) { 466 return false; 467 } 468 469 // render it 470 // 471 ?> 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); 477 } 478 479 /** 480 * Prints a list of all the values from the <i>$_SESSION</i> array. 481 * 482 * @access public 483 * @static 484 */ 485 Function session() { 486 487 // disabled ? 488 // 489 if (!krumo::_debug()) { 490 return false; 491 } 492 493 // render it 494 // 495 ?> 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); 501 } 502 503 /** 504 * Prints a list of all the values from an INI file. 505 * 506 * @param string $ini_file 507 * 508 * @access public 509 * @static 510 */ 511 Function ini($ini_file) { 512 513 // disabled ? 514 // 515 if (!krumo::_debug()) { 516 return false; 517 } 518 519 // read it 520 // 521 if (!$_ = @parse_ini_file($ini_file, 1)) { 522 return false; 523 } 524 525 // render it 526 // 527 ?> 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($_); 533 } 534 535 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 536 537 /** 538 * Dump information about a variable 539 * 540 * @param mixed $data,... 541 * @access public 542 * @static 543 */ 544 Function dump($data) { 545 546 // disabled ? 547 // 548 if (!krumo::_debug()) { 549 return false; 550 } 551 552 // more arguments ? 553 // 554 if (func_num_args() > 1) { 555 $_ = func_get_args(); 556 foreach($_ as $d) { 557 krumo::dump($d); 558 } 559 return; 560 } 561 562 // the css ? 563 // 564 krumo::_css(); 565 566 // find caller 567 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; 574 } 575 } 576 577 // the content 578 // 579 ?> 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> 589 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 596 </li> 597 </ul> 598 </div> 599 <?php 600 // flee the hive 601 // 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]); 609 } 610 } 611 } 612 613 // PHP 4.x.x array reference bug... 614 // 615 if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) { 616 unset($GLOBALS[krumo::_marker()]); 617 } 618 } 619 620 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 621 622 /** 623 * Print the skin (CSS) 624 * 625 * @return boolean 626 * @access private 627 * @static 628 */ 629 Function _css() { 630 631 static $_css = false; 632 633 // already set ? 634 // 635 if ($_css) { 636 return true; 637 } 638 639 $css = ''; 640 641 // DEVEL: changed for Drupal variables system 642 $skin = variable_get('devel_krumo_skin', 'orange'); 643 644 // custom selected skin ? 645 // 646 $_ = KRUMO_DIR . "skins/{$skin}/skin.css"; 647 if ($fp = @fopen($_, 'r', 1)) { 648 $css = fread($fp, filesize($_)); 649 fclose($fp); 650 } 651 652 // defautl skin ? 653 // 654 if (!$css && ($skin != 'default')) { 655 $skin = 'default'; 656 $_ = KRUMO_DIR . "skins/default/skin.css"; 657 $css = join('', @file($_)); 658 } 659 660 // print ? 661 // 662 if ($_css = $css != '') { 663 664 // fix the urls 665 // 666 667 // DEVEL: changed for Drupal path system. 668 $css_url = base_path() . drupal_get_path('module', 'devel') . "/krumo/skins/{$skin}/"; 669 670 $css = preg_replace('~%url%~Uis', $css_url, $css); 671 672 // the CSS 673 // 674 ?> 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?> 679 680 /**/--> 681 </style> 682 <?php 683 // the JS 684 // 685 ?> 686 <script type="text/javascript"> 687 <!--// 688 <?php echo join(file(KRUMO_DIR . "krumo.js"));?> 689 690 //--> 691 </script> 692 <?php 693 } 694 695 return $_css; 696 } 697 698 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 699 700 /** 701 * Enable Krumo 702 * 703 * @return boolean 704 * @access public 705 * @static 706 */ 707 Function enable() { 708 return true === krumo::_debug(true); 709 } 710 711 /** 712 * Disable Krumo 713 * 714 * @return boolean 715 * @access public 716 * @static 717 */ 718 Function disable() { 719 return false === krumo::_debug(false); 720 } 721 722 /** 723 * Get\Set Krumo state: whether it is enabled or disabled 724 * 725 * @param boolean $state 726 * @return boolean 727 * @access private 728 * @static 729 */ 730 Function _debug($state=null) { 731 732 static $_ = true; 733 734 // set 735 // 736 if (isset($state)) { 737 $_ = (boolean) $state; 738 } 739 740 // get 741 // 742 return $_; 743 } 744 745 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 746 747 /** 748 * Dump information about a variable 749 * 750 * @param mixed $data 751 * @param string $name 752 * @access private 753 * @static 754 */ 755 Function _dump(&$data, $name='...') { 756 757 // object ? 758 // 759 if (is_object($data)) { 760 return krumo::_object($data, $name); 761 } 762 763 // array ? 764 // 765 if (is_array($data)) { 766 767 // PHP 4.x.x array reference bug... 768 // 769 if (version_compare(PHP_VERSION, "5", "<")) { 770 771 // prepare the GLOBAL reference list... 772 // 773 if (!isset($GLOBALS[krumo::_marker()])) { 774 $GLOBALS[krumo::_marker()] = array(); 775 } 776 if (!is_array($GLOBALS[krumo::_marker()])) { 777 $GLOBALS[krumo::_marker()] = (array) $GLOBALS[krumo::_marker()]; 778 } 779 780 // extract ? 781 // 782 if (!empty($GLOBALS[krumo::_marker()])) { 783 $d = array_shift($GLOBALS[krumo::_marker()]); 784 if (is_array($d)) { 785 $data = $d; 786 } 787 } 788 } 789 790 return krumo::_array($data, $name); 791 } 792 793 // resource ? 794 // 795 if (is_resource($data)) { 796 return krumo::_resource($data, $name); 797 } 798 799 // scalar ? 800 // 801 if (is_string($data)) { 802 return krumo::_string($data, $name); 803 } 804 805 if (is_float($data)) { 806 return krumo::_float($data, $name); 807 } 808 809 if (is_integer($data)) { 810 return krumo::_integer($data, $name); 811 } 812 813 if (is_bool($data)) { 814 return krumo::_boolean($data, $name); 815 } 816 817 // null ? 818 // 819 if (is_null($data)) { 820 return krumo::_null($name); 821 } 822 } 823 824 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 825 826 /** 827 * Render a dump for a NULL value 828 * 829 * @param string $name 830 * @return string 831 * @access private 832 * @static 833 */ 834 Function _null($name) { 835 ?> 836 <li class="krumo-child"> 837 <div class="krumo-element" 838 onMouseOver="krumo.over(this);" 839 onMouseOut="krumo.out(this);"> 840 841 <a class="krumo-name"><?php echo $name;?></a> 842 (<em class="krumo-type krumo-null">NULL</em>) 843 </div> 844 </li> 845 <?php 846 } 847 848 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 849 850 /** 851 * Return the marked used to stain arrays 852 * and objects in order to detect recursions 853 * 854 * @return string 855 * @access private 856 * @static 857 */ 858 Function _marker() { 859 860 static $_recursion_marker; 861 if (!isset($_recursion_marker)) { 862 $_recursion_marker = uniqid('krumo'); 863 } 864 865 return $_recursion_marker; 866 } 867 868 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 869 870 /** 871 * Adds a variable to the hive of arrays and objects which 872 * are tracked for whether they have recursive entries 873 * 874 * @param mixed &$bee either array or object, not a scallar vale 875 * @return array all the bees 876 * 877 * @access private 878 * @static 879 */ 880 Function &_hive(&$bee) { 881 882 static $_ = array(); 883 884 // new bee ? 885 // 886 if (!is_null($bee)) { 887 888 // stain it 889 // 890 $_recursion_marker = krumo::_marker(); 891 (is_object($bee)) 892 ? @($bee->$_recursion_marker++) 893 : @($bee[$_recursion_marker]++); 894 895 $_[0][] =& $bee; 896 } 897 898 // return all bees 899 // 900 return $_[0]; 901 } 902 903 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 904 905 /** 906 * Render a dump for the properties of an array or objeect 907 * 908 * @param mixed &$data 909 * @access private 910 * @static 911 */ 912 Function _vars(&$data) { 913 914 $_is_object = is_object($data); 915 916 // test for references in order to 917 // prevent endless recursion loops 918 // 919 $_recursion_marker = krumo::_marker(); 920 $_r = ($_is_object) 921 ? @$data->$_recursion_marker 922 : @$data[$_recursion_marker] ; 923 $_r = (integer) $_r; 924 925 // recursion detected 926 // 927 if ($_r > 0) { 928 return krumo::_recursion(); 929 } 930 931 // stain it 932 // 933 krumo::_hive($data); 934 935 // render it 936 // 937 ?> 938 <div class="krumo-nest" style="display:none;"> 939 <ul class="krumo-node"> 940 <?php 941 942 // keys ? 943 // 944 $keys = ($_is_object) 945 ? array_keys(get_object_vars($data)) 946 : array_keys($data); 947 948 // itterate 949 // 950 foreach($keys as $k) { 951 952 // skip marker 953 // 954 if ($k === $_recursion_marker) { 955 continue; 956 } 957 958 // get real value 959 // 960 if ($_is_object) { 961 $v =& $data->$k; 962 } else { 963 $v =& $data[$k]; 964 } 965 966 // PHP 4.x.x array reference bug... 967 // 968 if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) { 969 $GLOBALS[krumo::_marker()][] =& $v; 970 } 971 972 krumo::_dump($v,$k); 973 } ?> 974 </ul> 975 </div> 976 <?php 977 } 978 979 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 980 981 /** 982 * Render a block that detected recursion 983 * 984 * @access private 985 * @static 986 */ 987 Function _recursion() { 988 ?> 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>∞</big></a> 996 (<em class="krumo-type">Recursion</em>) 997 </div> 998 999 </li> 1000 </ul> 1001 </div> 1002 <?php 1003 } 1004 1005 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1006 1007 /** 1008 * Render a dump for an array 1009 * 1010 * @param mixed $data 1011 * @param string $name 1012 * @access private 1013 * @static 1014 */ 1015 Function _array(&$data, $name) { 1016 ?> 1017 <li class="krumo-child"> 1018 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);"> 1023 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>) 1030 1031 1032 <?php 1033 // callback ? 1034 // 1035 if (is_callable($data)) { 1036 $_ = array_values($data); 1037 ?> 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 1044 } 1045 ?> 1046 1047 </div> 1048 1049 <?php if (count($data)) { 1050 krumo::_vars($data); 1051 } ?> 1052 </li> 1053 <?php 1054 } 1055 1056 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1057 1058 /** 1059 * Render a dump for an object 1060 * 1061 * @param mixed $data 1062 * @param string $name 1063 * @access private 1064 * @static 1065 */ 1066 Function _object(&$data, $name) { 1067 ?> 1068 <li class="krumo-child"> 1069 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);"> 1074 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> 1079 1080 <?php if (count($data)) { 1081 krumo::_vars($data); 1082 } ?> 1083 </li> 1084 <?php 1085 } 1086 1087 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1088 1089 /** 1090 * Render a dump for a resource 1091 * 1092 * @param mixed $data 1093 * @param string $name 1094 * @access private 1095 * @static 1096 */ 1097 Function _resource($data, $name) { 1098 ?> 1099 <li class="krumo-child"> 1100 1101 <div class="krumo-element" 1102 onMouseOver="krumo.over(this);" 1103 onMouseOut="krumo.out(this);"> 1104 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> 1109 1110 </li> 1111 <?php 1112 } 1113 1114 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1115 1116 /** 1117 * Render a dump for a boolean value 1118 * 1119 * @param mixed $data 1120 * @param string $name 1121 * @access private 1122 * @static 1123 */ 1124 Function _boolean($data, $name) { 1125 ?> 1126 <li class="krumo-child"> 1127 1128 <div class="krumo-element" 1129 onMouseOver="krumo.over(this);" 1130 onMouseOut="krumo.out(this);"> 1131 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> 1136 1137 </li> 1138 <?php 1139 } 1140 1141 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1142 1143 /** 1144 * Render a dump for a integer value 1145 * 1146 * @param mixed $data 1147 * @param string $name 1148 * @access private 1149 * @static 1150 */ 1151 Function _integer($data, $name) { 1152 ?> 1153 <li class="krumo-child"> 1154 1155 <div class="krumo-element" 1156 onMouseOver="krumo.over(this);" 1157 onMouseOut="krumo.out(this);"> 1158 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> 1163 1164 </li> 1165 <?php 1166 } 1167 1168 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1169 1170 /** 1171 * Render a dump for a float value 1172 * 1173 * @param mixed $data 1174 * @param string $name 1175 * @access private 1176 * @static 1177 */ 1178 Function _float($data, $name) { 1179 ?> 1180 <li class="krumo-child"> 1181 1182 <div class="krumo-element" 1183 onMouseOver="krumo.over(this);" 1184 onMouseOut="krumo.out(this);"> 1185 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> 1190 1191 </li> 1192 <?php 1193 } 1194 1195 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1196 1197 /** 1198 * Render a dump for a string value 1199 * 1200 * @param mixed $data 1201 * @param string $name 1202 * @access private 1203 * @static 1204 */ 1205 Function _string($data, $name) { 1206 1207 // extra ? 1208 // 1209 $_extra = false; 1210 $_ = $data; 1211 if (strLen($data) > KRUMO_TRUNCATE_LENGTH) { 1212 $_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...'; 1213 $_extra = true; 1214 } 1215 ?> 1216 <li class="krumo-child"> 1217 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);"> 1222 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> 1228 1229 <?php 1230 // callback ? 1231 // 1232 if (is_callable($data)) { 1233 ?> 1234 <span class="krumo-callback"> | 1235 (<em class="krumo-type">Callback</em>) 1236 <strong class="krumo-string"><?php echo htmlSpecialChars($_);?>();</strong></span> 1237 <?php 1238 } 1239 ?> 1240 1241 </div> 1242 1243 <?php if ($_extra) { ?> 1244 <div class="krumo-nest" style="display:none;"> 1245 <ul class="krumo-node"> 1246 1247 <li class="krumo-child"> 1248 <div class="krumo-preview"><?php echo htmlSpecialChars($data);?></div> 1249 </li> 1250 1251 </ul> 1252 </div> 1253 <?php } ?> 1254 </li> 1255 <?php 1256 } 1257 1258 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1259 1260 //--end-of-class-- 1261 } 1262 1263 ////////////////////////////////////////////////////////////////////////////// 1264 1265 /** 1266 * Alias of {@link krumo::dump()} 1267 * 1268 * @param mixed $data,... 1269 * 1270 * @see krumo::dump() 1271 */ 1272 Function krumo() { 1273 $_ = func_get_args(); 1274 return call_user_func_array( 1275 array('krumo', 'dump'), $_ 1276 ); 1277 } 1278 1279 ////////////////////////////////////////////////////////////////////////////// 1280 1281 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |