nieuws: port excelsior toc and year filtering
[minimedit.git] / nieuws.inc.php
index ca16b4a13a0bcddc5d3f62750376c17edf69f5f1..7e723e4095e68febd3abde4fcc957217320168f8 100644 (file)
@@ -32,7 +32,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 "<article>";
                ob_start();
                include $url;
@@ -42,3 +43,16 @@ function shownews($root, $limit = 5)
                if (--$limit <= 0) break;
        }
 }
+
+function printtoc($root)
+{
+       print '<ul>';
+       foreach (array_reverse(glob("$root/*.html")) as $page) {
+               $title = fgets(fopen($page, 'r'));
+               $title = strip_tags($title);
+               $linkurl = preg_replace('/\.html$/', '', $page);
+               printf('<li><a href="/%s">%s <small class="date">%s</small></a></li>',
+                       $linkurl, $title, shownewsdate($linkurl));
+       }
+       print "</ul>\n";
+}