diff --git a/core/Controller/Redirect/RedirectAdminController.php b/core/Controller/Redirect/RedirectAdminController.php index c56567e..2916a3c 100644 --- a/core/Controller/Redirect/RedirectAdminController.php +++ b/core/Controller/Redirect/RedirectAdminController.php @@ -111,24 +111,24 @@ class RedirectAdminController extends CrudController ->setField('index', 'Label', Field\TextField::class, [ 'property' => 'label', - 'attr' => ['class' => 'col-3'], + 'attr' => ['class' => 'col-4'], ]) ->setField('index', 'Rule', Field\TextField::class, [ 'view' => '@Core/redirect/redirect_admin/field/rule.html.twig', - 'attr' => ['class' => 'col-5'], + 'attr' => ['class' => 'col-6'], ]) ->setField('index', 'Enabled', Field\ButtonField::class, [ 'property_builder' => function(EntityInterface $entity) { return $entity->getIsEnabled() ? 'Yes' : 'No'; }, - 'attr' => ['class' => 'col-2'], + 'attr' => ['class' => 'col-1'], 'button_attr_builder' => function(EntityInterface $entity) { return ['class' => 'btn btn-sm btn-'.($entity->getIsEnabled() ? 'success' : 'primary')]; }, ]) ->setField('index', 'Type', Field\ButtonField::class, [ 'property' => 'redirectCode', - 'attr' => ['class' => 'col-2'], + 'attr' => ['class' => 'col-1'], 'button_attr' => ['class' => 'btn btn-sm btn-light border-secondary font-weight-bold'], ]) ->setBatchAction('index', 'enable', 'Enable', function (EntityInterface $entity, EntityManager $manager) { diff --git a/core/FileManager/FsFileManager.php b/core/FileManager/FsFileManager.php index a572e1e..137e63b 100644 --- a/core/FileManager/FsFileManager.php +++ b/core/FileManager/FsFileManager.php @@ -72,26 +72,7 @@ class FsFileManager $finder = new Finder(); $finder->directories()->depth('== 0')->in($this->path.'/'.$directory); - - if (isset($options['sort'])) { - $sort = $options['sort']; - $sorted = false; - $direction = $options['sort_direction']; - - if ('name' === $sort) { - $finder->sortByName(); - $sorted = true; - } elseif ('modification_date' === $sort) { - $sorted = true; - $finder->sortByModifiedTime(); - } - - if ($sorted) { - if ('desc' === $direction) { - $finder->reverseSorting(); - } - } - } + $this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc'); foreach ($finder as $file) { $data['directories'][] = [ @@ -106,6 +87,8 @@ class FsFileManager $finder = new Finder(); $finder->files()->depth('== 0')->in($this->path.'/'.$directory); + $this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc'); + foreach ($finder as $file) { $data['files'][] = [ 'basename' => $file->getBasename(), @@ -287,6 +270,19 @@ class FsFileManager return $this->pathLocked; } + protected function applySort(Finder $finder, string $sort, string $direction) + { + if ('name' === $sort) { + $finder->sortByName(); + } elseif ('modification_date' === $sort) { + $finder->sortByModifiedTime(); + } + + if ('desc' === $direction) { + $finder->reverseSorting(); + } + } + protected function normalizePath(string $path): string { return (string) u($path)