X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Ffunctions.php;h=6a39ddd3383a804040a36b55d26d8f51811f0ba9;hb=7e79094af6491632cec5287d4a0471ab4d227726;hp=0f2e0e782662a9881b523a5763382524d697c45a;hpb=adaa23b9f9bbfb55f5c1cd85d6e84c49b950887d;p=readifood.git diff --git a/lib/functions.php b/lib/functions.php index 0f2e0e7..6a39ddd 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -320,7 +320,32 @@ function get_address_map_link($address) { $postcode = trim($address->getPostcode()); if ($postcode) { - return " " . get_small_link("Map", "http://maps.google.co.uk/maps?q=" . urlencode($postcode)); + # mrt=loc specifies a location search. + $map = "maps.google.co.uk/maps?q=" . urlencode($postcode) . "&mrt=loc"; + $url = "http://$map"; + # output=embed allows display in an iframe. + # iwloc=near hides the popup window for the embedded view. + $embed = $GLOBALS['http'] . "://$map&output=embed&iwloc=near"; + $html = " "; + $html .= get_small_link_with_id("map", "Map", $url); + $html .= ""; + return $html; } } @@ -428,9 +453,9 @@ function show_role_form($role, $roles) { for ($i = 0; $i < count($roles); $i++) { - echo " $roles[$i]\n"; + echo ">\n"; } } @@ -486,37 +511,13 @@ } function show_date_form($name, $date = null) { - $past = 60; - $future = 60; - echo "\n"; - return; - if (! isset($date)) $date = date('Y-m-d'); - list($y, $m, $d) = iso8601_to_ymd($date); - - echo "Year: "; - echo "Month: "; - echo "Day: "; + if (! isset($date)) $date = date('Y-m-d', time()); + datepicker($name, $date); } function validate_postcode($postcode, &$outward = null, &$inward = null) { /* - Valid postcode formats (BS766): + Valid postcode formats (BS7666): AN NLL ABN NLL @@ -560,19 +561,28 @@ } } - function get_small_link() { - /* Args are , , [ ...] */ + function get_small_link_with_id() { + /* Args are , , , [ ...] */ $args = func_get_args(); + $id = array_shift($args); + if (isset($id)) $id = " id=\"$id\""; $html = htmlspecialchars(array_shift($args)); $url = array_shift($args); - return vsprintf("$html\n", $args); + return vsprintf("$html\n", $args); + } + + function get_small_link() { + /* Args are , , [ ...] */ + $args = func_get_args(); + array_unshift($args, null); + return call_user_func_array("get_small_link_with_id", $args); } function small_link() { echo call_user_func_array("get_small_link", func_get_args()); } - include_once("$lib_root/admin.php"); - include_once("$lib_root/forms.php"); + include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "admin.php"))); + include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "forms.php"))); ?>