Location: PHPKode > projects > Particle Blogger > particle-blogger/includes/functions_blog.php
<?php
function displaytags($postid){
	global $db, $dbprefix, $tags;
	
	// establish variables
	$taglist = Array();
	$code = "Tags: ";
	
	// get recordset
	$sql = "SELECT * FROM " . $dbprefix . "posttags WHERE postid = " . intval($postid);
	$rec = $db->execute($sql);
	if ($rec->rows < 1){
		return false;
	} else { do {
		array_push($taglist, $rec->fields["tagid"]);
	} while ($rec->loop()); }
	
	// now loop through tags and build list
	foreach ($tags["tag"] as $t => $x){
		if (in_array($t, $taglist)){
			$code .= '<a href="' . linktag($tags["slug"][$t]) . '">' . $x . '</a>, ';
		}
	}
	
	// and return
	return substr($code, 0, -2);
}

function LinkArchive($year, $month){
	global $config;
	
	if ($config["friendlyurls"] == "1"){
		// using SEO urls
		$thelink = $config["root"] . $year . "/" . $month . "/";
	} else {
		// using regular Joe urls!
		$thelink = $config["root"] . "archives.php?year=" . $year . "&month=" . $month;
	}
	
	// return the path
	return $thelink;
}

function LinkPost($postid, $external = 0){
	global $config, $dbprefix, $db;
	
	if ($config["friendlyurls"] == "1"){
		// do SEO urls
		$tolink = $db->execute("SELECT * FROM " . $dbprefix . "posts WHERE ID = " . dbSecure($postid));
		if ($tolink->rows < 1){ die("Critical error: Post could not be found"); }
		
		if ($external == 1){
			$linkroot = $config["rooturl"];
		} else {
			$linkroot = $config["root"];
		}
		
		$thelink = $linkroot . date("Y", $tolink->fields["postdate"]) . "/" . date("m", $tolink->fields["postdate"]) . "/" . $tolink->fields["ID"] . $config["fileextention"];
	} else {
		// do normal URLS
		if ($external == 1){
			$thelink = $config["rooturl"] . "post.php?postid=" . $postid;
		} else {
			$thelink = $config["root"] . "post.php?postid=" . $postid;
		}
	}
	
	// return the link
	return $thelink;
}

function linktag($slug){
	global $config;
	
	if ($config["friendlyurls"] == "1"){
		$url = $config["root"] . "tags/" . $slug . "/";
	} else {
		$url = $config["root"] . "index.php?tag=" . $slug;
	}
	
	return $url;
}

function taglist(){
	global $db, $dbprefix;
	
	// initialise variables
	$tags["tag"] = Array();
	$tags["slug"] = Array();
	
	// recordset to array
	$sql = "SELECT * FROM " . $dbprefix . "tags ORDER BY tag ASC";
	$tlr = $db->execute($sql);
	if ($tlr->rows > 0){ do {
			$tags["tag"][$tlr->fields["tagid"]] = $tlr->fields["tag"];
			$tags["slug"][$tlr->fields["tagid"]] = $tlr->fields["slug"];
	} while ($tlr->loop()); }
	
	// and return
	return $tags;
}
?>
Return current item: Particle Blogger