<?php
function litimgurls($imgid=0)
{
    global $lit_imglist,$dsql;
    //获取附加表
    $row = $dsql->GetOne("SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c 
                                                            ON a.channel=c.id where a.id='$imgid'");
    $addtable = trim($row['addtable']);
    
    //获取图片附加表imgurls字段内容进行处理
    $row = $dsql->GetOne("Select imgurls From `$addtable` where aid='$imgid'");
    
    //调用inc_channel_unit.php中ChannelUnit类
    $ChannelUnit = new ChannelUnit(2,$imgid);
    
    //调用ChannelUnit类中GetlitImgLinks方法处理缩略图
    $lit_imglist = $ChannelUnit->GetlitImgLinks($row['imgurls']);
    
    //返回结果
    return $lit_imglist;
}

function GetOneDocUrl($aid)
{
    global $dsql;
    include_once(DEDEINC."/channelunit.func.php");
    $aid = trim(ereg_replace('[^0-9]','',$aid));

    $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `dede_arctiny` arc left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");

    if(!is_array($chRow)) {
        return $reArr;
    }
    else {
        if(empty($chRow['maintable'])) $chRow['maintable'] = 'dede_archives';
    }

    if($chRow['issystem']!=-1)
    {
        $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
                    From `{$chRow['maintable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid
                    where arc.id='$aid' ";
    }
    else
    {
        $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
                    From `{$chRow['addtable']}` arc left join `dede_arctype` tp on tp.id=arc.typeid
                    where arc.aid='$aid' ";
    }

    $arcRow = $dsql->GetOne($nquery);

    $Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);
    return $Url;
}


function getleftguide($typeid)
{ 
	global $dsql;
	global $listarr;
	$listleftg = '';
	$typeid = trim(ereg_replace('[^0-9]','',$typeid));

	$query="select id,typedir,typename,defaultname from dede_arctype where reid in(select reid from dede_arctype where id = '$typeid') order by sortrank";
	$dsql->SetQuery($query);
	$dsql->Execute();
			while($rows = $dsql->getarray())
			{
					
					if($typeid == $rows['id'])
					{
        			$listleftg .= "<li class='thisclass'><a href=".$rows['typedir']."/".$rows['defaultname']." title='".$rows['typename']."'>".$rows['typename']."</a></li>\n";
					}
					else
					{
					$listleftg .="<li><a href=".$rows['typedir']."/".$rows['defaultname'].">".$rows['typename']."</a></li>\n";
					}
			}
   
   return $listleftg;
}


function getleftarc($aid)
{ 
	global $dsql;
	global $listarr;
	$listleftg = '';
	$typeid = trim(ereg_replace('[^0-9]','',$typeid));

	$query="select title,id from dede_archives where typeid in(select typeid from dede_archives where id='$aid') order by pubdate desc ";
	$dsql->SetQuery($query);
	$dsql->Execute();
			while($rows = $dsql->getarray())
			{
					
					if($aid == $rows['id'])
					{
        			$listleftg .= "<li class='thisclass'><a href='".GetOneDocUrl($rows['id'])."' title='".html2text($rows['title'])."'>".$rows['title']."</a></li>\n";
					}
					else
					{
					$listleftg .= "<li><a href=".GetOneDocUrl($rows['id'])." title='".html2text($rows['title'])."'>".$rows['title']."</a></li>\n";
					}
			}
   
   return $listleftg;
}

function getaboutleft($aid)
{ 
	global $dsql;
	global $listarr;
	$listleftg = '';
	$typeid = trim(ereg_replace('[^0-9]','',$typeid));

	$query="select title,id from dede_archives where typeid in(select typeid from dede_archives where id='$aid') order by weight ";
	$dsql->SetQuery($query);
	$dsql->Execute();
			while($rows = $dsql->getarray())
			{
					
					if($aid == $rows['id'])
					{
        			$listleftg .= "<li class='thisclass'><a href='".GetOneDocUrl($rows['id'])."' title='".html2text($rows['title'])."'>".$rows['title']."</a></li>\n";
					}
					else
					{
					$listleftg .= "<li><a href=".GetOneDocUrl($rows['id'])." title='".html2text($rows['title'])."'>".$rows['title']."</a></li>\n";
					}
			}
   
   return $listleftg;
}



function getleftcooper($typeid)
{ 
	global $dsql;
	global $listarr;
	$listleftg = '';
	$typeid = trim(ereg_replace('[^0-9]','',$typeid));

	$query="select title,id from dede_archives where typeid ='$typeid' ";
	$dsql->SetQuery($query);
	$dsql->Execute();
			while($rows = $dsql->getarray())
			{
		
					$listleftg .= "<li><a href=".GetOneDocUrl($rows['id'])." title='".html2text($rows['title'])."'>".$rows['title']."</a></li>\n";
					
			}
   
   return $listleftg;
}

?>