Development

/branches/1.4/lib/debug/sfWebDebugPanelConfig.class.php

You must first sign up to be able to contribute.

root/branches/1.4/lib/debug/sfWebDebugPanelConfig.class.php

Revision 19774, 3.0 kB (checked in by Kris.Wallsmith, 5 years ago)

[1.3] Initial entry of the view panel for the web debug toolbar. This panel includes information about parameters passed to templates and partials. (WIP)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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$
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 }
82
Note: See TracBrowser for help on using the browser.