From 3edb156749844de83627711f22c95d2b8b232f4b Mon Sep 17 00:00:00 2001 From: Fabian de Boer Date: Mon, 20 Jul 2026 01:14:00 +0200 Subject: [PATCH] clean up code in ZapHome and ZapDisplay (#19 and #20) --- kanban/activity.jsonl | 6 ++++++ ...ingle-source-of-truth-for-word-count-cleanup.md | 8 ++++++-- ...istent-template-rendering-pattern-across-all.md | 8 ++++++-- lib/ZAPDisplay.class.php | 14 +++++--------- lib/ZAPHome.class.php | 9 +-------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/kanban/activity.jsonl b/kanban/activity.jsonl index 1453eab..0aab3a4 100644 --- a/kanban/activity.jsonl +++ b/kanban/activity.jsonl @@ -85,3 +85,9 @@ {"timestamp":"2026-07-19T21:49:54.312195218+02:00","action":"edit","task_id":21,"detail":"Consolidate duplicated screen-size constants"} {"timestamp":"2026-07-19T21:49:54.312297605+02:00","action":"claim","task_id":21,"detail":"rain-raven"} {"timestamp":"2026-07-19T21:49:54.334491216+02:00","action":"move","task_id":21,"detail":"todo -\u003e done"} +{"timestamp":"2026-07-19T22:54:27.983080764+02:00","action":"edit","task_id":20,"detail":"Consistent template rendering pattern across all handlers"} +{"timestamp":"2026-07-19T22:54:27.98319541+02:00","action":"claim","task_id":20,"detail":"rain-raven"} +{"timestamp":"2026-07-19T22:54:28.007952955+02:00","action":"move","task_id":20,"detail":"todo -\u003e done"} +{"timestamp":"2026-07-20T01:09:23.947300407+02:00","action":"edit","task_id":19,"detail":"Single source of truth for word count + cleanup handleWords"} +{"timestamp":"2026-07-20T01:09:23.947430566+02:00","action":"claim","task_id":19,"detail":"rain-raven"} +{"timestamp":"2026-07-20T01:09:23.97076796+02:00","action":"move","task_id":19,"detail":"todo -\u003e done"} diff --git a/kanban/tasks/019-single-source-of-truth-for-word-count-cleanup.md b/kanban/tasks/019-single-source-of-truth-for-word-count-cleanup.md index 5d4982b..c0685a6 100644 --- a/kanban/tasks/019-single-source-of-truth-for-word-count-cleanup.md +++ b/kanban/tasks/019-single-source-of-truth-for-word-count-cleanup.md @@ -1,12 +1,16 @@ --- id: 19 title: Single source of truth for word count + cleanup handleWords -status: todo +status: done priority: low created: 2026-07-17T03:58:05.365933671+02:00 -updated: 2026-07-17T03:58:05.365933671+02:00 +updated: 2026-07-20T01:09:23.968637294+02:00 +started: 2026-07-20T01:09:23.970603129+02:00 +completed: 2026-07-20T01:09:23.970603129+02:00 tags: - cleanup +claimed_by: rain-raven +claimed_at: 2026-07-20T01:09:23.968637294+02:00 class: standard --- diff --git a/kanban/tasks/020-consistent-template-rendering-pattern-across-all.md b/kanban/tasks/020-consistent-template-rendering-pattern-across-all.md index 0d22f76..9dd7b1d 100644 --- a/kanban/tasks/020-consistent-template-rendering-pattern-across-all.md +++ b/kanban/tasks/020-consistent-template-rendering-pattern-across-all.md @@ -1,12 +1,16 @@ --- id: 20 title: Consistent template rendering pattern across all handlers -status: todo +status: done priority: low created: 2026-07-17T03:58:11.987251314+02:00 -updated: 2026-07-17T03:58:11.987251314+02:00 +updated: 2026-07-19T22:54:28.006158702+02:00 +started: 2026-07-19T22:54:28.007766996+02:00 +completed: 2026-07-19T22:54:28.007766996+02:00 tags: - cleanup +claimed_by: rain-raven +claimed_at: 2026-07-19T22:54:28.006158702+02:00 class: standard --- diff --git a/lib/ZAPDisplay.class.php b/lib/ZAPDisplay.class.php index 65656e9..3be56b0 100755 --- a/lib/ZAPDisplay.class.php +++ b/lib/ZAPDisplay.class.php @@ -80,15 +80,11 @@ class ZAPDisplay implements ZAPHandler { */ private function handleWords() { $words = array(); - $ix = 1; - $postix = sprintf("%02d", $ix); - $wd = 'word' . $postix; - - while(!empty($_POST[$wd])) { - array_push($words, $_POST[$wd]); - $ix++; - $postfix = sprintf("%02d", $ix); - $wd = 'word' . $postfix; + for ($i = 1; $i <= MAX_WORDS; $i++) { + $key = 'word' . sprintf("%02d", $i); + if (!empty($_POST[$key])) { + $words[] = $_POST[$key]; + } } return $words; } diff --git a/lib/ZAPHome.class.php b/lib/ZAPHome.class.php index 21de450..207b0f8 100755 --- a/lib/ZAPHome.class.php +++ b/lib/ZAPHome.class.php @@ -8,11 +8,6 @@ class ZAPHome implements ZAPHandler { */ private $template = 'index'; - /** - * ZAP version - */ - private $ver; - /** * Parsable content */ @@ -22,10 +17,8 @@ class ZAPHome implements ZAPHandler { * Constructor */ public function __construct() { - $this->ver = ZAP_VERSION; - extract(get_object_vars($this)); - ob_start(); + $ver = ZAP_VERSION; include getZAPTemplate($this->template); $this->tpl .= ob_get_clean(); }