Dotclear


Ignore:
Timestamp:
12/17/12 10:09:09 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • Add DebugInfo? to context and to main template layout (no more use of DC_DEV)
Location:
inc/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.admincontext.php

    r1070 r1071  
    4444               'vendor_name'  => DC_VENDOR_NAME, 
    4545                
    46                'safe_mode'    => isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'] 
     46               'safe_mode'    => isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'], 
     47               'debug_mode'   => DC_DEBUG 
    4748          ); 
    4849     } 
     
    118119     { 
    119120          return array( 
    120                '__'           => new Twig_Function_Function("__", array('is_safe' => array('html'))) 
     121               '__'           => new Twig_Function_Function("__", array('is_safe' => array('html'))), 
     122               'debug_info' => new Twig_Function_Method($this, 'getDebugInfo', array('is_safe' => array('html'))) 
    121123               //,'page_menu' => new Twig_Function_Method($this, 'pageMenu', array('is_safe' => array('html'))) 
    122124          ); 
     
    327329          } 
    328330     } 
     331      
     332     /** 
     333     Get an array of debug/dev infos 
     334     */ 
     335     public function getDebugInfo() 
     336     { 
     337          if (!DC_DEBUG) { 
     338               return array(); 
     339          } 
     340           
     341          $di = array( 
     342               'global_vars' => implode(', ',array_keys($GLOBALS)), 
     343               'memory' => array( 
     344                    'usage' => memory_get_usage(), 
     345                    'size' => files::size(memory_get_usage()) 
     346               ), 
     347               'xdebug' => array() 
     348          ); 
     349           
     350          if (function_exists('xdebug_get_profiler_filename')) { 
     351           
     352               $url = http::getSelfURI(); 
     353               $url .= strpos($url,'?') === false ? '?' : '&'; 
     354               $url .= 'XDEBUG_PROFILE'; 
     355                
     356               $di['xdebug'] = array( 
     357                    'elapse_time' => xdebug_time_index(), 
     358                    'profiler_file' => xdebug_get_profiler_filename(), 
     359                    'profiler_url' =>  $url 
     360               ); 
     361                
     362               /* xdebug configuration: 
     363               zend_extension = /.../xdebug.so 
     364               xdebug.auto_trace = On 
     365               xdebug.trace_format = 0 
     366               xdebug.trace_options = 1 
     367               xdebug.show_mem_delta = On 
     368               xdebug.profiler_enable = 0 
     369               xdebug.profiler_enable_trigger = 1 
     370               xdebug.profiler_output_dir = /tmp 
     371               xdebug.profiler_append = 0 
     372               xdebug.profiler_output_name = timestamp 
     373               */ 
     374          } 
     375           
     376          return $di; 
     377     } 
    329378} 
    330379?> 
  • inc/admin/default-templates/layout.html.twig

    r1064 r1071  
    9595          </div> 
    9696     </div> 
     97     {% block debug %} 
     98       {% set debug_info = debug_info() %} 
     99       {% if debug_info is not empty %} 
     100          <div id="debug"><div> 
     101          <p>memory usage: {{ debug_info.memory.usage }} ({{ debug_info.memory.size }})</p> 
     102          {% if debug_info.xdebug is not empty %} 
     103            <p>Elapsed time: {{ debug_info.xdebug.elapse_time }} seconds</p> 
     104            {% if debug_info.xdebug.profiler_file is not empty %} 
     105               <p>Profiler file : {{ debug_info.xdebug.profiler_file }}</p> 
     106            {% else %} 
     107               <p><a href="{{ debug_info.xdebug.profiler_url }}">Trigger profiler</a></p> 
     108            {% endif %} 
     109          {% endif %} 
     110          <p>Global vars: {{ debug_info.global_vars }}</p> 
     111          </div></div> 
     112       {% endif %} 
     113     {% endblock %} 
    97114     </body> 
    98115</html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map