clean up code in ZapHome and ZapDisplay (#19 and #20)

This commit is contained in:
Fabian de Boer 2026-07-20 01:14:00 +02:00
commit 3edb156749
5 changed files with 24 additions and 21 deletions

View file

@ -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"}

View file

@ -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
---

View file

@ -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
---

View file

@ -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;
}

View file

@ -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();
}