Exemplo n.º 1
0
 function cgmp_shortcode_googlemap_handler($attr, $content = null, $code = null)
 {
     if (is_admin() || is_feed()) {
         return;
     }
     wp_enqueue_script('cgmp-google-map-jsapi');
     wp_enqueue_script('cgmp-google-map-orchestrator-framework');
     $shortcode_attribs = shortcode_atts(array('shortcodeid' => -1, 'latitude' => 0, 'longitude' => 0, 'zoom' => '7', 'width' => 400, 'height' => 400, 'maptype' => 'ROADMAP', 'maptypecontrol' => 'true', 'pancontrol' => 'true', 'addresscontent' => '', 'zoomcontrol' => 'true', 'scalecontrol' => 'true', 'streetviewcontrol' => 'true', 'scrollwheelcontrol' => 'false', 'showbike' => 'false', 'styles' => '', 'enablemarkerclustering' => 'false', 'bubbleautopan' => 'false', 'distanceunits' => 'miles', 'showtraffic' => 'false', 'showpanoramio' => 'false', 'addmarkerlist' => '', 'kml' => '', 'directionhint' => 'false', 'mapalign' => 'center', 'panoramiouid' => '', 'enablegeolocationmarker' => 'false', 'addmarkermashup' => 'false', 'language' => 'default', 'poweredby' => 'false', 'draggable' => 'true', 'tiltfourtyfive' => 'false', 'addmarkermashupbubble' => 'false'), $attr);
     extract($shortcode_attribs);
     $id = md5(time() . ' ' . rand());
     $map_data_properties = array();
     $addmarkerlist = strip_tags($addmarkerlist);
     if ($addmarkermashup == 'true') {
         $json_data_arr = make_marker_geo_mashup_2();
         $addmarkerlist = $json_data_arr["data"];
         $map_data_properties["debug"] = $json_data_arr["debug"];
     } else {
         if ($addmarkermashup == 'false') {
             $addmarkerlist = update_markerlist_from_legacy_locations($latitude, $longitude, $addresscontent, $addmarkerlist);
             $addmarkerlist = htmlspecialchars($addmarkerlist);
         }
     }
     $bad_entities = array(""", "'");
     $addmarkerlist = str_replace($bad_entities, "", $addmarkerlist);
     $addmarkerlist = cgmp_parse_wiki_style_links($addmarkerlist);
     $not_map_data_properties = array("title", "latitude", "longitude", "addresscontent", "addmarkerlist", "showmarker", "animation", "infobubblecontent", "markerdirections", "locationaddmarkerinput", "bubbletextaddmarkerinput");
     foreach ($shortcode_attribs as $key => $value) {
         $value = trim($value);
         $value = !isset($value) || empty($value) ? '' : esc_attr(strip_tags($value));
         if (!in_array($key, $not_map_data_properties)) {
             $key = str_replace("hidden", "", $key);
             $key = str_replace("_", "", $key);
             $map_data_properties[$key] = $value;
         }
     }
     if ($addmarkermashup == 'false' && trim($addmarkerlist) != "") {
         $post_type = "custom";
         $post_id = -1;
         global $post;
         if (isset($post)) {
             if (is_object($post)) {
                 $post_type = isset($post->post_type) ? $post->post_type : $post_type;
                 $post_id = isset($post->ID) ? $post->ID : $post_id;
             } else {
                 if (is_array($post) && !empty($post)) {
                     $post_type = isset($post['post_type']) ? $post['post_type'] : $post_type;
                     $post_id = isset($post['ID']) ? $post['ID'] : $post_id;
                 }
             }
         }
         if (is_numeric($shortcodeid) && $shortcodeid == -1) {
             $shortcodeid = md5($addmarkerlist);
         }
         $json_data_arr = cgmp_get_post_page_cached_markerlist($shortcodeid, $post_id, $post_type, $addmarkerlist);
         $addmarkerlist = $json_data_arr["data"];
         $map_data_properties['debug'] = $json_data_arr["debug"];
     }
     $map_data_properties['id'] = $id;
     $map_data_properties['markerlist'] = $addmarkerlist;
     $map_data_properties['kml'] = cgmp_clean_kml($map_data_properties['kml']);
     $map_data_properties['panoramiouid'] = cgmp_clean_panoramiouid($map_data_properties['panoramiouid']);
     cgmp_set_google_map_language($language);
     cgmp_map_data_injector(json_encode($map_data_properties), $id);
     return cgmp_draw_map_placeholder($id, $width, $height, $mapalign, $directionhint, $poweredby);
 }
Exemplo n.º 2
0
 public function form($instance)
 {
     $settings = array();
     $json_html_elems = cgmp_fetch_json_data_file(CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS);
     $json_default_values = cgmp_fetch_json_data_file(CGMP_JSON_DATA_DEFAULT_WIDGET_PARAM_VALUES);
     if (is_array($json_html_elems)) {
         $legacy_params = array("latitude" => "", "longitude" => "", "addresscontent" => "", "addmarkerlisthidden" => "");
         foreach ($json_html_elems as $data_chunk) {
             $id = $data_chunk['dbParameterId'];
             $value = isset($instance[$id]) && trim($instance[$id]) != "" ? trim($instance[$id]) : "";
             $value = !isset($value) || empty($value) ? isset($json_default_values[$id]) ? $json_default_values[$id] : esc_attr(strip_tags($value)) : esc_attr(strip_tags($value));
             if (array_key_exists($id, $legacy_params)) {
                 $legacy_params[$id] = $value;
             }
             if ($id == "addmarkerlisthidden") {
                 extract($legacy_params);
                 $addmarkerlisthidden = update_markerlist_from_legacy_locations($latitude, $longitude, $addresscontent, $addmarkerlisthidden);
                 $value = $addmarkerlisthidden;
             }
             $data_chunk['dbParameterValue'] = $value;
             $data_chunk['dbParameterId'] = $this->get_field_id($id);
             $data_chunk['dbParameterName'] = $this->get_field_name($id);
             cgmp_set_values_for_html_rendering($settings, $data_chunk);
         }
     }
     $template_values = cgmp_build_template_values($settings);
     $template_values['SHORTCODEBUILDER_FORM_TITLE'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_WIDGET_FORM_TITLE);
     $template_values['SHORTCODEBUILDER_HTML_FORM'] = "";
     $tokens_with_values = array();
     $tokens_with_values['WIDGET_ID_TOKEN'] = $this->id;
     $tokens_with_values['MAP_CONFIGURATION_FORM_TEMPLATE_TOKEN'] = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM);
     echo cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_WIDGET);
 }
Exemplo n.º 3
0
 function make_marker_geo_mashup()
 {
     $is_purge_geomashup_cache = get_option(CGMP_DB_PURGE_GEOMASHUP_CACHE);
     $serial = get_option(CGMP_DB_GEOMASHUP_CONTENT);
     if (isset($serial) && trim($serial) != '') {
         $geomashup_content_arr = unserialize(base64_decode($serial));
         if (is_array($geomashup_content_arr) && sizeof($geomashup_content_arr) > 0) {
             if (!isset($is_purge_geomashup_cache) || $is_purge_geomashup_cache == "false") {
                 //echo "Running cached! You know it..";
                 return json_encode($geomashup_content_arr);
             }
         }
     }
     //echo "Running fresh! w00t?!";
     $db_markers = cgmp_extract_markers_from_published_content();
     if (is_array($db_markers) && count($db_markers) > 0) {
         $filtered = array();
         foreach ($db_markers as $postID => $post_data) {
             $title = $post_data['title'];
             $permalink = $post_data['permalink'];
             $markers = $post_data['markers'];
             $excerpt = $post_data['excerpt'];
             $markers = implode("|", $markers);
             $addmarkerlist = update_markerlist_from_legacy_locations(0, 0, "", $markers);
             $markers = explode("|", $addmarkerlist);
             foreach ($markers as $full_loc) {
                 $tobe_filtered_loc = $full_loc;
                 if (strpos($full_loc, CGMP_SEP) !== false) {
                     $loc_arr = explode(CGMP_SEP, $full_loc);
                     $tobe_filtered_loc = $loc_arr[0];
                 }
                 $tobe_filtered_loc = trim($tobe_filtered_loc);
                 if (!isset($filtered[$tobe_filtered_loc])) {
                     $filtered[$tobe_filtered_loc]['addy'] = $full_loc;
                     $filtered[$tobe_filtered_loc]['permalink'] = $permalink;
                     $bad_entities = array(""", "'", "'", "\"");
                     if (isset($title) && trim($title) != "") {
                         $title = str_replace($bad_entities, "", $title);
                         $title = trim($title);
                     }
                     $filtered[$tobe_filtered_loc]['title'] = $title;
                     if (isset($excerpt) && trim($excerpt) != "") {
                         $excerpt = str_replace($bad_entities, "", $excerpt);
                         $excerpt = trim($excerpt);
                     }
                     $filtered[$tobe_filtered_loc]['excerpt'] = $excerpt;
                 }
             }
         }
         return json_encode(cgmp_do_serverside_address_validation($filtered));
     }
 }