You are here

function backup_migrate_ui_destination_display_files in Backup and Migrate 6.2

Same name and namespace in other branches
  1. 8.2 includes/destinations.inc \backup_migrate_ui_destination_display_files()
  2. 8.3 includes/destinations.inc \backup_migrate_ui_destination_display_files()
  3. 5.2 includes/destinations.inc \backup_migrate_ui_destination_display_files()
  4. 6.3 includes/destinations.inc \backup_migrate_ui_destination_display_files()
  5. 7.3 includes/destinations.inc \backup_migrate_ui_destination_display_files()
  6. 7.2 includes/destinations.inc \backup_migrate_ui_destination_display_files()

List the backup files in the given destination.

1 string reference to 'backup_migrate_ui_destination_display_files'
backup_migrate_destination::get_menu_items in includes/destinations.inc
Add the menu items specific to the destination type.

File

includes/destinations.inc, line 275

Code

function backup_migrate_ui_destination_display_files($destination_id = NULL) {
  $rows = $sort = array();
  if ($destination = backup_migrate_get_destination($destination_id)) {

    // Refresh the file listing cache if requested.
    if (isset($_GET['refresh'])) {
      $destination
        ->file_cache_clear();
      drupal_goto($_GET['q']);
    }
    drupal_set_title(t('%title Files', array(
      '%title' => $destination
        ->get_name(),
    )));
    $headers = array(
      array(
        'data' => 'Filename',
        'field' => 'filename',
      ),
      array(
        'data' => 'Date',
        'field' => 'filetime',
      ),
      array(
        'data' => 'Age',
        'field' => 'filetime',
        'sort' => 'desc',
      ),
      array(
        'data' => 'Size',
        'field' => 'filesize',
      ),
      t('Operations'),
    );
    $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;
    $files = $destination
      ->list_files();
    $i = 0;
    foreach ((array) $files as $file) {
      $info = $file
        ->info();

      // Show only files that can be restored from.
      if ($file
        ->is_recognized_type()) {
        $sort[] = $info[$sort_key];
        $rows[] = array(
          check_plain($info['filename']),
          format_date($info['filetime'], 'small'),
          format_interval(time() - $info['filetime'], 1),
          format_size($info['filesize']),
          implode(" | ", $destination
            ->get_file_links($file
            ->file_id())),
        );
      }
    }
    array_multisort($sort, $sort_dir, $rows);
    if ($files) {
      $out = theme("table", $headers, $rows);
    }
    else {
      $out = t('There are no backup files to display.');
    }
    if ($destination->cache_files && $destination->fetch_time) {
      $out .= '<div class="description">' . t('This listing was fetched !time ago. !refresh', array(
        '!time' => format_interval(time() - $destination->fetch_time, 1),
        '!refresh' => l(t('fetch now'), $_GET['q'], array(
          'query' => 'refresh=true',
        )),
      )) . '</div>';
    }
    return $out;
  }
  drupal_goto(BACKUP_MIGRATE_MENU_PATH . "/destination");
}