1 restore.php | restore_backup_form($form, &$form_state) |
Form constructor for the list of available database module updates.
File
- core/
restore.php, line 80 - Administrative page for restoring backup database and configuration files.
Code
function restore_backup_form($form, &$form_state) {
$backups = backup_directory_list();
// This function uses st() because it needs to function even when there is
// no database available.
$help = st('The restore process may take several minutes, depending on the size of your database.');
$no_backups_help = st('No backups are currently available to be restored.');
$form['help'] = array(
'#type' => 'help',
'#markup' => $no_backups_help,
'#weight' => -5,
);
if ($backups) {
$form['help']['#markup'] = $help;
$form['backup'] = array(
'#type' => 'radios',
'#title' => st('Select backup'),
'#options' => array(),
);
$backups = backup_directory_list();
backdrop_sort($backups, array('timestamp' => SORT_NUMERIC), SORT_DESC);
foreach ($backups as $backup_directory => $backup_info) {
$form['backup']['#options'][$backup_directory] = $backup_info['label'] ? : $backup_info['name'];
if (!$backup_info['valid']) {
$form['backup'][$backup_directory]['#disabled'] = TRUE;
$form['backup'][$backup_directory]['#description'] = st('This backup is missing a backup information file and cannot be restored.');
}
else {
if ($backup_info['description']) {
$form['backup'][$backup_directory]['#description'] = check_plain($backup_info['description']);
}
else {
$form['backup'][$backup_directory]['#description'] = st('Contains backup files: @list', array(
'@list' => implode(', ', array_keys($backup_info['targets'])),
));
}
}
}
// Set the default to the most recent backup.
$first_backup = key($form['backup']['#options']);
$form['backup']['#default_value'] = $first_backup;
$form['backup']['#options'][$first_backup] .= ' ' . st('(most recent)');
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => st('Restore backup'),
);
}
$form['actions']['cancel'] = array(
'#type' => 'link',
'#href' => '<front>',
'#title' => st('Cancel'),
);
return $form;
}