topical media & game development

talk show tell print

mashup-delicious-15-rally2007-index.php / php



  <?php
  //base tag feed url
  define('BASE_FEED_URL','http://del.icio.us/rss/YOURNAME/');
  
  //the default tag meant to identify all posts to the rally project
  define('DEFAULT_TAG',"rally2007");
  
  //your Yahoo Application ID
  define('YAHOO_APP_ID','YOURAPPLICATIONID');
  
  //bring in magpie
  require_once('lib/rss_fetch.inc');
  
  //set cache directory
  define('MAGPIE_CACHE_DIR', 'cache');
  
  //get rid of error Notices because magpie produces some
  error_reporting(E_ERROR | E_WARNING | E_PARSE);
  
  //determine if an additional tag needs to be a part of the RSS feed url
  if (isset(_GET['category']) && _GET['category'] != '')
      cluster_tag = "+"._GET['category'];
  else
      cluster_tag = '';
  
  feed_url = BASE_FEED_URL.DEFAULT_TAG.cluster_tag;
  rss = fetch_rss(feed_url);
  bookmarks = rss->items;
  
  //returns the tag list minus the default tag
  function get_category(tag_list)
  {
      //break the tag list into an array
      tags = explode(" ",tag_list);
      //return the first tag that isn't DEFAULT_TAG (if you allow multiple
      //tags you'll want to change this to return an array of remaining tags)
      foreach (tags as tag) {
          if (tag != DEFAULT_TAG) {
              return tag; 
              break;
          }
      }
  }
  
  //creates a link to show a map if geotag data exists
  function show_map_link(tag_list,title)
  {
      //break the tag list into an array
      tags = explode(" ",tag_list);
      //use regex to get the lat and lon values
      lat = '';
      lon = '';
      foreach (tags as tag) {
          if (preg_match('/^geo:lat=(.*)/i',tag,latmatch))
              lat = latmatch[1];
          if (preg_match('/^geo:lon=(.*)/i',tag,lonmatch))
              lon = lonmatch[1];
      }
      if (lat != '' && lon != '')
          echo "<a href=\"#\" onclick=\"javascript:show_map(lat,lon,'title')\">[ Show Map ]</a>";
  }
  ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>Rally 2007</title>
  <link rel="stylesheet" href="stylesheet.css" type="text/css" />
  <script type="text/javascript" 
  src="http://maps.yahooapis.com/v3.03/fl/javascript/apiloader.js?appid= echo YAHOO_APP_ID; ?>"> 
  </script>
  <script type="text/javascript">
  function show_map(lat,lon,title)
  {
      //create yahoo maps latlon object
      var latlon = new LatLon(lat, lon);
      //display map centered at zoom level 3
      var map = new Map("map", "<?php echo YAHOO_APP_ID; ?>", latlon, 3);
      //add a marker
      marker = new CustomPOIMarker('A',title);
      map.addMarkerByLatLon(marker,latlon);
      //this makes the map draggable
      map.addTool( new PanTool(), true );
      //show map_container
      document.getElementById('map_container').style.display = "block";
  }
  function hide_map()
  {
      //hide map_container
      document.getElementById('map_container').style.display = "none";
  }
  </script>
  </head>
  
  <body>
  
  <div id="map_container">
      <div id="map"></div>
      <a href="#" onclick="javascript:hide_map()">[ Hide Map ]</a>
  </div>
  
  <h1>Rally 2007</h1>
  <p>Here's the collected web references for the upcoming rally. You can use the "Category" dropdown to filter them by category.  Feel free to add a reference using the Firefox extension provided or the "Add a Bookmark" link. Please contact me if you have any questions.</p>
  
  <div class="category_form">
  <span style="float: right">
      <a href="manage_incoming.php">Manage Incoming Links</a>
      |
      <a href="#" onclick="javascript:window.open('save_popup.php', '', 'width=700,height=400,menubar=0,toolbar=0,scrollbars=1,location=0,status=1,resizable=1');">Add a Bookmark</a>
  </span>
  <form method="get">
      Category:
      <select name="category" onchange="this.form.submit()">
          <option>Filter by Category...</option>
          <option value="">All Bookmarks</option>
          <option>Vendors</option>
          <option>Restaurants</option>
          <option>Hotels</option>
          <option>Services</option>
          <option>Sponsor</option>
          <option>Other</option>
      </select>
      (Currently browsing <?php 
          if (isset(_GET['category']) && _GET['category'] != '') { 
              echo _GET['category']; 
          } else { 
              echo "all bookmarks"; } 
      ?>.)
  </form>
  </div>
  
  <div id="calendar">
  <iframe src="http://www.google.com/calendar/embed?src=12345abcdef%40group.calendar.google.com&chrome=NAVIGATION&mode=AGENDA&height=588" style=" border-width:0 " width="320" frameborder="0" height="588"></iframe>
  </div>
  
  <ul>
  <?php
  i = 0; //for tracking alternate row colors
  foreach(bookmarks as bookmark) {
      ?>
      <li<?php if (i % 2) { echo ' class="li_alternate"'; }?>>
      <a href="<?php echo bookmark['link']; ?>">
      <?php echo bookmark['title']; ?>
      </a>
      <div>
      <?php 
      if (isset(bookmark['description'])) { 
          echo bookmark['description']; 
      }
      ?>
      </div>
      <div class="other_metadata">
          <?php show_map_link(bookmark['dc']['subject'],bookmark['title']); ?>
      </div>
      <div class="category">
      Category:
      <?php
          //get the category for this link (the tag other than the default one)
          this_category = get_category(bookmark['dc']['subject']);
      ?>
      <a href="index.php?category=<?php echo this_category; ?>">
      <?php echo this_category ?>
      </a>
      </div>
      </li>
      <?php
      i++;
  }
  ?>
  </ul>
  
  </body>
  </html>
  


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