diff -r 56308e61381c -r 846026b8422b index.php --- a/index.php Wed Oct 26 20:56:15 2011 +0200 +++ b/index.php Wed Oct 26 21:44:35 2011 +0200 @@ -1,92 +1,83 @@ -add_entry($_REQUEST); - break; - case 'search': $entries = $abook->search_entries($_REQUEST['pattern']); - break; - } - -} -catch (ErrorException $e) { - print "INTERNAL ERROR: " . $e->getMessage(); -} -catch (Exception $e) { - print "Application error: " . $e->getMessage(); - exit; -} - -?> - - - - - - - - - [ Home ] - - [ Add Entries ] - - -

Adressbuch

- - -

-

- -
- -
- -
- - -
- - - -
- - - -
- - - - - - - - -
NameTelefonMail
- - -
- - Sorry. - - - - - +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());