diff --git a/pinc/ThemedTable.inc b/pinc/ThemedTable.inc index 0f0b5aaa9..bf25d5eeb 100644 --- a/pinc/ThemedTable.inc +++ b/pinc/ThemedTable.inc @@ -13,49 +13,28 @@ class ThemedTable /** @var string[] */ private array $column_alignments; - /** - * @param array{ - * theme_striped?: mixed, - * border?: int, - * width?: int|string, - * subtitle?: string, - * } $options - * TODO: Make these into keyword args - */ - public function __construct(int $n_cols, string $title, array $options = []) - { + public function __construct( + int $n_cols, + string $title, + bool $theme_striped = false, + string $border = "", + string $width = "", + string $subtitle = "", + ) { $this->n_cols = $n_cols; $class = "themed"; $border = 1; - $width = ""; - $subtitle = null; - foreach ($options as $option_name => $option_value) { - switch ($option_name) { - case 'theme_striped': - $class .= ' theme_striped'; - break; - case 'border': - $border = $option_value; - break; - case 'width': - $width = " width: $option_value;"; - break; - case 'subtitle': - $subtitle = $option_value; - break; - } + if ($theme_striped) { + $class .= ' theme_striped'; } + $width_css = $width === "" ? "" : " width: $width;"; echo "\n"; - echo ""; + echo "
"; { - $possible_subtitle = - is_null($subtitle) - ? '' - : "
$subtitle"; - + $possible_subtitle = $subtitle === "" ? "" : "
$subtitle"; echo "\n"; echo ""; $maybe_colspan = ""; diff --git a/stats/includes/member.inc b/stats/includes/member.inc index b3e6a7eb5..b72201c3d 100644 --- a/stats/includes/member.inc +++ b/stats/includes/member.inc @@ -490,7 +490,7 @@ function showMbrNeighbors(User $user, string $tally_name): void $t = new ThemedTable( 4, _("Neighbors"), - ['theme_striped' => true] + theme_striped: true ); $t->set_column_widths(15, 28, 28, 29); $t->column_headers( @@ -546,7 +546,7 @@ function showMbrTeams(User $user): void $t = new ThemedTable( 2, _("Teams"), - ['theme_striped' => true] + theme_striped: true ); $t->set_column_widths(50, 50); $t->column_headers( diff --git a/stats/includes/team.inc b/stats/includes/team.inc index b27e32db2..44168203f 100644 --- a/stats/includes/team.inc +++ b/stats/includes/team.inc @@ -132,7 +132,7 @@ function showTeamProfile(array $curTeam, bool $preview = false): void $t = new ThemedTable( 2, html_safe($curTeam['teamname']) . " $xml_button$editlink$joinquitlink", - ['width' => 100] + width: "100" ); $t->set_column_widths(25, 75); $t->set_column_alignments('left', 'left'); @@ -271,7 +271,7 @@ function showTeamStats(array $curTeam, ?string $tally_name): void $t = new ThemedTable( 2, _("Team Statistics"), - ['theme_striped' => true] + theme_striped: true ); $t->set_column_widths(60, 40); @@ -317,10 +317,8 @@ function showTeamMbrs(array $curTeam, ?string $tally_name): void $t = new ThemedTable( 3, _("Team Member Details"), - [ - 'theme_striped' => true, - 'subtitle' => $subtitle, - ] + theme_striped: true, + subtitle: $subtitle ); $t->set_column_widths(35, 35, 30); diff --git a/stats/index.php b/stats/index.php index 57c8b44ec..24d281ff8 100644 --- a/stats/index.php +++ b/stats/index.php @@ -76,7 +76,7 @@ function count_books_in_state(string $state, string $clauses = ""): int $table = new ThemedTable( 2, _('General Site Statistics'), - ['width' => 'auto'] + width: 'auto' ); $table->set_column_alignments('left', 'right');