Skip to content

Commit

Permalink
Feature to show or hide file counts (#98)
Browse files Browse the repository at this point in the history
* Add backward compatible config value for showing numbers in the tree view

* Don't show number of files when configuration value is false

* Add documentation for the show_file_count config
  • Loading branch information
Martin1982 committed Feb 10, 2022
1 parent e86388f commit 643db45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Controller/ManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,11 @@ private function retrieveSubDirectories(FileManager $fileManager, string $path,
$queryParametersRoute = $queryParameters;
unset($queryParametersRoute['route']);

$filesNumber = $this->retrieveFilesNumber($directory->getPathname(), $fileManager->getRegex());
$fileSpan = $filesNumber > 0 ? " <span class='label label-default'>{$filesNumber}</span>" : '';
$fileSpan = '';
if (true === $fileManager->getConfiguration()['show_file_count']) {
$filesNumber = $this->retrieveFilesNumber($directory->getPathname(), $fileManager->getRegex());
$fileSpan = $filesNumber > 0 ? " <span class='label label-default'>{$filesNumber}</span>" : '';
}

$directoriesList[] = [
'text' => $directory->getFilename().$fileSpan,
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function getConfigTreeBuilder(): TreeBuilder {
->scalarNode('dir')->end()
->enumNode('type')->values(['file', 'image', 'media'])->end()
->booleanNode('tree')->end()
->booleanNode('show_file_count')->defaultValue(true)->end()
->scalarNode('twig_extension')->end()
->booleanNode('cachebreaker')->defaultValue(true)->end()
->enumNode('view')->values(['thumbnail', 'list'])->defaultValue('list')->end()
Expand Down
8 changes: 8 additions & 0 deletions Resources/doc/book/1-basic-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ artgris_file_manager:

Adding a cachebreaker ?time=RANDOM_NUMBER or & &time=RANDOM_NUMBER at the end of the images (preview) url. It's removed if you have used "twig_extension" option.

## `show_file_count` to show the number of files per directory in the file browser tree

| Option | Type | Required | Default value |
|:------------------|:--------:|:--------:|:-------------:|
| `show_file_count` | `bool` | False | True |

Having a large number of files in a (sub-)directory can have a huge impact on performance, setting this to false will improve the performance at the cost of the display of files per directory

## `upload` A non-exhaustive configuration of the File Upload widget [blueimp/jQuery-File-Upload](https://github.com/blueimp/jQuery-File-Upload)
> [Exhaustive options](https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php) can only be defined with [The service configuration](2-service-configuration.md)
Expand Down

0 comments on commit 643db45

Please sign in to comment.