edit: restyle to upstream ckeditor configuration
[minimedit.git] / nieuws.inc.php
index 7e723e4095e68febd3abde4fcc957217320168f8..8af5694a62dfb5e2c12987d57561e8921c9891a5 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+global $monthname;
 $monthname = ['?',
        'januari', 'februari', 'maart', 'april', 'mei', 'juni',
        'juli', 'augustus', 'september', 'oktober', 'november', 'december',
@@ -6,12 +7,11 @@ $monthname = ['?',
 
 function shownewsdate($url)
 {
-       $parts = pathinfo($url);
-       $year = pathinfo($parts['dirname'], PATHINFO_FILENAME);
-       @list ($month, $day) = explode('-', $parts['filename'], 3);
+       if (!preg_match('</(\d{4})/(\d{2})-(\d{2})->', $url, $parts)) return;
        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],
+       ]));
 }
 
 function shownewsarticle($url, $link = TRUE, $title = NULL)
@@ -30,10 +30,10 @@ function shownewsarticle($url, $link = TRUE, $title = NULL)
        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) {
+       if (!is_array($input)) $input = glob("$input/*.html");
+       foreach (array_reverse($input) as $url) {
                print "<article>";
                ob_start();
                include $url;
@@ -44,10 +44,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);