1. sfWebDebugPanelConfig.class.php
  2. /** * sfWebDebugPanelConfig adds a panel to the web debug toolbar with the current configuration. * * @package symfony * @subpackage debug * @author Fabien Potencier * @version SVN: $Id: sfWebDebugPanelConfig.class.php 19774 2009-07-01 09:46:42Z Kris.Wallsmith $ */
  3. class sfWebDebugPanelConfig extends sfWebDebugPanel
  4. {
  5. public function getTitle()
  6. {
  7. return '<img src="'.$this->webDebug->getOption('image_root_path').'/config.png" alt="Config" /> config';
  8. }
  9. public function getPanelTitle()
  10. {
  11. return 'Configuration';
  12. }
  13. public function getPanelContent()
  14. {
  15. $config = array(
  16. 'debug' => sfConfig::get('sf_debug') ? 'on' : 'off',
  17. 'xdebug' => extension_loaded('xdebug') ? 'on' : 'off',
  18. 'logging' => sfConfig::get('sf_logging_enabled') ? 'on' : 'off',
  19. 'cache' => sfConfig::get('sf_cache') ? 'on' : 'off',
  20. 'compression' => sfConfig::get('sf_compressed') ? 'on' : 'off',
  21. 'tokenizer' => function_exists('token_get_all') ? 'on' : 'off',
  22. 'eaccelerator' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') ? 'on' : 'off',
  23. 'apc' => extension_loaded('apc') && ini_get('apc.enabled') ? 'on' : 'off',
  24. 'xcache' => extension_loaded('xcache') && ini_get('xcache.cacher') ? 'on' : 'off',
  25. );
  26. $html = '<ul id="sfWebDebugConfigSummary">';
  27. foreach ($config as $key => $value)
  28. {
  29. $html .= '<li class="is'.$value.($key == 'xcache' ? ' last' : '').'">'.$key.'</li>';
  30. }
  31. $html .= '</ul>';
  32. $context = sfContext::getInstance();
  33. $html .= $this->formatArrayAsHtml('request', sfDebug::requestAsArray($context->getRequest()));
  34. $html .= $this->formatArrayAsHtml('response', sfDebug::responseAsArray($context->getResponse()));
  35. $html .= $this->formatArrayAsHtml('user', sfDebug::userAsArray($context->getUser()));
  36. $html .= $this->formatArrayAsHtml('settings', sfDebug::settingsAsArray());
  37. $html .= $this->formatArrayAsHtml('globals', sfDebug::globalsAsArray());
  38. $html .= $this->formatArrayAsHtml('php', sfDebug::phpInfoAsArray());
  39. $html .= $this->formatArrayAsHtml('symfony', sfDebug::symfonyInfoAsArray());
  40. return $html;
  41. }
  42. /**
  43. * Converts an array to HTML.
  44. *
  45. * @param string $id The identifier to use
  46. * @param array $values The array of values
  47. *
  48. * @return string An HTML string
  49. */
  50. protected function formatArrayAsHtml($id, $values)
  51. {
  52. $id = ucfirst(strtolower($id));
  53. return '
  54. <h2>'.$id.' '.$this->getToggler('sfWebDebug'.$id).'</h2>
  55. <div id="sfWebDebug'.$id.'" style="display: none"><pre>'.htmlspecialchars(sfYaml::dump(sfDebug::removeObjects($values)), ENT_QUOTES, sfConfig::get('sf_charset')).'</pre></div>
  56. ';
  57. }
  58. }

Debug toolbar