You are here

function bulkdelete_form in Bulk Delete 7

Same name and namespace in other branches
  1. 6 bulkdelete.admin.inc \bulkdelete_form()

Implements hook_form().

1 string reference to 'bulkdelete_form'
bulkdelete_menu in ./bulkdelete.module
Implements hook_menu().

File

./bulkdelete.admin.inc, line 11
Administrative interface for the bulkdelete module.

Code

function bulkdelete_form($form, &$form_state) {
  $options = array();
  $types = node_type_get_types();
  ksort($types);
  foreach ($types as $key => $values) {
    $count = db_select('node')
      ->condition('type', $key)
      ->countQuery()
      ->execute()
      ->fetchField();
    if ($count > 0) {
      $options[$key] = "{$values->name} ({$key}) ({$count})";
    }
  }
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types for deletion'),
    '#options' => $options,
    '#description' => t('All nodes of these types will be deleted using the batch API.'),
  );
  $form['quick'] = array(
    '#type' => 'radios',
    '#title' => t('API'),
    '#default_value' => 0,
    '#options' => array(
      0 => t('Standard'),
      1 => t('Quick'),
    ),
    '#description' => t('Please choose how to delete the nodes.'),
  );
  $form['standard_desc'] = array(
    '#type' => 'item',
    '#markup' => t('<strong>Standard</strong> means we use node_delete() which is slower but reliable. <strong>Warning!</strong> You will get a watchdog message for every node that is deleted.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
  );
  return $form;
}