<?php
function lib_mytag(&$ctag,&$refObj)
{
	$attlist="typeid|0,name|,ismake|no";
	FillAttsDefault($ctag->CAttribute->Items,$attlist);
	extract($ctag->CAttribute->Items, EXTR_SKIP);

	if(trim($ismake)=='') $ismake = 'no';
	$body = lib_GetMyTagT($typeid,$name,'#@__mytag');
	//±àÒë
	if($ismake=='yes')
	{
		$pvCopy = new PartView($typeid);
		$pvCopy->SetTemplet($body,"string");
		$body = $pvCopy->GetResult();
	}
	return $body;
}

function lib_GetMyTagT($typeid,$tagname,$tablename)
{
	global $dsql,$envs;
	if($tagname=='') return '';
	if(trim($typeid)=='') $typeid=0;
	if($envs['typeid'] > 0 && $typeid==0) $typeid = $envs['typeid'];
	$typesql = $row = '';
	if($typeid > 0) $typesql = " And typeid in(0,".GetTopids($typeid).") ";
	$row = $dsql->GetOne(" Select * From $tablename where tagname like '$tagname' $typesql order by typeid desc ");
	if(!is_array($row))
	{
		return '';
	}
	$nowtime = time();
	if($row['timeset']==1 && ($nowtime<$row['starttime'] || $nowtime>$row['endtime']) )
	$body = $row['expbody'];
	else
	$body = $row['normbody'];
	return $body;
}
?>