nieuws: support tagged article links
[minimedit.git] / nieuws / index.php
1 <?php
2 include 'nieuws.inc.php';
3
4 $replyform = $Page == 'melding' && !empty($User);
5 @list ($year, $page) = explode('/', trim($Args, '/'));
6
7 if ($page and !is_numeric($page)) {
8         $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
9         $article = new ArchiveArticle("$Page$Args.html");
10         $Place[1] = ' <small class="date">'.$article->date.'</small>';
11         print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
12         if ($article->image) {
13                 $Place['image'] = "https://lijtweg.nl/".$article->thumb('600x');
14         }
15         if ($replyform) {
16                 print placeholder_include('nieuws/replies');
17         }
18         return 1;
19 }
20
21 if ($year) {
22         ob_clean();
23         $match = $Page;
24         $title = "Nieuws";
25         if (is_numeric($year) and $year > 999) {
26                 $match .= "/$year";
27                 if (is_numeric($page)) {
28                         $title .= ' '.$monthname[intval($page)];
29                         $match .= sprintf('%02d-', $page);
30                 }
31                 $title .= ' '.$year;
32         }
33         elseif ($year === '19') {
34                 $match .= "/19??";
35                 $title .= " vóór 2000";
36         }
37         elseif (file_exists("$Page/.tags/$year")) {
38                 $match .= "/.tags/$year";
39                 $title .= " met $year";
40         }
41
42         print "<h2>$title</h2>\n\n";
43         print placeholder_include('nieuws', [$match]);
44         return 1;
45 }
46
47 if (!empty($User['admin'])) {
48         print '<script src="/nieuws/edit.js"></script>'."\n";
49 }