nieuws: inline code to format article overviews
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 27 Jun 2019 21:27:17 +0000 (23:27 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 28 Jun 2019 01:20:30 +0000 (03:20 +0200)
No distinct callers remain, only the placement page which is included
instead.

nieuws.inc.php
nieuws.php

index 34b565a1358b656df7072c20d8d1ef222a31e50f..c6f3be9680d34b5d331cbf1c52c0c2f342add3d1 100644 (file)
@@ -120,53 +120,3 @@ class ArchiveArticle
                );
        }
 }
-
-function shownews($input, $limit = 1000)
-{
-       if (!is_array($input)) $input = glob("$input/*.html");
-       foreach (array_reverse($input) as $filename) {
-               $article = new ArchiveArticle($filename);
-               print '<article class="left">';
-               if ($article->thumb) {
-                       $imgattr = ' class="left"';
-                       if (preg_match('{ (\s alt="[^"]+") }x', $article->img, $img)) {
-                               $imgattr .= $img[0];  # preserve alt value
-                       }
-                       printf('<img src="/%s"%s />', $article->thumb, $imgattr);
-               }
-               print '<div>';
-               printf(
-                       '<h3><a href="/%s">%s <small class="date">%s</small></a></h3>',
-                       $article->link, $article->title, $article->date
-               );
-               print $article->body;
-               print '</div>';
-               print "</article>\n\n";
-
-               if (--$limit <= 0) break;
-       }
-}
-
-function printtoc($input, $class = FALSE)
-{
-       if (!is_array($input)) $input = glob("$input/*.html");
-       print '<ul';
-       if ($class) printf(' class="%s"', $class);
-       print '>';
-       foreach (array_reverse($input) as $page) {
-               $article = new ArchiveArticle($page);
-               $html = $article->safetitle;
-               $dateparts = $article->dateparts;
-               if ($class) {
-                       $dateparts[0] = NULL;  # omit year
-               }
-               $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
-               if ($class == 'gallery' and $article->img) {
-                       $html = "<div>$html</div>";
-                       $html = sprintf('<img src="%s" />', $article->thumb(200)) . $html;
-               }
-               $html = sprintf('<a href="/%s">%s</a>', $article->link, $html);
-               print "<li><article>$html</article></li>\n";
-       }
-       print "</ul>\n";
-}
index 338a6b6693d2fdfee42b8303d09552888f10c723..251443842cd67d20105c0af95898bfdb631faeca 100644 (file)
@@ -1,5 +1,58 @@
 <?php
 include_once 'nieuws.inc.php';
+
+if (!function_exists('shownews')) {
+function shownews($input, $limit = 1000)
+{
+       if (!is_array($input)) $input = glob("$input/*.html");
+       foreach (array_reverse($input) as $filename) {
+               $article = new ArchiveArticle($filename);
+               print '<article class="left">';
+               if ($article->thumb) {
+                       $imgattr = ' class="left"';
+                       if (preg_match('{ (\s alt="[^"]+") }x', $article->img, $img)) {
+                               $imgattr .= $img[0];  # preserve alt value
+                       }
+                       printf('<img src="/%s"%s />', $article->thumb, $imgattr);
+               }
+               print '<div>';
+               printf(
+                       '<h3><a href="/%s">%s <small class="date">%s</small></a></h3>',
+                       $article->link, $article->title, $article->date
+               );
+               print $article->body;
+               print '</div>';
+               print "</article>\n\n";
+
+               if (--$limit <= 0) break;
+       }
+}
+
+function printtoc($input, $class = FALSE)
+{
+       if (!is_array($input)) $input = glob("$input/*.html");
+       print '<ul';
+       if ($class) printf(' class="%s"', $class);
+       print '>';
+       foreach (array_reverse($input) as $page) {
+               $article = new ArchiveArticle($page);
+               $html = $article->safetitle;
+               $dateparts = $article->dateparts;
+               if ($class) {
+                       $dateparts[0] = NULL;  # omit year
+               }
+               $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
+               if ($class == 'gallery' and $article->img) {
+                       $html = "<div>$html</div>";
+                       $html = sprintf('<img src="%s" />', $article->thumb(200)) . $html;
+               }
+               $html = sprintf('<a href="/%s">%s</a>', $article->link, $html);
+               print "<li><article>$html</article></li>\n";
+       }
+       print "</ul>\n";
+}
+}
+
 $articles = (ltrim($Args, '/') ?: 'nieuws');
 if (strpos($articles, '/') === FALSE) {
        if (@$Place['view'] === 'toc') {