This is a Drupal 7 module.

http://drupal.org/sandbox/scot.hubbard/1531046
git clone http://git.drupal.org/sandbox/scot.hubbard/1531046.git google_map_field

This module allows users to add a "Google Map Field" field-type to any content type. This will then present the content editor with an interactive Google map so that the editor can find the point at which to drop a marker. This map will then be displayed on the final content page when viewed.

Another feature of this module is a WYSIWYG button to allow the inline insertion of map tokens directly in to content. This is feature is compatible with the WYSIWYG module (the button must be enabled in the usual way that WYSIWYG plugins are enabled for WYSIWYG profiles.

Other Projects Reviewed:
(1)
http://drupal.org/node/1538196#comment-5905968
http://drupal.org/node/1281192#comment-5906286
http://drupal.org/node/1434306#comment-5906384 (done)
(2)
http://drupal.org/node/1536778#comment-5912576
http://drupal.org/node/1281192#comment-5912652
http://drupal.org/node/1395500#comment-5912780 (done)
(3)
http://drupal.org/node/1417258#comment-5914974
http://drupal.org/node/1425060#comment-5915172
http://drupal.org/node/1273586#comment-5915252 (done)
(4)
http://drupal.org/node/1512124#comment-5926078
http://drupal.org/node/1536250#comment-5926162
http://drupal.org/node/1421888#comment-5926280 (done)
(5)
http://drupal.org/node/1432692#comment-5920658
http://drupal.org/node/1422616#comment-5930812
http://drupal.org/node/1268140#comment-5930888

Comments

patrickd’s picture

Status: Needs review » Needs work

welcome,

You are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

As installation and usage instructions are quite important for us to review, please take a moment to make your project page follow tips for a great project page. Also create a README.txt that follows the guidelines for in-project documentation.

Remove the license file as it will be added automatically later and all code hosted on d.o is under gpl anyway. Also the old $id$ tags are deprecated since we got git on drupal.org.

while waiting for an in-depht review of your module you can start out fixing some coding style issues detected by automated tools:
http://ventral.org/pareview/httpgitdrupalorgsandboxscothubbard1531046git

We do really need more hands in the application queue and highly recommend to get a review bonus so we can come back to your application sooner.

regards

scot.hubbard’s picture

Status: Needs work » Needs review

Many thanks for the quick response.

I have fixed all but the "still working on master branch" issues, which I still need to get my head around (working with git is completely new to me!)

pgogy’s picture

Git can be a real pain

I like this module - all seems ok in coder, and it is simple to run and set up (no problems here).

I would consider looking into use hook_help (http://api.drupal.org/api/drupal/modules%21help%21help.api.php/function/...) and possible hook_permission (http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...) to see if you only want to allow certain people to be able to change map data - could see a case for this.

Only UX issue I found was that if you allow the field to have multiple values - you can't set them using the map?
Maybe limit the field to one value?

Very impressed though, well done.

scot.hubbard’s picture

Thanks for the suggestions - I shall implement these.

Could you expand on your comment, "if you allow the field to have multiple values - you can't set them using the map?", I don't quite understand what you mean - it all seems to work fine for me.

pgogy’s picture

Ahhh, I see now. I get 5 maps if I say have 5 values, not one map to which I could add multiple values :)

It might be interesting to support multiple default map positions.

Could I give maps a label?

scot.hubbard’s picture

I shall add the ability to label individual maps. Thanks for the feedback.

luxpaparazzi’s picture

Status: Needs review » Needs work
Master Branch
It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
  $js = '
    var map_' . $delta . ';
    jQuery(document).ready(function(){
      var latlng = new google.maps.LatLng(' . $lat . ', ' . $lon . ');
      var mapOptions = {
        zoom: ' . $zom . ',
        center: latlng,
        streetViewControl: false,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      map_' . $delta . ' = new google.maps.Map(document.getElementById("google_map_field_' . $delta . '"), mapOptions);
      // add a marker to the map for the dealer
      marker = new google.maps.Marker({
        position: latlng,
        map: map_' . $delta . ',
      });

Javascript should go into .JS files, and parameters/settings should be passes with the settings function ... see http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add...

<div class="google-map-field"><div class="google-map-field-label">' . $name . '</div><div id="google_map_field_' . $delta . '" style="width: ' . $wth . 'px; height: ' . $hth . 'px;"></div></div>

Markup should best be placed into theme functions or template files ...

return t("To insert a google map field, <a href='/google-map-field/token-builder' target='_new'>click here for the token builder</a> (opens in a new window)");
Links should be created with the l() function, and html should not be passed to t()!

The response time for a review is now approaching 4 weeks.
Get a review bonus and we will come back to your application sooner.
See: http://drupal.org/node/1410826

You could for example start by evaluating my own project:
http://drupal.org/node/1302786

scot.hubbard’s picture

Thanks for the response luxpaparazzi. The reason the JS is not in a .js file is because I have to declare the javascript variables on-the-fly to cope with multiple map fields.

If you can suggest a better way I'd be happy to take a look.

luxpaparazzi’s picture

scot.hubbard’s picture

My problem is that each map (you can have unlimited maps using google map field) needs its own global variable so I cannot declare them in a static JS file.

It may be my inexperience showing through, but I don't see how Drupal.settings can help.

luxpaparazzi’s picture

you could create arrays with drupal.settings, even so I'm not an expert on this subject, I suppose it should be possible...

scot.hubbard’s picture

Status: Needs work » Needs review

Moved as much inline JS as possible into static JS files as per comment #7.

scot.hubbard’s picture

All issues above have now been addressed and the git repo is branched to 7.x-1.x from master.

Remaining inline JS is there due to the fact that the user can use this module in insert multiple inline maps using the WYSIWYG feature (map token builder), and when this is done the JS needs a global var for each map, and at this point there is a disconnect between Drupal and the JS (I can't dynamically declare the globals needed in the JS, therefore the JS has to be built on the fly and inlined).

scot.hubbard’s picture

Issue summary: View changes

Added link to review comment for another project.

scot.hubbard’s picture

Issue summary: View changes

Added second project review.

scot.hubbard’s picture

Issue tags: +PAreview: review bonus

Added PAReview: review bonus tag.

luxpaparazzi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

@scot, your reviews are quite short, but I won't judge on them ;)

1. Callback functions should not be "hidden" functions, so remove "_" at the geginning:

  $filters['google_map_field_token'] = array(
    'title' => t('Google Map Field'),
    'description' => t('Use tokens to insert Google Map Fields.'),
    'process callback' => '_google_map_field_filter_process',
    'cache' => FALSE,
    'tips callback' => '_google_map_field_filter_tips',
  );

2. It's bad practice setting height and width fix in code:
'#markup' => '<div id="google_map_field_selector" style="width: 300px; height: 250px;"></div>'
they should be defined in CSS files!
I would even suggest putting as much html-code into theme functions or template files.

--
The response time for a review is now approaching 4 weeks.
Get a review bonus and we will come back to your application sooner.
See: http://drupal.org/node/1410826

You could consider evaluating my own application:
http://drupal.org/node/1302786

scot.hubbard’s picture

Status: Needs work » Needs review

Thanks luxpaparazzi.

As per point 1 I have removed the leading underscore character from the callback function names.

With regard to point 2, I have moved the style from inline to the CSS file on the line you have highlighted, however, I feel that as much as possible has been done to remove further CSS/HTML from this module. The nature of the module means that a lot of markup, include JS and CSS, has to be built on-the-fly and I feel that moving any more HTML in to theme function would just complicate and slow the module down unnecessarily.

sepph’s picture

I agree with luxaparazzi... it would be good to try and get as much of your markup as possible in to theme functions or tpl's.

I'd also suggest that you add some simple validation to the form values used by the field as it will let you add some values that'll break the output of the field.

Also it looks as though the field does not respect the 'required field' option when adding the field to an entity.

Other than that though I like the look of this module. It looks nice and lightweight.

scot.hubbard’s picture

Thanks sepph.

The width and height fields have been removed from the google_map_field in favour of these being set by the themer via CSS (the module will drop in default values, which can obviously be overridden). The required field issue is therefore no longer extant.

Also, all HTML in '#markup' fields has been moved the theme functions.

scot.hubbard’s picture

Added hook_help() to provide simple config message for end users.

scot.hubbard’s picture

Issue summary: View changes

Added third project review.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue tags: +PAreview: review bonus

Added PAReview bonus tag.

patrickd’s picture

Issue tags: -PAreview: review bonus

Thanks for your participation, but I'm afraid the comments you did are not very detailed and IMHO not really "reviews".
A good deep review can take up to an hour, this is not about just pointing out 2 things and set the issues to needs work.

Sorry, removing tag.

patrickd’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue tags: +PAreview: review bonus

Added review bonus tag.

scot.hubbard’s picture

Status: Needs review » Needs work

I have changed this to need works as I have found a validation bug.

I am leaving the review bonus tag in place, but please do not review until the status is back to needs review.

Thanks!

scot.hubbard’s picture

Status: Needs work » Needs review

Field validation issues are now fixed. Status changed back to needs review.

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

Thanks for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no flaws).

manual review:

  1. google_map_field_help(): all user facing text must run through t() for translation.
  2. "* Implements hook_menu().": There should be only one space after the "*". Also elsewhere.
  3. google_map_field_menu(): please add a comment why the menu path is unprotected, so that I don't have the feeling that this is a security issue.
  4. "t('Invalid value - ') . $element['#title']": do not concatenate translatable strings, use placeholders in t() instead.
  5. google_map_field_filter_process(): put the JS in a separate file for easier maintenance and pass the settings to it.
  6. google_map_field_filter_process(): do not use jQuery(document).ready() but Drupal.behaviors, see http://drupal.org/node/304258 and http://drupal.org/node/756722 . Same for all your JS files.
  7. google_map_field_wysiwyg_include_directory(): that is a hook implementation and should be documented as such, see http://drupal.org/node/1354#hookimpl
  8. Javascript: please use the same documentation guidelines as for PHP, i.e. please document every function.
  9. google_map_field_format_field(): this is not a hook?
  10. Your module is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as map name I get a nasty javascript popup. Please read http://drupal.org/writing-secure-code and all subpages, especially http://drupal.org/node/28984

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

scot.hubbard’s picture

Status: Needs work » Needs review

Hi Klausi,

Many thanks for the deep review - your comments and provided links have help me out enormously.

All issues should now be fixed and the project is ready for review again.

With regard to point 3, I thought it didn't really matter if users could access this page as it didn't really do anything. However, on reflection, it is only needed by people who can edit content so I have applied the 'access administration pages' permission to the path.

Some of the points your discovered are silly things that should never have been there, but sometimes you get so close to something you can't see the big picture!

Thanks again, and I shall continue with my reviews of other projects...

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Marked preview PAReview project links as done.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Added review bonus tag.

klausi’s picture

Issue tags: +PAreview: security

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

scot.hubbard’s picture

My apologies - it was not done intentionally.

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  1. google_map_field_field_is_empty(): doc block is wrong.
  2. "t('Invalid value - :title', array(':title' => $element['#title']))": The ":" is not a valid placeholder character for t().
  3. google_map_field_edit_form.js: not entirely sure, but I think you should prefix the functions with your module name to avoid name collisions.

But otherwise this looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

scot.hubbard’s picture

Hi klausi,

Many thanks for your review, I have fixed all the issues highlighted.

Will work on further reviews now.

Thanks again.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue summary: View changes

Added project review link.

scot.hubbard’s picture

Issue tags: +PAreview: review bonus

Added review bonus tag.

patrickd’s picture

Status: Reviewed & tested by the community » Fixed

Your project page could still be enhanced by making it a little more structured you may have a look at the tips for a great project page.

You should make the label translatable:
'label' => 'Google Map Field',

FYI, this has probably no effect.

'instance_settings' => array(
'cardinality' => 1,
),

to make your function naming consistent may should rename google_map_field_default to google_map_field_formatter

'default_widget' => 'google_map_field_widget',
'default_formatter' => 'google_map_field_default',

Maybe not a bad idea to make "http://maps.googleapis.com/maps/api/js?sensor=false" configurable ?

After all I don't think here's anything serious.

Thanks for your contribution and welcome to the community of project contributors on drupal.org!

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.

Thanks to the dedicated reviewer(s) as well.

scot.hubbard’s picture

Many thanks to patrickd, Klausi and all the reviewers.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added project review link.