/[drupal]/contributions/modules/debug/debug.module
ViewVC logotype

Diff of /contributions/modules/debug/debug.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Tue Oct 23 21:24:29 2007 UTC revision 1.3, Fri Nov 16 02:31:21 2007 UTC
# Line 11  Line 11 
11   */   */
12    
13  // global var for default parmaters of debug window  // global var for default parmaters of debug window
14    define('DEBUG_OPACITY',9);
15    define('DEBUG_BGCOLOR','#7BD270');
16    define('DEBUG_REMEMBER',1);
17    define('DEBUG_X','50px');
18    define('DEBUG_Y','50px');
19    define('DEBUG_W','500');
20    define('DEBUG_IN_HTML','inside');
21    
22    
23  $default_params = array(  $default_params = array(
24          "opacity"       => '9',          "opacity"       => '9',
25          "bgcolor"       => '#7bd270',          "bgcolor"       => '#7bd270',
# Line 42  function debug(){ Line 51  function debug(){
51                  $args[] = array(                  $args[] = array(
52                          'lbl'=>$arg_list[$i],                          'lbl'=>$arg_list[$i],
53                          'val'=>$arg_list[$i+1],                          'val'=>$arg_list[$i+1],
54                          'ilk'=>gettype($arg_list[$i+1])                          'ilk'=>gettype($arg_list[$i+1]),
55                            'backtrace'=>debug_backtrace()
56                  );                  );
57          }          }
58    
# Line 71  function debug_help($section='') { Line 81  function debug_help($section='') {
81   *   *
82   */   */
83  function debug_footer(){  function debug_footer(){
84          return debug_output();          if(variable_get('debug_in_html', DEBUG_IN_HTML) == "inside"){
85                    return debug_output();
86            }
87  }  }
88    
89  /**  /**
90     * implimentation of hook_init()
91     *
92     */
93    function debug_init(){
94            if(variable_get('debug_in_html', DEBUG_IN_HTML) == "outside"){
95                    register_shutdown_function('debug_output');
96            }
97    }
98    
99    
100    /**
101   * Implimentation of hook_menu()   * Implimentation of hook_menu()
102   */   */
103  function debug_menu($may_cache){  function debug_menu($may_cache){
# Line 111  function debug_perm() { Line 134  function debug_perm() {
134   * Define the settings form   * Define the settings form
135   */   */
136  function debug_admin_settings(){  function debug_admin_settings(){
         global $default_params;  
   
137          $form['debug_opacity'] = array(          $form['debug_opacity'] = array(
138                  '#type'                         => 'select',                  '#type'                         => 'select',
139                  '#title'                        => t('Set the opacity level (%) of the debug window.'),                  '#title'                        => t('Set the opacity level (%) of the debug window.'),
140                  '#default_value'        => variable_get('debug_opacity', $default_params['opacity']),                  '#default_value'        => variable_get('debug_opacity', DEBUG_OPACITY),
141                  '#options'                      => range(0,100,10),                  '#options'                      => range(0,100,10),
142                  '#description'          => t('100% = no transparency | 0% = hide the debug window'),                  '#description'          => t('100% = no transparency | 0% = hide the debug window'),
143          );          );
# Line 124  function debug_admin_settings(){ Line 145  function debug_admin_settings(){
145                  '#type' => 'colorpicker',                  '#type' => 'colorpicker',
146                  '#title' => t('Background Color'),                  '#title' => t('Background Color'),
147                  '#description' => t('Click in this textfield to start picking your color'),                  '#description' => t('Click in this textfield to start picking your color'),
148                  '#default_value' => variable_get('debug_bgcolor', $default_params['bgcolor'])                  '#default_value' => variable_get('debug_bgcolor', DEBUG_BGCOLOR)
149          );          );
150          $form['debug_remember'] = array(          $form['debug_remember'] = array(
151                  '#type' => 'checkbox',                  '#type' => 'checkbox',
152                  '#title' => t('Remember the size and position of the debug window'),                  '#title' => t('Remember the size and position of the debug window'),
153                  '#description' => t('If unchecked, the debug window will always appear at the top left of the browser window'),                  '#description' => t('If unchecked, the debug window will always appear at the top left of the browser window'),
154                  '#default_value' => variable_get('debug_remember', $default_params['remember'])                  '#default_value' => variable_get('debug_remember', DEBUG_REMEMBER)
155            );
156            $form['debug_in_html'] = array(
157                    '#type'=> 'radios',
158                    '#title' => t('Output debug statements inside the html tag or outside the html tag'),
159                    '#default_value' =>   variable_get('debug_in_html', DEBUG_IN_HTML),
160                    '#options' => array("inside"=>t('inside <html> tag (w3c compliant; js works; debug function fails in tpl files)'), "outside"=>t('outside <html> tag (not w3c compliant; js fails; debug function works in tpl files)')),
161                    '#description' => t('Debug messages can be output more predictably within the footer (W3C compliant) but the function cannot be called within tpls. Or debug messages can be output outside of the html tag (not W3C compliant) tag with less predictible results but the function can be called at any time after drupal has been bootstrapped.')
162          );          );
163    
164          return system_settings_form($form);          return system_settings_form($form);
# Line 141  function debug_admin_settings(){ Line 169  function debug_admin_settings(){
169   * uses variable_set to remember the x,y position & width of the debug window   * uses variable_set to remember the x,y position & width of the debug window
170   *   *
171   */   */
172  function debug_set_window_params(){  function debug_set_window_params(){
173          global $default_params;          $params = variable_get('debug_window_params',array("x"=>DEBUG_X,"y"=>DEBUG_Y,"w"=>DEBUG_W));
   
         $params = variable_get('debug_window_params',array("x"=>$default_params['x'],"y"=>$default_params['y'],"w"=>$default_params['w']));  
174          if(isset($_GET['x']) && isset($_GET['y'])){          if(isset($_GET['x']) && isset($_GET['y'])){
175                  $params['x'] = $_GET['x'];                  $params['x'] = $_GET['x'];
176                  $params['y'] = $_GET['y'];                  $params['y'] = $_GET['y'];
# Line 166  function debug_set_window_params(){ Line 192  function debug_set_window_params(){
192   *   *
193   */   */
194  function debug_output(){  function debug_output(){
         global $default_params;  
   
195          $params = array();          $params = array();
196          $params['opacity']      = variable_get('debug_opacity',$default_params['opacity']) * 10;          $params['opacity']      = variable_get('debug_opacity',DEBUG_OPACITY) * 10;
197          $params['bgcolor']      = variable_get('debug_bgcolor',$default_params['bgcolor']);          $params['bgcolor']      = variable_get('debug_bgcolor',DEBUG_BGCOLOR);
198          $params['remember']     = variable_get('debug_remember',$default_params['remember']);          $params['remember']     = variable_get('debug_remember',DEBUG_REMEMBER);
199          $params = array_merge($params,variable_get('debug_window_params',array("x"=>$default_params['x'],"y"=>$default_params['y'],"w"=>$default_params['w'])));          $params = array_merge($params,variable_get('debug_window_params',array("x"=>DEBUG_X,"y"=>DEBUG_Y,"w"=>DEBUG_W)));
200    
201          $_debug = debug();          $_debug = debug();
202    
203          if(!empty($_debug)){          if(!empty($_debug)){
204                  return theme('debug_msgs',debug(),$params);                  if(variable_get('debug_in_html', DEBUG_IN_HTML) == "inside"){
205                            return theme('debug_msgs',debug(),$params);
206                    }else{
207                            print theme('debug_msgs',debug(),$params);
208                    }
209          }          }
210  }  }
211    
# Line 192  function theme_debug_msgs($msgs,$params Line 220  function theme_debug_msgs($msgs,$params
220          // if user has 'view' permission add the required js          // if user has 'view' permission add the required js
221          if(user_access('view debug window')){          if(user_access('view debug window')){
222                  jquery_ui_backport_add(); // jquib module - adds jquery ui                  jquery_ui_backport_add(); // jquib module - adds jquery ui
223                  if(variable_get('debug_remember',$default_params['remember'])){                  if(variable_get('debug_remember',DEBUG_REMEMBER)){
224                          // register the ajaxUrl for setting window params                          // register the ajaxUrl for setting window params
225                          drupal_add_js( array('debug_set_window_params' => array('ajaxUrl' => url('debug/set_window_params', null, null, true))), 'setting' );                          drupal_add_js( array('debug_set_window_params' => array('ajaxUrl' => url('debug/set_window_params', null, null, true))), 'setting' );
226                  }                  }
# Line 245  function theme_debug($args){ Line 273  function theme_debug($args){
273    
274          // print each lbl,val pair according to the val's type          // print each lbl,val pair according to the val's type
275          foreach($args AS $arg){          foreach($args AS $arg){
276                  $output .= "<div class='lbl'><div class='ilk'>";                  $output .= "<div class='lbl'><p class='ilk'>";
277                  $output .= !empty($arg['ilk']) ? $arg['ilk'] : "Unknown Type";                  $output .= !empty($arg['ilk']) ? $arg['ilk'] : "Unknown Type";
278                  $output .= "</div>";                  $output .= "</p>";
279                    $output .= "<span class='expand'>-</span> <span class='info'>i</span>";
280                  $output .= !empty($arg['lbl']) ? $arg['lbl'] : "Unknown Label";                  $output .= !empty($arg['lbl']) ? $arg['lbl'] : "Unknown Label";
281    
282                    $output .= "<p class='backtrace'>Called from <code>".$arg['backtrace'][0]['file']."</code>, line <code>".$arg['backtrace'][0]['line']."</code></p>";
283                  $output .= "</div>";                  $output .= "</div>";
284    
285                  $output .= "<div>";                  $output .= "<div>";

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2