Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make collection query page size configurable #51

Open
wants to merge 3 commits into
base: 7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ Admin settings are available at `admin/islandora/tools/islandora_simple_map`:

Enabling the **Google Maps Javascript API** opens configuration for:

![islandora_simple_map_admin1](https://user-images.githubusercontent.com/2857697/38567430-d202110c-3cab-11e8-8aa3-aee56a2cf48d.jpg)

* Your API key (required).
* Disabling mouse wheel from causing map zoom.
* Disable the map embed in the page. Useful if using the map block.
* Enable [collection level maps](#collection-maps).

It also displays **all** coordinates found, the Embed API only displays the first.

Common configuration options are:

![islandora_simple_map_admin3](https://user-images.githubusercontent.com/2857697/38567445-d9e92e0a-3cab-11e8-905a-7f9437f9e86b.jpg)

* A delimiter to split multiple coordinates on.
* the XPath expressions to the MODS elements where your map data is stored
* the map's height, width, default zoom level, and whether or not the map is collapsed or expanded by default, and
Expand All @@ -52,10 +57,24 @@ Common configuration options are:

Once you enable the module, any object whose MODS file contains coordinates in the expected element will have a Google map appended to its display.

If you have checked the "Enable collection level maps?" option, you can then enable a map for each collection within the collection's Manage subtabs.
### Collection maps
You can enable a map for each collection by checking the "Enable collection level maps?" option, you can then enable a map for a collection within the collection's Manage -> Collection sub-tab.

You can see all collections you have enabled collection maps on from the Admin -> Islandora -> Islandora Utility Modules
-> Islandora Simple Map -> Collections with Maps tab.

Collection maps retrieve all the objects for a collection via "paging" queries. (ie. grab 0-20, then 21-40, etc).
You can change the number of results per query with the "Collection page size" setting.


### Solr integration

There is also the __Coordinates Solr field__ option if you index your object's coordinates. If you fill this in, then a
Solr query will be done to retrieve the collections coordinates instead of parsing each collection member's MODS record.
![islandora_simple_map_admin2](https://user-images.githubusercontent.com/2857697/38567440-d6934be6-3cab-11e8-9f9c-a2d11dfa8414.jpg)

To use Solr to return the coordinates instead of parsing the MODS records you can check the "Use Solr for object map queries" checkbox.
This will reveal an autocomplete field to enter the Solr field containing your object's coordinates.

This affects **both** individual maps and collection map generation.

### Extract from MODS using XPath

Expand Down Expand Up @@ -127,10 +146,9 @@ The XPath expressions used to retrieve map data are executed in the order they a

`hook_islandora_simple_map_get_coordinates(AbstractObject $object)`

Implementations of this hook should return an array of decimal coordinates.
These are merged with all other implementations.
If you are using the Javascript API, they are then validated/filtered to ensure they are decimal coordinates.
Lastly (using either API) they are de-duplicated to determine the points to show on the map.
Implementations of this hook should return an array of coordinates.
These are merged with all other implementations and passed off to be parsed by implementations
of the below hook.

`hook_islandora_simple_map_parse_coordinates_callback()`

Expand All @@ -149,7 +167,12 @@ Where
* `function_name` is a function that accepts an array of coordinates of various formats and returns an associative
array of coordinates that it could parse where the key is the original value and value is the parsed value.
* `file` is the file to include to access this function. (Optional)
* `weight` is to order the hooks. Default is 100. (Optional)
* `weight` is to order the hooks. Default is 100. (Optional)

If you are using the Javascript API, the parsed coordinates are then validated/filtered to ensure they are decimal coordinates.

Lastly (using either API) they are de-duplicated to determine the points to show on the map for an object.

## Maintainer

* [Mark Jordan](https://github.com/mjordan)
Expand Down
23 changes: 17 additions & 6 deletions includes/admin_form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,28 @@ function islandora_simple_map_admin_settings() {
'#default_value' => variable_get('islandora_simple_map_collection_maps', FALSE),
'#return_value' => TRUE,
),
'islandora_simple_map_collection_maps_cache' => array(
'#type' => 'checkbox',
'#title' => t('Enable collection map cache for anonymous users.'),
'#description' => t('This will cache the marker points for a collection map to speed up the map loading. This is only enabled for anonymous users to avoid issues in caching privileged objects.'),
'#default_value' => variable_get('islandora_simple_map_collection_maps_cache', FALSE),
'#return_value' => TRUE,
'islandora_simple_map_collection_wrapper' => array(
'#type' => 'container',
'#states' => array(
'visible' => array(
':input[name="islandora_simple_map_collection_maps"]' => array('checked' => TRUE),
),
),
'islandora_simple_map_collection_maps_cache' => array(
'#type' => 'checkbox',
'#title' => t('Enable collection map cache for anonymous users.'),
'#description' => t('This will cache the marker points for a collection map to speed up the map loading. This is only enabled for anonymous users to avoid issues in caching privileged objects.'),
'#default_value' => variable_get('islandora_simple_map_collection_maps_cache', FALSE),
'#return_value' => TRUE,
),
'islandora_simple_map_collection_pagesize' => array(
'#type' => 'textfield',
'#title' => t("Collection page size"),
'#description' => t("Queries performed to get all the coordinates from a collection in chunks of this size. You can adjust it to grab more or less items per query if that helps performance. Defaults to 20"),
'#size' => 25,
'#element_validate' => array('element_validate_integer_positive'),
'#default_value' => variable_get('islandora_simple_map_collection_pagesize', 20),
),
),
);
$form['islandora_simple_map_solr_fieldset'] = array(
Expand Down
4 changes: 2 additions & 2 deletions includes/utilities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function _islandora_simple_map_get_collection_points(AbstractObject $object) {
function _islandora_simple_map_get_collection_points_load(AbstractObject $object) {
$points = array();
$page_num = -1;
$page_size = 20;
$page_size = (int) variable_get('islandora_simple_map_collection_pagesize', 20);
$count = NULL;
$members = array();
do {
Expand Down Expand Up @@ -384,7 +384,7 @@ function _islandora_simple_map_get_collection_points_solr(AbstractObject $object
$member_field = variable_get('islandora_solr_member_of_collection_field', 'RELS_EXT_isMemberOfCollection_uri_ms');
$coord_field = variable_get('islandora_simple_map_coordinate_solr_field', '');
$page_num = -1;
$page_size = 20;
$page_size = (int) variable_get('islandora_simple_map_collection_pagesize', 20);
$count = NULL;
$members = array();
$solr_build = new IslandoraSolrQueryProcessor();
Expand Down
1 change: 1 addition & 0 deletions islandora_simple_map.install
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function islandora_simple_map_uninstall() {
'islandora_simple_map_use_solr',
'islandora_simple_map_collection_maps',
'islandora_simple_map_collection_maps_cache',
'islandora_simple_map_collection_pagesize',
);
array_walk($variables, 'variable_del');
}
Expand Down