Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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