Пример #1
0
// Copyright Jamit Software LTD 2010
/*
The Iframe is used for marking the location on the map when the form is in
editing mode.
Iframe is not used for displaying the map
*/
define('NO_HOUSE_KEEPING', true);
$dir = dirname(__FILE__);
$dir = explode(DIRECTORY_SEPARATOR, $dir);
array_pop($dir);
array_pop($dir);
array_pop($dir);
$dir = implode('/', $dir);
require $dir . '/config.php';
require_once JB_basedirpath() . 'include/classes/JBGoogleMap.php';
$GMAP = JBGoogleMap::get_instance();
$map_id = (int) $_REQUEST['map_id'];
$form_id = (int) $_REQUEST['form_id'];
if (is_numeric($_REQUEST['lat']) && is_numeric($_REQUEST['lng']) && $_REQUEST['lat'] != 0) {
    if (is_numeric($_REQUEST['z'])) {
        $zoom = (int) $_REQUEST['z'];
    } else {
        $zoom = JB_GMAP_ZOOM;
    }
    $coords = $GMAP->add_map($map_id, array('lat' => $_REQUEST['lat'], 'lng' => $_REQUEST['lng']), $zoom);
    $lat = $_REQUEST['lat'];
    $lng = $_REQUEST['lng'];
} else {
    // use the default lat and lng
    $coords = $GMAP->add_map($map_id, array('lat' => JB_GMAP_LAT, 'lng' => JB_GMAP_LNG), JB_GMAP_ZOOM);
    $lat = JB_GMAP_LAT;
Пример #2
0
 function get_extra_markup($where)
 {
     static $DATE_CAL_HEADER_SET;
     static $EDITOR_HEADER_SET;
     static $GMAP_HEADER_SET;
     global $label, $JBMarkup;
     foreach ($this->tag_to_field_id as $field) {
         switch ($field['field_type']) {
             case 'DATE_CAL':
                 if ($where == 'header' && $this->is_edit_mode()) {
                     if (!isset($DATE_CAL_HEADER_SET)) {
                         $extra_str .= $JBMarkup->get_stript_include_tag(jb_get_SCW_js_src());
                         $DATE_CAL_HEADER_SET = true;
                     }
                 }
                 break;
             case 'EDITOR':
                 if ($where == 'header' && $this->is_edit_mode()) {
                     if (!isset($EDITOR_HEADER_SET)) {
                         $DFM = $this->get_DynamicFormMarkup();
                         $extra_str .= $DFM->get_editor_field_header();
                         $EDITOR_HEADER_SET = true;
                     }
                 }
                 break;
             case 'GMAP':
                 $lat = $this->get_value($field['field_id'] . '_lat');
                 $lng = $this->get_value($field['field_id'] . '_lng');
                 $zoom = $this->get_value($field['field_id']);
                 if (!$zoom) {
                     $zoom = JB_GMAP_ZOOM;
                 }
                 // Only add extra markup if there is map data.
                 if (is_numeric($lat) && is_numeric($lng) && $lat != 0) {
                     require_once JB_basedirpath() . 'include/classes/JBGoogleMap.php';
                     $GMAP = JBGoogleMap::get_instance();
                     if ($where == 'header') {
                         $GMAP->add_map($field['field_id'], array('lat' => $lat, 'lng' => $lng), $zoom);
                         $GMAP->add_marker($field['field_id'], $lat, $lng, 'A', '', false);
                         $args = array('gmap' => $GMAP, 'Form' => $this, 'field' => $field);
                         JBPlug_do_callback('gmap_add_map_after', $args);
                         // plugin authors can manipulate the map here, eg. add more markers, etc.
                         if (!isset($GMAP_HEADER_SET)) {
                             $extra_str .= $GMAP->get_header_js();
                             $GMAP_HEADER_SET = true;
                         }
                         $extra_str .= $GMAP->get_map_js($field['field_id']);
                     }
                     if ($where == 'onload_function') {
                         $extra_str .= $GMAP->get_onload_js($field['field_id']);
                     }
                 }
                 break;
             default:
                 JBPlug_do_callback('before_body_end_markup', $extra_str, $field, $where);
                 break;
         }
     }
     return $extra_str;
 }