You are here

function potx_coder_review in Translation template extractor 7

Same name and namespace in other branches
  1. 6.3 potx.module \potx_coder_review()
  2. 6.2 potx.module \potx_coder_review()
  3. 7.3 potx.module \potx_coder_review()
  4. 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 324
Gettext translation template and translation extractor.

Code

function potx_coder_review(&$coder_args, $review, $rule, $lines, &$results) {
  include_once drupal_get_path('module', 'potx') . '/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).
  $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_review_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 {
      $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_review_error($results, $rule, $severity_name, $lineno, $line);
  }
}