From b95195ed4540a07ac0f31c363101698ada841d67 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 9 Jun 2018 00:05:43 +0200 Subject: [PATCH] nieuws: archive pages by year only --- nieuws.inc.php | 8 ++++---- nieuws.php | 2 +- nieuws/edit.js | 2 +- nieuws/index.php | 19 +++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/nieuws.inc.php b/nieuws.inc.php index f4d42d8..8af5694 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -7,7 +7,7 @@ $monthname = ['?', function shownewsdate($url) { - if (!preg_match('', $url, $parts)) return; + if (!preg_match('', $url, $parts)) return; global $monthname; return implode(' ', array_filter([ intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1], @@ -30,10 +30,10 @@ function shownewsarticle($url, $link = TRUE, $title = NULL) return preg_replace('{

(.*?)

}', $title, $html); } -function shownews($root, $limit = 1000) +function shownews($input, $limit = 1000) { - if (strpos($root, '/') === FALSE) $root .= '/*'; - foreach (array_reverse(glob("$root/*.html")) as $url) { + if (!is_array($input)) $input = glob("$input/*.html"); + foreach (array_reverse($input) as $url) { print "
"; ob_start(); include $url; diff --git a/nieuws.php b/nieuws.php index 83fdc7a..cafc94c 100644 --- a/nieuws.php +++ b/nieuws.php @@ -1,4 +1,4 @@ $title\n\n"; print '
'."\n\n"; - shownews($match); + shownews(glob($match.'*.html')); print "
\n\n"; return 1; } @@ -38,10 +37,10 @@ print '
'."\n\n"; foreach (array_reverse(glob("$Page/2???")) as $page) { $year = basename($page, '.html'); printf('

%s

'."\n", $page, $year); - printtoc("$page/??"); + printtoc($page); } -if ($pages = glob("$Page/19??/??/*.html")) { +if ($pages = glob("$Page/19??/*.html")) { printf('

%s

'."\n", "$Page/oud", 'Eerder'); printtoc($pages); } -- 2.30.0