seq 0 100 |while read n; do
filter_type="$(POST "filter_type${n}")"
filter_text="$(POST "filter_text${n}")"
- [ ! "$filter_type" -a ! "$filter_text" ] && break
- if [ "$filter_type" = CATEGORIES ]; then
+ if [ ! "$filter_type" -a ! "$filter_text" ]; then
+ break
+ elif [ "$filter_type" = CATEGORIES ]; then
printf '^CATEGORIES:'
seq 0 $(POST_COUNT filter_cat$n) |while read m; do
printf '|%s' "$(POST filter_cat$n $m)"
done
+ elif [ "$filter_type" = course ]; then
+ printf '^course:'
+ seq 0 $(POST_COUNT filter_course$n) |while read m; do
+ printf '|%s' "$(POST filter_course$n $m)"
+ done
else
printf '^%s:%s' "$filter_type" "$filter_text"
fi
done
}
+filter_attendance(){
+ fatt="$1"
+ attfile="$_DATA/mappings/attendance"
+
+ if [ ! "$fatt" ]; then
+ # debug 'list all'
+ printf '%s\n' "$_DATA/vcard"/*.vcf
+ elif [ "${fatt#* }" = "${fatt}" ]; then
+ # debug "list $fatt"
+ grep -xiE "(${fatt}) .+vcf" "$attfile" \
+ | while read vcf; do
+ printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }"
+ done
+ else
+ # debug "filter ${fatt%% *}"
+ filter_attendance "${fatt#* }" \
+ | while read vcf; do
+ grep -xiE "(${fatt%% *}) ${vcf##*/}" "$attfile"
+ done \
+ | while read vcf; do
+ printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }"
+ done
+ fi
+}
+
filter_cards(){
local filter f fex='x;p;'
filter="$(printf %s "${filter}" \
- | sed -E 's;[]\/\(\)\\\$\?\.\+\*\;\[\{\}];\\\\&;g;
+ | sed -E 's;[]\/\(\)\\\$\?\.\+\*\;\[\{\}];\\&;g;
'"$upcase"
)^"
case $f in
'') break
;;
+ COURSE:*) fatt="${fatt}${fatt:+ }${f#*:}"
+ ;;
ANY:*) fex="/\n.*(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
;;
NAME:*) fex="/\n(N|FN|NICKNAME)(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
esac
done
- for cardfile in "${_DATA}"/vcard/*.vcf; do
+ # for cardfile in "${_DATA}"/vcard/*.vcf; do
+ filter_attendance "$fatt" |while read cardfile; do
printf '%s\n' "$cardfile"
cat "$cardfile"
done \
[fieldset .item
[legend $(l10n filter_item):]
- $(for field in any name street zip TEL BDAY CATEGORIES; do
+ $(for field in any name street zip TEL BDAY CATEGORIES course; do
printf '[input id="%s%i" type="radio" name="filter_type%i" value="%s" %s][label for="%s%i" %s ]' \
"$field" "$n" "$n" "$field" "$([ "$1" = "$field" ] && printf checked )" \
"$field" "$n" "$(l10n filter_$field)"
done)
- [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
+ [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES -o "$1" = course ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
[fieldset .categories
$(list_categories | while read cat; do
printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ]' \
done)
[a href="/categories/" $(l10n edit_categories)]
]
+ [fieldset .courses
+ $(for course in "$_DATA/ical"/*.ics; do
+ printf '[label [checkbox "filter_course%i" "|%s" %s] %s ]' \
+ "$n" "$(HTML "${course##*/}")" \
+ "$(printf %s "${course##*/}" |grep -qxEe "$2" && printf checked )" \
+ "$(pdi_value "$(pdi_load "$course")" SUMMARY |HTML)"
+ done)
+ ]
]
EOF
}
z-index: 1;
}
form.filter fieldset.item input[type=text],
+form.filter fieldset.item fieldset.courses,
form.filter fieldset.item fieldset.categories {
position: relative;
display: block;
border: 1pt solid;
box-shadow: .125em .125em .25em #888;
}
+form.filter fieldset.item fieldset.courses,
form.filter fieldset.item fieldset.categories { display: none; }
-form.filter fieldset.item input[value=CATEGORIES]:checked + label + input[type=text] { display: none; }
-form.filter fieldset.item input[value=CATEGORIES]:checked + label + input[type=text] + fieldset.categories { display: block; }
+form.filter fieldset.item input[value=course]:checked ~ input[type=text],
+form.filter fieldset.item input[value=CATEGORIES]:checked ~ input[type=text] { display: none; }
+form.filter fieldset.item input[value=course]:checked ~ fieldset.courses,
+form.filter fieldset.item input[value=CATEGORIES]:checked ~ fieldset.categories { display: block; }
form.filter fieldset.order legend {
float: left; margin-right: 1em;