widget: copy doclist and countdown from lijtweg.nl
[minimedit.git] / widget / doclist.php
diff --git a/widget/doclist.php b/widget/doclist.php
new file mode 100644 (file)
index 0000000..78b8c49
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+$cal = [];
+foreach (glob("$Page$Args/2*") as $url) {
+       $parts = pathinfo($url);
+       @list ($date, $suffix) = explode('.', $parts['filename'], 2);
+       $cal[$date][ $suffix ? '' : @$parts['extension'] ] =
+               preg_replace('/\.html$/', '', $url);
+}
+
+print '<ul';
+if (count($cal) > 5) print ' class="cols"';
+print ">\n";
+foreach (array_reverse($cal) as $title => $versions) {
+       print '<li>';
+       if ($url = @$versions['html']) {
+               printf('<a href="/%s">%s</a>', $url, $title);
+       }
+       elseif (implode('', array_keys($versions))) {
+               list ($format, $url) = each($versions);
+               include_once('format.inc.php');
+               printf('%s (<a href="/%s">%sB %s</a>)',
+                       $title, $url, showsize(filesize($url)), $format
+               );
+       }
+       else {
+               print $title;
+       }
+       print "\n";
+}
+print "</ul>\n\n";
+