]> git.plutz.net Git - confetti/commitdiff
implemented filters
authorpaul <paul@plutz.net>
Mon, 7 Oct 2013 09:27:04 +0000 (09:27 +0000)
committerpaul <paul@plutz.net>
Mon, 7 Oct 2013 09:27:04 +0000 (09:27 +0000)
svn path=/trunk/; revision=12

pages/attendees.sh
templates/attendees.html.sh
templates/view_attendee.sh

index b6088d660a4a7a028c17b7b0526bc984b93393e0..a2730e6e4db40265889e3bcb24f25670b8f99de0 100755 (executable)
@@ -1,7 +1,31 @@
 #!/bin/sh
 
+[ "$_GET[\"action\"]" = "del_filter" ] && _GET["filter"]="" && _GET["filtertype"]="" 
 listcards() {
-  ls -1 ${_DATA}/vcard/*vcf
+  case "$_GET["filtertype"]" in
+    any)
+       grep -il "$_GET[\"filter\"]" ${_DATA}/vcard/*vcf |debug
+      ;;
+    name)
+       egrep -xil "(FN|NICKNAME|N)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+      ;;
+    street)
+       egrep -xil "(ADR)(;.+)*:([^;]*;){2}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+      ;;
+    zip)
+       egrep -xil "(ADR)(;.+)*:([^;]*;){5}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+      ;;
+    telephone)
+       egrep -xil "(TEL)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+      ;;
+    birth)
+       egrep -xil "(BDAY)(;.+)*:$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+      ;;
+    course)
+      ;;
+    *) ls -1 ${_DATA}/vcard/*vcf
+      ;;
+  esac
 }
 
 vcf_parse() {
index 002db6329ef449610b75171429d42050a9c5ce0d..c481c61c9077f24fc40661286e87da344ae9d2f8 100644 (file)
@@ -1,19 +1,23 @@
 . ${_EXEC}/templates/view_attendee.sh
 
+check(){
+  [ "$_GET[\"filtertype\"]" = "$1" ] && echo 'checked="checked"'
+}
+
 cat <<EOF
 <div class="filter">
 <form action="/" method="GET">
   <div class="search">
     <span class="label">Filter:</span>
     <input type="hidden" name="page" value="attendees"/>
-    <input type="text" name="filter"/>
-    <input type="radio" name="filtertype" value="any" checked="checked">Alles</input>
-    <input type="radio" name="filtertype" value="name">Name</input>
-    <input type="radio" name="filtertype" value="street">Straße</input>
-    <input type="radio" name="filtertype" value="zip">PLZ.</input>
-    <input type="radio" name="filtertype" value="telephone">Telefon</input>
-    <input type="radio" name="filtertype" value="birth">Geburtsjahr</input>
-    <input type="radio" name="filtertype" value="course">Kurs</input>
+    <input type="text" name="filter" value="$_GET["filter"]"/><br/>
+    <input type="radio" name="filtertype" value="any" $(check any)>Alles</input>
+    <input type="radio" name="filtertype" value="name" $(check name)>Name</input>
+    <input type="radio" name="filtertype" value="street" $(check street)>Straße</input>
+    <input type="radio" name="filtertype" value="zip" $(check zip)>PLZ.</input>
+    <input type="radio" name="filtertype" value="telephone" $(check telephone)>Telefon</input>
+    <input type="radio" name="filtertype" value="birth" $(check birth)>Geburtsjahr</input>
+    <input type="radio" name="filtertype" value="course" $(check course)>Kurs</input><br/>
     <button type="submit" name="action" value="new_filter">Filtern</button>
     <button type="submit" name="action" value="del_filter">Filter löschen</button>
   </div>
index 8a0f2d53b6aae0170ef544de02c6fdcadc8367b1..c9adf7f9c8169b96ca487125826f183bd59c951a 100755 (executable)
@@ -44,7 +44,7 @@ item_name[VERSION]=""
 item_name[XML]=""
 
 l10n() {
-  [ -n "$item_name[$1]" ] && echo "$item_name[$1]" || echo "$1"
+  [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
 }
 
 view_card_item() {
@@ -57,8 +57,8 @@ view_card_item() {
       echo "<h2 CLASS=\"FN\">$value</h2>"
       ;;
     *)
-      echo "<span class=\"item\"><span class=\"KEY $key\">$(l10n "$key")"
-      [ -n "$tag[TYPE]" ] && echo "($tag[TYPE])"
+      echo -n "<span class=\"item\"><span class=\"KEY $key\">$(l10n "$key")"
+      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
       echo ":</span>"
       ;|
     EMAIL)
@@ -86,6 +86,8 @@ view_attendee() {  #Parameter: Cardfile
         else
           view_card_item
           eval "$line"
+         unset value
+         unset tag
         fi
       ;;
     esac