      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157:

    <?php

    namespace WPGMZA;

    /**
     * This class represents the map engine selection dialog, which is presented to the user on the map edit page.
     */
    class MapsEngineDialog
    {
        /**
         * Processes AJAX POST when the user makes a selection
         * @return void
         */
        public static function post()
        {
            $settings = get_option('WPGMZA_OTHER_SETTINGS');

            $settings['wpgmza_maps_engine'] = $_POST['engine'];
            $settings['wpgmza_maps_engine_dialog_done'] = true;

            update_option('WPGMZA_OTHER_SETTINGS', $settings);

            wp_send_json(array('success' => 1));
            exit;
        }

        /**
         * Echos the dialog HTML
         * @return void
         */
        public function html()
        {
            ?>
            <div id="wpgmza-maps-engine-dialog" style="display: none;">
                <h1>
                    <?php
                    _e('Choose a maps engine', 'wp-google-maps');
                    ?>
                </h1>

                <div class="wpgmza-inner">
                    <div>
                        <input type="radio"
                            name="wpgmza_maps_engine"
                            id="wpgmza_maps_engine_open-layers"
                            value="open-layers"
                            />
                        <label for="wpgmza_maps_engine_open-layers">
                            <div>
                                <!--<h3>
                                    <?php
                                    _e('OpenLayers', 'wp-google-maps');
                                    ?>
                                </h3>-->

                                <img class="wpgmza-engine-logo" src="<?php echo plugin_dir_url(__DIR__) . 'images/OpenLayers_logo.svg.png'?>"/>

                                <ul>
                                    <li>
                                        <?php _e('No API keys required', 'wp-google-maps'); ?>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <?php _e('Limited functionality', 'wp-google-maps'); ?>
                                    </li>
                                </ul>
                            </div>

                            <!--<p class="wpgmza-centered">
                                <button class="button button-primary" data-maps-engine="open-layers">
                                    <?php
                                    _e('Use OpenLayers', 'wp-google-maps');
                                    ?>

                                </button>
                            </p>-->

                            <p class="wpgmza-mock-radio wpgmza-centered">
                                <span class="wpgmza-mock-radio-button"></span>
                                <img class="wpgmza-mock-radio-label"
                                    src="<?php echo plugin_dir_url(__DIR__); ?>images/openlayers_logo.png"
                                    />
                            </p>
                        </label>
                    </div>

                    <div>
                        <input type="radio"
                            name="wpgmza_maps_engine"
                            id="wpgmza_maps_engine_google-maps"
                            value="google-maps"
                            />
                        <label for="wpgmza_maps_engine_google-maps">
                            <div>
                                <!--<h3>
                                    <?php
                                    _e('Google Maps', 'wp-google-maps');
                                    ?>
                                </h3>-->

                                <img class="wpgmza-engine-logo" src="<?php echo plugin_dir_url(__DIR__) . 'images/icons8-google-maps-500.png'?>"/>

                                <!--<ul class="wpgmza-pros">
                                    <li>
                                        <?php _e('Full functionality', 'wp-google-maps'); ?>
                                    </li>
                                </ul>-->

                                <ul>
                                    <li>
                                        <?php _e('API Key required', 'wp-google-maps'); ?>
                                    </li>
                                </ul>
                            </div>

                            <!--<p class="wpgmza-centered">
                                <button class="button button-primary" data-maps-engine="google-maps">
                                    <?php
                                    _e('Use Google Maps', 'wp-google-maps');
                                    ?>
                                </button>
                            </p>-->

                            <p class="wpgmza-mock-radio wpgmza-centered">
                                <span class="wpgmza-mock-radio-button"></span>
                                <img class="wpgmza-mock-radio-label"
                                    src="<?php echo plugin_dir_url(__DIR__); ?>images/Google_maps_logo.png"
                                    />
                            </p>
                        </label>
                    </div>
                </div>

                <p class="wpgmza-centered">
                    <button class="button button-primary" id="wpgmza-confirm-engine" disabled>
                        <?php
                        _e('Select Engine', 'wp-google-maps');
                        ?>
                    </button>
                </p>

                <!--<footer>
                    <img src="<?php echo plugin_dir_url(__DIR__); ?>images/WP-google-maps-logo-1-B-transparent.png"
                        alt="<?php _e('WP Google Maps', 'wp-google-maps'); ?>"
                        />
                    <img src="<?php echo plugin_dir_url(__DIR__); ?>images/codecabin.png"
                        alt="by CODECABIN_"
                        />
                </footer>-->
            </div>
            <?php
        }
    }

    add_action('wp_ajax_wpgmza_maps_engine_dialog_set_engine', array('WPGMZA\\MapsEngineDialog', 'post'));