From 88f73ba789fb0aeb1037a89b0864a3ad2869d4aa Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Fri, 13 Jul 2018 13:55:54 -0400 Subject: Modernize the archive listing with SPL, headings and columns --- archives/planet/index.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'archives/planet/index.php') diff --git a/archives/planet/index.php b/archives/planet/index.php index 6a2c70d..4d58783 100644 --- a/archives/planet/index.php +++ b/archives/planet/index.php @@ -7,6 +7,11 @@ + @@ -59,17 +64,28 @@ "; - foreach ($scandir as $curdir) { - if ( substr($curdir,0,5) == "index" || $curdir == ".." || $curdir == "." ) continue; - $cscan = scandir('./' . $curdir, 1); - foreach($cscan as $filename) { - if ( $filename == "." || $filename == ".." ) continue; - echo "
  • $filename
  • \n"; + class SortedFileIterator extends SplHeap { + public function __construct(Iterator $iterator) { + foreach($iterator as $item) { + $this->insert($item); + } } + public function compare($b, $a) { + return strcmp($b->getRealpath(), $a->getRealpath()); + } + } + foreach (new SortedFileIterator(new FilesystemIterator('.')) as $entry) { + if (!$entry->isDir()) continue; + $path = $entry->getFileName(); + echo "
    $path
    "; + foreach (new SortedFileIterator(new FilesystemIterator($entry)) as $file) { + if (!$file->isFile()) continue; + $filename = $file->getFileName(); + $basename = $file->getBaseName('.html'); + echo "
    {$basename}
    \n"; + } + echo "

    "; } - echo ""; ?> -- cgit v1.2.3-65-gdbad