sfWebDebugPanelConfig.class.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfWebDebugPanelConfig adds a panel to the web debug toolbar with the current configuration.
  11. *
  12. * @package symfony
  13. * @subpackage debug
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfWebDebugPanelConfig.class.php 13931 2008-12-10 22:43:27Z FabianLange $
  16. */
  17. class sfWebDebugPanelConfig extends sfWebDebugPanel
  18. {
  19. public function getTitle()
  20. {
  21. return '<img src="'.$this->webDebug->getOption('image_root_path').'/config.png" alt="Config" /> config';
  22. }
  23. public function getPanelTitle()
  24. {
  25. return 'Configuration';
  26. }
  27. public function getPanelContent()
  28. {
  29. $config = array(
  30. 'debug' => sfConfig::get('sf_debug') ? 'on' : 'off',
  31. 'xdebug' => extension_loaded('xdebug') ? 'on' : 'off',
  32. 'logging' => sfConfig::get('sf_logging_enabled') ? 'on' : 'off',
  33. 'cache' => sfConfig::get('sf_cache') ? 'on' : 'off',
  34. 'compression' => sfConfig::get('sf_compressed') ? 'on' : 'off',
  35. 'tokenizer' => function_exists('token_get_all') ? 'on' : 'off',
  36. 'eaccelerator' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') ? 'on' : 'off',
  37. 'apc' => extension_loaded('apc') && ini_get('apc.enabled') ? 'on' : 'off',
  38. 'xcache' => extension_loaded('xcache') && ini_get('xcache.cacher') ? 'on' : 'off',
  39. );
  40. $html = '<ul id="sfWebDebugConfigSummary">';
  41. foreach ($config as $key => $value)
  42. {
  43. $html .= '<li class="is'.$value.($key == 'xcache' ? ' last' : '').'">'.$key.'</li>';
  44. }
  45. $html .= '</ul>';
  46. $context = sfContext::getInstance();
  47. $html .= $this->formatArrayAsHtml('request', sfDebug::requestAsArray($context->getRequest()));
  48. $html .= $this->formatArrayAsHtml('response', sfDebug::responseAsArray($context->getResponse()));
  49. $html .= $this->formatArrayAsHtml('user', sfDebug::userAsArray($context->getUser()));
  50. $html .= $this->formatArrayAsHtml('settings', sfDebug::settingsAsArray());
  51. $html .= $this->formatArrayAsHtml('globals', sfDebug::globalsAsArray());
  52. $html .= $this->formatArrayAsHtml('php', sfDebug::phpInfoAsArray());
  53. $html .= $this->formatArrayAsHtml('symfony', sfDebug::symfonyInfoAsArray());
  54. return $html;
  55. }
  56. /**
  57. * Converts an array to HTML.
  58. *
  59. * @param string $id The identifier to use
  60. * @param array $values The array of values
  61. *
  62. * @return string An HTML string
  63. */
  64. protected function formatArrayAsHtml($id, $values)
  65. {
  66. $id = ucfirst(strtolower($id));
  67. return '
  68. <h2>'.$id.' <a href="#" onclick="sfWebDebugToggle(\'sfWebDebug'.$id.'\'); return false;"><img src="'.$this->webDebug->getOption('image_root_path').'/toggle.gif" alt="Toggle details" /></a></h2>
  69. <div id="sfWebDebug'.$id.'" style="display: none"><pre>'.htmlspecialchars(sfYaml::dump(sfDebug::removeObjects($values)), ENT_QUOTES, sfConfig::get('sf_charset')).'</pre></div>
  70. ';
  71. }
  72. }