<?php
// get portal category name
// structure = return structure instead of name only
// link = with link
function pcat_name ($cat_id, $structure = TRUE, $link = FALSE)
{
global $db_prefix, $config;
if (empty ($cat_id)) return FALSE;
// get cat name & info
$row = sql_qquery ("SELECT cat_id, cat_name, cat_structure, cat_struct_id FROM ".$db_prefix."pcategory WHERE cat_id='$cat_id' LIMIT 1");
// return cat name & info
if ($config['enable_adp'] == 3) $url = create_seo_url ($row['cat_name'], $cat_id); else $url = $cat_id;
if (!$structure && !$link) return $row['cat_name'];
if (!$structure && $link) return "<a href=\"task.php?mod=portal&cmd=cat&cid=$url\">$row[cat_name]</a>";
if ($structure && !$link) return $row['cat_structure'];
if ($structure && $link)
{
$cid = explode (',', $row['cat_struct_id']);
$nid = explode ("\r\n", $row['cat_structure']);
$foo = array_pair ($cid, $nid);
$t = array ();
foreach ($foo as $key => $val)
{
if ($config['enable_adp'] == 3) $ci = create_seo_url ($key, $val); else $ci = $key;
$t[] = "<a href=\"task.php?mod=portal&cmd=cat&cid=$ci\">$val</a>";
}
return implode (" $config[cat_separator] ", $t);
}
}
$cmd = get_param ('cmd');
switch ($cmd)
{
case 'read':
require ('./module/portal/read.php');
break;
case 'cat':
require ('./module/portal/cat.php');
break;
default:
redir ($config['site_url']);
break;
}
?>