Esempio n. 1
0
 function widget($args, $instance)
 {
     if (is_admin() || is_feed()) {
         return;
     }
     extract($args);
     $map_data_properties = array();
     $not_map_data_properties = array("title", "width", "height", "mapalign", "directionhint", "latitude", "longitude", "addresscontent", "addmarkerlisthidden", "addmarkermashuphidden", "addmarkerinput", "showmarker", "animation", "infobubblecontent", "markerdirections", "locationaddmarkerinput", "bubbletextaddmarkerinput");
     $json_default_values = cgmp_fetch_json_data_file(CGMP_JSON_DATA_DEFAULT_WIDGET_PARAM_VALUES);
     foreach ($instance as $key => $value) {
         $value = trim($value);
         $value = !isset($value) || empty($value) ? $json_default_values[$key] : esc_attr(strip_tags($value));
         $instance[$key] = $value;
         if (!in_array($key, $not_map_data_properties)) {
             $key = str_replace("hidden", "", $key);
             $key = str_replace("_", "", $key);
             $map_data_properties[$key] = $value;
         }
     }
     extract($instance);
     echo $before_widget;
     if (isset($title)) {
         echo $before_title . $title . $after_title;
     }
     $addmarkermashuphidden = isset($addmarkermashuphidden) ? $addmarkermashuphidden : 'false';
     if ($addmarkermashuphidden == 'true') {
         $addmarkerlisthidden = make_marker_geo_mashup();
     } else {
         if ($addmarkermashuphidden == 'false') {
             $addmarkerlisthidden = update_markerlist_from_legacy_locations($latitude, $longitude, $addresscontent, $addmarkerlisthidden);
             $addmarkerlisthidden = htmlspecialchars($addmarkerlisthidden);
         }
     }
     $bad_entities = array(""", "'");
     $addmarkerlisthidden = str_replace($bad_entities, "", $addmarkerlisthidden);
     $addmarkerlisthidden = cgmp_parse_wiki_style_links($addmarkerlisthidden);
     $id = md5(time() . ' ' . rand());
     $map_data_properties['id'] = $id;
     $map_data_properties['markerlist'] = $addmarkerlisthidden;
     $map_data_properties['addmarkermashup'] = $addmarkermashuphidden;
     $map_data_properties['kml'] = cgmp_clean_kml($map_data_properties['kml']);
     $map_data_properties['panoramiouid'] = cgmp_clean_panoramiouid($map_data_properties['panoramiouid']);
     //When widget was saved and untouched for a long time, the new added config options were not initialized
     $map_data_properties['scrollwheelcontrol'] = isset($map_data_properties['scrollwheelcontrol']) ? $map_data_properties['scrollwheelcontrol'] : "false";
     $map_data_properties['tiltfourtyfive'] = isset($map_data_properties['tiltfourtyfive']) ? $map_data_properties['tiltfourtyfive'] : "false";
     $map_data_properties['draggable'] = isset($map_data_properties['draggable']) ? $map_data_properties['draggable'] : "true";
     $poweredby = isset($poweredby) ? $poweredby : "false";
     $language = isset($language) ? $language : "en";
     echo cgmp_draw_map_placeholder($id, $width, $height, $mapalign, $directionhint, $poweredby);
     cgmp_set_google_map_language($language);
     cgmp_map_data_injector(json_encode($map_data_properties), $id);
     echo $after_widget;
 }
Esempio n. 2
0
 public function widget($args, $instance)
 {
     if (is_admin() || is_feed()) {
         return;
     }
     wp_enqueue_script('cgmp-google-map-jsapi');
     wp_enqueue_script('cgmp-google-map-orchestrator-framework');
     extract($args);
     $map_data_properties = array();
     $not_map_data_properties = array("title", "width", "height", "mapalign", "directionhint", "latitude", "longitude", "addresscontent", "addmarkerlisthidden", "addmarkermashuphidden", "enablegeolocationmarkerhidden", "addmarkerinput", "showmarker", "animation", "infobubblecontent", "markerdirections", "locationaddmarkerinput", "bubbletextaddmarkerinput");
     $json_default_values = cgmp_fetch_json_data_file(CGMP_JSON_DATA_DEFAULT_WIDGET_PARAM_VALUES);
     foreach ($instance as $key => $value) {
         $value = trim($value);
         $value = !isset($value) || empty($value) ? isset($json_default_values[$key]) ? $json_default_values[$key] : esc_attr(strip_tags($value)) : esc_attr(strip_tags($value));
         $instance[$key] = $value;
         if (!in_array($key, $not_map_data_properties)) {
             $key = str_replace("hidden", "", $key);
             $key = str_replace("_", "", $key);
             $map_data_properties[$key] = $value;
         }
     }
     extract($instance);
     echo $before_widget;
     if (isset($title)) {
         echo $before_title . $title . $after_title;
     }
     $addmarkermashuphidden = isset($addmarkermashuphidden) ? $addmarkermashuphidden : "false";
     $enablegeolocationmarkerhidden = isset($enablegeolocationmarkerhidden) ? $enablegeolocationmarkerhidden : "false";
     $enablemarkerclusteringhidden = isset($enablemarkerclusteringhidden) ? $enablemarkerclusteringhidden : "false";
     if ($addmarkermashuphidden == "true") {
         $json_data_arr = make_marker_geo_mashup_2();
         $addmarkerlisthidden = $json_data_arr["data"];
         $map_data_properties['debug'] = $json_data_arr["debug"];
     } else {
         if ($addmarkermashuphidden == "false") {
             $latitude = isset($latitude) && trim($latitude) != "" ? $latitude : "";
             $longitude = isset($longitude) && trim($longitude) != "" ? $longitude : "";
             $addresscontent = isset($addresscontent) && trim($addresscontent) != "" ? $addresscontent : "";
             $addmarkerlisthidden = update_markerlist_from_legacy_locations($latitude, $longitude, $addresscontent, $addmarkerlisthidden);
             $addmarkerlisthidden = htmlspecialchars($addmarkerlisthidden);
         }
     }
     $bad_entities = array(""", "'");
     $addmarkerlisthidden = str_replace($bad_entities, "", $addmarkerlisthidden);
     $addmarkerlisthidden = cgmp_parse_wiki_style_links($addmarkerlisthidden);
     if ($addmarkermashuphidden == 'false' && trim($addmarkerlisthidden) != "") {
         $cached_marker_data_json = get_option(CGMP_MAP_CACHE_WIDGET_PREFIX . $this->id);
         if (isset($cached_marker_data_json) && trim($cached_marker_data_json) != "") {
             $addmarkerlisthidden = $cached_marker_data_json;
             $cache_time = get_option(CGMP_MAP_CACHE_WIDGET_TIME_PREFIX . $this->id);
             $map_data_properties['debug'] = array("widget_id" => $this->id, "state" => "cached", "since" => $cache_time);
         } else {
             $addmarkerlisthidden = cgmp_do_serverside_address_validation_2($addmarkerlisthidden);
             $map_data_properties['debug'] = array("widget_id" => $this->id, "state" => "fresh", "since" => time());
             update_option(CGMP_MAP_CACHE_WIDGET_PREFIX . $this->id, $addmarkerlisthidden);
             update_option(CGMP_MAP_CACHE_WIDGET_TIME_PREFIX . $this->id, time());
         }
     }
     $id = md5(time() . ' ' . rand());
     $map_data_properties['id'] = $id;
     $map_data_properties['markerlist'] = $addmarkerlisthidden;
     $map_data_properties['addmarkermashup'] = $addmarkermashuphidden;
     $map_data_properties['enablegeolocationmarker'] = $enablegeolocationmarkerhidden;
     $map_data_properties['enablemarkerclustering'] = $enablemarkerclusteringhidden;
     $map_data_properties['kml'] = cgmp_clean_kml($map_data_properties['kml']);
     $map_data_properties['panoramiouid'] = cgmp_clean_panoramiouid($map_data_properties['panoramiouid']);
     //When widget was saved and untouched for a long time, the new added config options were not initialized
     $map_data_properties['distanceunits'] = isset($map_data_properties['distanceunits']) ? $map_data_properties['distanceunits'] : "miles";
     $map_data_properties['scrollwheelcontrol'] = isset($map_data_properties['scrollwheelcontrol']) ? $map_data_properties['scrollwheelcontrol'] : "false";
     $map_data_properties['enablemarkerclustering'] = isset($map_data_properties['enablemarkerclustering']) ? $map_data_properties['enablemarkerclustering'] : "false";
     $map_data_properties['tiltfourtyfive'] = isset($map_data_properties['tiltfourtyfive']) ? $map_data_properties['tiltfourtyfive'] : "false";
     $map_data_properties['draggable'] = isset($map_data_properties['draggable']) ? $map_data_properties['draggable'] : "true";
     $map_data_properties['styles'] = isset($map_data_properties['styles']) ? cgmp_clean_styles($map_data_properties['styles']) : "";
     $map_data_properties['styles'] = trim($map_data_properties['styles']) != "" ? base64_encode($map_data_properties['styles']) : $map_data_properties['styles'];
     $poweredby = isset($poweredby) ? $poweredby : "false";
     $language = isset($language) ? $language : "en";
     echo cgmp_draw_map_placeholder($id, $width, $height, $mapalign, $directionhint, $poweredby);
     cgmp_set_google_map_language($language);
     cgmp_map_data_injector(json_encode($map_data_properties), $id);
     echo $after_widget;
 }
Esempio n. 3
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);
 }