You are here

function Presentation::theme_dir_listing_statistics in Filebrowser 3.x

Same name and namespace in other branches
  1. 8.2 src/Presentation.php \Drupal\filebrowser\Presentation::theme_dir_listing_statistics()

File

src/Presentation.php, line 280

Class

Presentation

Namespace

Drupal\filebrowser

Code

function theme_dir_listing_statistics($statistics) {

  // $white_list is used to restrict indexes to filebrowser indexes.
  // Issue #2616738 indicates addition of 'index' to the array
  $output = "<div class='dir-listing-status'>";
  if ($statistics['empty']) {
    $output .= $statistics['empty'];
  }
  else {
    $white_list = [
      'files',
      'total_size',
      'empty',
      'folders',
    ];
    $white_listed_statistics = [];
    foreach ($statistics as $key => $statistic) {
      if (in_array($key, $white_list) && !empty($statistic)) {
        $white_listed_statistics[] = $statistic;
      }
    }
    $output .= implode(" - ", $white_listed_statistics);
  }
  $output .= "</div>";
  return $output;
}