function revision_deletion_admin_overview in Revision Deletion 7
Form builder for the revisions overview administration form.
See also
revision_deletion_admin_overview_submit()
1 string reference to 'revision_deletion_admin_overview'
- revision_deletion_menu in ./
revision_deletion.module - Implements hook_menu().
File
- ./
revision_deletion.admin.inc, line 227
Code
function revision_deletion_admin_overview($form, &$form_state) {
if (isset($form_state['storage']['confirm'])) {
return revision_deletion_admin_overview_confirm($form_state, 'admin/config/content/revision_deletion');
}
$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',
),
'title' => array(
'data' => t('Title'),
'field' => 'n.title',
'sort' => 'asc',
),
'name' => array(
'data' => t('User'),
),
'date' => array(
'data' => t('Created'),
'field' => 'r.timestamp',
'sort' => 'desc',
),
'type' => array(
'data' => t('Type'),
),
'status' => t('Status'),
'notes' => t('Notes'),
'op' => t('Operations'),
);
$show_notes = variable_get('revision_deletion_list_show_notes');
if (!$show_notes) {
unset($header['notes']);
}
$revisions = _revision_deletion_get_list(NULL, $header);
$rows = array();
$default_value = array();
$accounts = array();
foreach ($revisions as $node) {
if (!isset($accounts[$node->uid])) {
$accounts[$node->uid] = theme('username', array(
'account' => user_load($node->uid),
));
}
$default_value[$node->vid] = $node->select;
$rows[$node->vid] = array(
'vid' => array(
'data' => array(
'#type' => 'link',
'#title' => $node->vid,
'#href' => 'node/' . $node->nid . '/revisions/' . $node->vid . '/view',
'#options' => array(
'title' => t('view revision'),
),
),
),
'title' => array(
'data' => array(
'#type' => 'link',
'#title' => $node->title,
'#href' => 'node/' . $node->nid,
'#options' => array(
'title' => t('view !type', array(
'!type' => $node->type,
)),
),
'#prefix' => '<strong>',
'#suffix' => '</strong><br />' . $node->log,
),
),
'name' => $accounts[$node->uid],
'date' => format_date($node->timestamp, 'small'),
'type' => check_plain(node_type_get_name($node)),
'status' => $node->status ? t('published') : t('not published'),
'notes' => filter_xss($node->notes),
'op' => array(
'data' => array(
'#type' => 'link',
'#title' => t('list revisions'),
'#href' => 'admin/config/content/revision_deletion/node/' . $node->nid,
),
),
);
if (!$show_notes) {
unset($rows[$node->vid]['notes']);
}
}
$form['revisions'] = array(
'#type' => 'tableselect',
'#multiple' => TRUE,
'#header' => $header,
'#options' => $rows,
'#sticky' => TRUE,
'#default_value' => $default_value,
'#empty' => t('No content with deletable revisions found.'),
);
foreach ($revisions as $node) {
if ($node->vid == $node->current) {
$form['revisions'][$node->vid]['#disabled'] = TRUE;
}
}
// Build some informational messages.
// The values are already 'sanitized.'.
$info_texts = array();
$frequency = variable_get('revision_deletion_frequency');
if ($frequency == 0) {
$auto_msg = t('Automatic deletion is not currently scheduled.');
}
else {
$auto_msg = t('Automatic deletion is scheduled to run every !interval.', array(
'!interval' => format_interval($frequency),
));
$last_update = variable_get('revision_deletion_cron');
if ($last_update) {
$msg_data = array(
'!last_update_time' => format_date($last_update, 'large'),
'!last_update_ago' => format_interval(time() - $last_update),
);
$auto_msg .= ' ' . t('It was last run !last_update_time (!last_update_ago ago).', $msg_data);
}
else {
$auto_msg .= ' ' . t('It has not yet run automatically.');
}
}
$info_texts[] = $auto_msg;
$keep_current = variable_get('revision_deletion_list_keep_current');
if ($keep_current > 0) {
$info_texts[] = t('If the current revision was created less than !current_age ago, the next older revision will be kept.', array(
'!current_age' => format_interval($keep_current),
));
}
if (variable_get('revision_deletion_list_keep_original')) {
$info_texts[] = t('The original revision will be kept.');
}
if (variable_get('revision_deletion_list_keep_date_last')) {
$info_texts[] = t('The last revision for each date will be kept.');
}
$age = variable_get('revision_deletion_age');
if ($age > 0) {
$info_texts[] = t('Revisions older than !age_interval will be deleted.', array(
'!age_interval' => format_interval($age),
));
}
$form['info'] = array(
'#type' => 'item',
'#markup' => theme('item_list', array(
'items' => $info_texts,
'type' => 'ul',
)),
);
$form['pager'] = array(
'#theme' => 'pager',
);
$form['button']['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete selected revisions'),
);
return $form;
}