<?php
if(!defined('DEDEINC'))
{
	exit("Request Error!");
}

function lib_flink(&$ctag,&$refObj)
{
	global $dsql;
	$attlist="type|textall,row|24,titlelen|24,linktype|1,typeid|0";
	FillAttsDefault($ctag->CAttribute->Items,$attlist);
	extract($ctag->CAttribute->Items, EXTR_SKIP);

	$totalrow = $row;
	$revalue = '';

	$wsql = " where ischeck >= '$linktype' ";
	if($typeid == 0)
	{
		$wsql .= '';
	}
	else
	{
		$wsql .= "And typeid = '$typeid'";
	}
	if($type=='image')
	{
		$wsql .= " And logo<>'' ";
	}
	else if($type=='text')
	{
		$wsql .= " And logo='' ";
	}

	$equery = "Select * from #@__flink $wsql order by sortrank asc limit 0,$totalrow";

	$dsql->SetQuery($equery);
	$dsql->Execute();
	while($dbrow=$dsql->GetObject())
	{
		if($type=='text'||$type=='textall')
		{
			$link = "<li><a href='".$dbrow->url."' target='_blank'>".cn_substr($dbrow->webname,$titlelen)."</a></li> ";
		}
		else if($type=='image')
		{
			$link = "<li><a href='".$dbrow->url."' target='_blank'><img src='".$dbrow->logo."' width='88' height='31' border='0'></a></li> ";
		}
		else
		{
			if($dbrow->logo=='')
			{
				$link = "<li><a href='".$dbrow->url."' target='_blank'>".cn_substr($dbrow->webname,$titlelen)."</a></li> ";
			}
			else
			{
				$link = "<li><a href='".$dbrow->url."' target='_blank'><img src='".$dbrow->logo."' width='88' height='31' border='0'></a></li> ";
			}
		}
		$revalue .= $link;
	}
	return $revalue;
}
?>