You are here

function theme_coder_review_warning in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_review/coder_review.common.inc \theme_coder_review_warning()

Format a coder_review 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_review_warning()
do_coder_reviews in coder_review/coder_review.module
Perform batch coder reviews for multiple files.
theme_coder_review_warning_msg in coder_review/coder_review.module
Format a coder_review warning to be included in results, creating the text.

File

coder_review/coder_review.module, line 2130

Code

function theme_coder_review_warning($variables) {

  // theme the output for the Drupal shell
  if (function_exists('_coder_review_drush_is_option') && _coder_review_drush_is_option('drush')) {
    return theme_drush_coder_review_warning($variables);
  }
  $warning = $variables['warning'];
  $severity_name = $variables['severity_name'];
  $lineno = $variables['lineno'];
  $line = $variables['line'];

  // Extract description from warning.
  if (is_array($warning)) {
    $description = isset($warning['#description']) ? $warning['#description'] : '';
    $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', array(
    'path' => $path . "/images/{$severity_name}.png",
    'alt' => $title,
    'title' => $title,
    'attributes' => array(
      'align' => 'right',
      'class' => 'coder',
    ),
    'getsize' => FALSE,
  ));
  if (!empty($description)) {
    $img .= theme('image', array(
      'path' => $path . '/images/more.png',
      'alt' => t('click to read more'),
      'atributes' => array(
        'align' => 'right',
        'class' => 'coder-more',
      ),
      'getsize' => FALSE,
    ));
    $warning .= '<div class="coder-description">Explanation: ' . $description . '</div>';
  }
  return '<div class="' . $class . '">' . $img . $warning . '</div>';
}