You are here

function theme_coder_warning in Coder 6.2

Same name and namespace in other branches
  1. 5.2 coder.module \theme_coder_warning()
  2. 5 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.

2 theme calls to theme_coder_warning()
do_coder_reviews in ./coder.module
Perform batch coder reviews for multiple files.
theme_coder_warning_msg in ./coder.module
Format a coder warning to be included in results, creating the text.

File

./coder.module, line 2010

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 = isset($warning['#description']) ? $warning['#description'] : '';
    $link = $warning['#link'];
    $warning_msg = $warning['#warning'];
    if (isset($warning['#link'])) {
      $warning_msg .= '  (' . l(t('Drupal Docs'), $warning['#link']) . ')';
    }
    $warning = $warning_msg;
  }
  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 (!empty($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>';
}