topical media & game development

talk show tell print

mashup-delicious-13-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");
  
  //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;
          }
      }
  }
  ?>
  <!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" />
  </head>
  
  <body>
  <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="#" 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>
  
  <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="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.