PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/drupal/profile/neurohub_commons/modules/contrib/devel/krumo/class.krumo.php

https://bitbucket.org/drn05r/neurohub-dev-davidn
PHP | 1281 lines | 597 code | 193 blank | 491 comment | 74 complexity | 7cf2d6d540027b9629b5fe86791590b2 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, BSD-3-Clause, LGPL-2.1, MPL-2.0-no-copyleft-exception
  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. * backward compatibility: the DIR_SEP constant isn't used anymore
  18. */
  19. if(!defined('DIR_SEP')) {
  20. define('DIR_SEP', DIRECTORY_SEPARATOR);
  21. }
  22. /**
  23. * backward compatibility: the PATH_SEPARATOR constant is availble since 4.3.0RC2
  24. */
  25. if (!defined('PATH_SEPARATOR')) {
  26. define('PATH_SEPARATOR', OS_WINDOWS ? ';' : ':');
  27. }
  28. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  29. /**
  30. * Set the KRUMO_DIR constant up with the absolute path to Krumo files. If it is
  31. * not defined, include_path will be used. Set KRUMO_DIR only if any other module
  32. * or application has not already set it up.
  33. */
  34. if (!defined('KRUMO_DIR')) {
  35. define('KRUMO_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  36. }
  37. /**
  38. * This constant sets the maximum strings of strings that will be shown
  39. * as they are. Longer strings will be truncated with this length, and
  40. * their `full form` will be shown in a child node.
  41. */
  42. if (!defined('KRUMO_TRUNCATE_LENGTH')) {
  43. define('KRUMO_TRUNCATE_LENGTH', 50);
  44. }
  45. //////////////////////////////////////////////////////////////////////////////
  46. /**
  47. * Krumo API
  48. *
  49. * This class stores the Krumo API for rendering and
  50. * displaying the structured information it is reporting
  51. *
  52. * @package Krumo
  53. */
  54. Class krumo {
  55. /**
  56. * Return Krumo version
  57. *
  58. * @return string
  59. * @access public
  60. * @static
  61. */
  62. Function version() {
  63. return '0.2a';
  64. }
  65. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  66. /**
  67. * Prints a debug backtrace
  68. *
  69. * @access public
  70. * @static
  71. */
  72. Function backtrace() {
  73. // disabled ?
  74. //
  75. if (!krumo::_debug()) {
  76. return false;
  77. }
  78. // render it
  79. //
  80. return krumo::dump(debug_backtrace());
  81. }
  82. /**
  83. * Prints a list of all currently declared classes.
  84. *
  85. * @access public
  86. * @static
  87. */
  88. Function classes() {
  89. // disabled ?
  90. //
  91. if (!krumo::_debug()) {
  92. return false;
  93. }
  94. // render it
  95. //
  96. ?>
  97. <div class="krumo-title">
  98. This is a list of all currently declared classes.
  99. </div>
  100. <?php
  101. return krumo::dump(get_declared_classes());
  102. }
  103. /**
  104. * Prints a list of all currently declared interfaces (PHP5 only).
  105. *
  106. * @access public
  107. * @static
  108. */
  109. Function interfaces() {
  110. // disabled ?
  111. //
  112. if (!krumo::_debug()) {
  113. return false;
  114. }
  115. // render it
  116. //
  117. ?>
  118. <div class="krumo-title">
  119. This is a list of all currently declared interfaces.
  120. </div>
  121. <?php
  122. return krumo::dump(get_declared_interfaces());
  123. }
  124. /**
  125. * Prints a list of all currently included (or required) files.
  126. *
  127. * @access public
  128. * @static
  129. */
  130. Function includes() {
  131. // disabled ?
  132. //
  133. if (!krumo::_debug()) {
  134. return false;
  135. }
  136. // render it
  137. //
  138. ?>
  139. <div class="krumo-title">
  140. This is a list of all currently included (or required) files.
  141. </div>
  142. <?php
  143. return krumo::dump(get_included_files());
  144. }
  145. /**
  146. * Prints a list of all currently declared functions.
  147. *
  148. * @access public
  149. * @static
  150. */
  151. Function functions() {
  152. // disabled ?
  153. //
  154. if (!krumo::_debug()) {
  155. return false;
  156. }
  157. // render it
  158. //
  159. ?>
  160. <div class="krumo-title">
  161. This is a list of all currently declared functions.
  162. </div>
  163. <?php
  164. return krumo::dump(get_defined_functions());
  165. }
  166. /**
  167. * Prints a list of all currently declared constants.
  168. *
  169. * @access public
  170. * @static
  171. */
  172. Function defines() {
  173. // disabled ?
  174. //
  175. if (!krumo::_debug()) {
  176. return false;
  177. }
  178. // render it
  179. //
  180. ?>
  181. <div class="krumo-title">
  182. This is a list of all currently declared constants (defines).
  183. </div>
  184. <?php
  185. return krumo::dump(get_defined_constants());
  186. }
  187. /**
  188. * Prints a list of all currently loaded PHP extensions.
  189. *
  190. * @access public
  191. * @static
  192. */
  193. Function extensions() {
  194. // disabled ?
  195. //
  196. if (!krumo::_debug()) {
  197. return false;
  198. }
  199. // render it
  200. //
  201. ?>
  202. <div class="krumo-title">
  203. This is a list of all currently loaded PHP extensions.
  204. </div>
  205. <?php
  206. return krumo::dump(get_loaded_extensions());
  207. }
  208. /**
  209. * Prints a list of all HTTP request headers.
  210. *
  211. * @access public
  212. * @static
  213. */
  214. Function headers() {
  215. // disabled ?
  216. //
  217. if (!krumo::_debug()) {
  218. return false;
  219. }
  220. // render it
  221. //
  222. ?>
  223. <div class="krumo-title">
  224. This is a list of all HTTP request headers.
  225. </div>
  226. <?php
  227. return krumo::dump(getAllHeaders());
  228. }
  229. /**
  230. * Prints a list of the configuration settings read from <i>php.ini</i>
  231. *
  232. * @access public
  233. * @static
  234. */
  235. Function phpini() {
  236. // disabled ?
  237. //
  238. if (!krumo::_debug()) {
  239. return false;
  240. }
  241. // render it
  242. //
  243. ?>
  244. <div class="krumo-title">
  245. This is a list of the configuration settings read from <code><b><?php echo get_cfg_var('cfg_file_path');?></b></code>.
  246. </div>
  247. <?php
  248. return krumo::dump(parse_ini_file(get_cfg_var('cfg_file_path'), true));
  249. }
  250. /**
  251. * Prints a list of all your configuration settings.
  252. *
  253. * @access public
  254. * @static
  255. */
  256. Function conf() {
  257. // disabled ?
  258. //
  259. if (!krumo::_debug()) {
  260. return false;
  261. }
  262. // render it
  263. //
  264. ?>
  265. <div class="krumo-title">
  266. This is a list of all your configuration settings.
  267. </div>
  268. <?php
  269. return krumo::dump(ini_get_all());
  270. }
  271. /**
  272. * Prints a list of the specified directories under your <i>include_path</i> option.
  273. *
  274. * @access public
  275. * @static
  276. */
  277. Function path() {
  278. // disabled ?
  279. //
  280. if (!krumo::_debug()) {
  281. return false;
  282. }
  283. // render it
  284. //
  285. ?>
  286. <div class="krumo-title">
  287. This is a list of the specified directories under your <code><b>include_path</b></code> option.
  288. </div>
  289. <?php
  290. return krumo::dump(explode(PATH_SEPARATOR, ini_get('include_path')));
  291. }
  292. /**
  293. * Prints a list of all the values from the <i>$_REQUEST</i> array.
  294. *
  295. * @access public
  296. * @static
  297. */
  298. Function request() {
  299. // disabled ?
  300. //
  301. if (!krumo::_debug()) {
  302. return false;
  303. }
  304. // render it
  305. //
  306. ?>
  307. <div class="krumo-title">
  308. This is a list of all the values from the <code><b>$_REQUEST</b></code> array.
  309. </div>
  310. <?php
  311. return krumo::dump($_REQUEST);
  312. }
  313. /**
  314. * Prints a list of all the values from the <i>$_GET</i> array.
  315. *
  316. * @access public
  317. * @static
  318. */
  319. Function get() {
  320. // disabled ?
  321. //
  322. if (!krumo::_debug()) {
  323. return false;
  324. }
  325. // render it
  326. //
  327. ?>
  328. <div class="krumo-title">
  329. This is a list of all the values from the <code><b>$_GET</b></code> array.
  330. </div>
  331. <?php
  332. return krumo::dump($_GET);
  333. }
  334. /**
  335. * Prints a list of all the values from the <i>$_POST</i> array.
  336. *
  337. * @access public
  338. * @static
  339. */
  340. Function post() {
  341. // disabled ?
  342. //
  343. if (!krumo::_debug()) {
  344. return false;
  345. }
  346. // render it
  347. //
  348. ?>
  349. <div class="krumo-title">
  350. This is a list of all the values from the <code><b>$_POST</b></code> array.
  351. </div>
  352. <?php
  353. return krumo::dump($_POST);
  354. }
  355. /**
  356. * Prints a list of all the values from the <i>$_SERVER</i> array.
  357. *
  358. * @access public
  359. * @static
  360. */
  361. Function server() {
  362. // disabled ?
  363. //
  364. if (!krumo::_debug()) {
  365. return false;
  366. }
  367. // render it
  368. //
  369. ?>
  370. <div class="krumo-title">
  371. This is a list of all the values from the <code><b>$_SERVER</b></code> array.
  372. </div>
  373. <?php
  374. return krumo::dump($_SERVER);
  375. }
  376. /**
  377. * Prints a list of all the values from the <i>$_COOKIE</i> array.
  378. *
  379. * @access public
  380. * @static
  381. */
  382. Function cookie() {
  383. // disabled ?
  384. //
  385. if (!krumo::_debug()) {
  386. return false;
  387. }
  388. // render it
  389. //
  390. ?>
  391. <div class="krumo-title">
  392. This is a list of all the values from the <code><b>$_COOKIE</b></code> array.
  393. </div>
  394. <?php
  395. return krumo::dump($_COOKIE);
  396. }
  397. /**
  398. * Prints a list of all the values from the <i>$_ENV</i> array.
  399. *
  400. * @access public
  401. * @static
  402. */
  403. Function env() {
  404. // disabled ?
  405. //
  406. if (!krumo::_debug()) {
  407. return false;
  408. }
  409. // render it
  410. //
  411. ?>
  412. <div class="krumo-title">
  413. This is a list of all the values from the <code><b>$_ENV</b></code> array.
  414. </div>
  415. <?php
  416. return krumo::dump($_ENV);
  417. }
  418. /**
  419. * Prints a list of all the values from the <i>$_SESSION</i> array.
  420. *
  421. * @access public
  422. * @static
  423. */
  424. Function session() {
  425. // disabled ?
  426. //
  427. if (!krumo::_debug()) {
  428. return false;
  429. }
  430. // render it
  431. //
  432. ?>
  433. <div class="krumo-title">
  434. This is a list of all the values from the <code><b>$_SESSION</b></code> array.
  435. </div>
  436. <?php
  437. return krumo::dump($_SESSION);
  438. }
  439. /**
  440. * Prints a list of all the values from an INI file.
  441. *
  442. * @param string $ini_file
  443. *
  444. * @access public
  445. * @static
  446. */
  447. Function ini($ini_file) {
  448. // disabled ?
  449. //
  450. if (!krumo::_debug()) {
  451. return false;
  452. }
  453. // read it
  454. //
  455. if (!$_ = @parse_ini_file($ini_file, 1)) {
  456. return false;
  457. }
  458. // render it
  459. //
  460. ?>
  461. <div class="krumo-title">
  462. 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.
  463. </div>
  464. <?php
  465. return krumo::dump($_);
  466. }
  467. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  468. /**
  469. * Dump information about a variable
  470. *
  471. * @param mixed $data,...
  472. * @access public
  473. * @static
  474. */
  475. Function dump($data) {
  476. // disabled ?
  477. //
  478. if (!krumo::_debug()) {
  479. return false;
  480. }
  481. // more arguments ?
  482. //
  483. if (func_num_args() > 1) {
  484. $_ = func_get_args();
  485. foreach($_ as $d) {
  486. krumo::dump($d);
  487. }
  488. return;
  489. }
  490. // the css ?
  491. //
  492. krumo::_css();
  493. // find caller
  494. // DEVEL: we added array_reverse() so the proper file+line number is found.
  495. $_ = array_reverse(debug_backtrace());
  496. while($d = array_pop($_)) {
  497. // DEVEL: changed if() condition below
  498. if ((strpos(@$d['file'], 'devel') === FALSE) && (strpos(@$d['file'], 'krumo') === FALSE) && @$d['class'] != 'krumo') {
  499. break;
  500. }
  501. }
  502. // the content
  503. //
  504. ?>
  505. <div class="krumo-root" dir="ltr">
  506. <ul class="krumo-node krumo-first">
  507. <?php echo krumo::_dump($data);?>
  508. <li class="krumo-footnote">
  509. <div class="krumo-version" style="white-space:nowrap;">
  510. <h6>Krumo version <?php echo krumo::version();?></h6> | <a
  511. href="http://krumo.sourceforge.net"
  512. target="_blank">http://krumo.sourceforge.net</a>
  513. </div>
  514. <?php if (@$d['file']) { ?>
  515. <span class="krumo-call" style="white-space:nowrap;">
  516. Called from <code><?php echo $d['file']?></code>,
  517. line <code><?php echo $d['line']?></code></span>
  518. <?php } ?>
  519. &nbsp;
  520. </li>
  521. </ul>
  522. </div>
  523. <?php
  524. // flee the hive
  525. //
  526. $_recursion_marker = krumo::_marker();
  527. if ($hive =& krumo::_hive($dummy)) {
  528. foreach($hive as $i=>$bee){
  529. if (is_object($bee)) {
  530. unset($hive[$i]->$_recursion_marker);
  531. } else {
  532. unset($hive[$i][$_recursion_marker]);
  533. }
  534. }
  535. }
  536. // PHP 4.x.x array reference bug...
  537. //
  538. if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
  539. unset($GLOBALS[krumo::_marker()]);
  540. }
  541. }
  542. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  543. /**
  544. * Print the skin (CSS)
  545. *
  546. * @return boolean
  547. * @access private
  548. * @static
  549. */
  550. Function _css() {
  551. static $_css = false;
  552. // already set ?
  553. //
  554. if ($_css) {
  555. return true;
  556. }
  557. $css = '';
  558. // DEVEL: changed for Drupal variables system
  559. $skin = variable_get('devel_krumo_skin', 'orange');
  560. // custom selected skin ?
  561. //
  562. $_ = KRUMO_DIR . "skins/{$skin}/skin.css";
  563. if ($fp = @fopen($_, 'r', 1)) {
  564. $css = fread($fp, filesize($_));
  565. fclose($fp);
  566. }
  567. // defautl skin ?
  568. //
  569. if (!$css && ($skin != 'default')) {
  570. $skin = 'default';
  571. $_ = KRUMO_DIR . "skins/default/skin.css";
  572. $css = join('', @file($_));
  573. }
  574. // print ?
  575. //
  576. if ($_css = $css != '') {
  577. // fix the urls
  578. //
  579. // DEVEL: changed for Drupal path system.
  580. $css_url = base_path() . drupal_get_path('module', 'devel') . "/krumo/skins/{$skin}/";
  581. $css = preg_replace('~%url%~Uis', $css_url, $css);
  582. // the CSS
  583. //
  584. ?>
  585. <!-- Using Krumo Skin: <?php echo preg_replace('~^' . preg_quote(realpath(KRUMO_DIR) . DIRECTORY_SEPARATOR) . '~Uis', '', realpath($_));?> -->
  586. <style type="text/css">
  587. <!--/**/
  588. <?php echo $css?>
  589. /**/-->
  590. </style>
  591. <?php
  592. // the JS
  593. //
  594. ?>
  595. <script type="text/javascript">
  596. <!--//
  597. <?php echo join(file(KRUMO_DIR . "krumo.js"));?>
  598. //-->
  599. </script>
  600. <?php
  601. }
  602. return $_css;
  603. }
  604. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  605. /**
  606. * Enable Krumo
  607. *
  608. * @return boolean
  609. * @access public
  610. * @static
  611. */
  612. Function enable() {
  613. return true === krumo::_debug(true);
  614. }
  615. /**
  616. * Disable Krumo
  617. *
  618. * @return boolean
  619. * @access public
  620. * @static
  621. */
  622. Function disable() {
  623. return false === krumo::_debug(false);
  624. }
  625. /**
  626. * Get\Set Krumo state: whether it is enabled or disabled
  627. *
  628. * @param boolean $state
  629. * @return boolean
  630. * @access private
  631. * @static
  632. */
  633. Function _debug($state=null) {
  634. static $_ = true;
  635. // set
  636. //
  637. if (isset($state)) {
  638. $_ = (boolean) $state;
  639. }
  640. // get
  641. //
  642. return $_;
  643. }
  644. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  645. /**
  646. * Dump information about a variable
  647. *
  648. * @param mixed $data
  649. * @param string $name
  650. * @access private
  651. * @static
  652. */
  653. Function _dump(&$data, $name='...') {
  654. // object ?
  655. //
  656. if (is_object($data)) {
  657. return krumo::_object($data, $name);
  658. }
  659. // array ?
  660. //
  661. if (is_array($data)) {
  662. // PHP 4.x.x array reference bug...
  663. //
  664. if (version_compare(PHP_VERSION, "5", "<")) {
  665. // prepare the GLOBAL reference list...
  666. //
  667. if (!isset($GLOBALS[krumo::_marker()])) {
  668. $GLOBALS[krumo::_marker()] = array();
  669. }
  670. if (!is_array($GLOBALS[krumo::_marker()])) {
  671. $GLOBALS[krumo::_marker()] = (array) $GLOBALS[krumo::_marker()];
  672. }
  673. // extract ?
  674. //
  675. if (!empty($GLOBALS[krumo::_marker()])) {
  676. $d = array_shift($GLOBALS[krumo::_marker()]);
  677. if (is_array($d)) {
  678. $data = $d;
  679. }
  680. }
  681. }
  682. return krumo::_array($data, $name);
  683. }
  684. // resource ?
  685. //
  686. if (is_resource($data)) {
  687. return krumo::_resource($data, $name);
  688. }
  689. // scalar ?
  690. //
  691. if (is_string($data)) {
  692. return krumo::_string($data, $name);
  693. }
  694. if (is_float($data)) {
  695. return krumo::_float($data, $name);
  696. }
  697. if (is_integer($data)) {
  698. return krumo::_integer($data, $name);
  699. }
  700. if (is_bool($data)) {
  701. return krumo::_boolean($data, $name);
  702. }
  703. // null ?
  704. //
  705. if (is_null($data)) {
  706. return krumo::_null($name);
  707. }
  708. }
  709. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  710. /**
  711. * Render a dump for a NULL value
  712. *
  713. * @param string $name
  714. * @return string
  715. * @access private
  716. * @static
  717. */
  718. Function _null($name) {
  719. ?>
  720. <li class="krumo-child">
  721. <div class="krumo-element"
  722. onMouseOver="krumo.over(this);"
  723. onMouseOut="krumo.out(this);">
  724. <a class="krumo-name"><?php echo $name;?></a>
  725. (<em class="krumo-type krumo-null">NULL</em>)
  726. </div>
  727. </li>
  728. <?php
  729. }
  730. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  731. /**
  732. * Return the marked used to stain arrays
  733. * and objects in order to detect recursions
  734. *
  735. * @return string
  736. * @access private
  737. * @static
  738. */
  739. Function _marker() {
  740. static $_recursion_marker;
  741. if (!isset($_recursion_marker)) {
  742. $_recursion_marker = uniqid('krumo');
  743. }
  744. return $_recursion_marker;
  745. }
  746. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  747. /**
  748. * Adds a variable to the hive of arrays and objects which
  749. * are tracked for whether they have recursive entries
  750. *
  751. * @param mixed &$bee either array or object, not a scallar vale
  752. * @return array all the bees
  753. *
  754. * @access private
  755. * @static
  756. */
  757. Function &_hive(&$bee) {
  758. static $_ = array();
  759. // new bee ?
  760. //
  761. if (!is_null($bee)) {
  762. // stain it
  763. //
  764. $_recursion_marker = krumo::_marker();
  765. (is_object($bee))
  766. ? @($bee->$_recursion_marker++)
  767. : @($bee[$_recursion_marker]++);
  768. $_[0][] =& $bee;
  769. }
  770. // return all bees
  771. //
  772. return $_[0];
  773. }
  774. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  775. /**
  776. * Render a dump for the properties of an array or objeect
  777. *
  778. * @param mixed &$data
  779. * @access private
  780. * @static
  781. */
  782. Function _vars(&$data) {
  783. $_is_object = is_object($data);
  784. // test for references in order to
  785. // prevent endless recursion loops
  786. //
  787. $_recursion_marker = krumo::_marker();
  788. $_r = ($_is_object)
  789. ? @$data->$_recursion_marker
  790. : @$data[$_recursion_marker] ;
  791. $_r = (integer) $_r;
  792. // recursion detected
  793. //
  794. if ($_r > 0) {
  795. return krumo::_recursion();
  796. }
  797. // stain it
  798. //
  799. krumo::_hive($data);
  800. // render it
  801. //
  802. ?>
  803. <div class="krumo-nest" style="display:none;">
  804. <ul class="krumo-node">
  805. <?php
  806. // keys ?
  807. //
  808. $keys = ($_is_object)
  809. ? array_keys(get_object_vars($data))
  810. : array_keys($data);
  811. // itterate
  812. //
  813. foreach($keys as $k) {
  814. // skip marker
  815. //
  816. if ($k === $_recursion_marker) {
  817. continue;
  818. }
  819. // get real value
  820. //
  821. if ($_is_object) {
  822. $v =& $data->$k;
  823. } else {
  824. $v =& $data[$k];
  825. }
  826. // PHP 4.x.x array reference bug...
  827. //
  828. if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
  829. $GLOBALS[krumo::_marker()][] =& $v;
  830. }
  831. krumo::_dump($v,$k);
  832. } ?>
  833. </ul>
  834. </div>
  835. <?php
  836. }
  837. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  838. /**
  839. * Render a block that detected recursion
  840. *
  841. * @access private
  842. * @static
  843. */
  844. Function _recursion() {
  845. ?>
  846. <div class="krumo-nest" style="display:none;">
  847. <ul class="krumo-node">
  848. <li class="krumo-child">
  849. <div class="krumo-element"
  850. onMouseOver="krumo.over(this);"
  851. onMouseOut="krumo.out(this);">
  852. <a class="krumo-name"><big>&#8734;</big></a>
  853. (<em class="krumo-type">Recursion</em>)
  854. </div>
  855. </li>
  856. </ul>
  857. </div>
  858. <?php
  859. }
  860. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  861. /**
  862. * Render a dump for an array
  863. *
  864. * @param mixed $data
  865. * @param string $name
  866. * @access private
  867. * @static
  868. */
  869. Function _array(&$data, $name) {
  870. ?>
  871. <li class="krumo-child">
  872. <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
  873. <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
  874. onMouseOver="krumo.over(this);"
  875. onMouseOut="krumo.out(this);">
  876. <a class="krumo-name"><?php echo $name;?></a>
  877. (<em class="krumo-type">Array, <strong class="krumo-array-length"><?php echo
  878. (count($data)==1)
  879. ?("1 element")
  880. :(count($data)." elements");
  881. ?></strong></em>)
  882. <?php
  883. // callback ?
  884. //
  885. if (is_callable($data)) {
  886. $_ = array_values($data);
  887. ?>
  888. <span class="krumo-callback"> |
  889. (<em class="krumo-type">Callback</em>)
  890. <strong class="krumo-string"><?php
  891. echo htmlSpecialChars($_[0]);?>::<?php
  892. echo htmlSpecialChars($_[1]);?>();</strong></span>
  893. <?php
  894. }
  895. ?>
  896. </div>
  897. <?php if (count($data)) {
  898. krumo::_vars($data);
  899. } ?>
  900. </li>
  901. <?php
  902. }
  903. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  904. /**
  905. * Render a dump for an object
  906. *
  907. * @param mixed $data
  908. * @param string $name
  909. * @access private
  910. * @static
  911. */
  912. Function _object(&$data, $name) {
  913. ?>
  914. <li class="krumo-child">
  915. <div class="krumo-element<?php echo count($data) > 0 ? ' krumo-expand' : '';?>"
  916. <?php if (count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
  917. onMouseOver="krumo.over(this);"
  918. onMouseOut="krumo.out(this);">
  919. <a class="krumo-name"><?php echo $name;?></a>
  920. (<em class="krumo-type">Object</em>)
  921. <strong class="krumo-class"><?php echo get_class($data);?></strong>
  922. </div>
  923. <?php if (count($data)) {
  924. krumo::_vars($data);
  925. } ?>
  926. </li>
  927. <?php
  928. }
  929. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  930. /**
  931. * Render a dump for a resource
  932. *
  933. * @param mixed $data
  934. * @param string $name
  935. * @access private
  936. * @static
  937. */
  938. Function _resource($data, $name) {
  939. ?>
  940. <li class="krumo-child">
  941. <div class="krumo-element"
  942. onMouseOver="krumo.over(this);"
  943. onMouseOut="krumo.out(this);">
  944. <a class="krumo-name"><?php echo $name;?></a>
  945. (<em class="krumo-type">Resource</em>)
  946. <strong class="krumo-resource"><?php echo get_resource_type($data);?></strong>
  947. </div>
  948. </li>
  949. <?php
  950. }
  951. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  952. /**
  953. * Render a dump for a boolean value
  954. *
  955. * @param mixed $data
  956. * @param string $name
  957. * @access private
  958. * @static
  959. */
  960. Function _boolean($data, $name) {
  961. ?>
  962. <li class="krumo-child">
  963. <div class="krumo-element"
  964. onMouseOver="krumo.over(this);"
  965. onMouseOut="krumo.out(this);">
  966. <a class="krumo-name"><?php echo $name;?></a>
  967. (<em class="krumo-type">Boolean</em>)
  968. <strong class="krumo-boolean"><?php echo $data?'TRUE':'FALSE'?></strong>
  969. </div>
  970. </li>
  971. <?php
  972. }
  973. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  974. /**
  975. * Render a dump for a integer value
  976. *
  977. * @param mixed $data
  978. * @param string $name
  979. * @access private
  980. * @static
  981. */
  982. Function _integer($data, $name) {
  983. ?>
  984. <li class="krumo-child">
  985. <div class="krumo-element"
  986. onMouseOver="krumo.over(this);"
  987. onMouseOut="krumo.out(this);">
  988. <a class="krumo-name"><?php echo $name;?></a>
  989. (<em class="krumo-type">Integer</em>)
  990. <strong class="krumo-integer"><?php echo $data;?></strong>
  991. </div>
  992. </li>
  993. <?php
  994. }
  995. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  996. /**
  997. * Render a dump for a float value
  998. *
  999. * @param mixed $data
  1000. * @param string $name
  1001. * @access private
  1002. * @static
  1003. */
  1004. Function _float($data, $name) {
  1005. ?>
  1006. <li class="krumo-child">
  1007. <div class="krumo-element"
  1008. onMouseOver="krumo.over(this);"
  1009. onMouseOut="krumo.out(this);">
  1010. <a class="krumo-name"><?php echo $name;?></a>
  1011. (<em class="krumo-type">Float</em>)
  1012. <strong class="krumo-float"><?php echo $data;?></strong>
  1013. </div>
  1014. </li>
  1015. <?php
  1016. }
  1017. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  1018. /**
  1019. * Render a dump for a string value
  1020. *
  1021. * @param mixed $data
  1022. * @param string $name
  1023. * @access private
  1024. * @static
  1025. */
  1026. Function _string($data, $name) {
  1027. // extra ?
  1028. //
  1029. $_extra = false;
  1030. $_ = $data;
  1031. if (strLen($data) > KRUMO_TRUNCATE_LENGTH) {
  1032. $_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...';
  1033. $_extra = true;
  1034. }
  1035. ?>
  1036. <li class="krumo-child">
  1037. <div class="krumo-element<?php echo $_extra ? ' krumo-expand' : '';?>"
  1038. <?php if ($_extra) {?> onClick="krumo.toggle(this);"<?php } ?>
  1039. onMouseOver="krumo.over(this);"
  1040. onMouseOut="krumo.out(this);">
  1041. <a class="krumo-name"><?php echo $name;?></a>
  1042. (<em class="krumo-type">String,
  1043. <strong class="krumo-string-length"><?php
  1044. echo strlen($data) ?> characters</strong> </em>)
  1045. <strong class="krumo-string"><?php echo htmlSpecialChars($_);?></strong>
  1046. <?php
  1047. // callback ?
  1048. //
  1049. if (is_callable($data)) {
  1050. ?>
  1051. <span class="krumo-callback"> |
  1052. (<em class="krumo-type">Callback</em>)
  1053. <strong class="krumo-string"><?php echo htmlSpecialChars($_);?>();</strong></span>
  1054. <?php
  1055. }
  1056. ?>
  1057. </div>
  1058. <?php if ($_extra) { ?>
  1059. <div class="krumo-nest" style="display:none;">
  1060. <ul class="krumo-node">
  1061. <li class="krumo-child">
  1062. <div class="krumo-preview"><?php echo htmlSpecialChars($data);?></div>
  1063. </li>
  1064. </ul>
  1065. </div>
  1066. <?php } ?>
  1067. </li>
  1068. <?php
  1069. }
  1070. // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  1071. //--end-of-class--
  1072. }
  1073. //////////////////////////////////////////////////////////////////////////////
  1074. /**
  1075. * Alias of {@link krumo::dump()}
  1076. *
  1077. * @param mixed $data,...
  1078. *
  1079. * @see krumo::dump()
  1080. */
  1081. Function krumo() {
  1082. $_ = func_get_args();
  1083. return call_user_func_array(
  1084. array('krumo', 'dump'), $_
  1085. );
  1086. }
  1087. //////////////////////////////////////////////////////////////////////////////
  1088. ?>