mail: lay out sender and date as subheader
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 6 Dec 2020 06:33:51 +0000 (07:33 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 19 Dec 2020 02:01:43 +0000 (03:01 +0100)
Similar to the GMail interface.

mail/index.php

index b4846cc8f48b5c4f8e21420562175a44eade63e9..d4d4c29a2131ac54e8e779b164ad2c6e5aacd3bf 100644 (file)
@@ -17,13 +17,17 @@ if ($msgid) {
        $filename = "$mailbox/$msgid";
        list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2);
        $head = parsemailhead($headerdata);
+       $head['date']->setTimezone(new DateTimeZone(date_default_timezone_get()));
 
        $Page->title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i');
        printf("<h2>%s</h2>\n", htmlspecialchars($head['Subject'] ?? 'Mailbericht zonder onderwerp'));
 
-       print '<dl class="terse">';
-       printf('<dt>Ontvangen:</dt><dd>%s</dd>', $head['date']->format('c'));
-       printf('<dt>Verzender:</dt><dd>%s</dd>', htmlspecialchars($head['From']));
+       printf('<h3><a href="mailto:%s">%s</a> <small class="date" title="%s">%s</small></h3>'."\n",
+               htmlspecialchars($head['From']),
+               htmlspecialchars(implode(', ', array_column($head['from'], 'display'))),
+               htmlspecialchars($head['Date']),
+               showdate(preg_split('/\D/', $head['date']->format('c')))
+       );
        print '</dl>';
 
        if (preg_match('{^text/plain}', $head['Content-Type'] ?? 'text/plain')) {
@@ -71,10 +75,12 @@ foreach (array_reverse($rows) as $filename) {
        $head = parsemailhead($headerdata);
 
        print $head['Subject'];
-       printf(' <small class="date">%s</small>',
+       printf(' <small class="date" title="%s">%s</small>',
+               htmlspecialchars($head['Date']),
                showdate(explode('-', $head['date']->format('Y-m-d')))
        );
-       printf(' <em class="right">%s</em>',
+       printf(' <em class="right" title="%s">%s</em>',
+               htmlspecialchars($head['From']),
                htmlspecialchars(implode(', ', array_column($head['from'], 'display')))
        );
        print "</a></li>\n";