Location: PHPKode > projects > PHPDug > tags.php
<?php
require_once('includes/config.php');
require_once('includes/functions/func.global.php');
require_once('includes/classes/class.template_engine.php');
require_once('includes/lang/lang_'.$config['lang'].'.php');

// Start the session
session_start();

// Connect to the database
db_connect($config);

// Check if the user has a remember cookie set
checkremember($config);

// Get site categories
$cats = get_cats($config,$lang);

// Get tags
$tags_init = get_tags($config,'all');

// Work out tag ranges
if(count($tags_init) > 0)
{
	$min_count = min(array_values($tags_init));
	$max_count = max(array_values($tags_init));
	$tag_range = $max_count - $min_count;
	if($tag_range == 0) 
	{
		$tag_range = 1;
	}
}
else
{
	$min_count = 0;
	$max_count = 0;
	$tag_range = 1;
}

// Font Sizes for cloud
$min_font_size = 12;
$max_font_size = 30;

$tags_loop = array();
$counter = 0;

foreach ($tags_init as $phrase => $times) 
{
	$size = $min_font_size + ($times - $min_count) * ($max_font_size - $min_font_size) / $tag_range;

	$tags_loop[$counter]['tag'] = $phrase;
	$tags_loop[$counter]['count'] = $times;
	$tags_loop[$counter]['size'] = floor($size);
	
	$counter++;
}

$page = new HtmlTemplate ('templates/' . $config['tpl_name'] . '/tags.html');
$page->SetLoop ('CATS', $cats);
$page->SetLoop ('TAGS', $tags_loop);
$page->SetParameter ('SITE_TITLE',$config['site_title']);
$page->SetParameter ('OVERALL_HEADER', create_header($config,$lang,$cats,$lang['TAGCLOUD']));
$page->SetParameter ('OVERALL_FOOTER', create_footer($config,$lang));
if(isset($_SESSION['duser']['id']))
{
	$page->SetParameter ('LOGGEDIN', 1);
}
else
{
	$page->SetParameter ('LOGGEDIN', 0);
}
$page->CreatePageEcho($lang,$config);
?>
Return current item: PHPDug