From 978a1651bac3faf5e91ddba327bf39aeb6a4cb63 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:28:59 +0200 Subject: Adding upstream version 0.10.0. Signed-off-by: Daniel Baumann --- library/Reporting/Web/Widget/HeaderOrFooter.php | 95 +++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 library/Reporting/Web/Widget/HeaderOrFooter.php (limited to 'library/Reporting/Web/Widget/HeaderOrFooter.php') diff --git a/library/Reporting/Web/Widget/HeaderOrFooter.php b/library/Reporting/Web/Widget/HeaderOrFooter.php new file mode 100644 index 0000000..dcb37e7 --- /dev/null +++ b/library/Reporting/Web/Widget/HeaderOrFooter.php @@ -0,0 +1,95 @@ +type = $type; + $this->data = $data; + } + + protected function resolveVariable($variable) + { + switch ($variable) { + case 'report_title': + $resolved = Html::tag('span', ['class' => 'title']); + break; + case 'time_frame': + $resolved = Html::tag('p', $this->getMacro('time_frame')); + break; + case 'time_frame_absolute': + $resolved = Html::tag('p', $this->getMacro('time_frame_absolute')); + break; + case 'page_number': + $resolved = Html::tag('span', ['class' => 'pageNumber']); + break; + case 'total_number_of_pages': + $resolved = Html::tag('span', ['class' => 'totalPages']); + break; + case 'page_of': + $resolved = Html::tag('p', Html::sprintf( + '%s / %s', + Html::tag('span', ['class' => 'pageNumber']), + Html::tag('span', ['class' => 'totalPages']) + )); + break; + case 'date': + $resolved = Html::tag('span', ['class' => 'date']); + break; + default: + $resolved = $variable; + break; + } + + return $resolved; + } + + protected function createColumn(array $data, $key) + { + $typeKey = "${key}_type"; + $valueKey = "${key}_value"; + $type = isset($data[$typeKey]) ? $data[$typeKey] : null; + + switch ($type) { + case 'text': + $column = Html::tag('p', $data[$valueKey]); + break; + case 'image': + $column = Html::tag('img', ['height' => 13, 'src' => Template::getDataUrl($data[$valueKey])]); + break; + case 'variable': + $column = $this->resolveVariable($data[$valueKey]); + break; + default: + $column = Html::tag('div'); + break; + } + + return $column; + } + + protected function assemble() + { + for ($i = 1; $i <= 3; ++$i) { + $this->add($this->createColumn($this->data, "{$this->type}_column{$i}")); + } + } +} -- cgit v1.2.3