development.html.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. use lithium\analysis\Debugger;
  9. use lithium\analysis\Inspector;
  10. $exception = $info['exception'];
  11. $replace = array('&lt;?php', '?&gt;', '<code>', '</code>', "\n");
  12. $context = 5;
  13. /**
  14. * Set Lithium-esque colors for syntax highlighing.
  15. */
  16. ini_set('highlight.string', '#4DDB4A');
  17. ini_set('highlight.comment', '#D42AAE');
  18. ini_set('highlight.keyword', '#D42AAE');
  19. ini_set('highlight.default', '#3C96FF');
  20. ini_set('highlight.htm', '#FFFFFF');
  21. $stack = Debugger::trace(array('format' => 'array', 'trace' => $exception->getTrace()));
  22. array_unshift($stack, array(
  23. 'functionRef' => '[exception]',
  24. 'file' => $exception->getFile(),
  25. 'line' => $exception->getLine()
  26. ));
  27. ?>
  28. <h3>Exception</h3>
  29. <div class="lithium-exception-class">
  30. <?=get_class($exception);?>
  31. <?php if ($code = $exception->getCode()): ?>
  32. <span class="code">(code <?=$code; ?>)</span>
  33. <?php endif ?>
  34. </div>
  35. <div class="lithium-exception-message"><?=$exception->getMessage(); ?></div>
  36. <h3 id="source">Source</h3>
  37. <div id="sourceCode"></div>
  38. <h3>Stack Trace</h3>
  39. <div class="lithium-stack-trace">
  40. <ol>
  41. <?php foreach ($stack as $id => $frame): ?>
  42. <?php
  43. $location = "{$frame['file']}: {$frame['line']}";
  44. $lines = range($frame['line'] - $context, $frame['line'] + $context);
  45. $code = Inspector::lines($frame['file'], $lines);
  46. ?>
  47. <li>
  48. <tt><a href="#source" id="<?=$id; ?>" class="display-source-excerpt">
  49. <?=$frame['functionRef']; ?>
  50. </a></tt>
  51. <div id="sourceCode<?=$id; ?>" style="display: none;">
  52. <div class="lithium-exception-location">
  53. <?=$location; ?>
  54. </div>
  55. <div class="lithium-code-dump">
  56. <pre><code><?php
  57. foreach ($code as $num => $content):
  58. $numPad = str_pad($num, 3, ' ');
  59. $content = str_ireplace(array('<?php', '?>'), '', $content);
  60. $content = highlight_string("<?php {$numPad}{$content} ?>", true);
  61. $content = str_replace($replace, '', $content);
  62. if ($frame['line'] === $num):
  63. ?><span class="code-highlight"><?php
  64. endif;?><?php echo "{$content}\n"; ?><?php
  65. if ($frame['line'] === $num):
  66. ?></span><?php
  67. endif;
  68. endforeach;
  69. ?></code></pre>
  70. </div>
  71. </div>
  72. </li>
  73. <?php endforeach; ?>
  74. </ol>
  75. </div>
  76. <script type="text/javascript">
  77. window.onload = function() {
  78. var $ = function() { return document.getElementById.apply(document, arguments); };
  79. var links = document.getElementsByTagName('a');
  80. for (i = 0; i < links.length; i++) {
  81. if (links[i].className.indexOf('display-source-excerpt') >= 0) {
  82. links[i].onclick = function() {
  83. $('sourceCode').innerHTML = $('sourceCode' + this.id).innerHTML;
  84. }
  85. }
  86. }
  87. $('sourceCode').innerHTML = $('sourceCode0').innerHTML;
  88. }
  89. </script>