You are here

function theme_comment_alter_diff in Comment Alter 7

Returns HTML for changes made by comment_alter.

Parameters

array $variables: An associative array containing:

  • changed_fields: a list of arrays of changed fields, with these indexes:

    • name: field's name being changed.
    • old: array of old field values.
    • new: array of new field values.
  • comment: Full comment object, for context.
  • langcode: The language code used for rendering the fields, for context.
1 theme call to theme_comment_alter_diff()
comment_alter_comment_view in ./comment_alter.module
Implements hook_comment_view().

File

./comment_alter.module, line 563
Provides UI to alter nodes' parameters from comment forms.

Code

function theme_comment_alter_diff(&$variables) {
  if ($variables['changed_fields']) {
    $rows = array();
    foreach ($variables['changed_fields'] as $field) {
      foreach ($field as $value) {
        $row = array(
          empty($value['name']) ? '' : $value['name'] . ':',
        );
        if (!empty($value['changes'])) {
          $row[] = array(
            'data' => $value['changes'],
            'colspan' => 3,
          );
        }
        else {
          $row[] = implode(', ', $value['old']);
          $row[] = '»';
          $row[] = implode(', ', $value['new']);
        }
        $rows[] = $row;
      }
    }
    drupal_add_css(drupal_get_path('module', 'comment_alter') . '/comment_alter.css');
    $build = array(
      '#theme' => 'table__comment_alter__diff',
      '#rows' => $rows,
      '#attributes' => array(
        'class' => array(
          'comment-alter-diff',
        ),
      ),
      '#sticky' => FALSE,
    );
    return drupal_render($build);
  }
}