Пример #1
0
 function cgmp_draw_map_placeholder($id, $width, $height, $align, $hint, $poweredby)
 {
     $widthunits = "px";
     $heightunits = "px";
     $width = strtolower($width);
     $height = strtolower($height);
     $directionswidth = $width;
     if (strpos($width, "%") !== false) {
         $widthunits = "%";
         $width = substr($width, 0, -1);
         $directionswidth = $width;
     }
     if (strpos($width, "px") !== false) {
         $width = substr($width, 0, -1);
         $directionswidth = $width - 10;
     }
     if (strpos($height, "%") !== false) {
         $height = substr($height, 0, -1);
     }
     if (strpos($height, "px") !== false) {
         $height = substr($height, 0, -1);
     }
     $toploading = ceil($height / 2) - 50;
     $map_marker_directions_hint_template = "";
     if ($hint == "true") {
         $tokens_with_values = array();
         $tokens_with_values['MARKER_DIRECTIONS_HINT_WIDTH_TOKEN'] = $width . $widthunits;
         $tokens_with_values['LABEL_DIRECTIONS_HINT'] = __('Click on map markers to get directions', CGMP_NAME);
         $map_marker_directions_hint_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_MAP_MARKER_DIRECTION_HINT);
     }
     $map_poweredby_notice_template = "";
     if ($poweredby == "true") {
         $tokens_with_values = array();
         $tokens_with_values['MARKER_DIRECTIONS_HINT_WIDTH_TOKEN'] = $width . $widthunits;
         $map_poweredby_notice_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_MAP_POWEREDBY_NOTICE);
     }
     $tokens_with_values = array();
     $tokens_with_values['MAP_PLACEHOLDER_ID_TOKEN'] = $id;
     $tokens_with_values['MAP_PLACEHOLDER_WIDTH_TOKEN'] = $width . $widthunits;
     $tokens_with_values['MAP_PLACEHOLDER_HEIGHT_TOKEN'] = $height . $heightunits;
     $tokens_with_values['LOADING_INDICATOR_TOP_POS_TOKEN'] = $toploading;
     $tokens_with_values['MAP_ALIGN_TOKEN'] = $align;
     $tokens_with_values['MARKER_DIRECTIONS_HINT_TOKEN'] = $map_marker_directions_hint_template;
     $tokens_with_values['MAP_POWEREDBY_NOTICE_TOKEN'] = $map_poweredby_notice_template;
     $tokens_with_values['IMAGES_DIRECTORY_URI'] = CGMP_PLUGIN_IMAGES;
     $tokens_with_values['DIRECTIONS_WIDTH_TOKEN'] = $directionswidth . $widthunits;
     $tokens_with_values['LABEL_GET_DIRECTIONS'] = __('Get Directions', CGMP_NAME);
     $tokens_with_values['LABEL_PRINT_DIRECTIONS'] = __('Print Directions', CGMP_NAME);
     $tokens_with_values['LABEL_ADDITIONAL_OPTIONS'] = __('Additional options', CGMP_NAME);
     $tokens_with_values['LABEL_AVOID_TOLLS'] = __('Avoid tolls', CGMP_NAME);
     $tokens_with_values['LABEL_AVOID_HIGHWAYS'] = __('Avoid highways', CGMP_NAME);
     $tokens_with_values['LABEL_KM'] = __('KM', CGMP_NAME);
     $tokens_with_values['LABEL_MILES'] = __('Miles', CGMP_NAME);
     return cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_MAP_PLACEHOLDER_AND_DIRECTIONS);
 }
Пример #2
0
 function cgmp_render_shortcode_builder_form()
 {
     $settings = array();
     $json_string = file_get_contents(CGMP_PLUGIN_DATA_DIR . "/" . CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS);
     $parsed_json = json_decode($json_string, true);
     if (is_array($parsed_json)) {
         foreach ($parsed_json as $data_chunk) {
             cgmp_set_values_for_html_rendering($settings, $data_chunk);
         }
     }
     $template_values = cgmp_build_template_values($settings);
     $template_values['SHORTCODEBUILDER_FORM_TITLE'] = "";
     $template_values['SHORTCODEBUILDER_HTML_FORM'] = "";
     $map_configuration_template = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM);
     $tokens_with_values = array("MAP_CONFIGURATION_FORM_TOKEN" => $map_configuration_template);
     echo cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_MAP_SHORTCODE_BUILDER_METABOX);
 }
Пример #3
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);
 }
Пример #4
0
 function cgmp_parse_menu_html()
 {
     if (!current_user_can('activate_plugins')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $json_html_doco_params = cgmp_fetch_json_data_file(CGMP_JSON_DATA_HTML_ELEMENTS_DOCO_PARAMS);
     if (is_array($json_html_doco_params)) {
         $map_configuration_form_template = cgmp_render_template_with_values($json_html_doco_params, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM);
         $template_values = array();
         $template_values["DOCUMENTATION_TOKEN"] = $map_configuration_form_template;
         echo cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIG_DOCUMENTATION_PAGE);
     }
 }
Пример #5
0
 function cgmp_generate_global_options()
 {
     $tokens_with_values = array();
     $tokens_with_values['LABEL_KML'] = '[TITLE] [MSG] ([STATUS])';
     $tokens_with_values['LABEL_DOCINVALID_KML'] = __('The KML file is not a valid KML, KMZ or GeoRSS document.', CGMP_NAME);
     $tokens_with_values['LABEL_FETCHERROR_KML'] = __('The KML file could not be fetched.', CGMP_NAME);
     $tokens_with_values['LABEL_LIMITS_KML'] = __('The KML file exceeds the feature limits of KmlLayer.', CGMP_NAME);
     $tokens_with_values['LABEL_NOTFOUND_KML'] = __('The KML file could not be found. Most likely it is an invalid URL, or the document is not publicly available.', CGMP_NAME);
     $tokens_with_values['LABEL_REQUESTINVALID_KML'] = __('The KmlLayer is invalid.', CGMP_NAME);
     $tokens_with_values['LABEL_TIMEDOUT_KML'] = __('The KML file could not be loaded within a reasonable amount of time.', CGMP_NAME);
     $tokens_with_values['LABEL_TOOLARGE_KML'] = __('The KML file exceeds the file size limits of KmlLayer.', CGMP_NAME);
     $tokens_with_values['LABEL_UNKNOWN_KML'] = __('The KML file failed to load for an unknown reason.', CGMP_NAME);
     $tokens_with_values = array_map('cgmp_escape_json', $tokens_with_values);
     $global_error_messages_json_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_GLOBAL_ERROR_MESSAGES);
     $tokens_with_values = array();
     $tokens_with_values['LABEL_STREETVIEW'] = __('Street View', CGMP_NAME);
     $tokens_with_values['LABEL_ADDRESS'] = __('Address', CGMP_NAME);
     $tokens_with_values['LABEL_DIRECTIONS'] = __('Directions', CGMP_NAME);
     $tokens_with_values['LABEL_TOHERE'] = __('To here', CGMP_NAME);
     $tokens_with_values['LABEL_FROMHERE'] = __('From here', CGMP_NAME);
     $tokens_with_values = array_map('cgmp_escape_json', $tokens_with_values);
     $info_bubble_translated_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_INFO_BUBBLE);
     global $cgmp_global_map_language;
     $cgmp_global_map_language = isset($cgmp_global_map_language) && $cgmp_global_map_language != '' ? $cgmp_global_map_language : "en";
     $errorArray = json_decode($global_error_messages_json_template, true);
     $translationArray = json_decode($info_bubble_translated_template, true);
     $properties = array();
     $properties['ajaxurl'] = admin_url('admin-ajax.php');
     $properties['noBubbleDescriptionProvided'] = CGMP_NO_BUBBLE_DESC;
     $properties['geoValidationClientRevalidate'] = CGMP_GEO_VALIDATION_CLIENT_REVALIDATE;
     $properties['cssHref'] = CGMP_PLUGIN_URI . "style.css?ver=" . CGMP_VERSION;
     $properties['language'] = $cgmp_global_map_language;
     $properties['customMarkersUri'] = CGMP_PLUGIN_IMAGES . "/markers/";
     foreach ($errorArray as $name => $value) {
         $properties[$name] = $value;
     }
     foreach ($translationArray as $name => $value) {
         $properties[$name] = $value;
     }
     $setting_map_should_fill_viewport = get_option(CGMP_DB_SETTINGS_MAP_SHOULD_FILL_VIEWPORT);
     if (isset($setting_map_should_fill_viewport) && $setting_map_should_fill_viewport == "true") {
         $properties['mapFillViewport'] = "true";
     } else {
         $properties['mapFillViewport'] = "false";
     }
     $properties[CGMP_TIMESTAMP] = wp_create_nonce(CGMP_AJAX_CACHE_MAP_ACTION);
     $properties['ajaxCacheMapAction'] = CGMP_AJAX_CACHE_MAP_ACTION;
     $properties['sep'] = CGMP_SEP;
     echo "<script type='text/javascript'>" . PHP_EOL;
     echo "/* <![CDATA[ */" . PHP_EOL;
     echo "// Comprehensive Google Map plugin v" . CGMP_VERSION . PHP_EOL;
     echo "var CGMPGlobal = " . json_encode($properties) . PHP_EOL;
     echo "/* ]]> */" . PHP_EOL;
     echo "</script>" . PHP_EOL;
 }
Пример #6
0
<strong>Anyway it is strongly advised to check your maps before and make a database backup or at least an export of your current content from <a style="text-decoration:underline;" href="' . admin_url() . 'export.php">(tools->export)</a>,  as the CGMP shortcodes can only be restored from a a backup!</strong>
</p></div>';
            $template_values['TRANSFERE_BUTTON'] = "<input type='submit' onclick='return confirm(\"Please click OK if you want to replace all existing CGMP shortcodes (please note that these can only be restored from a backup!)\")' style='float:left;margin-top:8px;' class='button-primary alignleft' tabindex='4' value='step 2/2: replace existing CGMP shortcodes' id='cgmp-save-settings' name='cgmp-replace-shortcodes' />";
            $template_values['RESET_BUTTON'] = "<input type='submit' style='float:right;margin-top:8px;' class='button-secondary alignleft' tabindex='4' value='or reset transfer and start again' id='cgmp-save-settings' name='cgmp-reset-export' />";
        }
    }
    $template_values['POSTS_WITH_SHORTCODES'] = '<p>You are currently using the following shortcodes:</p>
<table cellspacing="0" cellpadding="0" >
                    <thead>
                        <th>CGMP shortcode</th>
                        <th style="width:20%">Link to Maps Marker Pro map</th>
                         <th style="width:20%">Maps Marker Pro Shortcode</th> 
                         <th style="width:15%">Link to content where shortcode is used</th>  
                    </thead>
                    <tbody>
                        ' . $shortcodes_data['results'] . '
                    </tbody>
                </table>
';
    // AUTO REPLACE ACTION
    if (isset($_POST['cgmp-replace-shortcodes'])) {
        $template_values['EXPORTED_MSG'] = '<div class="updated" id="message"> Transfer is finished - all shortcodes from the "comprehensive google map plugin" have been replaced with "Maps Marker Pro" shortcodes. You can now disable and optionally delete the "comprehensive google map plugin".</div>';
        $autoreplace = cgmp_autoreplace_shortcodes($stored_shortcodes);
        $template_values['POSTS_WITH_SHORTCODES'] = $autoreplace;
        $template_values['TRANSFERE_BUTTON'] = "";
        delete_transient('cgmp_layers_markers_export');
    }
    // Assign shortcodes table
    echo cgmp_render_template_with_values($template_values, 'page_admin_menu_export.tpl');
}
Пример #7
0
 function cgmp_render_shortcode_builder_form()
 {
     include_once CGMP_PLUGIN_INCLUDE_DIR . '/shortcode_builder_form.php';
     echo cgmp_render_template_with_values(array("MAP_CONFIGURATION_FORM_TOKEN" => $map_configuration_template), "map_shortcode_builder_metabox.tpl");
 }
<?php

/*
Copyright (C) 2011  Alexander Zagniotov

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
$settings = array();
$json_string = file_get_contents(CGMP_PLUGIN_DATA_DIR . "/" . CGMP_JSON_DATA_HTML_ELEMENTS_FORM_PARAMS);
$parsed_json = json_decode($json_string, true);
if (is_array($parsed_json)) {
    foreach ($parsed_json as $data_chunk) {
        cgmp_set_values_for_html_rendering($settings, $data_chunk);
    }
}
$template_values = cgmp_build_template_values($settings);
$map_configuration_template = cgmp_render_template_with_values($template_values, CGMP_HTML_TEMPLATE_MAP_CONFIGURATION_FORM);
Пример #9
0
 function cgmp_google_map_init_global_html_object()
 {
     $tokens_with_values = array();
     //This one gets alerted in native browser alert
     $tokens_with_values['LABEL_OLD_JQUERY'] = __('ATTENTION! (by Comprehensive Google Map Plugin)\\n\\nYour blog/site theme or one of your plugins uses jQuery javascript library which is older than the version 1.3.0.\\nThe Comprehensive Google Map plugin will not work with such outdated jQuery version.\\n\\nThe minimum jQuery requirement for Comprehensive Google Map plugin is version 1.3.0. Apologies for the inconvenience..', CGMP_NAME);
     $tokens_with_values['LABEL_BAD_ADDRESSES'] = __('<b>ATTENTION</b>! (by Comprehensive Google Map Plugin)<br /><br />Google found the following address(es) as NON-geographic and could not find them:<br /><br />[REPLACE]<br />Consider revising the address(es). Did you make a mistake when creating marker locations or did not provide a full geo-address? Alternatively use Google web to validate the address(es)', CGMP_NAME);
     $tokens_with_values['LABEL_MISSING_MARKERS'] = __('<b>ATTENTION</b>! (by Comprehensive Google Map Plugin)<br /><br />Dear blog/website owner,<br />You did not specify any marker locations for the Google map! Please check the following when adding marker locations:<br /><b>[a]</b> In the shortcode builder, did you add location(s) and clicked the Add button before generating shortcode?<br /><b>[b]</b> In the widget, did you add location(s) and clicked Add button before clicking Save?<br /><br />Please revisit and reconfigure your widget or shortcode configuration. The map requires at least one marker location to be added..', CGMP_NAME);
     $tokens_with_values['LABEL_KML'] = __('<b>ATTENTION</b>! (by Comprehensive Google Map Plugin)<br /><br />Dear blog/website owner,<br />Google returned the following error when trying to load KML file:<br /><br />[MSG] ([STATUS])', CGMP_NAME);
     $tokens_with_values['LABEL_DOCINVALID_KML'] = __('The KML file is not a valid KML, KMZ or GeoRSS document.', CGMP_NAME);
     $tokens_with_values['LABEL_FETCHERROR_KML'] = __('The KML file could not be fetched.', CGMP_NAME);
     $tokens_with_values['LABEL_LIMITS_KML'] = __('The KML file exceeds the feature limits of KmlLayer.', CGMP_NAME);
     $tokens_with_values['LABEL_NOTFOUND_KML'] = __('The KML file could not be found. Most likely it is an invalid URL, or the document is not publicly available.', CGMP_NAME);
     $tokens_with_values['LABEL_REQUESTINVALID_KML'] = __('The KmlLayer is invalid.', CGMP_NAME);
     $tokens_with_values['LABEL_TIMEDOUT_KML'] = __('The KML file could not be loaded within a reasonable amount of time.', CGMP_NAME);
     $tokens_with_values['LABEL_TOOLARGE_KML'] = __('The KML file exceeds the file size limits of KmlLayer.', CGMP_NAME);
     $tokens_with_values['LABEL_UNKNOWN_KML'] = __('The KML file failed to load for an unknown reason.', CGMP_NAME);
     $tokens_with_values['LABEL_GOOGLE_APIV2'] = __('<b>ATTENTION</b>! (by Comprehensive Google Map Plugin)<br /><br />Dear blog/website owner,<br />It looks like your webpage has reference to the older Google API v2, in addition to the API v3 used by Comprehensive Google Map! An example of plugin using the older API v2, can be jquery.gmap plugin.<br /><br />Please disable conflicting plugin(s). In the meanwhile, map generation is aborted!', CGMP_NAME);
     $tokens_with_values['LABEL_NO_GOOGLE'] = __('<b>ATTENTION</b>!(by Comprehensive Google Map Plugin)<br /><br />Dear blog/website owner,<br />It looks like Google map API could not be reached. Map generation was aborted!<br /><br />Please check that Google API script was loaded in the HTML source of your web page', CGMP_NAME);
     $tokens_with_values = array_map('cgmp_escape_json', $tokens_with_values);
     $global_error_messages_json_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_GLOBAL_ERROR_MESSAGES);
     $tokens_with_values = array();
     $tokens_with_values['LABEL_STREETVIEW'] = __('Street View', CGMP_NAME);
     $tokens_with_values['LABEL_ADDRESS'] = __('Address', CGMP_NAME);
     $tokens_with_values['LABEL_DIRECTIONS'] = __('Directions', CGMP_NAME);
     $tokens_with_values['LABEL_TOHERE'] = __('To here', CGMP_NAME);
     $tokens_with_values['LABEL_FROMHERE'] = __('From here', CGMP_NAME);
     $tokens_with_values = array_map('cgmp_escape_json', $tokens_with_values);
     $info_bubble_translated_template = cgmp_render_template_with_values($tokens_with_values, CGMP_HTML_TEMPLATE_INFO_BUBBLE);
     global $cgmp_global_map_language;
     $cgmp_global_map_language = isset($cgmp_global_map_language) && $cgmp_global_map_language != '' ? $cgmp_global_map_language : "en";
     echo "<object id='global-data-placeholder' style='background-color:transparent !important;border:none !important;height:0 !important;left:10000000px !important;line-height:0 !important;margin:0 !important;outline:medium none !important;padding:0 !important;position:absolute !important;top:100000px !important;width:0 !important;z-index:9999786 !important'>" . PHP_EOL;
     echo "    <param id='sep' name='sep' value='" . CGMP_SEP . "' />" . PHP_EOL;
     echo "    <param id='cssHref' name='cssHref' value='" . CGMP_PLUGIN_URI . "style.css?ver=" . CGMP_VERSION . "' />" . PHP_EOL;
     echo "    <param id='language' name='language' value='" . $cgmp_global_map_language . "' />" . PHP_EOL;
     echo "    <param id='customMarkersUri' name='customMarkersUri' value='" . CGMP_PLUGIN_IMAGES . "/markers/' />" . PHP_EOL;
     echo "    <param id='errors' name='errors' value='" . $global_error_messages_json_template . "' />" . PHP_EOL;
     echo "    <param id='translations' name='translations' value='" . $info_bubble_translated_template . "' />" . PHP_EOL;
     echo "</object> " . PHP_EOL;
 }