issue/activity: format replies for dashboard
[minimedit.git] / widget / issue / activity.php
index cd99e486916af3e58e888fdc1ed6080fd226a9de..153034efb84124dba0476239382858daab2ce74e 100644 (file)
@@ -7,28 +7,37 @@ $cols = 'm.*, i.subject, i.updated, i.closed';
 $sql = "SELECT $cols FROM messages m JOIN issues i ON i.id = issue";
 $sql .= " WHERE message IS NOT NULL";
 $sql .= " ORDER BY m.created DESC LIMIT $limit";
-$sql = "SELECT * FROM ($sql) x ORDER BY updated DESC, created, id"; # grouped issues
 $query = $Db->query($sql);
 
+$msgformat = [
+       "{(?=</p>\n).+}s" => ' <small class="footer">(Meer op de site)</small>',
+       '{(.*)(<p><img [^>]+></p>)\s*}' => "$2\n$1",
+       '{(?<=<img src=")(?=/)}' => '/thumb/300x',
+];
+
 print '<dl class="replies">';
 
 $group = NULL;
 while ($row = $query->fetch()) {
-       $rowuser = new User("profile/{$row->author}");
+       print '<dt>';
        if ($group !== $row->issue) {
                $group = $row->issue;
-               print '<dt>';
                printf('<a href="/%s">%s</a>', $row->page, $row->subject);
                if ($row->closed) {
                        print ' <em>(opgelost)</em>';
                }
-               print '</dt>';
        }
-       print '<dd>';
-       printf('<strong>%s</strong> <small class="date">%s</small>',
-               $rowuser->html, showdate(preg_split('/\D/', $row->created))
+       print '<span class="right">';
+       if ($row->author and $rowuser = new User("profile/{$row->author}")) {
+               printf('<strong>%s</strong> ', $rowuser->html);
+       }
+       printf('<small class="date">%s</small>',
+               showdate(preg_split('/\D/', $row->created))
        );
-       printf("\n\t<blockquote>%s</blockquote>", $row->message);
+       print "</span>";
+       print '</dt>';
+       print '<dd>';
+       print preg_replace(array_keys($msgformat), array_values($msgformat), $row->message);
        print "</dd>\n";
 }