Locator

From e107 Wiki

Jump to: navigation, search

Contents

Locator

a plugin by nlstart.

Locator v1.2 has been released February 09, 2010.

Locator is an easy e107 plugin with map integration.

Purpose of the Locator plugin

  • GOAL: Create an easy way for e107 0.7.8 (or higher) to display locations and integrates with maps.

What is a location? It can be anything geographically. If you can specify it with a street name and zip code, you've got a location. Possible usage: store locator, dealer locator, collegues locator, friends locator, branch locator, office locator, retail locator.


This e107 plugin has been written with EasyShop users with multiple physical stores in mind. You can provide your visitors with a simple list of all your stores. You just type in the addresses, the locator plugin provides the link to a map automatically. Dependent on your own preference, you can choose from map providers Google Maps or Mapquest.

If you want to provide a specific URL per location, that is also possible!

Features

  • Supports Google Maps or Mapquest.
  • The menu Locations will only be visible if at least one active country AND one active category have been specified. At the locator settings (admin_locations.php) the locator title field can be filled in. This title will be displayed on the locator page that is shown to your visitors (locator.php).
  • Default sort order; you can define in 'Maintain locations' your own order. You can choose from the following order sortings: 'Your specified order', locator ID, zip code, client name, category ID or city. Also when presenting groups; they will be sorted according the sorting you have defined.
  • Print total header gives you control over the header; if this is 'Yes' a total number of all locations is printed on the locator page that is shown to your visitors (locator.php).
  • Paginate will give you control over the returned list of locations. If it is 'On' it will paginate your list, otherwise it will show you the whole list at once. When you have a lot of locations, it is advised to set the Paginate option 'On', otherwise your locations page might time out. This option is introduced in RC 4. Number of locations per page will only be applied if the previous setting Paginate is set to 'On'. You can choose from the following preset options: 5, 10, 15, 20, 25, 50, 75, 100. This option is introduced in RC 4.
  • With the Map Type you can control the type of link: choose between Google maps or Mapquest. In case you selected Mapquest you can also define the default Mapquest zoom factor. In case you leave the field empty or define an invalid value the default zoom factor of 9 will be used. Since RC2 it is possible to have a Google Map embedded on top of your Locator page. A Google Maps API key is required for displaying the embedded Google Map. You can download a free Google Maps API key.

The following settings of the embedded map can be self defined by using the admin configuration:

  • Show Map control (zoom/move/center) ; on/off
  • Map control type ; large/small
  • Show Map type choice (map/satellite/hybrid) ; on/off
  • Map type default ; map/satellite/hybrid
  • Map scale control ; on/off
  • Map width (in pixels, default: 500) ; any desired pixel size
  • Map height (in pixels, default: 500) ; any desired pixel size
  • Map side bar ; on/off (It's adviced to set it off when you have a long list of locations)
  • Show info window on click on location ; on/off
  • Display extra text line in info window; on/off
 This will trigger an extra field when maintaining locations, it will be shown in the info window of the location
  • Show map directions inside info window ; on/off
  • Show group on category; on/off
  • Show group on country; on/off
  • Show group on city; on/off
  • City group length (default value is complete city description if left blank)
 This option will group the city into a smaller group. E.g. length one will create a basic index from A till Z.
  • Show group on zip code; on/off
  • Zip code group length (default value is 1 if left blank)
 This option will group the zipcode in multiple groups. E.g. zipcode 1234 and 1235 will group to group '12' when 
 length is set to '2'and group on zip code is 'On'.
  • Grouping divide character (default value is '-' if left blank)
 This option enables you to set the group divide character. Paginate will also use this divide character.
  • Display group list only
 If a group is displayed, you can either show all locations or just the locations from the selected group. It's 
 strongly advised to set it on when you have a long list of locations.
  • Show tooltips; on/off
 Displays tooltips when hovering the mouse over a location in the map
  • Input coordinates (latitude, longitude); on/off
 When set to 'On' it is possible to give latitude and longitude into each location. If filled in, the position 
 on the Google map will be based on the given coordinates.
  • Suppress coordinates in info text
 When set to 'On' the coordinates will not be shown inside the info window.
  • Display opening hours in info window
 When set to 'On' the opening hours will be displayed in the info window of the embedded Google Map.
  • Location submission user class
 Defaults to 'No one (inactive)'. When set to another available user class the members of that user class will see 
 an extra link 'Submit new location' at the top right corner of the locator.php screen.
 When they submit a new location, the admin can view it under 'Approve locations' in the Locator menu. Also in the
 'Latest' menu section of the generic admin area (admin.php) a link will be displayed 'Submitted locations'.




What can the locator plugin do for you? Create any address list, the Locator plugin will automatically add a link to your map of choice: Google Maps or Mapquest.

You can sort the address list on ID (number of entering), your own indicated order, location name, zip code, or on category ID.

Examples of usage: client locator, store locator, offices locator, dealer locator, collegues locator, friends locator.

Latest version

version v1.2

Prerequisites

Before actually using Locator functionality on your website, you will need the following:

REQUIRED

  • e107 core v0.7.7 (or newer) installed.
  • When you want to embed a Google Map integrated on your Locator page on your site you need a Google Maps API key; getting a Google Maps API key is free and easy: http://maps.google.com/apis/maps/signup.html.

If you don't have an API key; no worries; a Locator link to the Google Maps website does not require a Google Map API key.

Support

Download: Locator download site

Forum: Locator forum

Bugs: Locator bugtracker

Requests: Locator requests

Installation

Important Release Candidate information

Release Candidates (recognizable on the abbreviation RC in the download name) are meant to be preliminary distributes before the actual release. Release Candidates of plugins - use at your own risk. All release candidates are tested on e107 v0.7.8 and v0.7.9. Possible new e107 features might be used and therefore this module might not function correctly on earlier versions, however for e107 0.7.7 this module is expected to run okay. It is strongly advised to test this module before implementing it on a live website.

Default install

  • a. Upload the Locator files into your 'e107_plugins' folder. Although 'Upload plugin' from the Admin section might work, uploading your files by using an FTP client program is recommended.
  • b. When working on Linux or Unix based server set the CHMOD settings of all .php files to 644.
  • c. Login as an administrator into e107, go to Plugin Manager, install Locator.
  • d. Check the Locator Countries, switch the flag(s) of the Countries you do not want to show to 'inactive'.
  • e. Create a new Locator Category, switch the flag of the Category to 'active', press the 'Save changes' button.
  • f. Create a new Locator Location, switch the flag of the Location to 'active', press the 'Save changes' button.
  • g. Currently there should be one location shown in your Locator link (URL in your browser ends on 'locator.php')

Updates

Normal e107 update procedure via Admin Area > Plugin Manager > Upgrade.

Known Bugs

Symptom: Parse error: syntax error, unexpected '}' in \www\yourdomain.tld\e107_plugins\locator\locator.php on line 228
Cause: On your host the PHP ini setting the short_open_tag is set to off with Locator 1.0 < RC 6
Solution: Change <? on line 1 of the locator.php into <?php or update to the latest version.
Fix: This fix is delivered since Locator 1.0 RC 6 (released January 8, 2008).

Important background information

The menu 'Locations' will only be visible if at least one active country AND one active category have been specified (admin_locations.php).

At the locator settings the locator title field can be filled in. This title will be displayed on the locator page that is shown to your visitors (locator.php).

Default sort order; you can define in 'Maintain locations' your own order. You can choose from the following order sortings: 'Your specified order', locator ID, zip code, client name, category ID or city. Print total header gives you control over the header; if this is 'Yes' a total number of all locations is printed on the locator page that is shown to your visitors (locator.php).

With the maptype you can control the type of link: choose between Google maps or Mapquest. In case you selected Mapquest you can also define the default Mapquest zoom factor. In case you leave the field empty or define an invalid value the default zoom factor of 9 will be used.

For groupings in general applies the fact that only groups will be shown that are actually used. E.g. if you have six active countries, but you only use two of them, only those two will be shown when grouping on country.


What countries is geocoding available in?

The Google Maps API Geocoder can currently geocode addresses in Austria, Australia, Belgium, Brazil, Canada, The Czech Republic, Denmark, Finland, France, Germany, Hong Kong, Hungary, India, Ireland, Italy, Japan, Luxembourg, The Netherlands, New Zealand, Norway, Poland, Portugal, Singapore, Spain, Sweden, Switzerland, Taiwan, The United Kingdom, and the United States. The accuracy of geocoded locations may vary per country.

Link for more info: http://code.google.com/support/bin/answer.py?answer=62668&topic=10946

RC4 must become somewhat faster; e107 caching is supported by default (even if caching setting in e107 is set off). It appeared that this sometimes accumulated into a lot of cache files; a fix has been supplied for this in release v1.0. New in RC4 are grouping possibilities: group on category, country, city and/or zip code. You can select any of the groups to be active or not. You can also create external links to directly apply a certain group. Example: if you have a category with id '1' (NOTE: not the category description!), you could link to 'locator.php?cat.1' (without the quotes). Furthermore, you can define the group dividing character yourself. Default would be e.g. group1 - group2 - group3.

  • Use locator.php?cat.n for linking to a category, where n is the category id. E.g. locator.php?cat.1, shows all active locations of category 1.
  • Use locator.php?cnt.n for linking to a country, where n is country id. E.g. locator.php?cnt.138, shows all active locations of The Netherlands.
  • Use locator.php?cty.n for linking to a (part of) city name, where n is the city name. E.g. locator.php?cty.London, shows all active locations in London. If the length of the setting is blank the whole city name is used to group. If the city name length is set to one, London will be displayed in locator.php?cty.L, together with all active locations of which citynames begin with an 'L'.
  • Use locator.php?zip.n for linking to a (part of) zip code. The length of the zip code parameter n must equal the settings (default = 1). E.g. locator.php?zip.8, shows all active locations where zip code starts with 8.

Also new is the setting Display group list only, which enables you to suppress the complete list. If Show tooltips is switched on, it displays the description of the location when hovering the mouse pointer over the location. Finally Input coordinates (latitude, longitude) will enable you to input latitude and longtitude at locations. If both the latitude and longitude are filled in, the external Google Map link behind the location, as well as the embedded Google Map will display the marker based on the coordinates you have put in. In all other cases, the location will be based on the address data. It is also possible to paginate, you can also define what the number of locations per page should be. Note: if all to be displayed locations fit on one page, the paging will be suppressed. The paginate setting will have effect on the admin tool for locations (admin_locations.php) and the location presentation for your visitors (locator.php). The pagination can be applied with or without groupings. E.g. use locator.php?p.3 to link to page 3, but use locator.php.cat.3.2 to go to page 2 of category list 3.

Locator v1.0 has a bugfix on the caching; instead of unique cache file per user there is only one cache file per location created. It also contains an automatic upgrade of the database to store opening times per location, and a class based category. The class based category allows you to hide or show certain categories. In previous versions, the setting of an active category was not relevant; now only active categories are shown and the user must belong to a user class that is entitled to view the category. After installing v1.0 by overwriting all files of a previous Locator RCx; go to the Plugin Manager, find the Locator plugin, press Upgrade and you're done. The setting "Suppress column 'Order online'" is introduced; even if field URL1 is filled in; it won't be shown in the location list. There is a new setting 'Location submission user class'; set default to 'No one (inactive)'. By setting this class you determine which user class is allowed to enter new locations. For users who are member of the class a new link 'Submit new location' will be presented at the right top of the locator.php page. Submitted locations must be approved by the administrator of the site.

Troubleshooting

In case you use Mapquest as your map type; please leave the country codes intact. They are important in finding the right location on the map.

In case you use Google as your map type; please leave the country descriptions intact. They are important in finding the right location on the map.

Including the Google Map on your page can seriously slow down the page load if you have a lot of locations. From a user perspective, there is not so much to be done about it... The plugin however has been provided of (automatically) working with cache memory for the map; also there is a paginate option and various group options. The best is to combine a limited pagination and small groups. This will lead to the best results when dealing with a large list of locations. Also you are adviced to change the default link into one of your groups, e.g. locator.php?cat.1 so that the first retrieval of locations will be directly only the locations from the first category.

The embedded Google Map shows up, but it only displays a grey box. If you only see a grey map, you might have to enable "third-party cookies" in your browser, or at least enable cookies coming from "maps.google.com".

Another reason for not showing the embedded Google map: Somehow on your server the GoogleMap API cannot define the latitude and longitude numbers. In other words: the function getCache to get the geocode lat/lon points from the e107 cache for a given address is not working. This might indicate you have insufficient rights to write in the folder http://yourdomain.tld/e107_files/cache. Try to see what the current CHMOD rights of your cache folder are and try to change the CHMOD to 777 for the cache folder.

Another readon for not showing the embedded Google map: Your host could be preventing 'include' commands: Try fixing it by adding this to your .htaccess file in the root of your e107 installation:

on PHP4:

php_flag "allow_url_fopen" "On"

on PHP5:

php_flag "allow_url_fopen" "On"
php_flag "allow_url_include" "On"


Changelog

Version 1.2 (released February 9, 2010):

* Sub-goals for release 1.2:
  - bugfix release
* Bugs Fixed:
  - locator.php: various security improvements
  - locator.php: unicode characters in city names
  - locator.php: using 'your specified order' went wrong above 10
  - admin_locations.php: using 'your specified order' went wrong above 10
  - admin_locations.php: when working with pages changing active locations on a page whiped out the status of other pages
* Minor Changes:
  - plugin.php: added US to country list at installation
* Known issues:
  - bugtracker #30: When in the map a location is opened; and the from or to field is filled with an address, the button to show the directions does not work. This problem is related to the theme used or it's CSS. Cause still unknown.
  - country 'US' United States of America is not included in the country list when upgrading from 1.1 or below. It can be added via 'Maintain Countries'.

Version 1.1 (released 03 September 2008):

* Sub-goals for release 1.1:
  - bugfix release
* New/Added Features:
  - none
* Altered Features:
  - admin_locations.php?approve: more interlinear spacing and use button style for cancel as well; thanks kroll
  - admin_openhrs.php: use button style for cancel as well; thanks kroll
* Bugs Fixed:
  - admin_categories: removed hardcoded language field 'CLASS' from line 241; thanks kroll
  - locator_submit.php: include language file to display javascript pop-up alert properly; thanks kroll
* Minor Changes:
  - admin_categories.php, admin_locations.php: centered the 'Actions' header
  - admin_openhrs.php: added break line before presenting the table (line 183); thanks kroll
  - plugin.php: adjusted for upgrade from 1.0 or older
* Known bugs:
  - bugtracker #30 (see changelist 1.0).

Version 1.0 (released 01 September 2008):

* Sub-goals for release 1.0:
  - launch a new e107 compliant plugin
  - make plugin language independent
  - initial version
  - introduce embedded Google Maps in Locator (RC 2)
* New/Added Features:
  - GoogleMapAPI2.5.class: added Google Map API 2.5 with modifications to use in e107 (RC 2)
  - build in possibilities to configure 'Show Google Map' (only available when Google Maps is selected) (RC 2)
  - locator.php: bugtracker #24: group functionality for Google Map API on category (RC4)
  - locator.php: bugtracker #24: group functionality for Google Map API on country (RC4)
  - locator.php: bugtracker #24: group functionality for Google Map API on city (RC4)
  - locator.php: bugtracker #24: group functionality for Google Map API on (part of) zip code (RC4)
  - locator.php: bugtracker #24: introduced display of groups only if setting is 'Yes' (RC4)
  - locator.php: introduced proper use of tooltip functionality (RC4)
  - locator.php: bugtracker #31: introduced use of looking up coordinates (Latitude, Longitude) (RC4)
  - locator.php: bugtracker #33: introduced display extra text line in info window if setting is 'Yes' (RC4)
  - locator.php: introduced pagination for large amounts of locations (RC4)
  - locator.php: show opening hours info is setting is activated (1.0)
  - locator.php: added class category functionality (1.0)
  - locator.php: bugtracker #32: added link to submit new locations for appropriate user class from Locator configuration (1.0)
  - locator_submit.php: bugtracker #32: new program for optional user submission of locations (1.0)
  - e_latest.php: bugtracker #32: new program that shows the new user submitted locations in the main admin Latest part (1.0)
  - admin_categories.php: added class category  functionality (1.0)
  - admin_categories.php: added cancel button in edit screen (1.0)
  - admin_categories_edit.php: added class category functionality (1.0)
  - admin_config.php: bugtracker #24: setting to switch group on category on/off (RC4)
  - admin_config.php: bugtracker #24: setting to switch group on country on/off (RC4)
  - admin_config.php: bugtracker #24: setting to switch group on city on/off (RC4)
  - admin_config.php: bugtracker #24: setting to determine length of city grouping (default is whole city name) (RC4)
  - admin_config.php: bugtracker #24: setting to switch group on zipcode on/off (RC4)
  - admin_config.php: bugtracker #24: setting to determine length of zipcode grouping (default = 1) (RC4)
  - admin_config.php: bugtracker #24: setting to determine divide character between groups (default = -) (RC4)
  - admin_config.php: bugtracker #24: setting to display group list only (RC4)
  - admin_config.php: setting to determine showing tooltips when hovering over locations (RC4)
  - admin_config.php: bugtracker #31: setting to display coordinates (RC4)
  - admin_config.php: bugtracker #33: setting to display extra text line in info window (RC4)
  - admin_config.php: setting to switch pagination on/off (RC4)
  - admin_config.php: setting to set number of locations per page (RC4)
  - admin_config.php: sorting method on city (RC4)
  - admin_config.php: new setting to 'suppress input coordindates in info window' (RC6)
  - admin_config.php: new setting to 'Suppress column "Order online"' (1.0)
  - admin_config.php: new setting to 'Display opening hours in info window ' (1.0)
  - admin_config.php: new setting 'Location submission user class' to define user class that is allowed to add new locations (1.0)
  - admin_locations.php: bugtracker #31: introduced fields for latitude and longitude if setting for coordinates is Yes (RC4)
  - admin_locations.php: introduced pagination for large amounts of locations (RC4)
  - admin_locations_edit.php: returns after editing to the page where it came from (RC6)
  - admin_openhrs.php: new program to maintain opening hours of locations (1.0)
  - e_search.php: introduced integrated e107 search (1.0)
* Altered Features:
  - GoogleMapAPI.2.5.class: adjusted for e107 caching (RC4); thanks bugrain
  - admin_categories: bugtracker #27: adjusted new and edit category form with active checkbox (RC4)
  - admin_categories_edit: bugtracker #27: adjusted new and edit locator category database saving with active checkbox (RC4)
  - admin_countries: bugtracker #27: adjusted new and edit country form with active checkbox (RC4)
  - admin_countries_edit: bugtracker #27: adjusted new and edit locator country database saving with active checkbox (RC4)
  - admin_locations: bugtracker #27: adjusted new and edit location form with active checkbox (RC4)
  - admin_locations_edit: bugtracker #27: adjusted new and edit locator location database saving with active checkbox (RC4)
* Bugs Fixed:
  - GoogleMapAPI2.5.class: fixed bug for setting GLatLngBounds in local formatting (RC3)
  - GoogleMapAPI2.5.class: fixed bug for displaying tooltips properly (RC4)
  - GoogleMapAPI2.5.class: bugfix for displaying within e107 table rendering (RC6)
  - GoogleMapAPI.2.5.class: bugfix for exploding e107 caching (1.0); thanks bugrain/steved
  - admin_categories_edit: bugtracker #26: changed way storing interval intval($tp->toDB($_POST['locator_test_integer'])) (RC4)
  - admin_config: bugtracker #25: changed Google Map API field from size 125 to size 50 (for small resolution screens) (RC4)
  - admin_locations: bugtracker #29: changed sorting order for add locations form (RC4)
  - in all programs: fixed language file retrieval method (RC4)
  - locator.php: in case city if not filled in the description of the sidebar equals the location name (RC4)
  - locator.php: bugfix on pagination without groups (RC5)
  - locator.php: bugfix on short open tag <? changed into <?php (see: http://nl2.php.net/manual/en/ini.core.php) (RC6)
  - locator.php: bugfix when users are putting HTML or BBcode in the fields 'Location' or 'Additional info window text' (RC6)
  - locator.php: bugfix for displaying Google Map within e107 table rendering (RC6)
  - locator.php: bugfixes for when showing groups: only the active records are selected (RC6)
  - locator.php: bugfixes for column span of groups underneath Google map (RC7)
  - locator.php: bugfixes for displaying correct divide character for pagination (RC7)
  - locator.php: bugfix on line 233 to add a break (thanks to kroll) (1.0)
* Minor Changes:
  - locator_sql.php: deleted specification DEFAULT CHARSET=latin1 ; it caused in at least one instance install problems (RC4)
  - locator_sql.php: added shop opening hours fields to table locator_sites (1.0)
  - plugin.php: made language independent (RC4)
  - plugin.php: update for additional opening hours fields to table locator_sites (1.0)
  - plugin.php: update for category class to table locator_cat (1.0)
  - Dutch.php: replaced special characters in Dutch language file with correct HTML (RC7)
  - logo files logo_16.png and logo_32.png replaced (1.0)
* Known bugs:
  - bugtracker #30: When in the map a location is opened; and the from or to field is filled with an address, the button to show the
    directions does not work. This problem is related to the theme used or it's CSS. Cause still unknown.


Future roadmap

  • actually monitor the buglist
  • monitor what features end users want
  • publish more languages support files that are handed over by the community

Technical aspects

Directory Structure

After a straight installation of Locator the directory structure in the e107_plugins folder should be as follows:

 e107_plugins
     |- Locator
             |- images
             |- includes
             |- languages
  • The images folder contains the images 'logo_16.png' and 'logo_32.png' which are called by plugin.php. It also contains image 'google_maps.png' that is called by locator.php.
  • The includes folder contains file config.php in which all database file names of the plugin are defined
  • The languages folder contains default language file English.php with all terms used by all modules of this plugin

Plugin Modules

The plugin consists of different files forming one integrated module. Each .php file contains a standard set of instructions to run properly under e107. The plugin files are heavily commented in order to show starting plugin developers why certain things are done.

admin_categories.php

Task is to maintain Locator categories. Each category can be flagged as active or inactive (default for newly added categories). At least one category must be flagged as active in order to view the Maintain locations menu.

admin_categories_edit.php

Task is to maintain Locator categories. This module handles all table updates (add, modify, delete) regarding the Locator Categories.

admin_config.php

Task is to maintain Locator main settings. The settings are written in the e107 Preference table.

admin_countries.php

Task is to maintain Locator countries. Each country can be flagged as active or inactive (default for newly added countries). At least one country must be flagged as active in order to view the Maintain locations menu. Also a sort order can be given in. In admin_locations.php the requested sort order is applied. Default sort order is on category ID. The plugin.php installs all possible Mapquest countries as active by default.

admin_countries_edit.php

Task is to maintain Locator countries. This module handles all table updates (add, modify, delete) regarding the Locator Countries.

admin_locations.php

Task is to maintain Locator locations. Locations can be anything geographically, e.g. a shop can be a location. The menu will become visible if there is at least one active country AND one active category. Each location can be flagged as active or inactive (default for newly added locations). Only active locations will be shown in the locator.php. The application also takes care about viewing new submitted locations to approve or reject.

admin_locations_edit.php

Task is to maintain Locator locations. This module handles all table updates (add, modify, delete) regarding the Locator Locations. The module also inserts new locations when the administator approves a user submitted location.

admin_menu.php

Task is to show the administator menu.

admin_openhrs.php

Task is to maintain opening hours of existing locations.

admin_readme.php

Task is to show the readme.txt from the menu.

e_latest.php

Task is to display newly submitted locations by users in the admin menu.

e_search.php

Task is to lookup locations with default e107 search functionality.

GoogleMapAPI.2.5.class.php

Task is to show the Google Map embedded in the Locator page. It is an adjusted version of GoogleMapAPI version 2.5.

help.php

Task is to display help text on the left side column of the administrator menu.

locator.php

The main plugin. It displays all adresses of the locations, and a link to a map where to find it (through Google Maps or Mapquest). If the order online status is set to 'Yes' AND a URL is specified, also a link per location is provided. This can be handy for directing visitors to your online shop like EasyShop.

locator_sql.php

This is a helpfile used by plugin.php with all table definitions of the Locator plugin.

locator_submit.php

This program will be called from locator.php when user is in the user class that is allowed to submit new locations.

plugin.php

General set-up file of e107 plugin to tell e107 Plugin Manager where files reside, which logo to use, etc. Also it pre-fills the country table with all Mapquest country codes.

readme.txt

Not really a module but called by admin_readme.php to display all relevant plugin background info, installation instructions etc.

License

Locator is distributed as free open source code released under the terms and conditions of the GNU General Public License.

Personal tools