Horde_Core_Ui_VarRenderer_Html::_renderVarDisplay_address PHP Méthode

_renderVarDisplay_address() protected méthode

protected _renderVarDisplay_address ( $form, &$var, &$vars, $text = true )
    protected function _renderVarDisplay_address($form, &$var, &$vars, $text = true)
    {
        global $registry;
        $address = $var->getValue($vars);
        if (empty($address)) {
            return '';
        }
        $info = $var->type->parse($address);
        $google_icon = 'map.png';
        if (!empty($info['country'])) {
            switch ($info['country']) {
                case 'uk':
                    /* Multimap.co.uk generated map */
                    $mapurl = 'http://www.multimap.com/map/browse.cgi?pc=' . urlencode($info['zip']);
                    $desc = Horde_Core_Translation::t("Multimap UK map");
                    $icon = 'map.png';
                    break;
                case 'au':
                    /* Whereis.com.au generated map */
                    $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
                    $desc = Horde_Core_Translation::t("Whereis Australia map");
                    $icon = 'map.png';
                    /* See if it's the street number & name. */
                    if (isset($info['streetNumber']) && isset($info['streetName'])) {
                        $mapurl .= '&streetNumber=' . urlencode($info['streetNumber']) . '&streetName=' . urlencode($info['streetName']);
                    }
                    /* Look for "Suburb, State". */
                    if (isset($info['city'])) {
                        $mapurl .= '&suburb=' . urlencode($info['city']);
                    }
                    /* Look for "State <4 digit postcode>". */
                    if (isset($info['state'])) {
                        $mapurl .= '&state=' . urlencode($info['state']);
                    }
                    break;
                case 'us':
                case 'ca':
                    /* American/Canadian address style. */
                    /* Mapquest generated map */
                    $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
                    $desc = Horde_Core_Translation::t("MapQuest map");
                    $icon = 'map.png';
                    if (!empty($info['street'])) {
                        $mapurl .= '&address=' . urlencode($info['street']);
                    }
                    if (!empty($info['city'])) {
                        $mapurl .= '&city=' . urlencode($info['city']);
                    }
                    if (!empty($info['state'])) {
                        $mapurl .= '&state=' . urlencode($info['state']);
                    }
                    if (!empty($info['zip'])) {
                        if ($info['country'] == 'ca') {
                            $mapurl .= '&country=CA';
                        }
                        $mapurl .= '&zipcode=' . urlencode($info['zip']);
                    }
                    /* Yahoo! generated map. */
                    $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
                    $desc2 = Horde_Core_Translation::t("Yahoo! map");
                    $icon2 = 'map.png';
                    if (!empty($info['street'])) {
                        $mapurl2 .= '&addr=' . urlencode($info['street']);
                    }
                    /* Give precedence to zipcode over city/state */
                    if (empty($info['zip']) && !empty($info['city']) && !empty($info['state'])) {
                        $mapurl2 .= '&csz=' . urlencode($info['city'] . ' ' . $info['state']);
                    }
                    if (!empty($info['zip'])) {
                        if (preg_match('|([a-zA-Z]\\d[a-zA-Z])\\s?(\\d[a-zA-Z]\\d)|', $info['zip'], $pcParts)) {
                            $mapurl2 .= '&country=ca';
                            /* make sure the postal-code has a space */
                            $info['zip'] = $pcParts[1] . ' ' . $pcParts[2];
                        }
                        $mapurl2 .= '&csz=' . urlencode($info['zip']);
                    }
                    break;
                default:
                    if (!count($info)) {
                        break;
                    }
                    /* European address style. */
                    $google_icon = 'map_eu.png';
                    /* Mapquest generated map. */
                    $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
                    $desc2 = Horde_Core_Translation::t("MapQuest map");
                    $icon2 = 'map_eu.png';
                    if (!empty($info['street'])) {
                        $mapurl2 .= '&address=' . urlencode($info['street']);
                    }
                    if (!empty($info['zip'])) {
                        $mapurl2 .= '&zipcode=' . urlencode($info['zip']);
                    }
                    if (!empty($info['city'])) {
                        $mapurl2 .= '&city=' . urlencode($info['city']);
                    }
                    break;
            }
        }
        $html = $text ? nl2br(htmlspecialchars($address)) : '';
        if (!empty($mapurl)) {
            $html .= '&nbsp;&nbsp;' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde::img($icon, $desc) . '</a>';
        }
        if (!empty($mapurl2)) {
            $html .= '&nbsp;' . Horde::link(Horde::externalUrl($mapurl2), $desc2, null, '_blank') . Horde::img($icon2, $desc2) . '</a>';
        }
        /* Google generated map. */
        if ($address) {
            $html .= '&nbsp;' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\\r?\\n/', ',', $address)) . '&hl=en'), Horde_Core_Translation::t("Google Maps"), null, '_blank') . Horde::img($google_icon, Horde_Core_Translation::t("Google Maps")) . '</a>';
        }
        return $html;
    }
Horde_Core_Ui_VarRenderer_Html