You are here

function theme_coder_warning in Coder 5.2

Same name and namespace in other branches
  1. 5 coder.module \theme_coder_warning()
  2. 6.2 coder.module \theme_coder_warning()
  3. 6 coder.module \theme_coder_warning()

Format a coder warning to be included in results.

Parameters

$warning: Either summary warning description, or an array in format:

  • '#warning' => Summary warning description;
  • '#description' => Detailed warning description;
  • '#link' => Link to an explanatory document.

$severity_name: String severity name.

$lineno: Integer line number of error.

$line: String contents of line.

3 theme calls to theme_coder_warning()
_coder_50_callback in includes/coder_50.inc
Define the rule callbacks for 5.x, see do_coder_review_callback().
_coder_6x_callback in includes/coder_6x.inc
Define the rule callbacks for 6.x, see do_coder_review_callback().
_coder_error_msg in ./coder.module
Does the actual saving of error to results array and generating its unique numeric id.

File

./coder.module, line 1536
Developer Module that assists with code review and version upgrade that supports a plug-in extensible hook system so contributed modules can define additional review standards.

Code

function theme_coder_warning($warning, $severity_name, $lineno = 0, $line = '') {

  // theme the output for the Drupal shell
  if (function_exists('_coder_drush_is_option') && _coder_drush_is_option('drush')) {
    return theme_drush_coder_warning($warning, $severity_name, $lineno, $line);
  }

  // Extract description from warning.
  if (is_array($warning)) {
    $description = $warning['#description'];
    $link = $warning['#link'];
    $warning = $warning['#warning'];
    if (isset($link)) {
      $warning .= '  (' . l('Drupal Docs', $link) . ')';
    }
  }
  if ($lineno) {
    $warning = t('Line @number: !warning', array(
      '@number' => $lineno,
      '!warning' => $warning,
    ));
    if ($line) {
      $warning .= '<pre>' . check_plain($line) . '</pre>';
    }
  }
  $class = 'coder-warning';
  if ($severity_name) {
    $class .= " coder-{$severity_name}";
  }
  $path = drupal_get_path('module', 'coder');
  $title = t('severity: @severity', array(
    '@severity' => $severity_name,
  ));
  $img = theme('image', $path . "/images/{$severity_name}.png", $title, $title, array(
    'align' => 'right',
    'class' => 'coder',
  ), FALSE);
  if (isset($description)) {
    $img .= theme('image', $path . '/images/more.png', t('click to read more'), '', array(
      'align' => 'right',
      'class' => 'coder-more',
    ), FALSE);
    $warning .= '<div class="coder-description">Explanation: ' . $description . '</div>';
  }
  return '<div class="' . $class . '">' . $img . $warning . '</div>';
}