You are here

function scanner_undo_page in Search and Replace Scanner 7

Same name and namespace in other branches
  1. 5.2 scanner.module \scanner_undo_page()
  2. 6 scanner.module \scanner_undo_page()

Page callback to display table of executed replace actions with undo/redo operation.

1 string reference to 'scanner_undo_page'
scanner_menu in ./scanner.module
Implements hook_menu().

File

./scanner.module, line 550
Search and Replace Scanner - works on all nodes text content.

Code

function scanner_undo_page() {
  $header = array(
    t('Date'),
    t('Searched'),
    t('Replaced'),
    t('Count'),
    t('Operation'),
  );
  $undoQuery = db_select('scanner', 's');
  $undoQuery
    ->fields('s', array(
    'undo_id',
    'time',
    'searched',
    'replaced',
    'count',
    'undone',
  ))
    ->orderBy('undo_id', 'DESC');
  $sandrs = $undoQuery
    ->execute();
  $rows = array();
  foreach ($sandrs as $sandr) {
    if ($sandr->undone) {
      $operation = l(t('Redo'), 'admin/content/scanner/undo/confirm', array(
        'query' => array(
          'undo_id' => $sandr->undo_id,
        ),
      ));
    }
    else {
      $operation = l(t('Undo'), 'admin/content/scanner/undo/confirm', array(
        'query' => array(
          'undo_id' => $sandr->undo_id,
        ),
      ));
    }
    $rows[] = array(
      format_date($sandr->time),
      check_plain($sandr->searched),
      check_plain($sandr->replaced),
      $sandr->count,
      $operation,
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => NULL,
    'caption' => 'Prior Search and Replace Events',
  ));
}