Create an map which can display one GPX file and/or Images from a piwigo category
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.5KB

  1. <?php // Prepare list of photos
  2. header('Content-type: text/javascript');
  3. define('PHPWG_ROOT_PATH','./');
  4. include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
  5. if(isset($_GET['catID'])) $catID = $_GET['catID'];
  6. else $catID = 0;
  7. $LIMIT_SEARCH = "FIND_IN_SET(".$catID.", c.uppercats) AND ";
  8. $INNER_JOIN = "INNER JOIN ".CATEGORIES_TABLE." AS c ON ic.category_id = c.id";
  9. $forbidden = get_sql_condition_FandF(
  10. array
  11. (
  12. 'forbidden_categories' => 'ic.category_id',
  13. 'visible_categories' => 'ic.category_id',
  14. 'visible_images' => 'i.id'
  15. ),
  16. "\n AND"
  17. );
  18. $query="SELECT i.latitude, i.longitude,
  19. IFNULL(i.name, '') AS `name`,
  20. IF(i.representative_ext IS NULL,
  21. CONCAT(SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', 1 ), '-sq.', SUBSTRING_INDEX(TRIM(LEADING '.' FROM i.path), '.', -1 )),
  22. TRIM(LEADING '.' FROM
  23. REPLACE(i.path, TRIM(TRAILING '.' FROM SUBSTRING_INDEX(i.path, '/', -1 )),
  24. CONCAT('pwg_representative/',
  25. CONCAT(
  26. TRIM(TRAILING '.' FROM SUBSTRING_INDEX( SUBSTRING_INDEX(i.path, '/', -1 ) , '.', 1 )),
  27. CONCAT('-sq.', i.representative_ext)
  28. )
  29. )
  30. )
  31. )
  32. ) AS `pathurl`,
  33. TRIM(TRAILING '/' FROM CONCAT( i.id, '/category/', IFNULL(i.storage_category_id, '') ) ) AS `imgurl`,
  34. IFNULL(i.comment, '') AS `comment`,
  35. IFNULL(i.author, '') AS `author`,
  36. i.width
  37. FROM ".IMAGES_TABLE." AS i
  38. INNER JOIN (".IMAGE_CATEGORY_TABLE." AS ic ".$INNER_JOIN.") ON i.id = ic.image_id
  39. WHERE ".$LIMIT_SEARCH." i.latitude IS NOT NULL AND i.longitude IS NOT NULL ".$forbidden." GROUP BY i.id;";
  40. $php_data = array_from_query($query);
  41. //print_r($php_data);
  42. $js_data = array();
  43. foreach($php_data as $array)
  44. {
  45. // MySQL did all the job
  46. //print_r($array);
  47. $js_data[] = array((double)$array['latitude'],
  48. (double)$array['longitude'],
  49. $array['name'],
  50. get_absolute_root_url() ."i.php?".$array['pathurl'],
  51. get_absolute_root_url() ."picture.php?/".$array['imgurl'],
  52. get_absolute_root_url() ."i.php?".str_replace('sq','xs',$array['pathurl']),
  53. $array['comment'],
  54. $array['author'],
  55. (int)$array['width']
  56. );
  57. }
  58. $js = $_GET['callback'].'('.str_replace("\/","/",json_encode($js_data)).')';
  59. echo $js;
  60. ?>