function delete_all_content in Delete all 6
Same name and namespace in other branches
- 5 delete_all.module \delete_all_content()
- 7 delete_all.module \delete_all_content()
2 string references to 'delete_all_content'
- delete_all_menu in ./delete_all.module
- delete_all_users in ./delete_all.module
File
- ./delete_all.module, line 35
Code
function delete_all_content() {
$result = db_query("SELECT type, COUNT(*) AS num FROM {node} GROUP BY type");
$count = array();
while ($data = db_fetch_object($result)) {
$count[$data->type] = $data->num;
}
$types = array();
foreach (node_get_types() as $type => $info) {
if ($count[$type] > 0) {
$types[$type] = $info->name . ' (' . $count[$type] . ')';
}
}
asort($types);
if (empty($types)) {
$form = array();
$form['no_content_types'] = array(
'#prefix' => '<p>',
'#suffix' => '</p>',
'#value' => t('There are no content types with content available to delete. You must <a href="@node-add">create some content</a> in order to delete it.', array(
'@node-add' => url('node/add'),
)),
);
if (module_exists('devel')) {
$form['generate_content_suggestion'] = array(
'#prefix' => '<p>',
'#suffix' => '</p>',
'#value' => t('You can generate content quickly at the <a href="@generate-content-page">generate content page</a>.', array(
'@generate-content-page' => url('admin/generate/content'),
)),
);
}
return $form;
}
drupal_add_js(drupal_get_path('module', 'delete_all') . '/delete_all.js');
$form = array();
$form['all'] = array(
'#type' => 'checkbox',
'#default_value' => TRUE,
'#title' => t('Delete All Content'),
'#description' => t('Select to delete all content'),
'#attributes' => array(
'class' => 'delete-all',
),
);
$form['type-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Types'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'types' => array(
'#type' => 'checkboxes',
'#options' => $types,
'#description' => t('Select the types of content to delete'),
'#theme' => 'delete_all_checkboxes',
),
);
$form['method-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Method'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'method' => array(
'#type' => 'radios',
'#title' => t('Method'),
'#options' => array(
'normal' => t('Normal'),
'quick' => t('Quick'),
),
'#default_value' => 'normal',
'#description' => t('Normal node delete calls node_delete() on every node in the database. If you have only a few hundred nodes, this can take a very long time. Use the quick node delete method to get around this problem. This method deletes directly from the database, skipping the extra php processing. The downside is that it can miss related tables that are normally handled by module hook_delete\'s.'),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['#action'] = url('admin/content/delete_content/confirm');
return $form;
}