set_title(html_escape("Stats")); $page->set_heading(html_escape("Stats - Top $limit")); $page->add_block(new NavBlock()); $page->add_block(new Block("Stats", $html, "main", 20)); } /** * @param array $data */ public function build_table(array $data, string $id, string $title, ?int $limit = 10): HTMLElement { $rows = emptyHTML(); $n = 1; foreach ($data as $user => $value) { $rows->appendChild( TR( TD([], $n), TD([], rawHTML((string)$value)), TD([], rawHTML(''.$user.'')) ) ); $n++; if ($n > $limit) { break; } } $table = TABLE( ["class" => "zebra stats-table"], THEAD( TR( TH( ["colspan" => 3], B($title) ) ), TR( TH([], "Place"), TH([], "Amount"), TH([], "User") ) ), TBODY($rows) ); return DIV( ["id" => "table$id", "class" => "stats-container"], $table ); } }