X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=lib%2Ffunctions.php;h=ec0b35ade4763feb1890792972f1f01166b1e107;hb=67672f1de588927289253f9b56270e5336aa537d;hp=7a02b2af054808cd98dd7b2343ab35354c7c5c49;hpb=a646a2cfbd63d70043e60d88afff0add11ad7e81;p=readifood.git diff --git a/lib/functions.php b/lib/functions.php index 7a02b2a..ec0b35a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -317,6 +317,38 @@ return $q->findOneById($address->getAreaId()); } + function get_address_map_link($address) { + $postcode = trim($address->getPostcode()); + if ($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; + } + } + function get_contact_address($contact) { $q = new AddressQuery; return $q->findOneById($contact->getAddressId()); @@ -421,9 +453,9 @@ function show_role_form($role, $roles) { for ($i = 0; $i < count($roles); $i++) { - echo " $roles[$i]\n"; + echo ">\n"; } } @@ -479,40 +511,71 @@ } 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: "; + 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); } function get_small_link() { /* Args are , , [ ...] */ $args = func_get_args(); - $html = htmlspecialchars(array_shift($args)); - $url = array_shift($args); - return vsprintf("$html\n", $args); + array_unshift($args, null); + return call_user_func_array("get_small_link_with_id", $args); } function small_link() {