Skip to content

Commit 4bb7059

Browse files
authored
Merge pull request #161 from 7tonin/master
new function to better feed get_image_ids_for_tags when pages got multiple tags
2 parents f627d7e + 22f3b00 commit 4bb7059

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

include/functions_map.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function osm_get_gps($page)
6666
}
6767
if ($page['section'] === 'tags' and isset($page['tags']) and isset($page['tags'][0]['id']) )
6868
{
69-
$items = get_image_ids_for_tags( array($page['tags'][0]['id']) );
69+
$items = get_image_ids_for_tags( array_reduce( $page['tags'], 'osm_get_page_tag_id' ) );
7070
if ( !empty($items) )
7171
{
7272
$LIMIT_SEARCH = "ic.image_id IN (".implode(',', $items).") AND ";
@@ -111,7 +111,7 @@ function osm_get_items($page)
111111
}
112112
if ($page['section'] === 'tags' and isset($page['tags']) and isset($page['tags'][0]['id']) )
113113
{
114-
$items = get_image_ids_for_tags( array($page['tags'][0]['id']) );
114+
$items = get_image_ids_for_tags( array_reduce( $page['tags'], 'osm_get_page_tag_id' ) );
115115
if ( !empty($items) )
116116
{
117117
$LIMIT_SEARCH = "ic.image_id IN (".implode(',', $items).") AND ";
@@ -605,4 +605,18 @@ function osm_bounds_from_url($str)
605605
return $b;
606606
}
607607

608+
/**
609+
* What is the id of this page tag ?
610+
*
611+
* Note : this function is called to grab every tags in a page
612+
*
613+
* @param array basket to collect id
614+
* @param array page tag
615+
* @return basket
616+
*/
617+
function osm_get_page_tag_id($basket, $page_tag) {
618+
$basket[] = $page_tag['id'];
619+
return $basket;
620+
}
621+
608622
?>

0 commit comments

Comments
 (0)