Ejemplo n.º 1
0
function insert_geo_location($catId, $itemId)
{
    $aItem = Item::newInstance()->findByPrimaryKey($itemId);
    $sAddress = isset($aItem['s_address']) ? $aItem['s_address'] : '';
    $sRegion = isset($aItem['s_region']) ? $aItem['s_region'] : '';
    $sCity = isset($aItem['s_city']) ? $aItem['s_city'] : '';
    $address = sprintf('%s, %s %s', $sAddress, $sRegion, $sCity);
    $response = osc_file_get_contents(sprintf('http://maps.google.com/maps/geo?q=%s&output=json&sensor=false&key=%s', urlencode($address), osc_google_maps_key()));
    $jsonResponse = json_decode($response);
    if (isset($jsonResponse->Placemark) && count($jsonResponse->Placemark[0]) > 0) {
        $coord = $jsonResponse->Placemark[0]->Point->coordinates;
        ItemLocation::newInstance()->update(array('d_coord_lat' => $coord[1], 'd_coord_long' => $coord[0]), array('fk_i_item_id' => $itemId));
    }
}
Ejemplo n.º 2
0
<?php

$key = '';
$dao_preference = new Preference();
if (Params::getParam('key') != '') {
    $key = Params::getParam('key');
} else {
    $key = osc_google_maps_key() != '' ? osc_google_maps_key() : '';
}
if (Params::getParam('option') == 'stepone') {
    $dao_preference->update(array("s_value" => $key), array("s_section" => "plugin-google_maps", "s_name" => "google_maps_key"));
    echo '<div style="text-align:center; font-size:22px; background-color:#00bb00;"><p>' . __('Congratulations. The plugin is now configured', 'google_maps') . '.</p></div>';
}
unset($dao_preference);
?>

<form action="<?php 
osc_admin_base_url(true);
?>
" method="post">
    <input type="hidden" name="page" value="plugins" />
    <input type="hidden" name="action" value="renderplugin" />
    <input type="hidden" name="file" value="google_maps/admin.php" />
    <input type="hidden" name="option" value="stepone" />
    <div>
        <?php 
_e('Please enter your Google Maps', 'google_maps');
?>
 <label for="key" style="font-weight: bold;"><?php 
_e('developer key', 'google_maps');
?>