topical media & game development

talk show tell print

mashup-delicious-15-rally2007-manage-incoming.php / php



  <?php
  //base tag feed url
  define('BASE_TAG_FEED_URL','http://del.icio.us/rss/YOURNAME/');
  
  //the default tag meant to identify all posts to the rally project
  define('DEFAULT_TAG',"rally2007");
  
  //private feed url
  define('PRIVATE_FEED_URL','http://del.icio.us/rss/for/YOURNAME?private=HASH');
  
  //bring in magpie
  require_once('lib/rss_fetch.inc');
  
  //set cache directory
  define('MAGPIE_CACHE_DIR', 'cache');
  
  //fetch the "links for you" feed
  rss = fetch_rss(PRIVATE_FEED_URL);
  incoming_bookmarks = rss->items;
  
  //also fetch all of the existing bookmarks
  rss2 = fetch_rss(BASE_TAG_FEED_URL.DEFAULT_TAG);
  existing_bookmark_items = rss2->items;
  //give the existing_bookmarks array each URL in existing_bookmarks_feed
  //to be checked against the incoming bookmarks later
  existing_bookmarks = array();
  foreach(existing_bookmark_items as existing_bookmark)
      existing_bookmarks[] = existing_bookmark['link'];
  ?>
  
  <!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"/>
  <link rel="stylesheet" href="stylesheet.css" type="text/css" />
  <title>Rally 2007 - Incoming Links</title>
  </head>
  
  <body>
  
  <h1>Rally 2007 - Incoming Links</h1>
  
  <p>This page contains links suggested by people outside the project team. To save the link to the main database, click the "Save to Project" link. Outsiders can send links to this page by posting bookmarks to <a href="http://del.icio.us/">del.icio.us</a> and tagging them with for:YOURNAME.</p>
  
  <div class="category_form">
      <a href=<index.php>>&laquo; Back to the Project Homepage</a>
  </div>
  
  <ul>
  <?php
  i = 0; //for tracking alternate row colors
  foreach(incoming_bookmarks as bookmark) {
      //if the incoming_bookmark's URL does not exist in existing_bookmarks
      //then display it
      if (!in_array(bookmark['link'], existing_bookmarks))
      {
          ?>
          <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 style="text-align: right">
          <a href="#" onclick="javascript:window.open('save_popup.php?
              location=<?php echo urlencode(bookmark['link']); ?>
              &title=<?php echo urlencode(bookmark['title']); ?>', '', 
               'width=700,height=400,menubar=0,toolbar=0,scrollbars=1,
              location=0,status=1,resizable=1');">Save to Project</a>
          </div>
          </li>
          <?php
          i++;
      }
  }
  //if there were no links, say so
  if (i == 0)
      echo "<li>There are no new incoming links at this time.</li>";
  ?>
  </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.