atrsimilar_result

Versions
6.1
atrsimilar_result($review)

Display an overview of similar strings.

Code

atr/modules/atrsimilar/includes/atrsimilar.result.inc, line 33

<?php
function atrsimilar_result($review) {
  drupal_add_js(drupal_get_path('module', 'atr') . '/js/atr.js');
  drupal_add_css(drupal_get_path('module', 'atr') . '/css/atr.css');
  drupal_add_css(drupal_get_path('module', 'atrsimilar') . '/css/atrsimilar.css');
  module_load_include('inc', 'atrsimilar', 'includes/atrsimilar.review');

  $header = array(
    array(
      'data' => t('String'),
      'field' => 's_a.string',
    ),
    array(
      'data' => t('Similar string'),
      'field' => 's_b.string',
    ),
    array(
      'data' => t('Similarity'),
      'field' => 'similarity',
    ),
  );

  $rows = array();
  $result = pager_query("SELECT ss.*, s_a.string AS string_a, s_b.string AS string_b
  FROM {atrsimilar_string} ss
  JOIN {atr_string} s_a ON ss.sid_a = s_a.sid
  JOIN {atr_string} s_b ON ss.sid_b = s_b.sid
  WHERE s_a.rid = %d" . tablesort_sql($header), 25, 0, NULL, $review->rid);
  while ($string_data = db_fetch_array($result)) {
    list($sid_a, $sid_b, $similarity, $string_a, $string_b) = array_values($string_data);
    $diff = atrsimilar_diff($string_a, $string_b);
    $rows[] = array(
      theme('atr_string', atrsimilar_render_old($diff), atr_string_locations($sid_a)),
      theme('atr_string', atrsimilar_render_new($diff), atr_string_locations($sid_b)),
      $similarity . '%',
    );
  }

  $pager = theme('pager');

  return $pager . theme_table($header, $rows) . $pager;
}
?>