From f4647b2cf4e71f6427d6a0c2886fe747d5aed098 Mon Sep 17 00:00:00 2001 From: anuko Date: Tue, 26 Dec 2017 14:17:19 +0000 Subject: [PATCH] Added an optional column footer to tables. --- WEB-INF/lib/form/Table.class.php | 23 +++++++++++++++++++++++ WEB-INF/lib/form/TableColumn.class.php | 17 ++++++++++++----- WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/WEB-INF/lib/form/Table.class.php b/WEB-INF/lib/form/Table.class.php index fa58b786..e5aed81d 100644 --- a/WEB-INF/lib/form/Table.class.php +++ b/WEB-INF/lib/form/Table.class.php @@ -34,6 +34,7 @@ class Table extends FormElement { var $mColumns = array(); // array of columns in table var $mData = null; // array of rows with data for column cells var $mHeaders = array(); // column headers + var $mFooters = array(); // column footers var $mInteractive = true; // adds a clickable checkbox column to table var $mIAScript = null; // sctipt to execute when a checkbox is clicked var $mKeyField = ''; // identifies a column used as key to access row data @@ -110,6 +111,7 @@ class Table extends FormElement { foreach ($this->mColumns as $column) { $this->mColumnFields[] = $column->getField(); $this->mHeaders[] = $column->getHeader(); + $this->mFooters[] = $column->getFooter(); } } @@ -176,6 +178,27 @@ class Table extends FormElement { $html .= "\n"; } + // Print footers. + if (($this->mInteractive && (count($this->mFooters) > 1)) || (!$this->mInteractive && (count($this->mFooters) > 0))) { + $html .= "mRowOptions) > 0) { + foreach ($this->mRowOptions as $k=>$v) { + $html .= " $k=\"$v\""; + } + } + $html .= ">\n"; + foreach ($this->mFooters as $footer) { + $html .= "mHeaderOptions) > 0) { + foreach ($this->mHeaderOptions as $k=>$v) { + $html .= " $k=\"$v\""; + } + } + $html .= ">$footer\n"; + } + $html .= "\n"; + } + $html .= ""; return $html; } diff --git a/WEB-INF/lib/form/TableColumn.class.php b/WEB-INF/lib/form/TableColumn.class.php index 06cad051..cb4bebf1 100644 --- a/WEB-INF/lib/form/TableColumn.class.php +++ b/WEB-INF/lib/form/TableColumn.class.php @@ -28,8 +28,13 @@ import('form.DefaultCellRenderer'); +// TableColumn class represents a single column in a table. class TableColumn { - var $mTitle = ""; + var $colHeader = ''; // Column header. + var $colFooter = ''; // Column footer, example: totals in week view. + +// TODO: refactoring ongoing down from here. + var $mIndexField = ""; var $mRenderer = null; var $mWidth = ""; @@ -37,9 +42,10 @@ class TableColumn { var $mBgColor = "#ffffff"; var $mFgColor = "#000000"; - function __construct($indexField, $title="",$renderer=null) { + function __construct($indexField, $header = '', $renderer = null, $footer = '') { $this->mIndexField = $indexField; - $this->mTitle = $title; + $this->colHeader = $header; + $this->colFooter = $footer; if ($renderer!=null) { $this->mRenderer = $renderer; } else { @@ -47,8 +53,9 @@ class TableColumn { } } - function getHeader() { return $this->mTitle; } - + function getHeader() { return $this->colHeader; } + function getFooter() { return $this->colFooter; } + function getField() { return $this->mIndexField; } function setTable(&$table) { $this->mTable = &$table; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 25463625..345ef379 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.12.3.3689 | Copyright © Anuko | +  Anuko Time Tracker 1.12.3.3690 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1