Source for file NewWindowDebugHandlerPrinter.class.php

Documentation is available at NewWindowDebugHandlerPrinter.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."debugHandler/DebugHandlerPrinter.interface.php");
  4. require_once(HARMONI."utilities/HTMLcolor.class.php");
  5.  
  6. /**
  7. * the NewWindowDebugHandlerPrinter prints debug items to a new HTML window.
  8. *
  9. * @package harmoni.utilities.debugging
  10. *
  11. * @copyright Copyright &copy; 2005, Middlebury College
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  13. *
  14. * @version $Id: NewWindowDebugHandlerPrinter.class.php,v 1.9 2007/09/04 20:25:33 adamfranco Exp $
  15. ***/
  16.  
  17. class NewWindowDebugHandlerPrinter extends DebugHandlerPrinterInterface {
  18. /**
  19. * Outputs the DebugItems in $debugHandler.
  20. *
  21. * @param object DebugHandler $debugHandler The DebugHandler object to output.
  22. * @param int $level The level to output. All output < $level will be displayed. Default = user Handler's internal output level.
  23. * @param optional string $category Limit output to only items under $category.
  24. * @access public
  25. * @return void
  26. ***/
  27. function printDebugHandler( $debugHandler, $level = null, $category = "" ) {
  28. if ($level == null) $level = $debugHandler->getOutputLevel();
  29. $items = $debugHandler->getDebugItems($category);
  30. if ($level == 0) return true;
  31. if (!count($items)) return true;
  32. print "<script type='text/javascript'>
  33. //<![CDATA[\n";
  34. print "<!--\n";
  35. print "debugWindow = window.open('','debug','scrollbars=yes,menubar=no,location=no,status=no,resizeable=yes,width=750,height=520');\n";
  36. print "debugWindow.document.write('<body style=\"color: #fff; background-color:#222\"><div style=\"padding-left:25px; padding-top: 10px; border-bottom: solid 1px gray\">Starting debug output :: ".date("H").":".date("i").".".date("s")."</div>');\n";
  37.  
  38. // some colors
  39. $base = new HTMLcolor("#833");
  40.  
  41. foreach (array_keys($items) as $key) {
  42. if (($l = $items[$key]->getLevel()) <= $level) {
  43. $btext = '';
  44. if ($bt = $items[$key]->getBacktrace() && isset($bt[2])) {
  45. $b = $bt[2];
  46. $btext = basename($b['file'])." :: ".$b['line']." :: ".$b['class'].$b['type'].$b['function']."()";
  47. $btext .= " ";
  48. }
  49. $color = $base; // $color = $base->__replicate();
  50. $color->lighten(2*$l);
  51. $color->shiftRed(10*$l);
  52. $htmlColor = $color->getHTMLcolor();
  53. $string = "<div style='padding-top: 3px'><font face='monaco' size=1>";
  54. $string .= "{$btext}</font>";
  55. $string .= "<div style='padding-left:10px'><font face='monaco' size=2>[<font color='#$htmlColor'>".$items[$key]->getCategory().":".$items[$key]->getLevel()."</font>] ".$items[$key]->getText();
  56. $string .= "</font></div></div>";
  57. print "debugWindow.document.write('".addslashes(str_replace("\n","<BR /> ",$string))."');\n";
  58. print "debugWindow.scrollBy(0,100000);\n";
  59. }
  60. }
  61.  
  62. // print "debugWindow.document.close();\n";
  63. print "debugWindow.document.write('</body>');\n";
  64. print "//-->\n";
  65. print "//]]>
  66. </script>\n";
  67. }
  68. }
  69.  
  70. ?>

Documentation generated on Wed, 19 Sep 2007 10:25:14 -0400 by phpDocumentor 1.3.0RC3