<?php
//$abnormal: when the flash and js can not support ,we can also use the links to access
//$abnormal format: '<a href="http://www.abc.com">abc</a>';
// $mytags: use to put in the sphere
// $mytags format:'<a href='http://www.baidu.com' style='font-size: 24.12pt;'>abc24</a> '
function tag_cloud($abnormal, $mytags)
{
$soname = 'so_' . rand(0,999999);
$moviename = 'mo_' . rand(0, 999999) ;
$mytags = urlencode('<tags>') . urlencode($mytags) . urlencode('</tags>');
$flashtag = '';
$flashtag .= '<div id="wp-cumulus" class="block">';
//remember to change the src
$flashtag .= '<script type="text/javascript" src="http://localhost/test/js/swfobject.js"></script>';
$flashtag .= '<div id = "tagcannotdis">';
$flashtag .= $abnarmal;
$flashtag .= '</div>';
$flashtag .= '<script type="text/javascript">';
// remember to change the url
$flashtag .= 'var ' . $soname .' = new SWFObject("http://localhost/test/js/tagcloud.swf?r=' . $moviename . '", "tagcloudflash", "800", "800", "9", "#ffffff");';
$flashtag .= $soname . '.addParam("wmode", "transparent");';
$flashtag .= $soname . '.addParam("allowScriptAccess", "always");';
$flashtag .= $soname . '.addVariable("tcolor", "0xb06002");';
$flashtag .= $soname . '.addVariable("tcolor2", "0x000000");';
$flashtag .= $soname . '.addVariable("hicolor", "0x814600");';
$flashtag .= $soname . '.addVariable("tspeed", "100");';
$flashtag .= $soname . '.addVariable("distr", "true");';
// if you want to add the categories , modify here
$flashtag .= $soname . '.addVariable("mode", "both");';
$flashtag .= $soname . '.addVariable("tagcloud", "' . $mytags . '");';
// if you want to add the categories , modify here
// 6 means the frequency or articles of this categorie
$flashtag .= $soname . '.addVariable("categories", "' . urlencode(' <a href="http://www.baidu.com">Baidu</a>(6)<br />') . '");';
$flashtag .= $soname . '.write("tagcannotdis");</script>';
$flashtag .= '</div>';
return $flashtag;
}
?>
<?php
// a demo how to use the function tag_cloud();
echo '<h1>标签云</h1><br />';
$a = "<a href='http://www.baiduc.com'>baidu</a>";
$c = "";
//<a href='http://www.baidu.com' style='font-size: 24.12pt;'>abc24</a>
for ( $i = 8 ; $i <= 70; $i++)
{
$c .= "<a href='http://www.baidu.com' style='font-size: " . $i . ".12pt;'>tag" . $i . "</a>";
}
echo tag_cloud($a, $c);
?>
</body>
</html>