topical media & game development

talk show tell print

mashup-flickr-13-Complete-gallery-geo.php / php



  <?php
  
  include (dirname(__FILE__) . '/../lib/gallery.php');
  
  function sortPhotosByTitle(a, b)
  {
    return strcasecmp(a['title'], b['title']);
  }
  
  gallery = new FlickrGallery();    
  swlat = _REQUEST['swlat'];
  swlng = _REQUEST['swlng'];
  nelat = _REQUEST['nelat'];
  nelng = _REQUEST['nelng'];
  
  bbox = NULL;
  
  if (!empty(swlat) && !empty(swlng) && !empty(nelat) && !empty(nelng))
  {
    bbox = "swlng, swlat, nelng, nelat";
  }
  
  photos = gallery->getWithGeoData(bbox);
  
  if (is_array(photos))
  {
    usort(photos, "sortPhotosByTitle");
  }
  
  header ("Content-Type: text/xml");
  
  echo "<?xml version=\"1.0\"?>\n";
  echo "<photos>\n";
  
  if (is_array(photos))
  {
    foreach (photos as p)
    {
      echo "<photo " .
        "id=\"" . p['id'] . "\" " .
        "latitude=\"" . p['latitude'] . "\" " .
        "longitude=\"" . p['longitude'] . "\" " .
        "title=\"" . htmlspecialchars(p['title']) . "\" " .
        " />\n";
    }
  }
  
  echo "</photos>";
  
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.