X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Farea.php;h=fbf739d0aae041bdb9c478dff41044b3167c476e;hb=ea0e53db8b5a264b6e231038815d2c350076d02a;hp=9b0d5e1181850517fd907a2ff17645b72f33d5e4;hpb=bacdf10614c315868adfc94c597208d8c8256181;p=readifood.git diff --git a/lib/area.php b/lib/area.php index 9b0d5e1..fbf739d 100644 --- a/lib/area.php +++ b/lib/area.php @@ -1,6 +1,7 @@ Added area.

\n"; @@ -8,22 +9,25 @@ } } else if ($_POST['city_id']) { - /* XXX: city_id is actually a string $city_name/$city_id */ - header(sprintf("Location: http%s://%s/%s/in/city/%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $_POST['city_id'])); + set_last_selected("city_id", $_POST['city_id']); + $city_id = $_POST['city_id']; + $city = get_city_by_id($city_id); + header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $city->getName(), $city_id)); exit; } else if ($_POST['update_area']) { update_area_delivery_days($parameters[0]); } - function show_areas($offset, $per_page, $city_name = null, $city_id = null) { + function show_areas($city_name = null, $city_id = null) { + list($first_page, $per_page) = pagination(); if (isset($city_name) || isset($city_id)) { if (isset($city_id)) $city = get_city_by_id($city_id); else if ($city_name) $city = get_city_by_name($city_name); if ($city) { echo "

Areas in " . $city->getLink(get_city_displayname($city)) . ":"; $q = new AreaQuery; - $areas = $q->filterByCityId($city_id)->find(); + $areas = $q->filterByCityId($city_id)->orderByName()->orderById()->paginate($first_page, $per_page); if (count($areas)) { foreach ($areas as $area) { @@ -37,6 +41,7 @@ echo " " . $area->getDeleteLink(); } } + show_pagination($areas); } else echo " none"; echo "

\n"; @@ -64,7 +69,7 @@ echo "

Show areas in\n"; echo "\n"; echo "\n"; @@ -242,7 +247,7 @@ if ($parameters[0] == "in") { if ($parameters[1] == "city") { $city_id = $parameters[3]; - show_areas(0, 10, $parameters[2], $city_id); + show_areas($parameters[2], $city_id); show_new_area_form($city_id); } }