diff -r 52fb6408b86a -r 2d22262da8e0 abook.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/abook.php Thu Oct 27 16:56:26 2011 +0200 @@ -0,0 +1,85 @@ +add_entry($_REQUEST)) { + header("Location: $_SERVER[PHP_SELF]?action=add"); + exit(0); + } + echo $twig->render("add.html", array()); + exit; + break; + + // Suchen… + case 'search': $entries = null; + $error = null; + try { + $entries = $abook->search_entries($_REQUEST['pattern']); + } + catch (Address_Book_Exception $e) { + $error = $e->getMessage(); + } + + if (@$_REQUEST['format'] == 'table') { + if (is_numeric($_REQUEST['max'])) { + $left = count($entries) - $_REQUEST['max']; + if ($left > 0) + $entries = array_slice($entries, 0, $_REQUEST['max']); + else + $left = NULL; + } + echo $twig->render("results.html", + array('entries' => $entries, + 'left' => $left, 'error' => $error)); + exit; + } + echo $twig->render("search.html", + array('entries' => $entries, 'error' => $error)); + exit; + } + break; + + } + catch (Address_Book_Exception $e) { + header("Content-Type: text/plain; charset=utf-8"); + print "Address Book Exception: " . $e->getMessage(); + exit; + } + catch (Exception $e) { + header("Content-Type: text/plain; charset=utf-8"); + print "Ohoh\n\n" . $e; + exit; + } +} + +echo $twig->render("search.html", array());