<?php

require_once 'HTML/TagCloud.php';

// ein User Agent muss gesetzt werden, damit Digg uns die Daten sendet
ini_set("user_agent""www.webholics.de");
// lese die Daten als XML von der Digg Api
$xml file_get_contents('http://services.digg.com/stories/popular?appkey=http%3A%2F%2Fwww.webholics.de&type=xml');
// Umwandlung in ein SimpleXMLElement-Objekt
$data = new SimpleXMLElement($xml);

$tags = new HTML_TagCloud(208);

foreach(
$data->story as $story) {
    
$tags->addElement($story->titlehtmlentities($story['link']), (int)$story['diggs'], (int)$story['submit_date']);
}

$html $tags->buildHTML();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />

        <meta name="author" content="Mario Volke" />

        <style type="text/css">

            body {
                margin:0;
                padding-top:10em;
            }

            h1 {
                width:50%;
                margin:0 auto;
                padding:0;
                color:#233b64;
            }

            div.tagcloud {
                width:50%;
                margin:0 auto;
                padding:1em;
                background-color:#2b5190;
                border:1em solid #233b64;
            }
            
            div.tagcloud a {
                text-decoration:none;
            }
            div.tagcloud a.earliest {
                color:#cccccc;
            }
            div.tagcloud a.earlier {
                color:#a9d3e2;
            }
            div.tagcloud a.later {
                color:#9ed6e0;
            }
            div.tagcloud a.latest {
                color:#00ecff;
            }
            div.tagcloud a.earliest:hover,
            div.tagcloud a.earlier:hover,
            div.tagcloud a.later:hover,
            div.tagcloud a.latest:hover {
                color:#ffdb3b;
                text-decoration:none;
            }
            div.tagcloud a.earliest:visited,
            div.tagcloud a.earlier:visited,
            div.tagcloud a.later:visited,
            div.tagcloud a.latest:visited {
                color:#ff86ff;
                text-decoration:none;
            }

        </style>

        <title>HTML_TagCloud example</title>
    </head>
    <body>

        <h1>Digg tag cloud</h1>
        <?php echo $html?>

    </body>
</html>