From a8f353047fdda9120299e81b7842f07bfdd2f0ee Mon Sep 17 00:00:00 2001 From: jnbn Date: Sun, 31 Jan 2016 01:34:57 +0200 Subject: [PATCH 1/2] added optional withHeaders method to Tables for specifying different colum names. (table headers) --- src/Bootstrapper/Table.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Bootstrapper/Table.php b/src/Bootstrapper/Table.php index 1da55a1e..65ac6903 100644 --- a/src/Bootstrapper/Table.php +++ b/src/Bootstrapper/Table.php @@ -241,6 +241,11 @@ private function getHeaders() } } + if(is_array($this->specialheaders)): + foreach($headers as $key=>$val): + if(!empty($this->specialheaders[$val])) $headers[$key] = $this->specialheaders[$val]; + endforeach; + endif; return $headers; } @@ -314,6 +319,11 @@ public function only(array $only) return $this; } + public function withHeaders(array $x){ + $this->specialheaders = $x; + return $this; + } + private function renderHeaders() { $headers = $this->getHeaders(); From 4cf4360dc8aaf6a1e864d4aa3ac809f83df78c29 Mon Sep 17 00:00:00 2001 From: jnbn Date: Sun, 31 Jan 2016 15:23:43 +0200 Subject: [PATCH 2/2] update headercaptions --- src/Bootstrapper/Table.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Bootstrapper/Table.php b/src/Bootstrapper/Table.php index 65ac6903..05c304c5 100644 --- a/src/Bootstrapper/Table.php +++ b/src/Bootstrapper/Table.php @@ -75,6 +75,8 @@ class Table extends RenderedObject */ protected $columnClasses = []; + protected $headercaptions; + /** * Renders the table * @@ -241,11 +243,6 @@ private function getHeaders() } } - if(is_array($this->specialheaders)): - foreach($headers as $key=>$val): - if(!empty($this->specialheaders[$val])) $headers[$key] = $this->specialheaders[$val]; - endforeach; - endif; return $headers; } @@ -319,8 +316,8 @@ public function only(array $only) return $this; } - public function withHeaders(array $x){ - $this->specialheaders = $x; + public function withHeaderCaptions(array $x){ + $this->headercaptions = $x; return $this; } @@ -332,6 +329,12 @@ private function renderHeaders() return ''; } + if(is_array($this->headercaptions)): + foreach($headers as $key=>$val): + if(!empty($this->headercaptions[$val])) $headers[$key] = $this->headercaptions[$val]; + endforeach; + endif; + $string = ''; foreach ($headers as $heading) { if (isset($this->columnClasses[$heading])) {