nieuws: ignore missing page description in new articles
[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 (!empty($User['admin'])) {
8         print '<script src="/nieuws/edit.js"></script>'."\n";
9 }
10
11 if ($page and !is_numeric($page)) {
12         $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
13         $article = new ArchiveArticle("$Page$Args.html");
14         $Place['title'] = $edit ?: $article->title;
15         if ($article->file) {
16                 $Place['description'] = $article->teaser;
17         }
18         $Place[1] = ' <small class="date">'.$article->date.'</small>';
19         print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
20         if ($article->file and $article->image) {
21                 $Place['image'] = "/".$article->thumb('600x');
22         }
23         if (!empty($User['admin'])) {
24                 $taglist = [];
25                 foreach (glob("$Page/.tags/*") as $tagpath) {
26                         $tagname = pathinfo($tagpath, PATHINFO_BASENAME);
27                         $tagvalue = file_exists("$tagpath/$year-$page.html");
28                         $tagtarget = is_writable($tagpath);
29                         $taglist[] = sprintf(
30                                 '<input type="checkbox" name="%s" value="%s" id="%s"%s%s />' .
31                                 '<label for="%3$s"> %s</label>',
32                                 "tags[$tagname]", $tagname, "tag-$tagname",
33                                 $tagvalue ? ' checked' : '',
34                                 ' disabled',
35                                 ucfirst($tagname)
36                         );
37                 }
38                 if ($taglist) {
39                         printf('<p class="tags"><strong>Tags:</strong> %s</p>'."\n",
40                                 implode("\n\t", $taglist)
41                         );
42                 }
43         }
44         if ($replyform) {
45                 print placeholder_include('nieuws/replies');
46         }
47         return 1;
48 }
49
50 if ($year) {
51         ob_clean();
52         $match = $Page;
53         $title = "Nieuws";
54         if (is_numeric($year) and $year > 999) {
55                 $match .= "/$year";
56                 if (is_numeric($page)) {
57                         $title .= ' '.$monthname[intval($page)];
58                         $match .= sprintf('%02d-', $page);
59                 }
60                 $title .= ' '.$year;
61         }
62         elseif ($year === '19') {
63                 $match .= "/19??";
64                 $title .= " vóór 2000";
65         }
66         elseif (file_exists("$Page/.tags/$year")) {
67                 $match .= "/.tags/$year";
68                 $title .= " met $year";
69         }
70
71         print "<h2>$title</h2>\n\n";
72         print placeholder_include('nieuws', [$match]);
73         return 1;
74 }