Author: Jim Winstead (jimwins) Committer: GitHub (web-flow) Pusher: Girgias Date: 2024-07-18T20:08:18+01:00
Commit: https://github.com/php/web-news/commit/d7c12ada4578db7698704951ed353cfbcfb1c341 Raw diff: https://github.com/php/web-news/commit/d7c12ada4578db7698704951ed353cfbcfb1c341.diff Group newsgroups by type (moderated, discussion, inactive) (#18) Changed paths: M index.php Diff: diff --git a/index.php b/index.php index 743d3b0..6a67768 100644 --- a/index.php +++ b/index.php @@ -5,6 +5,11 @@ try { $nntpClient = new \Web\News\Nntp(NNTP_HOST); $groups = $nntpClient->listGroups(); + /* Reorder so it's moderated, active, and inactive */ + $order = [ 'm' => 1, 'y' => 2, 'n' => 3 ]; + uasort($groups, function ($a, $b) use ($order) { + return $order[$a['status']] <=> $order[$b['status']]; + }); } catch (Exception $e) { error($e->getMessage()); } @@ -38,8 +43,18 @@ <th>rss</th> <th>rdf</th> </tr> + <tr> + <th colspan="4">Moderated Lists</th> + </tr> <?php +$last_status = 'm'; foreach ($groups as $group => $details) { + if ($details['status'] != $last_status) { + $last_status = $details['status']; + echo '<tr><th colspan="4">', + $last_status == 'y' ? 'Discussion Lists' : 'Inactive Lists', + "</th></tr>\n"; + } echo " <tr>\n"; echo " <td><a class=\"active{$details['status']}\" href=\"/$group\">$group</a></td>\n"; echo " <td class=\"align-right\">", $details['high']-$details['low']+1, "</td>\n";