topical media & game development

talk show tell print

mashup-flickr-07-Step-3-gallery-info.php / php



  <?php
  
  include (dirname(__FILE__) . '/../lib/gallery.php');
  
  function decodeHTML(text)
  {
    s = str_replace("&lt;", "<", text);
    s = str_replace("&gt;", ">", s);
    s = str_replace("&quot;", "\"", s);
    s = str_replace("&amp;", "&", s);
  
    return s;
  }
  
  function formatDateTaken(d)
  {
    // This is of the form YYYY-MM-DD HH:mm:SS
  
    format = 'j F Y';
    formattedDate = date(format, strtotime(d));
    return formattedDate;
  }
  
  function formatDatePosted(d)
  {
    // This is a unix timestamp
  
    format = 'j F Y';
    formattedDate = date(format, d);
    return formattedDate;
  }
  
  gallery = new FlickrGallery();        
  id = _REQUEST['id'];
  if (!empty(id))
  {
    info = gallery->getPhotoInfo(id);
    description = nl2br(decodeHTML(info['description']));
    tags = info['tags']['tag'];
  
  ?>
  <div class="photo-more"><a href="#" onclick="hideInfo(<?php echo id ?>); return false;">Hide info</a></div>
  <div class="photo-info">
    <div class="photo-description"><?php echo description ?></div>
    <ul class="photo-tags">
  <?php
    if (!empty(tags))
    {
      foreach (tags as tag)
      {
  ?>
      <li><?php echo tag['raw'] ?></li>
  <?php 
      }
    }
  ?>
    </ul>
    <div class="photo-date-taken">Taken on: <?php echo formatDateTaken(info['dates']['taken']) ?></div>
    <div class="photo-date-posted">Posted on: <?php echo formatDatePosted(info['dates']['posted']) ?></div>
    <div class="photo-edit-link"><a href="edit.php?id=<?php echo id 
  ?>">Edit</a></div>
  </div>
  <?php
  }
  ?>
  


(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.