diff --git a/Themes/default/BoardIndex.template.php b/Themes/default/BoardIndex.template.php
index 22c218c72e..385875b1d5 100644
--- a/Themes/default/BoardIndex.template.php
+++ b/Themes/default/BoardIndex.template.php
@@ -82,12 +82,43 @@ function template_boardindex()
';
- /* Each board in each category's boards has:
- new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
- children (see below.), link_children (easier to use.), children_new (are they new?),
- topics (# of), posts (# of), link, href, and last_post. (see below.) */
- foreach ($category['boards'] as $board) {
- echo '
+ template_bi_board_list($category['boards']);
+
+ echo '
+
+ ';
+ }
+
+ echo '
+ ';
+
+ // Show the mark all as read button?
+ if (!User::$me->is_guest && !empty(Utils::$context['categories'])) {
+ echo '
+
+ ', template_button_strip(Utils::$context['mark_read_button'], 'right'), '
+
';
+ }
+}
+
+/**
+ * Outputs a list of boards, each one drawn by the template_bi_* helpers below.
+ *
+ * The board index calls this once per category, and the message index calls it
+ * for the child boards of the board being viewed. Both used to carry their own
+ * copy of this loop.
+ *
+ * Each board has: new (is it new?), id, name, description, moderators (see
+ * below), link_moderators (just a list.), children (see below.), link_children
+ * (easier to use.), children_new (are they new?), topics (# of), posts (# of),
+ * link, href, and last_post. (see below.)
+ *
+ * @param array $boards The boards to draw, in the order they go in.
+ */
+function template_bi_board_list(array $boards): void
+{
+ foreach ($boards as $board) {
+ echo '
', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), '
@@ -96,43 +127,27 @@ function template_boardindex()
', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board), '
';
- // Show some basic information about the number of posts, etc.
- echo '
+ // Show some basic information about the number of posts, etc.
+ echo '
', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), '
';
- // Show the last post if there is one.
- echo'
+ // Show the last post if there is one.
+ echo '
', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), '
';
- // Won't somebody think of the children!
- if (function_exists('template_bi_' . $board['type'] . '_children')) {
- call_user_func('template_bi_' . $board['type'] . '_children', $board);
- } else {
+ // Won't somebody think of the children!
+ if (function_exists('template_bi_' . $board['type'] . '_children')) {
+ call_user_func('template_bi_' . $board['type'] . '_children', $board);
+ } else {
template_bi_board_children($board);
- }
-
- echo '
-
';
}
echo '
-
- ';
- }
-
- echo '
- ';
-
- // Show the mark all as read button?
- if (!User::$me->is_guest && !empty(Utils::$context['categories'])) {
- echo '
-
- ', template_button_strip(Utils::$context['mark_read_button'], 'right'), '
-
';
+ ';
}
}
diff --git a/Themes/default/MessageIndex.template.php b/Themes/default/MessageIndex.template.php
index 74c75452b5..4a5c728871 100644
--- a/Themes/default/MessageIndex.template.php
+++ b/Themes/default/MessageIndex.template.php
@@ -79,38 +79,7 @@ function template_main()
', Lang::getTxt('sub_boards', file: 'General'), '
';
- foreach (Utils::$context['boards'] as $board) {
- echo '
-
-
- ', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), '
-
-
- ', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board), '
-
';
-
- // Show some basic information about the number of posts, etc.
- echo '
-
- ', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), '
-
';
-
- // Show the last post if there is one.
- echo '
-
- ', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), '
-
';
-
- // Won't somebody think of the children!
- if (function_exists('template_bi_' . $board['type'] . '_children')) {
- call_user_func('template_bi_' . $board['type'] . '_children', $board);
- } else {
- template_bi_board_children($board);
- }
-
- echo '
-
';
- }
+ template_bi_board_list(Utils::$context['boards']);
echo '
';