function potx_coder_review in Translation template extractor 6.3
Same name and namespace in other branches
- 6.2 potx.module \potx_coder_review()
- 7.3 potx.module \potx_coder_review()
- 7 potx.module \potx_coder_review()
- 7.2 potx.module \potx_coder_review()
Callback implementation for coder review of one file.
1 string reference to 'potx_coder_review'
- potx_reviews in ./
potx.module - Implementation of hook_reviews(). Coder module integration.
File
- ./
potx.module, line 61 - Drupal translation template extractor.
Code
function potx_coder_review(&$coder_args, $review, $rule, $lines, &$results) {
// Include potx API.
include_once __DIR__ . '/potx.inc';
// Request collection of error messages internally in a structured format.
potx_status('set', POTX_STATUS_STRUCTURED);
// Process the file (but throw away the result). We are only interested in
// the errors found, no the strings identified.
$filename = realpath($coder_args['#filename']);
_potx_process_file($filename);
// Grab the errors and empty the error list.
$errors = potx_status('get', TRUE);
$severity_name = _coder_severity_name($coder_args, $review, $rule);
foreach ($errors as $error) {
// Errors contain the message, file name (which we did not use here), in
// most cases the line number and in some cases a code excerpt for the
// error. Not all errors know about the exact line number, so it might
// not be there, in which case we provide some sensible defaults.
list($message, $file, $lineno, $excerpt, $docs_url) = $error;
if (empty($lineno)) {
// $lineno might be NULL so set to 0.
$lineno = 0;
$line = '';
}
else {
// potx numbers lines from 1 (as in text editors),
// coder from 0 (as in the array index I guess).
$lineno--;
$line = $coder_args['#all_lines'][$lineno];
}
$rule['#warning'] = htmlspecialchars_decode($message, ENT_QUOTES) . (!empty($docs_url) ? ' <a href="' . $docs_url . '">' . t('Read the documentation') . '</a>.' : '');
_coder_error($results, $rule, $severity_name, $lineno, $line);
}
}