Archive for February, 2005

SimpleTest 1.0!

Posted 2/26/2005 By Jason

Marcus Baker has released SimpleTest version 1.0! Download the files here and view the API documentation here. Congratulations Marcus, this is a fine work and an outstanding contribution to the PHP community.

For anyone who has not caught testing fever, try it out. There has been no other programming practice which has positively affected my programming practices the way unit testing and test driven development have.

I alluded to my in progress book in an earlier post. Each of the examples in the book was developed with unit testing coverage using SimpleTest, and all of these tests will be available in the source code download for the book. I hope the book shows good coding practices as well as demonstrating design patterns in PHP.

Added My Del.icio.us Bookmarks

Posted 2/12/2005 By Jason

I added my recent del.icio.us bookmarks to this blog under the calendar in the side bar. I googled for the basic plugin, and tweaked it a bit to suit how I wanted to use it.

The plugin looks like:

<?php

/*
Plugin Name: del.icio.us
Plugin URI: http://del.icio.us/
Description: Fetches your <a href="http://del.icio.us/">del.icio.us</a> bookmarks list using the standard HTML method.
Provides one function, delicious().
Author: Phil Ulrich
Author URI: http://interalia.org/
*/
function delicious($username='sweatje', $count=10, $extended="Bookmarks",
 $divclass="link", $aclass="storytitle", $tags="yes", $tagclass="meta", 
 $tagsep="/", $tagsepclass="delTagSep", $bullet="raquo",
 $rssbutton="yes", $extendeddiv="no", $extendedclass="")
{
    $cache = 'cache/del.icio.us';
    if (file_exists($cache)
        && false !== ($mtime = filemtime($cache) )
        && (mktime() - $mtime) < 3600) {
        echo file_get_contents($cache);
        return;
    }
    $queryString = "http://del.icio.us/html/";
    $queryString .= "$username/";
    $queryString .= "?count=$count";
    $queryString .= "&extended=$extended";
    $queryString .= "&divclass=$divclass";
    $queryString .= "&aclass=$aclass";
    $queryString .= "&tags=$tags";
    $queryString .= "&tagclass=$tagclass";
    $queryString .= "&tagsep=$tagsep";
    $queryString .= "&tagsepclass=$tagsepclass";
    $queryString .= "&bullet=$bullet";
    $queryString .= "&rssbutton=$rssbutton";
    $queryString .= "&extendeddiv=$extendeddiv";
    $queryString .= "&extendedclass=$extendedclass";

    $html = implode(' ', file($queryString));
    $data = str_replace(array('<div class="link">',''),array('<li>','</li>'),$html);
    // php5 only file_put_contents($cache, $data);
    $fh = fopen($cache, 'w');
    fwrite($fh, $data);
    fclose($fh);
    echo $data;
}
</>
?>

Update: Per the comment from Darren, I added caching. I was on me “TODO” list, but you know how those go 😉