You are here

function revision_deletion_node_overview in Revision Deletion 7

Form builder for the node revisions administration form.

See also

revision_deletion_node_overview_submit()

1 string reference to 'revision_deletion_node_overview'
revision_deletion_node in ./revision_deletion.admin.inc
Menu callback; present an administrative revisions listing for a node.

File

./revision_deletion.admin.inc, line 410

Code

function revision_deletion_node_overview($form, &$form_state, $node) {
  if (isset($form_state['storage']['confirm'])) {
    return revision_deletion_admin_overview_confirm($form_state, 'admin/config/content/revision_deletion/node/' . $node->nid);
  }
  drupal_set_title(t('Revisions for "@title"', array(
    '@title' => $node->title,
  )));
  $form = array();
  $form['help'] = array(
    '#type' => 'item',
    '#markup' => '<p>' . t('Using revisions is a good way to improve the integrity of your node content; however, it may result in a significant increase in your database size. This page lists the nodes that currently have revisions meeting the deletion criteria and allows you to delete them.') . '</p>' . '<p>' . t('Click the title to view the current content; click the revision ID to view the revision. Clicking on the <strong>Delete selected revisions</strong> button will delete all of the selected revisions, even if they are shown on other pages.') . '</p>',
  );
  $header = array(
    'vid' => array(
      'data' => t('Revision'),
      'field' => 'r.vid',
      'sort' => 'asc',
    ),
    'name' => array(
      'data' => t('User'),
    ),
    'date' => array(
      'data' => t('Created'),
      'field' => 'r.timestamp',
      'sort' => 'desc',
    ),
    'notes' => t('Notes'),
    'op' => t('Operations'),
  );
  $show_notes = variable_get('revision_deletion_list_show_notes');
  if (!$show_notes) {
    unset($header['notes']);
  }
  $destination = drupal_get_destination();
  $revisions = _revision_deletion_get_list($node->nid, $header);
  $rows = array();
  $default_value = array();
  $accounts = array();
  foreach ($revisions as $revision) {
    if (!isset($accounts[$revision->uid])) {
      $accounts[$revision->uid] = theme('username', array(
        'account' => user_load($revision->uid),
      ));
    }
    $ops = array();
    if ($revision->vid != $revision->current) {
      $ops['revert'] = array(
        'title' => t('revert'),
        'href' => 'node/' . $revision->nid . '/revisions/' . $revision->vid . '/revert',
        'query' => $destination,
      );
      $ops['delete'] = array(
        'title' => t('delete'),
        'href' => 'node/' . $revision->nid . '/revisions/' . $revision->vid . '/delete',
        'query' => $destination,
      );
    }
    $default_value[$revision->vid] = $revision->select;
    $rows[$revision->vid] = array(
      'vid' => array(
        'data' => array(
          '#type' => 'link',
          '#title' => $revision->vid,
          '#href' => 'node/' . $revision->nid . '/revisions/' . $revision->vid . '/view',
          '#options' => array(
            'title' => t('view revision'),
          ),
          '#suffix' => '<br />' . $revision->log,
        ),
      ),
      'name' => $accounts[$revision->uid],
      'date' => format_date($revision->timestamp, 'small'),
      'status' => $revision->status ? t('published') : t('not published'),
      'notes' => filter_xss($revision->notes),
      'op' => array(
        'data' => array(
          '#theme' => 'links__revision_deletion',
          '#links' => $ops,
          '#attributes' => array(
            'class' => array(
              'links',
              'inline',
            ),
          ),
        ),
      ),
    );
    if (!$show_notes) {
      unset($rows[$revision->vid]['notes']);
    }
  }
  $form['revisions'] = array(
    '#type' => 'tableselect',
    '#multiple' => TRUE,
    '#header' => $header,
    '#options' => $rows,
    '#sticky' => TRUE,
    '#default_value' => $default_value,
    '#empty' => t('No revisions found.'),
  );
  foreach ($revisions as $revision) {
    if ($revision->vid == $revision->current) {
      $form['revisions'][$revision->vid]['#disabled'] = TRUE;
    }
  }
  $form['pager'] = array(
    '#theme' => 'pager',
  );
  $form['button']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete selected revisions'),
  );
  return $form;
}