ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
inc.debug.php File Reference

Go to the source code of this file.

Namespaces

 ilias
 redirection script todo: (a better solution should control the processing via a xml file)
 

Functions

 vd ()
 shortcut for var_dump with enhanced debug information More...
 
 pr ($var, $name='')
 shortcut for print_r More...
 
 cf ($backjumps=1)
 prints an information about the function that called the function that invoked this function (the optional backjump param conrols the level in backtrace) More...
 
 getPhpSourceCodePositionInfo ($backjumps=0)
 returns an array containing function information from backtrace (the optional backjump param conrols the level in backtrace) More...
 

Function Documentation

◆ cf()

cf (   $backjumps = 1)

prints an information about the function that called the function that invoked this function (the optional backjump param conrols the level in backtrace)

Author
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de public
Parameters
integer$backjumps

Definition at line 124 of file inc.debug.php.

References getPhpSourceCodePositionInfo().

125 {
126  list($fileC, $funcC) = getPhpSourceCodePositionInfo(($backjumps - 1) + 1);
127  list($fileF, $funcF) = getPhpSourceCodePositionInfo(($backjumps) + 1);
128 
129  echo "<pre style=\"text-align:left;\">$fileC - $funcC\nIS CALLED FROM: $fileF - $funcF</pre>";
130 
131  // BH: php 5.3 seems to not flushing the output consequently so following redirects are still performed
132  // and the output of vd() would be lost in nirvana if we not flush the output manualy
133  flush();
134  ob_flush();
135 }
getPhpSourceCodePositionInfo($backjumps=0)
returns an array containing function information from backtrace (the optional backjump param conrols ...
Definition: inc.debug.php:145
+ Here is the call graph for this function:

◆ getPhpSourceCodePositionInfo()

getPhpSourceCodePositionInfo (   $backjumps = 0)

returns an array containing function information from backtrace (the optional backjump param conrols the level in backtrace)

Author
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de public
Parameters
integer$backjumps

Definition at line 145 of file inc.debug.php.

References $i.

Referenced by cf(), and vd().

146 {
147  $i = $backjumps;
148  $j = $backjumps + 1;
149 
150  $e = new Exception();
151  $trace = $e->getTrace();
152 
153  $file = basename($trace[$i]['file']) . ':' . $trace[$i]['line'];
154 
155  $func = '';
156 
157  if (isset($trace[$j]['class']) && strlen($trace[$j]['class'])) {
158  $func = $trace[$j]['class'];
159 
160  if (isset($trace[$j]['class']) && strlen($trace[$j]['class'])) {
161  $func .= $trace[$j]['type'];
162  } else {
163  $func .= '::';
164  }
165  }
166 
167  $func .= $trace[$j]['function'] . '()';
168 
169  return array($file, $func);
170 }
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ pr()

pr (   $var,
  $name = '' 
)

shortcut for print_r

Author
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de public
Parameters
mixedany number of parameters
stringname of variable (optional)

Definition at line 95 of file inc.debug.php.

References $name, and ilAuthFactory\getContext().

96 {
97  if ($name != '') {
98  $name .= ' = ';
99  }
100  $print = $name . print_r($var, true);
101 
102  if (ilAuthFactory::getContext() == ilAuthFactory::CONTEXT_CRON) {
103  $hr = "\n---------------------------------------------------------------\n";
104  echo $hr . $print . $hr;
105  } else {
106  echo '<pre>' . $print . '</pre>';
107  }
108 
109  // BH: php 5.3 seems to not flushing the output consequently so following redirects are still performed
110  // and the output of vd() would be lost in nirvana if we not flush the output manualy
111  flush();
112  ob_flush();
113 }
+ Here is the call graph for this function:

◆ vd()

vd ( )

shortcut for var_dump with enhanced debug information

Author
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e public
Parameters
mixedany number of parameters

Definition at line 42 of file inc.debug.php.

References ilAuthFactory\getContext(), and getPhpSourceCodePositionInfo().

Referenced by ilTinyMCE\__construct(), ilTinyMCE\_getEditorLanguage(), ilTinyMCE\addCustomRTESupport(), ilTinyMCE\addRTESupport(), ilTinyMCE\addUserTextEditor(), and ilTestPlayerDynamicQuestionSetGUI\showQuestionSelectionCmd().

43 {
44  list($file, $func) = getPhpSourceCodePositionInfo(1);
45 
46  $numargs = func_num_args();
47 
48  if ($numargs == 0) {
49  return false;
50  }
51 
52  $arg_list = func_get_args();
53  $num = 1;
54 
55  include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
56  if (ilAuthFactory::getContext() == ilAuthFactory::CONTEXT_CRON) {
57  $cli = true;
58  } else {
59  $cli = false;
60  }
61 
62  foreach ($arg_list as $arg) {
63  if (!$cli) {
64  $printbefore = "<pre style=\"text-align:left;\">";
65  $printbefore .= "$file - $func - variable $num:<br/>";
66  $printafter = "</pre><br/>";
67  } else {
68  $printbefore = "\n\n_________________________________________________" .
69  "_________________________________________________\n";
70  $printbefore .= "$file - $func - variable $num:\n\n";
71  $printafter = "_________________________________________________" .
72  "_________________________________________________\n\n";
73  }
74 
75  echo $printbefore;
76  var_dump($arg);
77  echo $printafter;
78  $num++;
79  }
80 
81  // BH: php 5.3 seems to not flushing the output consequently so following redirects are still performed
82  // and the output of vd() would be lost in nirvana if we not flush the output manualy
83  flush();
84  ob_flush();
85 }
getPhpSourceCodePositionInfo($backjumps=0)
returns an array containing function information from backtrace (the optional backjump param conrols ...
Definition: inc.debug.php:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function: