prefix."lugmap";
if ( isset( $_POST['lugmap_api_key'] ) && isset( $_POST['lugmap_coord'] ) ) {
if($_POST['lugmap_api_key'])
update_option('lugmap_api_key', attribute_escape($_POST['lugmap_api_key']));
if($_POST['lugmap_coord'])
update_option('lugmap_coord', attribute_escape($_POST['lugmap_coord']));
?>
.
prefix."lugmap";
$lm_name = $wpdb->escape($_POST['lm_name']);
$lm_org = $wpdb->escape($_POST['lm_org']);
$lm_email = $wpdb->escape($_POST['lm_email']);
$lm_web = $wpdb->escape(apply_filters("the_title",$_POST['lm_web']));
$lm_dsc = $wpdb->escape(apply_filters("comment_status_pre ",$_POST['lm_dsc']));
$lm_point = $wpdb->escape(strtok($_POST['lm_point'],"()"));
$wpdb->query("
INSERT INTO $table(name, cord, email, web, dsc, point)
VALUES('$lm_name', '$lm_org', '$lm_email', '$lm_web', '$lm_dsc', '$lm_point')
");
}
/**
* Gmaps markers generation
*/
function lugmap_markers() {
global $wpdb;
$table = $wpdb->prefix."lugmap";
$markers = $wpdb->get_results("SELECT point FROM $table");
foreach($markers as $marker) {
echo "\t"."var point = new GLatLng(".stripslashes($marker->point).");"."\n";
$point_data = null; //otherwise it will collect the whole world :)
$marker_data = $wpdb->get_results("SELECT `name`,`cord`,`email`,`web`,`dsc` FROM `$table` WHERE `point` = '$marker->point'");
foreach($marker_data as $item) {
$point_data .= "
";
}
echo "\t"."var marker = createMarker(point,'$point_data');"."\n";
echo "\t"."map.addOverlay(marker);"."\n\n";
}
}
/**
* Loading meta stuff like js files and etc.
*/
function lugmap_header() {
$lugmap_api_key = get_option('lugmap_api_key');
$lugmap_coord = get_option('lugmap_coord');
?>
';
$output .= '
';
$output .= '
';
return $output;
}
/**
* Clean lugmap table
*/
function lugmap_clean() {
global $wpdb;
$table = $wpdb->prefix."lugmap";
$wpdb->query("DROP TABLE $table");
lugmap_install();
}
/**
* Creating database tables and the rest of needed stuff
*/
function lugmap_install() {
global $wpdb;
$table = $wpdb->prefix."lugmap";
$structure = "CREATE TABLE $table (
id INT(9) NOT NULL AUTO_INCREMENT,
name VARCHAR(80) NOT NULL,
cord VARCHAR(40) NOT NULL,
email VARCHAR(40) NOT NULL,
web VARCHAR(1000) NOT NULL,
dsc VARCHAR(2000) NOT NULL,
point VARCHAR(20) NOT NULL,
UNIQUE KEY id (id)
);";
$wpdb->query('CHARACTER SET utf8 COLLATE utf8_general_ci');
$wpdb->query($structure);
// Populate table
$wpdb->query("INSERT INTO $table(name, cord, email, web, dsc, point)
VALUES('Grupul pentru software liber', 'Adi Roiban', 'adiroiban@gmail.com', 'http://softwareliber.ro/', 'Grupul pentru software liber s-a conturat la începutul anului 2005 in jurul unor studenți din cadrul Universității Tehnice din Cluj-Napoca. Ținta grupului a fost promovarea software-lui liber în rândurile studenților și profesorilor din facultate și continuarea activitații începute de Igor Știrbu la sfarșitul anului 2004.', '46.776306, 23.60429')");
add_option('lugmap_coord','45.943161, 24.96676');
add_option('lugmap_api_key','Please add your Google Maps key');
}
//l10n stuff
$lugmap_domain = 'lug-map';
$lugmap_domain_path = PLUGINDIR.'/'.dirname(plugin_basename(__FILE__));
load_plugin_textdomain($lugmap_domain,$lugmap_domain_path.'/l10n' );
add_shortcode('LUGMAP', 'lugmap_content');
add_action('admin_menu', 'lugmap_admin');
add_action('wp_head', 'lugmap_header');
register_activation_hook(__FILE__,'lugmap_install');
?>