function node_type_delete_confirm

Page callback: Form constructor for the content type delete form.

Parameters

$type: Content type object.

Return value

Form array for delete confirmation form.

See also

node_type_delete_confirm_submit()

Related topics

1 string reference to 'node_type_delete_confirm'
node_menu in drupal/core/modules/node/node.module
Implements hook_menu().

File

drupal/core/modules/node/content_types.inc, line 460
Content type editing user interface.

Code

function node_type_delete_confirm($form, &$form_state, $type) {
  $form['type'] = array(
    '#type' => 'value',
    '#value' => $type->type,
  );
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $type->name,
  );
  $message = t('Are you sure you want to delete the content type %type?', array(
    '%type' => $type->name,
  ));
  $num_nodes = db_query("SELECT COUNT(*) FROM {node} WHERE type = :type", array(
    ':type' => $type->type,
  ))
    ->fetchField();
  if ($num_nodes) {
    drupal_set_title($message, PASS_THROUGH);
    $caption = '<p>' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array(
      '%type' => $type->name,
    )) . '</p>';
    $form['description'] = array(
      '#markup' => $caption,
    );
    return $form;
  }
  $caption = '<p>' . t('This action cannot be undone.') . '</p>';
  return confirm_form($form, $message, 'admin/structure/types', $caption, t('Delete'));
}