X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Fcity.php;h=dd60e360899b5d9d8442f9ba5d06f5905a342b98;hb=f181270af10ecded4b40d9ad3f838216835eb5f4;hp=29f2c753312793dbce5ad4dbc563ac49f0297cdd;hpb=6fdbfe32798452ec1c0fdbda57edabb892518409;p=readifood.git diff --git a/lib/city.php b/lib/city.php index 29f2c75..dd60e36 100644 --- a/lib/city.php +++ b/lib/city.php @@ -18,10 +18,12 @@ if (count($p)) { foreach ($p as $city) { echo "
\nCity: " . $city->getStrongLink(get_city_displayname($city)); - printf(" Areas", urlencode($city->getName()), $city->getID()); - printf(" Contacts", urlencode($city->getName()), $city->getId()); - printf(" Donations", urlencode($city->getName()), $city->getId()); - printf(" Orders", urlencode($city->getName()), $city->getId()); + $n = $city->getName(); + $i = $city->getId(); + echo " " . get_small_link("Areas", "/area/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Contacts", "/contact/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Donations", "/donation/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Orders", "/order/in/city/%s/%d", $n, $i); if (check_admin(1)) { echo " " . $city->getDeleteLink(); } @@ -34,7 +36,7 @@ function show_new_city_form() { if (! check_admin(1)) return; - echo "
\n"; + form("noprint standout"); echo "

Add a new city \n"; echo "with postcode prefix \n"; echo "

\n"; @@ -74,6 +76,17 @@ return $city->getId(); } + function confirm_delete_city($name, $id = null) { + if (! check_admin(1, "delete a city")) return; + + if (isset($id)) $city = get_city_by_id($id); + else $city = get_city_by_name($name); + if (! $city) return false; + + echo "

Confirm deletion

\n"; + echo "

You must confirm deletion of city " . $city->getName() . ": " . $city->getDeleteLink(true) . "

\n"; + } + function delete_city($name, $id = null) { if (! check_admin(1, "delete a city")) return; @@ -100,10 +113,12 @@ if (! $city) return; echo "

City: " . get_city_displayname($city) . ""; - printf(" Areas", urlencode($city->getName), $city->getID()); - printf(" Contacts", urlencode($city->getName()), $city->getId()); - printf(" Donations", urlencode($city->getName()), $city->getId()); - printf(" Orders", urlencode($city->getName()), $city->getId()); + $n = $city->getName(); + $i = $city->getId(); + echo " " . get_small_link("Areas", "/area/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Contacts", "/contact/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Donations", "/donation/in/city/%s/%d", $n, $i); + echo " " . get_small_link("Orders", "/order/in/city/%s/%d", $n, $i); if (check_admin(1)) { echo " " . $city->getDeleteLink(); } @@ -124,6 +139,10 @@ if (count($args)) { switch ($args[0]) { case "delete": + confirm_delete_city($name, $id); + break; + + case "confirmdelete": delete_city($name, $id); break; @@ -134,12 +153,9 @@ } } else if (isset($name)) show_city($name, $id); - else { - show_cities(0, 10); - show_new_city_form(); - } + else show_cities(0, 10); + + if (count($parameters)) echo "

Show all cities

\n"; + show_new_city_form(); - # XXX: Format URL in branch case... - if (count($parameters)) - echo "

Show all cities

\n"; ?>