first import
This commit is contained in:
12
sites/all/modules/locationmap/INSTALL.txt
Normal file
12
sites/all/modules/locationmap/INSTALL.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Location Map module
|
||||
|
||||
**Installation:
|
||||
1. Unpack the Location Map folder and contents in the modules directory of your Drupal installation (usually /sites/all/modules).
|
||||
2. Enable the Location Map module in the administration tools (http://www.example.com/admin/build/modules).
|
||||
3. If you're not using Drupal's default administrative account, make sure your user account has the "Administer location map" permission (http://example.com/admin/user/permissions).
|
||||
4. Set your location in the Location Map settings page (http://www.example.com/admin/settings/locationmap).
|
||||
5. If you wish to use the block provided that links to your Location Map page, navigate to the Block administration section and enable the block, assigning it to the desired region (http://www.example.com/admin/build/block).
|
||||
|
||||
Visit http://www.example.com/locationmap to see the map and fine tune your position. [Note: Fine tuning is not yet working in the initial Drupal 7 version.] If you wish to have this page appear at a different URL, set a URL alias at http://www.example.com/admin/config/search/path
|
||||
|
||||
Finally, add the block "Location Map static image block" to some region of the website if you wish.
|
339
sites/all/modules/locationmap/LICENSE.txt
Normal file
339
sites/all/modules/locationmap/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
17
sites/all/modules/locationmap/README.txt
Normal file
17
sites/all/modules/locationmap/README.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
Location Map module (http://drupal.org/project/locationmap)
|
||||
|
||||
** Description:
|
||||
The Location Map module displays a single geographic location for a website via Google Maps. It has following features:
|
||||
|
||||
* Creates a single Google Maps page (at http://yoursite.com/locationmap), designed to display one location for the site, with an address marker.
|
||||
* The map location is automatically geocoded from a street address.
|
||||
* Anyone with "Administer location map" permissions can drag the marker to further fine-tune its position if geocoding did not place the marker exactly where you wish it to be.
|
||||
* Creates a block with a static image of the centre of the map, which links to the location map page on your site.
|
||||
|
||||
Location map module is simple by design and will remain that way. It creates only a single map for a site. It is not designed to attach locations to nodes, users, or other content. If you wish any of these more extensive features, see the GMap project (http://drupal.org/project/gmap) which is significantly more powerful and is designed to do all of these things.
|
||||
|
||||
(Location map is the successor of the Drupal 5.x-6.x module "gmaplocation". The name of the module was changed to reduce confusion with the submodule of the gmap project called gmap_location. On installing Location Map, map configuration data stored by any previous version of gmaplocation, as well as role permissions and any URL aliases to the map page are automatically updated.)
|
||||
|
||||
** Credits:
|
||||
Duncan Babbage (http://wavelength.org.nz), maintainer since the 6.x version of gmaplocation.
|
||||
Bojan Mihelac (http://source.mihelac.org), original developer of gmaplocation module.
|
17
sites/all/modules/locationmap/locationmap.info
Normal file
17
sites/all/modules/locationmap/locationmap.info
Normal file
@@ -0,0 +1,17 @@
|
||||
name = Location Map
|
||||
description = Display one geographical location via Google Maps.
|
||||
core = 7.x
|
||||
|
||||
files[] = locationmap.install
|
||||
files[] = locationmap.module
|
||||
files[] = potx-cli.php
|
||||
files[] = potx.inc
|
||||
files[] = tests/locationmap.test
|
||||
|
||||
configure = admin/config/locationmap
|
||||
; Information added by drupal.org packaging script on 2012-03-21
|
||||
version = "7.x-2.1"
|
||||
core = "7.x"
|
||||
project = "locationmap"
|
||||
datestamp = "1332365750"
|
||||
|
121
sites/all/modules/locationmap/locationmap.install
Normal file
121
sites/all/modules/locationmap/locationmap.install
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the locationmap module.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rename 5.x-1.0 permission "admin gmaplocation", 6.x-1.0 permission
|
||||
* "edit gmaplocation", and 6.x-2.0 permission "administer gmaplocation"
|
||||
* to "Administer location map".
|
||||
*/
|
||||
function locationmap_update_104() {
|
||||
// Location map module is the Drupal 7 successor to gmaplocation module.
|
||||
// If role permissions exist from gmaplocation, these are updated for Location map.
|
||||
// Set up the $replace array which holds strings both the old and new permissions.
|
||||
$replace = array(
|
||||
'admin gmaplocation' => 'administer locationmap',
|
||||
'edit gmaplocation' => 'administer locationmap',
|
||||
'administer gmaplocation' => 'administer locationmap'
|
||||
);
|
||||
|
||||
// Loop over all the changes, performing necessary updates.
|
||||
foreach ($replace as $old_permission => $new_permission) {
|
||||
db_update('role_permission')
|
||||
->fields(array('permission' => $new_permission, 'module' => 'locationmap'))
|
||||
->condition('rid', 3, '<>')
|
||||
->condition('permission', $old_permission)
|
||||
->execute();
|
||||
}
|
||||
|
||||
// Update any URL aliases previously set for gmaplocation to point to locationmap.
|
||||
db_update('url_alias')
|
||||
->fields(array('source' => 'locationmap'))
|
||||
->condition('source', 'gmaplocation')
|
||||
->execute();
|
||||
|
||||
// Create locationmap variables. If gmaplocation variables exist, set to those values.
|
||||
variable_set('locationmap_address', variable_get('gmaplocation_address'));
|
||||
variable_set('locationmap_block_text_top', variable_get('gmaplocation_block_text_top'));
|
||||
variable_set('locationmap_body', variable_get('gmaplocation_body'));
|
||||
variable_set('locationmap_footer', variable_get('gmaplocation_footer'));
|
||||
variable_set('locationmap_height', variable_get('gmaplocation_height'));
|
||||
variable_set('locationmap_info', variable_get('gmaplocation_info'));
|
||||
variable_set('locationmap_key', variable_get('gmaplocation_key'));
|
||||
variable_set('locationmap_lat', variable_get('gmaplocation_lat'));
|
||||
variable_set('locationmap_lng', variable_get('gmaplocation_lng'));
|
||||
variable_set('locationmap_title', variable_get('gmaplocation_title'));
|
||||
variable_set('locationmap_type', variable_get('gmaplocation_type'));
|
||||
variable_set('locationmap_width', variable_get('gmaplocation_width'));
|
||||
variable_set('locationmap_zoom', variable_get('gmaplocation_zoom'));
|
||||
|
||||
// Remove redundant gmaplocation variables.
|
||||
variable_del('gmaplocation_address');
|
||||
variable_del('gmaplocation_block_text_top');
|
||||
variable_del('gmaplocation_body');
|
||||
variable_del('gmaplocation_footer');
|
||||
variable_del('gmaplocation_height');
|
||||
variable_del('gmaplocation_info');
|
||||
variable_del('gmaplocation_key');
|
||||
variable_del('gmaplocation_lat');
|
||||
variable_del('gmaplocation_lng');
|
||||
variable_del('gmaplocation_title');
|
||||
variable_del('gmaplocation_type');
|
||||
variable_del('gmaplocation_width');
|
||||
variable_del('gmaplocation_zoom');
|
||||
|
||||
// hook_update_N() no longer returns a $ret array. Instead, return
|
||||
// nothing or a translated string indicating the update ran successfully.
|
||||
// See http://drupal.org/node/224333#update_sql.
|
||||
return t('Upgraded any legacy permissions and variables from gmaplocation module to locationmap.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change maps API v2 variables to v3 values.
|
||||
* Unset the API key var, as it's not required any more.
|
||||
*/
|
||||
|
||||
function locationmap_update_105() {
|
||||
|
||||
$locationmap_type = variable_get('locationmap_type', '');
|
||||
|
||||
// Only do anything if this is set
|
||||
if ($locationmap_type) {
|
||||
|
||||
// Maps old values to new values:
|
||||
$locationmap_type_new = array(
|
||||
'G_NORMAL_MAP' => 'google.maps.MapTypeId.ROADMAP',
|
||||
'G_SATELLITE_MAP' => 'google.maps.MapTypeId.SATELLITE',
|
||||
'G_HYBRID_MAP' => 'google.maps.MapTypeId.HYBRID',
|
||||
);
|
||||
|
||||
// Only reset this if it's a value we can translate:
|
||||
if (isset($locationmap_type_new[$locationmap_type])) {
|
||||
variable_set('locationmap_type', $locationmap_type_new[$locationmap_type]);
|
||||
}
|
||||
}
|
||||
|
||||
// We don't need this any more
|
||||
variable_del('locationmap_key');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function locationmap_uninstall() {
|
||||
variable_del('locationmap_address');
|
||||
variable_del('locationmap_block_text_top');
|
||||
variable_del('locationmap_body');
|
||||
variable_del('locationmap_footer');
|
||||
variable_del('locationmap_height');
|
||||
variable_del('locationmap_info');
|
||||
variable_del('locationmap_key');
|
||||
variable_del('locationmap_lat');
|
||||
variable_del('locationmap_lng');
|
||||
variable_del('locationmap_title');
|
||||
variable_del('locationmap_type');
|
||||
variable_del('locationmap_width');
|
||||
variable_del('locationmap_zoom');
|
||||
}
|
45
sites/all/modules/locationmap/locationmap.js
Normal file
45
sites/all/modules/locationmap/locationmap.js
Normal file
@@ -0,0 +1,45 @@
|
||||
(function($){
|
||||
Drupal.behaviors.locationmap = {
|
||||
attach: function(context, settings) {
|
||||
var target_point = new google.maps.LatLng(Drupal.settings.locationmap.lat, Drupal.settings.locationmap.lng);
|
||||
|
||||
var mapOptions = {
|
||||
zoom: parseInt(Drupal.settings.locationmap.zoom),
|
||||
center: target_point,
|
||||
mapTypeId: eval(Drupal.settings.locationmap.type),
|
||||
mapTypeControl: true
|
||||
};
|
||||
|
||||
var map = new google.maps.Map(document.getElementById("locationmap_map"), mapOptions);
|
||||
|
||||
var markerOptions = {
|
||||
position: target_point,
|
||||
draggable: Drupal.settings.locationmap.admin,
|
||||
map: map
|
||||
};
|
||||
|
||||
var marker = new google.maps.Marker(markerOptions);
|
||||
|
||||
var infowindow = new google.maps.InfoWindow({
|
||||
content: Drupal.settings.locationmap.info
|
||||
});
|
||||
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
infowindow.open(map, marker);
|
||||
});
|
||||
|
||||
// Allow fine tuning of the marker position in admin mode.
|
||||
if (Drupal.settings.locationmap.admin) {
|
||||
|
||||
google.maps.event.addListener(marker, 'dragend', function(event) {
|
||||
$('#edit-locationmap-lat').val(event.latLng.lat());
|
||||
$('#edit-locationmap-lng').val(event.latLng.lng());
|
||||
});
|
||||
|
||||
google.maps.event.addListener(map, 'zoom_changed', function(event) {
|
||||
$('#edit-locationmap-zoom').val(map.getZoom());
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
458
sites/all/modules/locationmap/locationmap.module
Normal file
458
sites/all/modules/locationmap/locationmap.module
Normal file
@@ -0,0 +1,458 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function locationmap_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/help#locationmap':
|
||||
$output = '<p>' . t('The Location Map module displays a map of your geographic location with Google Maps.') . ' ' .
|
||||
l(t('The page for the map'), 'locationmap') . ' ' . t('is automatically generated.') . ' ' .
|
||||
t('A block is also created that displays a thumbnail of the map, linking to the map page.') . ' ' .
|
||||
t('This can be assigned to a page region on the') . ' ' . l(t('block administration page'), 'admin/structure/block') . '.</p>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function locationmap_menu() {
|
||||
$items = array();
|
||||
$items['admin/config/locationmap'] = array(
|
||||
'title' => 'Google Maps location',
|
||||
'description' => 'Configure Location Map.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('locationmap_admin_settings'),
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('administer locationmap'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
$items['locationmap'] = array('title' => 'Our Location',
|
||||
'access callback' => TRUE,
|
||||
'page callback' => 'locationmap_page',
|
||||
'type' => MENU_SUGGESTED_ITEM,
|
||||
);
|
||||
$items['locationmap/view'] = array(
|
||||
'title' => 'View',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'weight' => -10
|
||||
);
|
||||
$items['locationmap/edit'] = array(
|
||||
'title' => 'Edit',
|
||||
'description' => 'Configure Location Map.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('locationmap_admin_settings'),
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('administer locationmap'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for admin settings page
|
||||
*/
|
||||
function locationmap_admin_settings($form, &$form_state) {
|
||||
|
||||
drupal_add_js(drupal_get_path('module', 'locationmap') . '/locationmap_admin.js');
|
||||
|
||||
$form['info'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Location information'),
|
||||
'#collapsible' => FALSE,
|
||||
);
|
||||
|
||||
$form['info']['locationmap_title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Title'),
|
||||
'#default_value' => variable_get('locationmap_title', t('Our Location')),
|
||||
'#description' => t("The title of the automatically generated ") . l(t('map page'), 'locationmap') . '.',
|
||||
);
|
||||
|
||||
$form['info']['locationmap_address'] = array('#type' => 'textfield',
|
||||
'#required' => TRUE,
|
||||
'#title' => t('Address of your location'),
|
||||
'#default_value' => variable_get('locationmap_address', ''),
|
||||
'#description' => t('Enter your address separated by commas. This will be sent to Google for geocoding to determine the geographical coordinates of your location. Include any suitable from: # Street, Suburb, City, Region/State, Postcode/Zip, Country.'),
|
||||
);
|
||||
|
||||
$form['info']['locationmap_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Map type'),
|
||||
'#default_value' => variable_get('locationmap_type', 'google.maps.MapTypeId.ROADMAP'),
|
||||
'#description' => NULL,
|
||||
'#options' => array(
|
||||
'google.maps.MapTypeId.ROADMAP' => 'the default view',
|
||||
'google.maps.MapTypeId.SATELLITE' => 'showing Google Earth satellite images',
|
||||
'google.maps.MapTypeId.HYBRID' => 'showing a mixture of normal and satellite views',
|
||||
'google.maps.MapTypeId.TERRAIN' => 'showing a physical map based on terrain information',
|
||||
),
|
||||
);
|
||||
|
||||
$zoom_levels = array('0' => t('0 - minimum zoom level, whole world'));
|
||||
for ($i = 1; $i < 17; $i++) {
|
||||
$zoom_levels["$i"] = "$i";
|
||||
}
|
||||
$zoom_levels['17'] = t('17 - maximum zoom level');
|
||||
|
||||
$form['info']['locationmap_zoom'] = array('#type' => 'select',
|
||||
'#title' => t('Map zoom level'),
|
||||
'#default_value' => variable_get('locationmap_zoom', '15'),
|
||||
'#description' => NULL,
|
||||
'#options' => $zoom_levels,
|
||||
);
|
||||
|
||||
$form['info']['locationmap_width'] = array('#type' => 'textfield',
|
||||
'#title' => t('Map Width'),
|
||||
'#default_value' => variable_get('locationmap_width', '500'),
|
||||
'#field_suffix' => 'px',
|
||||
'#description' => NULL,
|
||||
'#size' => 10,
|
||||
);
|
||||
|
||||
$form['info']['locationmap_height'] = array('#type' => 'textfield',
|
||||
'#title' => t('Map Height'),
|
||||
'#default_value' => variable_get('locationmap_height', '500'),
|
||||
'#field_suffix' => 'px',
|
||||
'#description' => NULL,
|
||||
'#size' => 10,
|
||||
);
|
||||
|
||||
$form['info']['latlng'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Geographical coordinates'),
|
||||
'#collapsible' => FALSE,
|
||||
'#description' => t('Geographical coordinates for your location. Location map will try to obtain this information from Google using the address above. You are also able to fine-tune this by dragging the marker on the' . ' ' . l(t('map page'), 'locationmap') . '. Under normal circumstances you would not set these coordinates manually.'),
|
||||
);
|
||||
|
||||
$form['info']['latlng']['locationmap_lat'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Latitude'),
|
||||
'#default_value' => variable_get('locationmap_lat', '-46.0868686'),
|
||||
);
|
||||
|
||||
$form['info']['latlng']['locationmap_lng'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Longitude'),
|
||||
'#default_value' => variable_get('locationmap_lng', '166.6822074'),
|
||||
);
|
||||
|
||||
$form['info']['locationmap_info'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Marker Information'),
|
||||
'#default_value' => variable_get('locationmap_info'),
|
||||
'#description' => t('The description that will be shown when a user clicks on the marker. If this field is empty, the address will be used.'),
|
||||
);
|
||||
|
||||
$form['info']['locationmap_body'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Additional information (displayed above map)'),
|
||||
'#required' => FALSE,
|
||||
'#default_value' => variable_get('locationmap_body'),
|
||||
'#description' => t('Any additional information that you would like to include above the map.'),
|
||||
);
|
||||
|
||||
$form['info']['locationmap_footer'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Additional information (displayed below map)'),
|
||||
'#required' => FALSE,
|
||||
'#default_value' => variable_get('locationmap_footer'),
|
||||
'#description' => t('Any additional information you would like to include below the map.'),
|
||||
);
|
||||
|
||||
$form['#validate'][] = 'locationmap_admin_settings_validate';
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Please document this function.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function locationmap_admin_settings_validate($form, &$form_state) {
|
||||
if ($form_state['values']['locationmap_address']) {
|
||||
if ($form_state['values']['locationmap_address'] == variable_get('locationmap_address', '')) {
|
||||
drupal_set_message('Address has not changed. In order to preserve any location marker fine-tuning, coordinates have not been updated.', 'status');
|
||||
return;
|
||||
}
|
||||
$latlng = locationmap_geocode_for_address_recursive($form_state['values']['locationmap_address']);
|
||||
if ($latlng != FALSE) {
|
||||
list($lat, $lng) = $latlng;
|
||||
$form_state['values']['locationmap_lat'] = $lat;
|
||||
$form_state['values']['locationmap_lng'] = $lng;
|
||||
}
|
||||
else {
|
||||
switch ($form_state['values']['locationmap_lat']) {
|
||||
// If Geocoding fails and there are no previous coordinates, set to the default: Round Island in New Zealand's Fiordland National Park.
|
||||
case '':
|
||||
$form_state['values']['locationmap_lat'] = '-46.0868686';
|
||||
$form_state['values']['locationmap_lng'] = '166.6822074';
|
||||
drupal_set_message('Unable to Geocode address provided. As no previous coordinates were recorded, default values have been inserted. Try slightly modifying the address and resubmit, e.g. giving more or less detail, such as leaving out the suburb or state.', 'warning');
|
||||
break;
|
||||
// If Geocoding fails and there are previous coordinates, set to those coordinates.
|
||||
default:
|
||||
$form_state['values']['locationmap_lat'] = variable_get('locationmap_lat', '-46.0868686');
|
||||
$form_state['values']['locationmap_lng'] = variable_get('locationmap_lng', '166.6822074');
|
||||
drupal_set_message('Unable to Geocode address provided—previous coordinates will be used. Try slightly modifying the address and resubmit, e.g. giving more detail, or leaving out the suburb or state.', 'warning');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function locationmap_permission() {
|
||||
return array(
|
||||
'administer locationmap' => array(
|
||||
'title' => t('administer locationmap'),
|
||||
'description' => t('Modify the address and change settings for the location map.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback; generate a page with Google Maps.
|
||||
*/
|
||||
function locationmap_page() {
|
||||
$locationmap_title = variable_get('locationmap_title', t('Our Location'));
|
||||
$locationmap_body = variable_get('locationmap_body');
|
||||
$locationmap_footer = variable_get('locationmap_footer');
|
||||
$path = drupal_get_path('module', 'locationmap');
|
||||
drupal_add_js('http://maps.google.com/maps/api/js?v=3&sensor=false', array('type' => 'external', 'weight' => 5));
|
||||
drupal_add_js($path . '/locationmap.js', array('type' => 'file', 'weight' => 6, 'scope' => 'footer'));
|
||||
$locationmap_settings = array(
|
||||
'address' => variable_get('locationmap_address', 'Fiordland, New Zealand'),
|
||||
'info' => variable_get('locationmap_info', 'Fiordland, New Zealand'),
|
||||
'lat' => variable_get('locationmap_lat', '-46.0868686'),
|
||||
'lng' => variable_get('locationmap_lng', '166.6822074'),
|
||||
'zoom' => variable_get('locationmap_zoom', 10),
|
||||
'type' => variable_get('locationmap_type', 'google.maps.MapTypeId.ROADMAP'),
|
||||
'admin' => user_access('administer locationmap'),
|
||||
);
|
||||
if (!$locationmap_settings['info']) {
|
||||
$locationmap_settings['info'] = $locationmap_settings['address'];
|
||||
}
|
||||
drupal_add_js(array('locationmap' => $locationmap_settings), 'setting');
|
||||
$output = '<div id="locationmap_body">' . $locationmap_body . '</div>';
|
||||
$output .= theme('locationmap_map');
|
||||
$output .= '<div id="locationmap_footer">' . $locationmap_footer . '</div>';
|
||||
if (user_access('administer locationmap')) {
|
||||
// TODO: Remove drupal_render and update to D7 desired behaviour. See http://drupal.org/update/modules/6/7#unrendered
|
||||
$form = drupal_get_form('locationmap_in_place_edit_form');
|
||||
$output .= drupal_render($form);
|
||||
}
|
||||
drupal_set_title($locationmap_title);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns latitude and longitude for $address or NULL if it cannot be found.
|
||||
* @returns FALSE if address not found
|
||||
*/
|
||||
function locationmap_geocode_for_address($address) {
|
||||
|
||||
$address = urlencode($address);
|
||||
$url = "http://maps.google.com/maps/geo?q=$address&output=csv";
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'max_redirects' => 10,
|
||||
'timeout' => 120,
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
$page = @file_get_contents( $url, false, $context );
|
||||
if (!$page) {
|
||||
return(FALSE);
|
||||
}
|
||||
$matches = explode(',', $page);
|
||||
if (!($matches[0] == '200')) {
|
||||
return(FALSE);
|
||||
}
|
||||
return (array($matches[2], $matches[3]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to get lat and lng information from address removing parts of address if not found.
|
||||
*/
|
||||
function locationmap_geocode_for_address_recursive($address) {
|
||||
while (TRUE) {
|
||||
$latlng = locationmap_geocode_for_address($address);
|
||||
if ($latlng) {
|
||||
return($latlng);
|
||||
}
|
||||
if (strpos($address, ',') === FALSE) {
|
||||
return (FALSE);
|
||||
}
|
||||
$address = preg_replace('/[^,]+,/', '', $address, 1);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Please document this function.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function locationmap_in_place_edit_form($form, &$form_state) {
|
||||
$form['#submit'][] = 'system_settings_form_submit';
|
||||
$form['description'] = array(
|
||||
'#prefix' => '<p>',
|
||||
'#markup' => t('Click and drag marker to fine tune position of your location. Set zoom level below.'),
|
||||
'#suffix' => '</p>',
|
||||
);
|
||||
$form['locationmap_lat'] = array('#type' => 'textfield',
|
||||
'#title' => t('Latitude'),
|
||||
'#default_value' => variable_get('locationmap_lat', ''),
|
||||
);
|
||||
$form['locationmap_lng'] = array('#type' => 'textfield',
|
||||
'#title' => t('Longitude'),
|
||||
'#default_value' => variable_get('locationmap_lng', ''),
|
||||
);
|
||||
$form['locationmap_zoom'] = array('#type' => 'textfield',
|
||||
'#title' => t('Zoom level'),
|
||||
'#default_value' => variable_get('locationmap_zoom', ''),
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save new location and zoom level'),
|
||||
);
|
||||
return($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_simpletest().
|
||||
*/
|
||||
function locationmap_simpletest() {
|
||||
// Scan through mymodule/tests directory for any .test files to tell SimpleTest module.
|
||||
$tests = file_scan_directory(drupal_get_path('module', 'locationmap') . '/tests', '/\.test/');
|
||||
return array_keys($tests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
function locationmap_block_info() {
|
||||
$blocks['image']['info'] = t('Location Map static image block');
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_configure().
|
||||
*/
|
||||
function locationmap_block_configure($delta) {
|
||||
$form = array();
|
||||
switch ($delta) {
|
||||
case 'image':
|
||||
$form['info']['locationmap_block_mapwidth'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Block map width'),
|
||||
'#description' => t('Provide the width of the block map in pixels'),
|
||||
'#default_value' => variable_get('locationmap_block_mapwidth', '160'),
|
||||
'#field_suffix' => 'px',
|
||||
'#description' => NULL,
|
||||
'#size' => 10,
|
||||
);
|
||||
$form['info']['locationmap_block_mapheight'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Block map height'),
|
||||
'#description' => t('Provide the height of the block map in pixels'),
|
||||
'#default_value' => variable_get('locationmap_block_mapheight', '120'),
|
||||
'#field_suffix' => 'px',
|
||||
'#description' => NULL,
|
||||
'#size' => 10,
|
||||
);
|
||||
$form['info']['locationmap_text_top'] = array(
|
||||
'#type' => 'text_format',
|
||||
'#title' => t('Additional text to show above the image'),
|
||||
'#default_value' => variable_get('locationmap_block_text_top'),
|
||||
'#format' => isset($edit['format']) ? $edit['format'] : NULL,
|
||||
);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_save().
|
||||
*/
|
||||
function locationmap_block_save($delta, $edit) {
|
||||
switch ($delta) {
|
||||
case 'image':
|
||||
variable_set('locationmap_block_mapheight', (int)$edit['locationmap_block_mapheight']);
|
||||
variable_set('locationmap_block_mapwidth', (int)$edit['locationmap_block_mapwidth']);
|
||||
variable_set('locationmap_block_text_top', $edit['locationmap_text_top']['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function locationmap_block_view($delta) {
|
||||
switch ($delta) {
|
||||
case 'image':
|
||||
$texttop = variable_get('locationmap_block_text_top');
|
||||
$blocktop = ($texttop) ? '<div id="locationmap-block-text-top">' . $texttop . '</div>' : '';
|
||||
$block = locationmap_block_image();
|
||||
$block['content'] = $blocktop . $block['content'];
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Please document this function.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function locationmap_static_image_url($w = 200, $h = 150) {
|
||||
$image_url = 'http://maps.googleapis.com/maps/api/staticmap?zoom=' . variable_get('locationmap_zoom', 5);
|
||||
$image_url .= "&size={$w}x{$h}";
|
||||
$image_url .= '&markers=' . variable_get('locationmap_lat', 0) . ',' . variable_get('locationmap_lng', 0);
|
||||
$image_url .= "&sensor=false";
|
||||
return($image_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Please document this function.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function locationmap_block_image() {
|
||||
$block = array();
|
||||
$block['subject'] = variable_get('locationmap_title', t('Our Location'));
|
||||
$block['content'] = theme('locationmap_block_image_link');
|
||||
return($block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format static image for display in the block.
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_locationmap_block_image_link() {
|
||||
$mapwidth = variable_get('locationmap_block_mapwidth', 160);
|
||||
$mapheight = variable_get('locationmap_block_mapheight', 120);
|
||||
return(l('<img src="' . locationmap_static_image_url($mapwidth, $mapheight) . '" alt="Location map" />', 'locationmap', array('html' => TRUE)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format div for display Google Maps in it.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_locationmap_map() {
|
||||
$width = variable_get('locationmap_width', '500') . 'px';
|
||||
$height = variable_get('locationmap_height', '500') . 'px';
|
||||
return ('<div id="locationmap_map" style="width: ' . $width . '; height: ' . $height . '"></div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function locationmap_theme() {
|
||||
return array(
|
||||
'locationmap_block_image_link' => array(),
|
||||
'locationmap_map' => array(),
|
||||
);
|
||||
}
|
8
sites/all/modules/locationmap/locationmap_admin.js
Normal file
8
sites/all/modules/locationmap/locationmap_admin.js
Normal file
@@ -0,0 +1,8 @@
|
||||
(function($){
|
||||
// DISABLED: When address changes, remove previous latitude and longitude.
|
||||
// TODO: Dynamically look up new coordinates when address changes.
|
||||
$("#edit-locationmap-address").bind('change', function() {
|
||||
// $('#edit-locationmap-lat').val("");
|
||||
// $('#edit-locationmap-lng').val("");
|
||||
});
|
||||
})(jQuery);
|
32
sites/all/modules/locationmap/tests/locationmap.test
Normal file
32
sites/all/modules/locationmap/tests/locationmap.test
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class locationmapTest extends DrupalTestCase {
|
||||
|
||||
function get_info() {
|
||||
return array(
|
||||
'name' => 'locationmap',
|
||||
'desc' => t('locationmap unit tests.'),
|
||||
'group' => 'locationmap',
|
||||
);
|
||||
}
|
||||
|
||||
function test_locationmap_geocode_for_address() {
|
||||
$result = locationmap_geocode_for_address("1600 Amphitheatre Parkway, Mountain View, CA");
|
||||
$expected = array("37.421972", "-122.084143");
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
function test_locationmap_geocode_for_address_not_found() {
|
||||
$this->assertEqual(FALSE, locationmap_geocode_for_address("abcdefgh123"));
|
||||
}
|
||||
|
||||
function test_locationmap_geocode_for_address_recursive() {
|
||||
$result = locationmap_geocode_for_address_recursive("NonExistentAddress 123, NonExistingCity, Croatia");
|
||||
$expected = array("44.466244", "16.461248");
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = locationmap_geocode_for_address_recursive("NonExistentAddress 123, Pula, Croatia");
|
||||
$expected = array("44.869652", "13.841147");
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user