# googlemapper.pl # Get and retreive maps from Google # by Kyrre Baker # http://kyrrebaker.com/2007/03/googlemapper_for_movable_type/ # V 1.8 ~ 10.01.2008 ## Minor cleanup in code # V 1.7 ~ 09.01.2008 ## Added the resource <$MTGoogleMapperLatLon$> for displaying the position # V 1.6 ~ 20.12.2007 ## Added the resource <$MTGoogleMapperZoomLevel$> for displaying the zoom level ## Added the resource <$MTGoogleMapperMaptype$> for displaying the maptype ## Changed the default zoom level from 3 to 12 ## Minor cleanup in code # V 1.5 ~ 04.04.2007 ## Minor cleanup in code # V 1.4 ~ 03.04.2007 ## Added the resource <$MTGoogleMapperHeadJS$> for creating the html/header JavaScript ## Minor cleanup in code ## Fixed the "context"- bug # V 1.3 ~ 02.04.2007 ## Added the resource <$MTGoogleMapperApiKey$> for displaying the API-Key ## Added the resource <$MTGoogleMapperVersion$> for displaying the plugin- version ## Killed the Scope for unique blogs and went back to a system wide setting # V 1.2 ~ 02.04.2007 ## Added the Scope for unique blogs ## Minor cleanup in code # V 1.1 ~ 01.04.2007 ## Changed the datafield from "excerpt" to "keywords" ## Made some minor ajustments to the CMS / settings pane use strict; package MT::Plugin::GoogleMapper; use vars qw( $VERSION ); $VERSION = '1.8'; my $plugin_key = 'GoogleMapper'; require MT::Template::Context; require MT::Plugin; require MT; # Invoke the plugin my $plugin = MT::Plugin->new({ name => $plugin_key, description => 'Get and retreive maps from Google', doc_link => 'http://kyrrebaker.com/arkiv/2007/03/googlemapper_for_movable_type/', author_name => 'Kyrre Baker', author_link => 'http://kyrrebaker.com/', version => $VERSION, system_config_template => \&_system_config_template, settings => new MT::PluginSettings([ ['googlemaps_api_key', { Default => '', Scope => 'system' }], ['googlemaps_maptype', { Default => 'G_NORMAL_MAP', Scope => 'system' }], ['googlemaps_zoomlevel', { Default => '12', Scope => 'system' }], ['googlemaps_latlon', { Default => '60, -25', Scope => 'system' }] ]) }); MT->add_plugin($plugin); # Add tags and templates MT::Template::Context->add_tag(GoogleMapperApiKey => \&_apikey); MT::Template::Context->add_tag(GoogleMapperHeadJS => \&_headerjs); MT::Template::Context->add_tag(GoogleMapperVersion => \&_version); MT::Template::Context->add_tag(GoogleMapperMaptype => \&_maptype); MT::Template::Context->add_tag(GoogleMapperZoomLevel => \&_zoomlevel); MT::Template::Context->add_tag(GoogleMapperLatLon => \&_latlon); MT->add_callback('bigpapi::template::edit_entry', 9, $plugin, \&_googlemapapi); # Get config my $config = $plugin->get_config_hash('system'); my $googlemaps_api_key = $config->{googlemaps_api_key}; my $googlemaps_maptype = $config->{googlemaps_maptype}; my $googlemaps_zoomlevel = $config->{googlemaps_zoomlevel}; my $googlemaps_latlon = $config->{googlemaps_latlon}; # Returns the API-Key <$MTGoogleMapperApiKey$> sub _apikey { return $googlemaps_api_key; } # Returns the plugin version <$MTGoogleMapperVersion$> sub _version { return $VERSION; } # Returns the default position <$MTGoogleMapperLatLon$> sub _latlon { return $googlemaps_latlon; } # Returns the default zoom level <$MTGoogleMapperZoomLevel$> sub _zoomlevel { return $googlemaps_zoomlevel; } # Returns the default map type <$MTGoogleMapperMaptype$> sub _maptype { return $googlemaps_maptype; } # Creates the headerinfo that's needed by Google Map <$MTGoogleMapperHeadJS$> sub _headerjs { return ''; } # Change the CMS / API sub _googlemapapi { my ($ctx, $app, $template) = @_; my $old = qq{}; $old = quotemeta($old); my $new = <
HTML $$template =~ s/$old/$new/; } # System settings panel sub _system_config_template { return <API-Settings


Map-Settings




HTML } # Stupid Perl 1;