Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions pinc/ThemedTable.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,43 +75,37 @@ class ThemedTable
*
* If you don't call this method, <td> tags will be output without a 'width' attribute.
*/
public function set_column_widths(): void
public function set_column_widths(int ...$widths): void
{
// There should be an arg (width) for each column.
assert(func_num_args() == $this->n_cols);
$this->column_widths = func_get_args();
assert(count($widths) == $this->n_cols);
$this->column_widths = $widths;

// They should add up to 100.
assert(array_sum($this->column_widths) == 100);
}

public function set_column_alignments(): void
public function set_column_alignments(string ...$alignments): void
{
assert(func_num_args() == $this->n_cols);
$this->column_alignments = func_get_args();
assert(count($alignments) == $this->n_cols);
$this->column_alignments = $alignments;

// Should check that they're sensible.
}

public function column_headers(): void
public function column_headers(?string ...$headers): void
{
$args = func_get_args();
$this->_row($args, true);
$this->_row($headers, true);
}

public function row(): void
public function row(?string ...$headers): void
{
$args = func_get_args();
$this->_row($args, false);
$this->_row($headers, false);
}

/** @param string[]|string[][] $cell_texts */
public function _row(array $cell_texts, bool $is_header): void
/** @param (?string)[] $cell_texts */
private function _row(array $cell_texts, bool $is_header): void
{
if ($this->n_cols > 1 && count($cell_texts) == 1 && is_array($cell_texts[0])) {
$cell_texts = $cell_texts[0];
}

// There should be an arg (cell content) for each column.
assert(count($cell_texts) == $this->n_cols);

Expand Down
2 changes: 1 addition & 1 deletion stats/includes/member.inc
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function showMbrNeighbors(User $user, string $tally_name): void
$day_html = "--/--/-- <i>(" . sprintf(_("%s days"), '---') .")</i>";
}
$t->row(
$rank,
(string) $rank,
$username_html,
$day_html,
$pagescompleted
Expand Down
2 changes: 1 addition & 1 deletion stats/includes/team.inc
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function showTeamMbrs(array $curTeam, ?string $tally_name): void
$header_content_[] = "<a href='$url'>$cd_header_text</a>$dir_indicator";
}

$t->column_headers($header_content_);
$t->column_headers(...$header_content_);

$users_tallyboard = new TallyBoard($tally_name, 'U');

Expand Down
14 changes: 7 additions & 7 deletions stats/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function count_books_in_state(string $state, string $clauses = ""): int

$table->row(
_("Books posted in the last 7 days:"),
$totalbooks
(string) $totalbooks
);


Expand All @@ -111,47 +111,47 @@ function count_books_in_state(string $state, string $clauses = ""): int

$table->row(
_("Books waiting to be released for first round:"),
$totalfirstwaiting
(string) $totalfirstwaiting
);

//get total non-English books waiting to be released
$totalnonwaiting = count_books_in_state(PROJ_P1_WAITING_FOR_RELEASE, "AND language != 'English'");

$table->row(
_("Non-English Books waiting to be released for first round:"),
$totalnonwaiting
(string) $totalnonwaiting
);

//get total books waiting to be post processed
$totalwaitingpost = count_books_in_state(PROJ_POST_FIRST_AVAILABLE);

$table->row(
_("Books waiting for post processing:"),
$totalwaitingpost
(string) $totalwaitingpost
);

//get total books being post processed
$totalinpost = count_books_in_state(PROJ_POST_FIRST_CHECKED_OUT);

$table->row(
_("Books being post processed:"),
$totalinpost
(string) $totalinpost
);

//get total books in verify
$totalverify = count_books_in_state(PROJ_POST_SECOND_AVAILABLE);

$table->row(
_("Books waiting to be verified:"),
$totalverify
(string) $totalverify
);

//get total books in verifying
$totalverifying = count_books_in_state(PROJ_POST_SECOND_CHECKED_OUT);

$table->row(
_("Books being verified:"),
$totalverifying
(string) $totalverifying
);

$table->end();
Expand Down