function wpdmp_save_marker_callback() { global $wpdb; //$markers = get_option ('wpdmp-markers'); $mid = intval($_POST['id']); //$map = pathinfo($_POST['map'], PATHINFO_FILENAME) . '.' . pathinfo($_POST['map'], PATHINFO_EXTENSION); $table_name = $wpdb->prefix . "wpdmp_marker_descr"; $wpdb->delete($table_name, array('markerid' => $mid)); $langs = explode('#%#', $_POST['desc']); foreach ($langs as $lang) { $x = explode('$%$', $lang); if (count($x) == 2 && $x[1] != "") { //exclude last empty part of $langs $rows_affected = $wpdb->insert($table_name, array('markerid' => $mid, 'descr' => $x[1], 'lang' => $x[0])); } if ($rows_affected != 1) { echo 'error wpdmp_add_marker_callback'; die; exit; } } $table_name = $wpdb->prefix . "wpdmp_marker"; $rows_affected = $wpdb->update($table_name, array('marker' => $_POST['marker']), array('id' => $mid)); $new_marker = wpdmp_get_marker($mid); ob_start(); wpdmp_marker_info($new_marker); $html = ob_get_contents(); ob_end_clean(); $new_marker['html'] = $html; echo json_encode($new_marker); die; exit; }
function wpdmp_print_site_list($map) { ?> <form action='' name='newmarkerform' id='newmarkerform' method='post'> <input type="hidden" name="f_id" id="f_id" /> <input type="hidden" name="freeX" id="freeX" /> <input type="hidden" name="freeY" id="freeY" /> <h1><?php _e("Map new place", 'wp-design-maps-and-places'); ?> </h1> <?php if ($map['type'] === 'freehand') { ?> <div class="form-field"> <label><?php _e('Click on the map to create a new place.', 'wp-design-maps-and-places'); ?> </label> </div> <?php } else { wpdmp_print_address_find_form('nonModal', false, $map); } ?> <div id="markerdesc"> <?php if ($map['type'] === 'freehand') { ?> <div class="form-field"> <label for="f_address"><?php echo __("Name"); ?> </label> <input type="text" name="f_address" id="f_address"/> </div> <?php } ?> <div class="form-field"> <label for="f_text"><?php _e('Popup description, use HTML to format, e.g. <br/> for newline:', 'wp-design-maps-and-places'); ?> </label> <?php $descr = array(); wpdmp_marker_tabs('new', $descr); wpdmp_marker_flags($map); ?> </div> </div> <p class="submit"> <input type="button" onclick="add_marker();" class="button-primary" <?php if (sizeof($map['markers']) == 0) { echo "disabled='true'"; } ?> tabindex="7" value='<?php _e(' ADD MARKER ', 'wp-design-maps-and-places'); ?> ' id="addmarker" name="addmarker" /> <!-- onclick="add_marker(jQuery('#mapimage').attr('mapid'), jQuery('#f_address').val(),jQuery('#f_latitude').val(),jQuery('#f_longitude').val(),jQuery('#f_text').val(),'en',jQuery('input[name=marker]:checked').val());" --> <input type="button" onclick="save_marker(jQuery('#mapimage').attr('mapid'), jQuery('#f_id').val(),jQuery('#f_address').val(),jQuery('#f_latitude').val(),jQuery('#f_longitude').val(),jQuery('#f_text').val(),jQuery('#f_text_en').val(),jQuery('input[name=marker]:checked').val());" class="button-primary" tabindex="7" value='<?php _e(' SAVE MARKER ', 'wp-design-maps-and-places'); ?> ' id="savemarker" name="savemarker" /> </p> </form> <div id="markerslist"> <!-- ?php wpdmp_print_site_list($mapid); ? --> <h1><?php _e('Places list', 'wp-design-maps-and-places'); ?> </h1> <?php $markers = wpdmp_get_map_places($map['id']); if ($markers) { foreach ($markers as $marker) { wpdmp_marker_info($marker); } } ?> <script type="text/javascript"> jQuery(document).ready(function(){$jq('.markerprint').each(function(index){if (index % 2 == 0){$jq(this).addClass('gray');}})}); </script> </div> <div id="progressbar" style="background: url(<?php echo WPDMP_PLUGIN_URL . 'images/spin.gif'; ?> ) center center no-repeat #fff"/></div> <?php }