<?php
+global $monthname;
$monthname = ['?',
'januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december',
];
-function shownewsdate($url)
+function showdate($parts)
{
- $parts = pathinfo($url);
- $year = pathinfo($parts['dirname'], PATHINFO_FILENAME);
- @list ($month, $day) = explode('-', $parts['filename'], 3);
global $monthname;
- return sprintf('<small class="date">%s %s %s</small>',
- intval($day), $monthname[intval($month)], $year);
+ return implode(' ', array_filter([
+ intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
+ count($parts) > 6 ? "$parts[4]:$parts[5]" : '',
+ ]));
+}
+
+function shownewsdate($url)
+{
+ if (!preg_match('</(\d{4})/(\d{2})-(\d{2})->', $url, $parts)) return;
+ return showdate($parts);
+}
+
+function shownewsimage($url)
+{
+ foreach (['jpg', 'png'] as $ext) {
+ if (file_exists("$url.$ext")) {
+ return "$url.$ext";
+ }
+ }
}
function shownewsarticle($url, $link = TRUE, $title = NULL)
$title = sprintf(
$link ? '<h3><a href="/%2$s">%s</a></h3>' : '<h2>%s</h2>',
getoutput([1 => ' <small class="date">'.$date.'</small>']),
- preg_replace('/\.html$/', '', $url)
+ $url
);
+
+ if (!$link and $image = shownewsimage($url)) {
+ global $Place;
+ $Place['image'] = "https://lijtweg.nl/thumb/600x/".$image;
+ ob_start();
+ print '[[1]]';
+ $html .= getoutput([
+ 1 => sprintf("\n".'<p><img src="%s" /></p>', "/thumb/640x/".$image),
+ ]);
+ }
+
return preg_replace('{<h2>(.*?)</h2>}', $title, $html);
}
-function shownews($root, $limit = 5)
+function shownews($input, $limit = 1000)
{
- if (strpos($root, '/') === FALSE) $root .= '/*';
- foreach (array_reverse(glob("$root/*.html")) as $url) {
- print "<article>";
+ if (!is_array($input)) $input = glob("$input/*.html");
+ print '<ul class="left">'."\n\n";
+ foreach (array_reverse($input) as $filename) {
+ $url = preg_replace('/\.html$/', '', $filename);
+ print '<li>';
+ if ($image = shownewsimage($url)) {
+ printf('<img src="%s" class="left" />', "/thumb/300x/".$image);
+ }
+ print '<article>';
ob_start();
- include $url;
+ include $filename;
print shownewsarticle($url);
- print "</article>\n\n";
+ print "</article></li>\n\n";
if (--$limit <= 0) break;
}
+ print "</ul>\n\n";
}
-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);