1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| function osm_get_items($page)
{
// Limit search by category, by tag, by smartalbum
$LIMIT_SEARCH="";
$INNER_JOIN="";
if (isset($page['section']))
{
if ($page['section'] === 'categories' and isset($page['category']) and isset($page['category']['id']) )
{
$LIMIT_SEARCH = "FIND_IN_SET(".$page['category']['id'].", c.uppercats) AND ";
$INNER_JOIN = "INNER JOIN ".CATEGORIES_TABLE." AS c ON ic.category_id = c.id";
}
if ($page['section'] === 'tags' and isset($page['tags']) and isset($page['tags'][0]['id']) )
{
$items = get_image_ids_for_tags( array_reduce( $page['tags'], 'osm_get_page_tag_id' ) );
if ( !empty($items) )
{
$LIMIT_SEARCH = "ic.image_id IN (".implode(',', $items).") AND ";
}
}
if ($page['section'] === 'tags' and isset($page['category']) and isset($page['category']['id']) )
{
$LIMIT_SEARCH = "FIND_IN_SET(".$page['category']['id'].", c.uppercats) AND ";
$INNER_JOIN = "INNER JOIN ".CATEGORIES_TABLE." AS c ON ic.category_id = c.id";
}
}
$forbidden = get_sql_condition_FandF(
array
(
'forbidden_categories' => 'ic.category_id',
'visible_categories' => 'ic.category_id',
'visible_images' => 'i.id'
),
"\n AND"
); |