X-Git-Url: http://git.shiar.nl/minimedit.git/blobdiff_plain/f74276ad4a38479c8a5f7ccf065ab576cf2d192d..v2.6-9-g3da476bb04:/nieuws.inc.php diff --git a/nieuws.inc.php b/nieuws.inc.php index ca16b4a..f9fec6a 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -6,12 +6,11 @@ $monthname = ['?', function shownewsdate($url) { - $parts = pathinfo($url); - $year = pathinfo($parts['dirname'], PATHINFO_FILENAME); - @list ($month, $day) = explode('-', $parts['filename'], 3); + if (!preg_match('', $url, $parts)) return; global $monthname; - return sprintf('%s %s %s', - intval($day), $monthname[intval($month)], $year); + return implode(' ', array_filter([ + intval($parts[3]), $monthname[intval($parts[2])], $parts[1], + ])); } function shownewsarticle($url, $link = TRUE, $title = NULL) @@ -32,7 +31,8 @@ function shownewsarticle($url, $link = TRUE, $title = NULL) function shownews($root, $limit = 5) { - foreach (array_reverse(glob("$root/*/*.html")) as $url) { + if (strpos($root, '/') === FALSE) $root .= '/*'; + foreach (array_reverse(glob("$root/*.html")) as $url) { print "
"; ob_start(); include $url; @@ -42,3 +42,16 @@ function shownews($root, $limit = 5) if (--$limit <= 0) break; } } + +function printtoc($root) +{ + print '\n"; +}