function _potx_find_watchdog_calls in Translation template extractor 5.2
Same name and namespace in other branches
- 8 potx.inc \_potx_find_watchdog_calls()
- 5 potx.inc \_potx_find_watchdog_calls()
- 6.3 potx.inc \_potx_find_watchdog_calls()
- 6 potx.inc \_potx_find_watchdog_calls()
- 6.2 potx.inc \_potx_find_watchdog_calls()
- 7.3 potx.inc \_potx_find_watchdog_calls()
- 7 potx.inc \_potx_find_watchdog_calls()
- 7.2 potx.inc \_potx_find_watchdog_calls()
Detect all occurances of watchdog() calls. Only for Drupal 6.
These sequences are searched for: watchdog + "(" + T_CONSTANT_ENCAPSED_STRING + "," + T_CONSTANT_ENCAPSED_STRING + something
Parameters
$file: Name of file parsed.
$save_callback: Callback function used to save strings.
1 call to _potx_find_watchdog_calls()
- _potx_process_file in ./
potx.inc - Process a file and put extracted information to the given parameters.
File
- ./
potx.inc, line 653 - Extraction API used by the web and command line interface.
Code
function _potx_find_watchdog_calls($file, $save_callback) {
global $_potx_tokens, $_potx_lookup;
// Lookup tokens by function name.
if (isset($_potx_lookup['watchdog'])) {
foreach ($_potx_lookup['watchdog'] as $ti) {
list($ctok, $par, $mtype, $comma, $message, $rig) = array(
$_potx_tokens[$ti],
$_potx_tokens[$ti + 1],
$_potx_tokens[$ti + 2],
$_potx_tokens[$ti + 3],
$_potx_tokens[$ti + 4],
$_potx_tokens[$ti + 5],
);
list($type, $string, $line) = $ctok;
if ($par == '(') {
// Both type and message should be a string literal.
if (in_array($rig, array(
')',
',',
)) && $comma == ',' && (is_array($mtype) && $mtype[0] == T_CONSTANT_ENCAPSED_STRING) && (is_array($message) && $message[0] == T_CONSTANT_ENCAPSED_STRING)) {
$save_callback(_potx_format_quoted_string($mtype[1]), $file, $line);
$save_callback(_potx_format_quoted_string($message[1]), $file, $line);
}
else {
// watchdog() found, but inside is something which is not a string literal.
_potx_marker_error($file, $line, 'watchdog', $ti);
}
}
}
}
}