function wpgmza_return_polyline_list($map_id, $admin = true, $width = "100%")
{
    wpgmaps_debugger("return_marker_start");
    global $wpdb;
    global $wpgmza_tblname_polylines;
    $results = $wpdb->get_results("\n\tSELECT *\n\tFROM {$wpgmza_tblname_polylines}\n\tWHERE `map_id` = '{$map_id}' ORDER BY `id` DESC\n    ");
    $wpgmza_tmp .= "\n        \n        <table id=\"wpgmza_table_polyline\" class=\"display\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">\n        <thead>\n        <tr>\n            <th><strong>" . __("ID", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Polyline Data", "wp-google-maps") . "</strong></th>\n            <th style='width:182px;'><strong>" . __("Action", "wp-google-maps") . "</strong></th>\n        </tr>\n        </thead>\n        <tbody>\n    ";
    $res = wpgmza_get_map_data($map_id);
    $default_marker = "<img src='" . $res->default_marker . "' />";
    //$wpgmza_data = get_option('WPGMZA');
    //if ($wpgmza_data['map_default_marker']) { $default_icon = "<img src='".$wpgmza_data['map_default_marker']."' />"; } else { $default_icon = "<img src='".wpgmaps_get_plugin_url()."/images/marker.png' />"; }
    foreach ($results as $result) {
        unset($poly_data);
        unset($poly_array);
        $poly_array = wpgmza_return_polyline_array($result->id);
        foreach ($poly_array as $poly_single) {
            $poly_data .= $poly_single . ",";
        }
        $wpgmza_tmp .= "\n            <tr id=\"wpgmza_poly_tr_" . $result->id . "\">\n                <td height=\"40\">" . $result->id . "</td>\n                <td height=\"40\"><small>" . $poly_data . "</small></td>\n                <td width='170' align='center'>\n                    <a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=wp-google-maps-menu&action=edit_polyline&map_id=" . $map_id . "&poly_id=" . $result->id . "\" title=\"" . __("Edit", "wp-google-maps") . "\" class=\"wpgmza_edit_poly_btn\" id=\"" . $result->id . "\">" . __("Edit", "wp-google-maps") . "</a> |\n                    <a href=\"javascript:void(0);\" title=\"" . __("Delete this polyline", "wp-google-maps") . "\" class=\"wpgmza_polyline_del_btn\" id=\"" . $result->id . "\">" . __("Delete", "wp-google-maps") . "</a>\n                </td>\n            </tr>";
    }
    $wpgmza_tmp .= "</tbody></table>";
    return $wpgmza_tmp;
}
/**
 * Returns the list of polylines displayed in the map editor
 *
 * @todo Build this as a hook or filter instead of a function call
 * 
 * @param  integer  $map_id Map ID
 * @param  boolean  $admin  Identify if user is admin or not
 * @param  string   $width  Width to be used for HTML output
 * @return string           List HTML
 */
function wpgmza_b_return_polyline_list($map_id, $admin = true, $width = "100%")
{
    wpgmaps_debugger("return_marker_start");
    global $wpdb;
    global $wpgmza_tblname_polylines;
    $wpgmza_tmp = "";
    $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpgmza_tblname_polylines} WHERE `map_id` = %d ORDER BY `id` DESC", intval($map_id)));
    $wpgmza_tmp .= "\n        \n        <table id=\"wpgmza_table_polyline\" class=\"display\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">\n        <thead>\n        <tr>\n            <th align='left'><strong>" . __("ID", "wp-google-maps") . "</strong></th>\n            <th align='left'><strong>" . __("Name", "wp-google-maps") . "</strong></th>\n            <th align='left' style='width:182px;'><strong>" . __("Action", "wp-google-maps") . "</strong></th>\n        </tr>\n        </thead>\n        <tbody>\n    ";
    $res = wpgmza_get_map_data($map_id);
    $default_marker = "<img src='" . $res->default_marker . "' />";
    //$wpgmza_data = get_option('WPGMZA');
    //if ($wpgmza_data['map_default_marker']) { $default_icon = "<img src='".$wpgmza_data['map_default_marker']."' />"; } else { $default_icon = "<img src='".wpgmaps_get_plugin_url()."/images/marker.png' />"; }
    foreach ($results as $result) {
        unset($poly_data);
        unset($poly_array);
        $poly_data = '';
        $poly_array = wpgmza_b_return_polyline_array($result->id);
        foreach ($poly_array as $poly_single) {
            $poly_data .= $poly_single . ",";
        }
        if (isset($result->polyname) && $result->polyname != "") {
            $poly_name = $result->polyname;
        } else {
            $poly_name = "Polyline" . $result->id;
        }
        $wpgmza_tmp .= "\n            <tr id=\"wpgmza_poly_tr_" . $result->id . "\">\n                <td height=\"40\">" . $result->id . "</td>\n                <td height=\"40\">" . esc_attr(stripslashes($poly_name)) . "</td>\n                <td width='170' align='left'>\n                    <a href=\"" . get_option('siteurl') . "/wp-admin/admin.php?page=wp-google-maps-menu&action=edit_polyline&map_id=" . $map_id . "&poly_id=" . $result->id . "\" title=\"" . __("Edit", "wp-google-maps") . "\" class=\"wpgmza_edit_poly_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-edit\"> </i></a> \n                    <a href=\"javascript:void(0);\" title=\"" . __("Delete this polyline", "wp-google-maps") . "\" class=\"wpgmza_polyline_del_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-times\"> </i></a>\n                </td>\n            </tr>";
    }
    $wpgmza_tmp .= "</tbody></table>";
    return $wpgmza_tmp;
}
Example #3
0
function wpgmaps_handle_db()
{
    wpgmaps_debugger("handle_db_start");
    global $wpdb;
    global $wpgmza_version;
    $table_name = $wpdb->prefix . "wpgmza";
    $sql = "\n        CREATE TABLE `" . $table_name . "` (\n          `id` int(11) NOT NULL AUTO_INCREMENT,\n          `map_id` int(11) NOT NULL,\n          `address` varchar(700) NOT NULL,\n          `desc` mediumtext NOT NULL,\n          `pic` varchar(700) NOT NULL,\n          `link` varchar(700) NOT NULL,\n          `icon` varchar(700) NOT NULL,\n          `lat` varchar(100) NOT NULL,\n          `lng` varchar(100) NOT NULL,\n          `anim` varchar(3) NOT NULL,\n          `title` varchar(700) NOT NULL,\n          `infoopen` varchar(3) NOT NULL,\n          PRIMARY KEY (`id`)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;\n    ";
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    dbDelta($sql);
    $sql2 = "alter table `" . $table_name . "` modify `desc` MEDIUMTEXT ;";
    $wpdb->query($sql2);
    $table_name = $wpdb->prefix . "wpgmza_maps";
    $sql = "\n        CREATE TABLE `" . $table_name . "` (\n          `id` int(11) NOT NULL AUTO_INCREMENT,\n          `map_title` varchar(50) NOT NULL,\n          `map_width` varchar(6) NOT NULL,\n          `map_height` varchar(6) NOT NULL,\n          `map_start_lat` varchar(700) NOT NULL,\n          `map_start_lng` varchar(700) NOT NULL,\n          `map_start_location` varchar(700) NOT NULL,\n          `map_start_zoom` INT(10) NOT NULL,\n          `default_marker` varchar(700) NOT NULL,\n          `type` INT(10) NOT NULL,\n          `alignment` INT(10) NOT NULL,\n          `directions_enabled` INT(10) NOT NULL,\n          `styling_enabled` INT(10) NOT NULL,\n          `styling_json` mediumtext NOT NULL,\n          `active` INT(1) NOT NULL,\n          `kml` VARCHAR(700) NOT NULL,\n          `bicycle` INT(10) NOT NULL,\n          `traffic` INT(10) NOT NULL,\n          `dbox` INT(10) NOT NULL,\n          `dbox_width` varchar(10) NOT NULL,\n          `listmarkers` INT(10) NOT NULL,\n          PRIMARY KEY (`id`)\n        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n    ";
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    dbDelta($sql);
    add_option("wpgmza_db_version", $wpgmza_version);
    update_option("wpgmza_db_version", $wpgmza_version);
    wpgmaps_debugger("handle_db_end");
}