#!/bin/sh
# Copyright 2015, 2017, 2018, 2021 Paul Hänsch
#
# This file is part of Confetti.
#
# Confetti is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Confetti is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Confetti. If not, see .
. $_EXEC/pdiread.sh
. $_EXEC/categories/l10n.sh
catfile="${_DATA}/mappings/categories"
list_categories() {
grep -vxE '[ ]*' "$catfile" |sort -u
}
list_catsel(){
local vcf="$1" card="$2" n=1 cats="${BR}"
while cats="${cats}${BR}$(pdi_value "$vcf" CATEGORIES $n)"; do n=$((n + 1)); done
list_categories |while read cat; do
printf '[li [label [input %s type="checkbox" name="%s" value="%s"] %s]]' \
"$([ "${cats%*${BR}${cat}${BR}*}" != "$cats" ] && printf checked=checked)" \
"$(HTML "$card")" "$(HTML "$cat")" "$(HTML "$cat")"
done
}
cat <