core.display_debug_console.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * Smarty debug_console function plugin
  9. *
  10. * Type: core<br>
  11. * Name: display_debug_console<br>
  12. * Purpose: display the javascript debug console window
  13. * @param array Format: null
  14. * @param Smarty
  15. */
  16. function smarty_core_display_debug_console($params, &$smarty)
  17. {
  18. // we must force compile the debug template in case the environment
  19. // changed between separate applications.
  20. if(empty($smarty->debug_tpl)) {
  21. // set path to debug template from SMARTY_DIR
  22. $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
  23. if($smarty->security && is_file($smarty->debug_tpl)) {
  24. $smarty->secure_dir[] = realpath($smarty->debug_tpl);
  25. }
  26. $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
  27. }
  28. $_ldelim_orig = $smarty->left_delimiter;
  29. $_rdelim_orig = $smarty->right_delimiter;
  30. $smarty->left_delimiter = '{';
  31. $smarty->right_delimiter = '}';
  32. $_compile_id_orig = $smarty->_compile_id;
  33. $smarty->_compile_id = null;
  34. $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
  35. if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
  36. {
  37. ob_start();
  38. $smarty->_include($_compile_path);
  39. $_results = ob_get_contents();
  40. ob_end_clean();
  41. } else {
  42. $_results = '';
  43. }
  44. $smarty->_compile_id = $_compile_id_orig;
  45. $smarty->left_delimiter = $_ldelim_orig;
  46. $smarty->right_delimiter = $_rdelim_orig;
  47. return $_results;
  48. }
  49. /* vim: set expandtab: */
  50. ?>