function _backup_migrate_ui_destination_display_file_list in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.3 includes/destinations.inc \_backup_migrate_ui_destination_display_file_list()
- 7.3 includes/destinations.inc \_backup_migrate_ui_destination_display_file_list()
List the backup files in the given destination.
2 calls to _backup_migrate_ui_destination_display_file_list()
- backup_migrate_ui_saved_backups in ./
backup_migrate.module - List the previously created backups from accross multiple destinations.
- _backup_migrate_ui_destination_display_files in includes/
destinations.inc - List the backup files in the given destination.
File
- includes/
destinations.inc, line 291
Code
function _backup_migrate_ui_destination_display_file_list($files, $limit = NULL, $show_pager = FALSE) {
drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
$rows = $sort = array();
if ($files) {
$headers = array(
array(
'data' => 'Filename',
'field' => 'filename',
),
array(
'data' => 'Created',
'field' => 'filetime',
'sort' => 'desc',
),
array(
'data' => 'Size',
'field' => 'filesize',
),
'',
);
$sort_order = tablesort_get_order($headers);
$sort_key = $sort_order['sql'] ? $sort_order['sql'] : 'filetime';
$sort_dir = tablesort_get_sort($headers) == 'desc' ? SORT_DESC : SORT_ASC;
$i = 0;
foreach ((array) $files as $file) {
$info = $file
->info();
// If there's a datestamp, it should override the filetime as it's probably more reliable.
$info['filetime'] = !empty($info['datestamp']) ? $info['datestamp'] : $info['filetime'];
$description = '';
// Add the description as a new row.
if (!empty($info['description'])) {
$description .= ' <div title="' . check_plain($info['description']) . '" class="backup-migrate-description">' . $info['description'] . '</div>';
}
// Add the backup source.
if (!empty($info['bam_sourcename'])) {
$description .= ' <div title="' . check_plain($info['bam_sourcename']) . '" class="backup-migrate-tags"><span class="backup-migrate-label">' . t('Source:') . ' </span>' . check_plain($info['bam_sourcename']) . '</div>';
}
// Add the tags as a new row.
if (!empty($info['tags'])) {
$tags = check_plain(implode(', ', (array) $info['tags']));
$description .= ' <div title="' . $tags . '" class="backup-migrate-tags"><span class="backup-migrate-label">' . t('Tags:') . ' </span>' . $tags . '</div>';
}
// Show only files that can be restored from.
$sort[] = $info[$sort_key];
$rows[] = array(
check_plain($info['filename']) . $description,
t('!time ago', array(
'!time' => format_interval(time() - $info['filetime'], 2),
)) . '<div class="backup-migrate-date">' . format_date($info['filetime'], 'small') . '</div>',
format_size($info['filesize']),
array(
'data' => implode(" | ", $file->destination
->get_file_links($file
->file_id())),
'class' => 'backup-migrate-actions',
),
);
}
array_multisort($sort, $sort_dir, $rows);
// Show only some of them if it's limited.
$showing = $pager = '';
if ($limit) {
$total = count($rows);
$start = 0;
if ($show_pager) {
$page = isset($_GET['page']) ? $_GET['page'] : '';
$start = $page * $limit;
$element = 0;
$GLOBALS['pager_total'][$element] = ceil($total / $limit);
$GLOBALS['pager_page_array'][$element] = $page;
$tags = array(
t('« newest'),
t('« newer'),
'',
t('older »'),
t('oldest »'),
);
$pager = theme('pager', $tags, $limit, $element, array(), ceil($total / $limit));
$end = min($total - 1, $start + $limit);
}
$showing = t('Showing @start to @end of @total files.', array(
'@start' => $start + 1,
'@end' => $end + 1,
'@total' => $total,
));
// Limit the number of rows shown.
$rows = array_slice($rows, $start, $limit, TRUE);
}
$out = theme("table", $headers, $rows, array(
'class' => 'backup-migrate-listing backup-migrate-listing-files',
));
$out .= $showing;
$out .= $pager;
}
else {
$out = t('There are no backup files to display.');
}
return $out;
}