b2evolution PHP Cross Reference Blogging Systems

Source: /plugins/_google_maps.plugin.php - 942 lines - 20970 bytes - Summary - Text - Print

Description: This file implements the Google Maps plugin plugin. For the most recent and complete Plugin API documentation see {@link Plugin} in ../evocore/_plugin.class.php.

   1  <?php
   2  /**
   3   * This file implements the Google Maps plugin plugin.
   4   *
   5   * For the most recent and complete Plugin API documentation
   6   * see {@link Plugin} in ../evocore/_plugin.class.php.
   7   *
   8   * This file is part of the evoCore framework - {@link http://evocore.net/}
   9   * See also {@link http://sourceforge.net/projects/evocms/}.
  10   *
  11   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  12   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  13   *
  14   * {@internal License choice
  15   * - If you have received this file as part of a package, please find the license.txt file in
  16   *   the same folder or the closest folder above for complete license terms.
  17   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  18   *   then you must choose one of the following licenses before using the file:
  19   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  20   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  21   * }}
  22   *
  23   * @package plugins
  24   *
  25   * @version $Id: _google_maps.plugin.php 6136 2014-03-08 07:59:48Z manuel $
  26   */
  27  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  28  
  29  
  30  /**
  31   * Google Maps Plugin
  32   *
  33   *
  34   *
  35   * @package plugins
  36   */
  37  class google_maps_plugin extends Plugin
  38  {
  39      /**
  40       * Variables below MUST be overriden by plugin implementations,
  41       * either in the subclass declaration or in the subclass constructor.
  42       */
  43      var $name = 'Google Maps';
  44      var $code = 'evo_Gmaps';
  45      var $priority = 50;
  46      var $version = '5.0.0';
  47      var $author = 'The b2evo Group';
  48      var $help_url = '';  // empty URL defaults to manual wiki
  49  
  50      /*
  51       * These variables MAY be overriden.
  52       */
  53      var $number_of_installs = 1;
  54      var $group = 'widget';
  55      var $number_of_widgets ;
  56  
  57  
  58      /**
  59       * Init
  60       *
  61       * This gets called after a plugin has been registered/instantiated.
  62       */
  63  	function PluginInit( & $params )
  64      {
  65          $this->short_desc = T_('Google Maps plugin');
  66          $this->long_desc = T_('This plugin responds to positioning users');
  67      }
  68  
  69  
  70      /**
  71       * Get the settings that the plugin can use.
  72       *
  73       * Those settings are transfered into a Settings member object of the plugin
  74       * and can be edited in the backoffice (Settings / Plugins).
  75       *
  76       * @see Plugin::GetDefaultSettings()
  77       * @see PluginSettings
  78       * @see Plugin::PluginSettingsValidateSet()
  79       * @return array
  80       */
  81  	function GetDefaultSettings( & $params )
  82      {
  83          $r = array(
  84              'height_back' => array(
  85                  'label' => T_( 'Map height on edit post page' ),
  86                  'defaultvalue' => '300',
  87                  'note' => '',
  88                  ),
  89              'map_type' => array(
  90                  'label' => T_( 'Map default view ' ),
  91                  'type' => 'radio',
  92                  'options' => array( array( 'map', T_( 'Map' ) ), array( 'satellite', T_( 'Satellite' ) ) ),
  93                  'defaultvalue' => 'map',
  94                  'note' => ''
  95              )
  96              );
  97          return $r;
  98      }
  99  
 100  
 101          /**
 102       * Get definitions for widget editable params
 103       *
 104       * @see Plugin::get_widget_param_definitions()
 105       * @param local params like 'for_editing' => true
 106       */
 107  	function get_widget_param_definitions( $params )
 108      {
 109          $r = array(
 110              'map_title' => array(
 111                  'label' => T_('Widget title'),
 112                  'defaultvalue' => T_('Google maps Widget'),
 113                  'note' => T_('Widget title'),
 114                  'set_for_plugin' => true,
 115                  ),
 116              'width' => array(
 117                  'label' => T_('Map width on page'),
 118                  'defaultvalue' => '',
 119                  'note' => T_('100% width if left empty'),
 120                  ),
 121              'height_front' => array(
 122                  'label' => T_('Map height on page'),
 123                  'defaultvalue' => '300px',
 124                  'note' => '',
 125              ),
 126              'map_type' => array(
 127                  'label' => T_( 'Map default view ' ),
 128                  'type' => 'radio',
 129                  'options' => array( array('map', T_( 'Map' ) ), array( 'satellite', T_( 'Satellite' ) ) ),
 130                  'defaultvalue' => 'map',
 131                  'note' => ''),
 132  
 133              );
 134          return $r;
 135      }
 136  
 137      /**
 138       * User settings.
 139       *
 140       * @see Plugin::GetDefaultUserSettings()
 141       * @see PluginUserSettings
 142       * @see Plugin::PluginUserSettingsValidateSet()
 143       * @return array
 144       */
 145  	function GetDefaultUserSettings()
 146      {
 147          return array();
 148      }
 149  
 150      
 151      /**
 152       *  Add 'px' to display param if need.
 153       *
 154       * @param mixed display param
 155       * @return string
 156       */
 157  	function display_param($param)
 158      {
 159          if ( ! empty ($param) )
 160          {
 161              if( ! preg_match("/\D{1,}$/", $param) )
 162              {
 163                  $param = $param.'px';
 164              }
 165          }
 166          else
 167          {
 168              $param = '100%';
 169          }
 170          return  $param;
 171      }
 172  
 173      /**
 174       * @see Plugin::AdminDisplayItemFormFieldset()
 175       */
 176  	function AdminDisplayItemFormFieldset( & $params )
 177      {
 178          global $Blog, $DB;
 179  
 180          // fp>vitaliy : make thhis title configurable per blog . default shoul dbe as below.
 181          $plugin_title = $this->Settings->get( 'map_title_coll'.$Blog->ID );
 182          $plugin_title = empty( $plugin_title ) ? T_( 'Google Maps plugin' ) : $plugin_title;
 183          $params['Form']->begin_fieldset( $plugin_title );
 184  
 185          if( !$Blog->get_setting( 'show_location_coordinates' ) )
 186          {
 187              echo T_('You must turn on the "Show location coordinates" setting in Blog settings Post Features tab so the Google Maps plugin can save its coordinates.');
 188              $params['Form']->end_fieldset();
 189              return;
 190          }
 191  
 192          $params['Form']->switch_layout( 'linespan' );
 193  
 194          $Item = $params['Item'];
 195          require_js( '#jqueryUI#' );
 196  
 197          $lat = $Item->get_setting('latitude');
 198          $lng = $Item->get_setting('longitude');
 199          $zoom = $Item->get_setting('map_zoom');
 200          $map_type = $Item->get_setting('map_type');
 201  
 202          $city_ID = $Item->get('city_ID');
 203          $subrg_ID = $Item->get('subrg_ID');
 204          $rgn_ID = $Item->get('rgn_ID');
 205          $ctry_ID = $Item->get('ctry_ID');
 206  
 207          $search_location = '';
 208  
 209          if (empty( $lat ) && empty( $lng ) )
 210          {    // post location not set
 211  
 212              if ( ! empty ( $city_ID ) )
 213              {
 214                  $query = '
 215                      SELECT city_name
 216                      FROM T_regional__city
 217                      WHERE city_ID  = '.$DB->quote( $city_ID );
 218  
 219                  $text = $DB->get_var($query);
 220                  $search_location .= "$text";
 221              }
 222  
 223              if ( ! empty ( $subrg_ID ) )
 224              {
 225                  $query = '
 226                      SELECT subrg_name
 227                      FROM T_regional__subregion
 228                      WHERE subrg_ID  = '.$DB->quote( $subrg_ID );
 229  
 230                  $text = $DB->get_var($query);
 231                  if ( empty ( $search_location ) )
 232                  {
 233                      $search_location .= "$text";
 234                  }
 235                  else
 236                  {
 237                      $search_location .= ", $text";
 238                  }
 239              }
 240  
 241              if ( ! empty ( $rgn_ID ) )
 242              {
 243                  $query = '
 244                      SELECT rgn_name
 245                      FROM T_regional__region
 246                      WHERE rgn_ID = '.$DB->quote( $rgn_ID );
 247  
 248                  $text = $DB->get_var($query);
 249                  if ( empty ( $search_location ) )
 250                  {
 251                      $search_location .= "$text";
 252                  }
 253                  else
 254                  {
 255                      $search_location .= ", $text";
 256                  }
 257              }
 258  
 259              if ( ! empty ( $ctry_ID ) )
 260              {
 261                  $query = '
 262                      SELECT ctry_name
 263                      FROM T_regional__country
 264                      WHERE ctry_ID = '.$DB->quote( $ctry_ID );
 265  
 266                  $text = $DB->get_var($query);
 267                  if ( empty ( $search_location ) )
 268                  {
 269                      $search_location .= "$text";
 270                  }
 271                  else
 272                  {
 273                      $search_location .= ", $text";
 274                  }
 275              }
 276  
 277          }
 278  
 279          if( empty( $zoom ) )
 280          {
 281              $zoom = 17;
 282          }
 283  
 284          if( empty( $map_type ) )
 285          {
 286              $map_type = (string)$this->Settings->get('map_type');
 287          }
 288  
 289          $params['Form']->hidden( 'google_map_zoom', $zoom, array('id' => 'google_map_zoom'));
 290          $params['Form']->hidden( 'google_map_type', $map_type, array('id' => 'google_map_type'));
 291          $params['Form']->text_input( 'address', $search_location, 40, '<strong>1. </strong>'.T_('<b>Search for an address</b> (may be approximate)'), '', array('maxlength'=>500, 'id' =>'searchbox'));
 292          $params['Form']->button(array ('id' => 'locate_on_map', 'type' =>'button', 'value' => T_('Locate on map') ) );
 293  
 294          $height = $this->display_param($this->Settings->get('height_back'));
 295          $height = 'height:'.$height;
 296  
 297          echo '<div style="margin-top:1ex"><strong>2. '.T_('Drag the pin to the exact location you want:').'</strong></div>';
 298  
 299      ?>
 300      <div id="map_canvas" style="width:100%; <?php echo $height; ?>; margin: 5px 0px;"></div>
 301      <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
 302      <script type="text/javascript">
 303      var post_position = 0;
 304      <?php
 305      switch ($map_type)
 306      {
 307          case 'satellite':
 308              ?>
 309              var mapTypeId = google.maps.MapTypeId.SATELLITE;
 310              <?php
 311              break;
 312          case 'hybrid':
 313              ?>
 314              var mapTypeId = google.maps.MapTypeId.HYBRID;
 315              <?php
 316              break;
 317          default:
 318              ?>
 319              var mapTypeId = google.maps.MapTypeId.ROADMAP;
 320              <?php
 321              break;
 322      }
 323      
 324      if (!empty( $lat ) || !empty( $lng ) )
 325      {
 326          ?>
 327          var latlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng;?>);
 328          var zoom = <?php echo $zoom; ?>;
 329          var post_position = 1; // position is set
 330          <?php
 331      }
 332      else
 333      {
 334          ?>
 335          var latlng = new google.maps.LatLng(48.856614, 2.3522219000000177);
 336          var zoom = 11;
 337          <?php
 338          if ( !empty ( $search_location ) )
 339          {
 340              ?>
 341  
 342              var geocoder = new google.maps.Geocoder();
 343              geocoder.geocode( {'address': '<?php echo $search_location; ?>'}, function(results, status)
 344              {
 345                  if (status == google.maps.GeocoderStatus.OK)
 346                  {
 347                      var searchLoc = results[0].geometry.location;
 348                      var bounds = results[0].geometry.bounds;
 349                      if (bounds != null)
 350                      {
 351                          map.fitBounds(bounds);
 352                      }
 353                      else
 354                      {
 355                          map.setCenter(searchLoc);
 356                      }
 357  
 358                      if (marker != null)
 359                      {
 360                          marker.setMap(null);
 361                      }
 362  
 363                      marker = new google.maps.Marker({
 364                          position: searchLoc,
 365                          map: map,
 366                          title:"Position",
 367                          draggable: true
 368                          });
 369                      marker_dragend(marker, map);
 370                  }
 371              });
 372  
 373              <?php
 374  
 375          }
 376      }
 377      ?>
 378  
 379  
 380      var mapTypes = new Array();
 381      mapTypes.push(google.maps.MapTypeId.HYBRID);
 382      mapTypes.push(google.maps.MapTypeId.ROADMAP);
 383      mapTypes.push(google.maps.MapTypeId.SATELLITE);
 384      mapTypes.push(google.maps.MapTypeId.TERRAIN);
 385  
 386  
 387      var myOptions = {
 388            zoom: zoom,
 389            center: latlng,
 390            mapTypeId: mapTypeId,
 391            scrollwheel : false,
 392            mapTypeControlOptions:
 393                {
 394                 style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
 395                 mapTypeIds: mapTypes
 396                }
 397          };
 398  
 399      var map = new google.maps.Map(document.getElementById("map_canvas"),
 400              myOptions);
 401  
 402      var marker = new google.maps.Marker({
 403          position: latlng,
 404          map: map,
 405          title:"Position",
 406          draggable: true
 407          });
 408  
 409      var geocoder = new google.maps.Geocoder();
 410      var geo_region = null;
 411  
 412  	function set_region(region_code)
 413      {
 414          geo_region = region_code;
 415      }
 416  
 417      geocoder.geocode({'latLng': latlng}, function(region_res, region_status)
 418          {
 419              if (region_status == google.maps.GeocoderStatus.OK)
 420              {
 421                  if (region_res)
 422                  {
 423                      var country = region_res.pop();
 424                      set_region(country.address_components[0].short_name);
 425                  }
 426              }
 427              else
 428              {
 429                  set_region('');
 430              }
 431          });
 432  
 433  
 434      var searchLoc = null;
 435      var bounds = null;
 436  
 437  	function marker_dragend(marker, map)
 438      {
 439      google.maps.event.addListener(marker, 'dragend', function()
 440      {
 441          map.setCenter(marker.getPosition());
 442          jQuery('input[name=item_latitude]').val(marker.getPosition().lat());
 443  
 444  
 445  
 446          jQuery('input[name=item_longitude]').val(marker.getPosition().lng());
 447  
 448          geocoder.geocode({'latLng': marker.getPosition()}, function(region_res, region_status)
 449          {
 450              if (region_status == google.maps.GeocoderStatus.OK)
 451              {
 452                  if (region_res)
 453                  {
 454                      var country = region_res.pop();
 455                      set_region(country.address_components[0].short_name);
 456                  }
 457              }
 458              else
 459              {
 460                  set_region('');
 461              }
 462          });
 463  
 464      });
 465      }
 466  
 467      marker_dragend(marker, map);
 468  
 469      google.maps.event.addListener(map, 'zoom_changed', function()
 470      {
 471          jQuery('#google_map_zoom').val(map.getZoom());
 472      });
 473      google.maps.event.addListener(map, 'maptypeid_changed', function()
 474      {
 475          jQuery('#google_map_type').val(map.getMapTypeId());
 476      });
 477      google.maps.event.addListener(map, 'click', function(event)
 478      {
 479          if (marker != null)
 480          {
 481              marker.setMap(null);
 482          }
 483          marker = new google.maps.Marker({
 484          position: event.latLng,
 485          map: map,
 486          title:"Position",
 487          draggable: true
 488          });
 489  
 490          geocoder.geocode({'latLng': event.latLng}, function(region_res, region_status)
 491          {
 492              if (region_status == google.maps.GeocoderStatus.OK)
 493              {
 494                  if (region_res)
 495                  {
 496                      var country = region_res.pop();
 497                      set_region(country.address_components[0].short_name);
 498                  }
 499              }
 500              else
 501              {
 502                  set_region('');
 503              }
 504          });
 505  
 506          map.setCenter(marker.getPosition());
 507          jQuery('input[name=item_latitude]').val(event.latLng.lat());
 508          jQuery('input[name=item_longitude]').val(event.latLng.lng());
 509  
 510          marker_dragend(marker, map);
 511      });
 512  
 513  
 514      jQuery("#searchbox").autocomplete(
 515          {
 516          source: function(request, response)
 517            {
 518              if (geocoder == null)
 519              {
 520                  geocoder = new google.maps.Geocoder();
 521              }
 522              geocoder.geocode( {'address': request.term, 'region' : geo_region, 'bounds':  map.getBounds() }, function(results, status)
 523              {
 524                  if (status == google.maps.GeocoderStatus.OK)
 525                  {
 526                      searchLoc = results[0].geometry.location;
 527                      bounds = results[0].geometry.bounds;
 528  
 529                      geocoder.geocode({'latLng': searchLoc}, function(results1, status1)
 530                      {
 531                          if (status1 == google.maps.GeocoderStatus.OK)
 532                          {
 533                              if (results1[1])
 534                              {
 535                                  response(jQuery.map(results1, function(loc)
 536                                  {
 537                                      return {
 538                                          label  : loc.formatted_address,
 539                                          value  : loc.formatted_address,
 540                                          bounds : loc.geometry.bounds,
 541                                          location : loc.geometry.location
 542                                        }
 543                                  })
 544                                  );
 545                              }
 546                          }
 547                      });
 548                  }
 549                  else
 550                  {
 551                      searchLoc = null;
 552                      bounds = null;
 553                  }
 554                    });
 555                 },
 556          select: function(event,ui)
 557          {
 558              var pos = ui.item.position;
 559              var lct = ui.item.locType;
 560              bounds = ui.item.bounds;
 561              searchLoc = ui.item.location;
 562          }
 563          });
 564  
 565  function locate()
 566  {
 567      if (searchLoc != null)
 568      {
 569  
 570      geocoder.geocode({'latLng': searchLoc}, function(region_res, region_status)
 571          {
 572              if (region_status == google.maps.GeocoderStatus.OK)
 573              {
 574                  if (region_res)
 575                  {
 576                      var country = region_res.pop();
 577                      set_region(country.address_components[0].short_name);
 578                  }
 579              }
 580              else
 581              {
 582                  set_region('');
 583              }
 584          });
 585  
 586          if (marker != null)
 587          {
 588              marker.setMap(null);
 589          }
 590  
 591          marker = new google.maps.Marker({
 592              position: searchLoc,
 593              map: map,
 594              title:"Position",
 595              draggable: true
 596              });
 597          if (bounds !== undefined)
 598          {
 599              map.fitBounds(bounds);
 600          }
 601          else
 602          {
 603              map.setCenter(searchLoc);
 604          }
 605          marker_dragend(marker, map);
 606          jQuery('input[name=item_latitude]').val(searchLoc.lat());
 607          jQuery('input[name=item_longitude]').val(searchLoc.lng());
 608          jQuery('#google_map_zoom').val(map.getZoom());
 609          jQuery('#google_map_type').val(map.getMapTypeId());
 610      }
 611  
 612  }
 613  
 614      jQuery("#searchbox").keypress(function(event){
 615          if (event.keyCode == 13)
 616          {
 617              locate();
 618              return false
 619          }
 620  
 621      });
 622  
 623      jQuery('#locate_on_map').click( locate );
 624  
 625  	function post_location_change( adress )
 626      {
 627          if ( adress == '')
 628          {
 629              adress = 'Paris, France';
 630          }
 631              jQuery('#searchbox').val(adress);
 632              geocoder.geocode( {'address': adress}, function(results, status)
 633              {
 634                  if (status == google.maps.GeocoderStatus.OK)
 635                  {
 636                      var searchLoc = results[0].geometry.location;
 637                      var bounds = results[0].geometry.bounds;
 638                      if (bounds != null)
 639                      {
 640                          map.fitBounds(bounds);
 641                      }
 642                      else
 643                      {
 644                          map.setCenter(searchLoc);
 645                      }
 646                      if (marker != null)
 647                      {
 648                          marker.setMap(null);
 649                      }
 650                      marker = new google.maps.Marker({
 651                          position: searchLoc,
 652                          map: map,
 653                          title:"Position",
 654                          draggable: true
 655                          });
 656                      marker_dragend(marker, map);
 657                  }
 658              });
 659  
 660      }
 661  
 662      jQuery(document).ready( function(){
 663          if ( post_position == 0 )
 664          {
 665              jQuery('#item_ctry_ID').change(function(){
 666                  var adress = '';
 667                  var text =  jQuery('#item_city_ID option:selected').text();
 668  
 669                  if (text != 'Unknown')
 670                  {
 671                      if (adress == '')
 672                      {
 673                          adress = adress + text;
 674                      }
 675                      else 
 676                      {
 677                          adress = adress + ', ' + text;
 678                      }
 679                  }
 680  
 681                  text =  jQuery('#item_subrg_ID option:selected').text();
 682                  if (text != 'Unknown')
 683                  {
 684                      if (adress == '')
 685                      {
 686                          adress = adress + text;
 687                      }
 688                      else
 689                      {
 690                          adress = adress + ', ' + text;
 691                      }
 692                  }
 693  
 694                  text =  jQuery('#item_rgn_ID option:selected').text();
 695                  if (text != 'Unknown')
 696                  {
 697                      if (adress == '')
 698                      {
 699                          adress = adress + text;
 700                      }
 701                      else
 702                      {
 703                          adress = adress + ', ' + text;
 704                      }
 705                  }
 706  
 707                  text =  jQuery('#item_ctry_ID option:selected').text();
 708                  if (text != 'Unknown')
 709                  {
 710                      if (adress == '')
 711                      {
 712                          adress = adress + text;
 713                      }
 714                      else 
 715                      {
 716                          adress = adress + ', ' + text;
 717                      }
 718                  }
 719  
 720              post_location_change( adress );
 721              });
 722  
 723              jQuery('#item_subrg_ID').change(function(){
 724                  var adress = '';
 725                  text =  jQuery('#item_subrg_ID option:selected').text();
 726                  if (text != 'Unknown')
 727                  {
 728                      if (adress == '')
 729                      {
 730                          adress = adress + text;
 731                      }
 732                      else
 733                      {
 734                          adress = adress + ', ' + text;
 735                      }
 736                  }
 737  
 738                  text =  jQuery('#item_rgn_ID option:selected').text();
 739                  if (text != 'Unknown')
 740                  {
 741                      if (adress == '')
 742                      {
 743                          adress = adress + text;
 744                      }
 745                      else
 746                      {
 747                          adress = adress + ', ' + text;
 748                      }
 749                  }
 750  
 751                  text =  jQuery('#item_ctry_ID option:selected').text();
 752                  if (text != 'Unknown')
 753                  {
 754                      if (adress == '')
 755                      {
 756                          adress = adress + text;
 757                      }
 758                      else
 759                      {
 760                          adress = adress + ', ' + text;
 761                      }
 762                  }
 763                  post_location_change( adress );
 764                  });
 765  
 766              jQuery('#item_rgn_ID').change(function(){
 767                  var adress = '';
 768                  text =  jQuery('#item_rgn_ID option:selected').text();
 769                  if (text != 'Unknown')
 770                  {
 771                      if (adress == '')
 772                      {
 773                          adress = adress + text;
 774                      }
 775                      else
 776                      {
 777                          adress = adress + ', ' + text;
 778                      }
 779                  }
 780  
 781                  text =  jQuery('#item_ctry_ID option:selected').text();
 782                  if (text != 'Unknown')
 783                  {
 784                      if (adress == '')
 785                      {
 786                          adress = adress + text;
 787                      }
 788                      else
 789                      {
 790                          adress = adress + ', ' + text;
 791                      }
 792                  }
 793                  post_location_change( adress );
 794                  });
 795  
 796              jQuery('#item_ctry_ID').change(function(){
 797                  var adress = '';
 798                  text =  jQuery('#item_ctry_ID option:selected').text();
 799                  if (text != 'Unknown')
 800                  {
 801                      if (adress == '')
 802                      {
 803                          adress = adress + text;
 804                      }
 805                      else
 806                      {
 807                          adress = adress + ', ' + text;
 808                      }
 809                  }
 810                  post_location_change( adress );
 811                  });
 812              }
 813  
 814          });
 815      </script>
 816  
 817      <?php
 818          $params['Form']->switch_layout( NULL );
 819  
 820          $params['Form']->end_fieldset();
 821      }
 822  
 823  
 824  	function DisplayItemFormFieldset(& $params)
 825      {
 826          $this->AdminDisplayItemFormFieldset( $params );
 827      }
 828  
 829  
 830      /**
 831       * @see Plugin::SkinBeginHtmlHead()
 832       */
 833  	function SkinBeginHtmlHead()
 834      {
 835          require_js( '#jquery#', 'blog' );
 836      }
 837  
 838  	function SkinTag( $params )
 839      {
 840          global $Item;
 841          global $Blog;
 842  
 843          $this->number_of_widgets += 1;
 844  
 845          if( !$Blog->get_setting( 'show_location_coordinates' ) )
 846          {
 847              return;
 848          }
 849  
 850          if( !empty( $Item ) )
 851          {
 852              $lat = $Item->get_setting('latitude');
 853              $lng = $Item->get_setting('longitude');
 854              if (empty($lat) && empty($lng))
 855              {
 856                  return;
 857              }
 858          }
 859          else
 860          {
 861              $lat = 0;
 862              $lng = 0;
 863          }
 864          $width = $this->display_param($this->get_widget_setting('width', $params));
 865          $width = 'width:'.$width;
 866  
 867          $height = $this->display_param($this->get_widget_setting('height_front', $params));
 868          $height = 'height:'.$height;
 869  
 870          ?>
 871          <div class="map_title"><?php echo $this->get_widget_setting('map_title_coll'.$Blog->ID, $params); ?></div>
 872          <div class="map_canvas" id="map_canvas<?php echo $this->number_of_widgets; ?>" style="<?php echo $width; ?>; <?php echo $height; ?>; margin: 5px 5px 5px 5px;"></div>
 873          <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
 874          <script type="text/javascript">
 875          <?php
 876          $map_type = (string)$this->get_widget_setting('map_type', $params);
 877          switch ($map_type)
 878          {
 879              case 'satellite':
 880                  ?>
 881                  var mapTypeId = google.maps.MapTypeId.SATELLITE;
 882                  <?php
 883                  break;
 884              default:
 885                  ?>
 886                  var mapTypeId = google.maps.MapTypeId.ROADMAP;
 887                  <?php
 888                  break;
 889          }
 890          ?>
 891              var latlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng;?>);
 892              var mapTypes = new Array();
 893              mapTypes.push(google.maps.MapTypeId.HYBRID);
 894              mapTypes.push(google.maps.MapTypeId.ROADMAP);
 895              mapTypes.push(google.maps.MapTypeId.SATELLITE);
 896              mapTypes.push(google.maps.MapTypeId.TERRAIN);
 897  
 898              var myOptions = {
 899                    zoom: 17,
 900                    center: latlng,
 901                    mapTypeId: mapTypeId,
 902                    scrollwheel: false,
 903                    mapTypeControlOptions:
 904                        {
 905                         style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
 906                         mapTypeIds: mapTypes
 907                        }
 908                  };
 909              var map<?php echo $this->number_of_widgets; ?> = new google.maps.Map(document.getElementById("map_canvas<?php echo $this->number_of_widgets; ?>"),
 910                      myOptions);
 911              var marker<?php echo $this->number_of_widgets; ?> = new google.maps.Marker({
 912                  position: latlng,
 913                  map: map<?php echo $this->number_of_widgets; ?>,
 914                  title:"Position"
 915                  });
 916              </script>
 917              <?php
 918      }
 919  
 920      /**
 921       * Event handler: Called when the plugin has been installed.
 922       * @see Plugin::AfterInstall()
 923       */
 924  	function AfterInstall()
 925      {
 926          $this->msg( T_('Google Maps plugin sucessfully installed.') );
 927      }
 928  
 929  
 930      /**
 931       * Event handler: Called before the plugin is going to be un-installed.
 932       * @see Plugin::BeforeUninstall()
 933       */
 934  	function BeforeUninstall()
 935      {
 936          $this->msg( T_('Google Maps plugin sucessfully un-installed.') );
 937          return true;
 938      }
 939  
 940  }
 941  
 942  ?>

title

Description

title

Description

title

Description

title

title

Body