nieuws: treat years before 2000 as single page
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 20 Apr 2018 06:46:09 +0000 (08:46 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 8 Jun 2018 22:37:07 +0000 (00:37 +0200)
nieuws.inc.php
nieuws.php

index 25952ef189a35f7a076d7385caf9789262ea02e3..3d88a263810e58205354a7459f65890fe64505a7 100644 (file)
@@ -43,10 +43,11 @@ function shownews($root, $limit = 5)
        }
 }
 
-function printtoc($root)
+function printtoc($input)
 {
+       if (!is_array($input)) $input = glob("$input/*.html");
        print '<ul>';
-       foreach (array_reverse(glob("$root/*.html")) as $page) {
+       foreach (array_reverse($input) as $page) {
                $title = fgets(fopen($page, 'r'));
                $title = strip_tags($title);
                $linkurl = preg_replace('/\.html$/', '', $page);
index 84a6172638cd446dc98a342f333497065bdfa9e4..b28f72bbf406f556a124ebb02a9867a4b310aed7 100644 (file)
@@ -11,15 +11,28 @@ if ($page) {
 
 if ($year) {
        ob_clean();
-       print "<h2>Nieuws $year</h2>\n\n";
-
+       if (is_numeric($year)) {
+               $title = "Nieuws ".($month ? $monthname[$month].' ' : '').$year;
+               $match = implode('/', [
+                       $Page, $year, $month ? sprintf('%02d', $month) : '??',
+               ]);
+       }
+       else {
+               $title = "Nieuws vóór 2000";
+               $match = "$Page/19??/??";
+       }
+
+       print "<h2>$title</h2>\n\n";
        print '<div id="news">'."\n\n";
-       shownews("$Page/$year/??", 100);
+       shownews($match, 100);
        print "</div>\n\n";
-
        return 1;
 }
 
+if ($Args) {
+       return;
+}
+
 print '<div id="news">'."\n\n";
 
 foreach (array_reverse(glob("$Page/2???")) as $page) {
@@ -28,6 +41,11 @@ foreach (array_reverse(glob("$Page/2???")) as $page) {
        printtoc("$page/??");
 }
 
+if ($pages = glob("$Page/19??/??/*.html")) {
+       printf('<h3><a href="/%s">%s</a></h3>'."\n", "$Page/oud", 'Eerder');
+       printtoc($pages);
+}
+
 print "</div>\n\n";
 
 if (!empty($User['admin'])) {