X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/328e964708c7e9dc479a25f9358b2d03e9d7f66c..a332183ffe74a1580779a5eeeeb7dbe02a398075:/nieuws.inc.php diff --git a/nieuws.inc.php b/nieuws.inc.php index 7e723e4..454c91c 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -1,4 +1,5 @@ ', $url, $parts)) return; global $monthname; - return sprintf('%s %s %s', - intval($day), $monthname[intval($month)], $year); + return implode(' ', array_filter([ + intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1], + ])); +} + +function shownewsimage($url) +{ + foreach (['jpg', 'png'] as $ext) { + if (file_exists("$url.$ext")) { + return "$url.$ext"; + } + } } function shownewsarticle($url, $link = TRUE, $title = NULL) @@ -25,29 +34,41 @@ function shownewsarticle($url, $link = TRUE, $title = NULL) $title = sprintf( $link ? '

%s

' : '

%s

', getoutput([1 => ' '.$date.'']), - 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".'

', "/thumb/640x/".$image), + ]); + } + return preg_replace('{

(.*?)

}', $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) { + if (!is_array($input)) $input = glob("$input/*.html"); + foreach (array_reverse($input) as $url) { print "
"; ob_start(); include $url; - print shownewsarticle($url); + print shownewsarticle(preg_replace('/\.html$/', '', $url)); print "
\n\n"; if (--$limit <= 0) break; } } -function printtoc($root) +function printtoc($input) { + if (!is_array($input)) $input = glob("$input/*.html"); print '