8
0

Add support for + at the beginning, fixes #18

Dieser Commit ist enthalten in:
Stéphane Goetz
2017-11-08 21:49:30 +01:00
Ursprung d898eb6edf
Commit d1c7b27563
5 geänderte Dateien mit 37 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -136,7 +136,7 @@ class Builder
*/
public static function removeSortingInformations($filename)
{
preg_match('/^-?[0-9]*_?(.*)/', $filename, $matches);
preg_match('/^[-+]?[0-9]*_?(.*)/', $filename, $matches);
// Remove the numeric part
// of the filename, only if

Datei anzeigen

@ -15,6 +15,8 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
{
// Separate the values into buckets to sort them separately
$buckets = [
'up_numeric' => [],
'up' => [],
'index' => [],
'numeric' => [],
'normal' => [],
@ -41,6 +43,17 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
continue;
}
if ($name[0] == '+') {
if (is_numeric($name[1])) {
$exploded = explode('_', $name);
$buckets['up_numeric'][abs(substr($exploded[0], 1))][$key] = $entry;
continue;
}
$buckets['up'][$key] = $entry;
continue;
}
if (is_numeric($name[0])) {
$exploded = explode('_', $name);
$buckets['numeric'][abs($exploded[0])][$key] = $entry;
@ -52,7 +65,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
$final = [];
foreach ($buckets as $name => $bucket) {
if ($name == 'numeric' || $name == 'down_numeric') {
if (substr($name, -7) == 'numeric') {
ksort($bucket);
foreach ($bucket as $sub_bucket) {
$final = $this->sortBucket($sub_bucket, $final);