From ac801e15438d347a82ff9e5700d9c3c6f8fd8c30 Mon Sep 17 00:00:00 2001 From: ruan Date: Fri, 16 Oct 2015 06:03:05 +0200 Subject: [PATCH] Simplify table header printing --- bans.php | 2 -- history.php | 1 - includes/page.php | 11 ++++++++++- kicks.php | 2 -- mutes.php | 2 -- warnings.php | 2 -- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bans.php b/bans.php index 64810de..a569922 100644 --- a/bans.php +++ b/bans.php @@ -6,14 +6,12 @@ use PDO; require_once './includes/page.php'; $page = new Page("bans"); $page->print_title(); -$headers = array("Name", "Banned By", "Reason", "Banned On", "Banned Until"); $page->print_page_header(); $page->print_check_form(); $page->table_begin(); -$page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { diff --git a/history.php b/history.php index 611b240..ed7eb64 100644 --- a/history.php +++ b/history.php @@ -114,7 +114,6 @@ try { if (!empty($all)) { $page->table_begin(); - $page->table_print_headers(array("Type", "Player", "Moderator", "Reason", "Date", "Expires")); $offset = 0; $limit = $page->settings->limit_per_page; diff --git a/includes/page.php b/includes/page.php index b35cd81..491c9b4 100644 --- a/includes/page.php +++ b/includes/page.php @@ -49,6 +49,7 @@ class Page { $this->header = $h; $h->print_header(); } + $this->table_headers_printed = false; } public function type_info($type) { @@ -264,7 +265,12 @@ class Page { echo "$title - $name"; } - function print_table_rows($row, $array) { + function print_table_rows($row, $array, $print_headers = true) { + if ($print_headers && !$this->table_headers_printed) { + $headers = array_keys($array); + $this->table_print_headers($headers); + $this->table_headers_printed = true; + } if ($this->settings->debug_mode > 0) { var_dump($row); } @@ -275,6 +281,9 @@ class Page { $style = ""; if ($header === "Reason") { $style = "style=\"width: 30%;\""; + if ($text === "") { + $text = "-"; + } } $a = "a"; if ($header === "Received Warning") { diff --git a/kicks.php b/kicks.php index 778d291..7471424 100644 --- a/kicks.php +++ b/kicks.php @@ -6,14 +6,12 @@ use PDO; require_once './includes/page.php'; $page = new Page("kicks"); $page->print_title(); -$headers = array("Name", "Kicked By", "Reason", "Date"); $page->print_page_header(); $page->print_check_form(); $page->table_begin(); -$page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { diff --git a/mutes.php b/mutes.php index 693786a..a1dc2c4 100644 --- a/mutes.php +++ b/mutes.php @@ -6,14 +6,12 @@ use PDO; require_once './includes/page.php'; $page = new Page("mutes"); $page->print_title(); -$headers = array("Name", "Muted By", "Reason", "Muted On", "Muted Until"); $page->print_page_header(); $page->print_check_form(); $page->table_begin(); -$page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { diff --git a/warnings.php b/warnings.php index 0992a5a..0c55ea1 100644 --- a/warnings.php +++ b/warnings.php @@ -6,14 +6,12 @@ use PDO; require_once './includes/page.php'; $page = new Page("warnings"); $page->print_title(); -$headers = array("Name", "Warned By", "Reason", "Warned Until", "Received Warning"); $page->print_page_header(); $page->print_check_form(); $page->table_begin(); -$page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) {