📄 arc.listview.class.php
字号:
if($infolen=="")
{
$infolen = 250;
}
if($imgwidth=="")
{
$imgwidth = 120;
}
if($imgheight=="")
{
$imgheight = 120;
}
if($listtype=="")
{
$listtype = "all";
}
if($orderby=="")
{
$orderby="default";
}
else
{
$orderby=strtolower($orderby);
}
if($orderWay=='')
{
$orderWay = 'desc';
}
$tablewidth = str_replace("%","",$tablewidth);
if($tablewidth=="")
{
$tablewidth=100;
}
if($col=="")
{
$col=1;
}
$colWidth = ceil(100/$col);
$tablewidth = $tablewidth."%";
$colWidth = $colWidth."%";
$innertext = trim($innertext);
if($innertext=="")
{
$innertext = GetSysTemplets("list_fulllist.htm");
}
//排序方式
$ordersql = '';
if($orderby=="senddate"||$orderby=="id")
{
$ordersql=" order by arc.id $orderWay";
}
else if($orderby=="hot"||$orderby=="click")
{
$ordersql = " order by arc.click $orderWay";
}
else if($orderby=="lastpost")
{
$ordersql = " order by arc.lastpost $orderWay";
}
else
{
$ordersql=" order by arc.sortrank $orderWay";
}
//获得附加表的相关信息
$addtable = $this->ChannelUnit->ChannelInfos['addtable'];
if($addtable!="")
{
$addJoin = " left join `$addtable` on arc.id = ".$addtable.'.aid ';
$addField = '';
$fields = explode(',',$this->ChannelUnit->ChannelInfos['listfields']);
foreach($fields as $k=>$v)
{
$nfields[$v] = $k;
}
if(is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields))
{
foreach($this->ChannelUnit->ChannelFields as $k=>$arr)
{
if(isset($nfields[$k]))
{
if(!empty($arr['rename']))
{
$addField .= ','.$addtable.'.'.$k.' as '.$arr['rename'];
}
else
{
$addField .= ','.$addtable.'.'.$k;
}
}
}
}
}
else
{
$addField = '';
$addJoin = '';
}
//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
if(ereg('hot|click|lastpost',$orderby))
{
$query = "Select arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
$addField
from `#@__archives` arc
left join `#@__arctype` tp on arc.typeid=tp.id
$addJoin
where {$this->addSql} $ordersql limit $limitstart,$row";
}
//普通情况先从arctiny表查出ID,然后按ID查询(速度非常快)
else
{
$t1 = ExecTime();
$ids = array();
$query = "Select id From `#@__arctiny` arc where {$this->addSql} $ordersql limit $limitstart,$row ";
$this->dsql->SetQuery($query);
$this->dsql->Execute();
while($arr=$this->dsql->GetArray())
{
$ids[] = $arr['id'];
}
$idstr = join(',',$ids);
if($idstr=='')
{
return '';
}
else
{
$query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,
tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
$addField
from `#@__archives` arc left join `#@__arctype` tp on arc.typeid=tp.id
$addJoin
where arc.id in($idstr) $ordersql ";
}
$t2 = ExecTime();
//echo $t2-$t1;
}
$this->dsql->SetQuery($query);
$this->dsql->Execute('al');
$t2 = ExecTime();
//echo $t2-$t1;
$artlist = '';
$this->dtp2->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
for($i=0;$i<$row;$i++)
{
if($col>1)
{
$artlist .= "<div>\r\n";
}
for($j=0;$j<$col;$j++)
{
if($row = $this->dsql->GetArray("al"))
{
$GLOBALS['autoindex']++;
$ids[$row['id']] = $row['id'];
//处理一些特殊字段
$row['infos'] = cn_substr($row['description'],$infolen);
$row['id'] = $row['id'];
if($row['corank'] > 0 && $row['arcrank']==0)
{
$row['arcrank'] = $row['corank'];
}
$row['filename'] = $row['arcurl'] = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
$row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
if(!eregi("^http://",$row['litpic']))
{
$row['picname'] = $row['litpic'] = $GLOBALS['cfg_multi_site'] == 'Y' ? $GLOBALS['cfg_mainsite'].$row['litpic'] : $row['litpic'];
}
else
{
$row['picname'] = $row['litpic'] = $row['litpic'];
}
$row['stime'] = GetDateMK($row['pubdate']);
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'],$titlelen);
if($row['color']!='')
{
$row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
}
if(ereg('c',$row['flag']))
{
$row['title'] = "<b>".$row['title']."</b>";
}
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
//编译附加表里的数据
foreach($row as $k=>$v)
{
$row[strtolower($k)] = $v;
}
foreach($this->ChannelUnit->ChannelFields as $k=>$arr)
{
if(isset($row[$k]))
{
$row[$k] = $this->ChannelUnit->MakeField($k,$row[$k]);
}
}
if(is_array($this->dtp2->CTags))
{
foreach($this->dtp2->CTags as $k=>$ctag)
{
if($ctag->GetName()=='array')
{
//传递整个数组,在runphp模式中有特殊作用
$this->dtp2->Assign($k,$row);
}
else
{
if(isset($row[$ctag->GetName()]))
{
$this->dtp2->Assign($k,$row[$ctag->GetName()]);
}
else
{
$this->dtp2->Assign($k,'');
}
}
}
}
$artlist .= $this->dtp2->GetResult();
}//if hasRow
}//Loop Col
if($col>1)
{
$i += $col - 1;
$artlist .= " </div>\r\n";
}
}//Loop Line
$t3 = ExecTime();
//echo ($t3-$t2);
$this->dsql->FreeResult('al');
return $artlist;
}
//获取静态的分页列表
function GetPageListST($list_len,$listitem="index,end,pre,next,pageno")
{
$prepage="";
$nextpage="";
$prepagenum = $this->PageNo-1;
$nextpagenum = $this->PageNo+1;
if($list_len==""||ereg("[^0-9]",$list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpage<=1 && $this->TotalResult>0)
{
return "<span class=\"pageinfo\">共 <strong>1</strong>页<strong>".$this->TotalResult."</strong>条记录</span>";
}
if($this->TotalResult == 0)
{
return "<span class=\"pageinfo\">共 <strong>0</strong>页<strong>".$this->TotalResult."</strong>条记录</span>";
}
$purl = $this->GetCurUrl();
$maininfo = "<span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span>";
$tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule = ereg_replace('^(.*)/','',$tnamerule);
//获得上一页和主页的链接
if($this->PageNo != 1)
{
$prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";
$indexpage="<li><a href='".str_replace("{page}",1,$tnamerule)."'>首页</a></li>\r\n";
}
else
{
$indexpage="<li>首页</li>\r\n";
}
//下一页,未页的链接
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<li><a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a></li>\r\n";
$endpage="<li><a href='".str_replace("{page}",$totalpage,$tnamerule)."'>末页</a></li>\r\n";
}
else
{
$endpage="<li>末页</li>";
}
//option链接
$optionlist = "";
/*
$optionlen = strlen($totalpage);
$optionlen = $optionlen*10+18;
$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
for($mjj=1;$mjj<=$totalpage;$mjj++)
{
if($mjj==$this->PageNo)
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."' selected>$mjj</option>\r\n";
}
else
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."'>$mjj</option>\r\n";
}
}
$optionlist .= "</select><li>";
*/
//获得数字链接
$listdd="";
$total_list = $list_len * 2 + 1;
if($this->PageNo >= $total_list)
{
$j = $this->PageNo-$list_len;
$total_list = $this->PageNo+$list_len;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
else
{
$j=1;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
for($j;$j<=$total_list;$j++)
{
if($j==$this->PageNo)
{
$listdd.= "<li class=\"thisclass\">$j</li>\r\n";
}
else
{
$listdd.="<li><a href='".str_replace("{page}",$j,$tnamerule)."'>".$j."</a></li>\r\n";
}
}
$plist = "";
if(eregi('info',$listitem))
{
$plist .= $maininfo.' ';
}
if(eregi('index',$listitem))
{
$plist .= $indexpage.' ';
}
if(eregi('pre',$listitem))
{
$plist .= $prepage.' ';
}
if(eregi('pageno',$listitem))
{
$plist .= $listdd.' ';
}
if(eregi('next',$listitem))
{
$plist .= $nextpage.' ';
}
if(eregi('end',$listitem))
{
$plist .= $endpage.' ';
}
if(eregi('option',$listitem))
{
$plist .= $optionlist;
}
return $plist;
}
//获取动态的分页列表
function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
{
global $cfg_rewrite;
$prepage="";
$nextpage="";
$prepagenum = $this->PageNo-1;
$nextpagenum = $this->PageNo+1;
if($list_len==""||ereg("[^0-9]",$list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpage<=1 && $this->TotalResult>0)
{
return "<span class=\"pageinfo\">共1页/".$this->TotalResult."条记录</span>";
}
if($this->TotalResult == 0)
{
return "<span class=\"pageinfo\">共0页/".$this->TotalResult."条记录</span>";
}
$purl = $this->GetCurUrl();
if($cfg_rewrite == 'Y')
{
$nowurls = ereg_replace("\-",".php?",$purl);
$nowurls = explode("?",$nowurls);
$purl = $nowurls[0];
}
$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."'>\r\n";
$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n";
$purl .= "?".$geturl;
//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n";
$indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n";
}
else
{
$indexpage="<li><a>首页</a></li>\r\n";
}
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n";
$endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
}
else
{
$endpage="<li><a>末页</a></li>";
}
//获得数字链接
$listdd="";
$total_list = $list_len * 2 + 1;
if($this->PageNo >= $total_list)
{
$j = $this->PageNo-$list_len;
$total_list = $this->PageNo+$list_len;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
else
{
$j=1;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
for($j;$j<=$total_list;$j++)
{
if($j==$this->PageNo)
{
$listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
}
else
{
$listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n";
}
}
$plist = $indexpage.$prepage.$listdd.$nextpage.$endpage;
if($cfg_rewrite == 'Y')
{
$plist = str_replace('.php?tid=', '-', $plist);
$plist = str_replace('&TotalResult=', '-', $plist);
$plist = preg_replace("/&PageNo=(\d+)/i",'-\\1.html',$plist);
}
return $plist;
}
//获得当前的页面文件的url
function GetCurUrl()
{
if(!empty($_SERVER["REQUEST_URI"]))
{
$nowurl = $_SERVER["REQUEST_URI"];
$nowurls = explode("?",$nowurl);
$nowurl = $nowurls[0];
}
else
{
$nowurl = $_SERVER["PHP_SELF"];
}
return $nowurl;
}
}//End Class
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -