📄 arc.freelist.class.php
字号:
$orwhere .= " And arc.channel = -1 ";
}
if(!empty($subday))
{
$starttime = time() - $subday*86400;
$orwhere .= " And arc.senddate > $starttime ";
}
$keyword = $this->ListObj->GetAtt('keyword');
if(!empty($keyword))
{
$orwhere .= " And CONCAT(arc.title,arc.keywords) REGEXP '$keyword' ";
}
$orderby = $this->ListObj->GetAtt('orderby');
$orderWay = $this->ListObj->GetAtt('orderway');
//排序方式
$ordersql = "";
if($orderby=="senddate")
{
$ordersql=" order by arc.senddate $orderWay";
}
else if($orderby=="pubdate")
{
$ordersql=" order by arc.pubdate $orderWay";
}
else if($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 if($orderby=="scores")
{
$ordersql = " order by arc.scores $orderWay";
}
else if($orderby=="rand")
{
$ordersql = " order by rand()";
}
else
{
$ordersql=" order by arc.sortrank $orderWay";
}
//获得附加表的相关信息
$addField = "";
$addJoin = "";
if(is_object($this->ChannelUnit))
{
$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;
}
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;
}
}
}
}
}
$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 {$this->maintable} arc
left join #@__arctype tp on arc.typeid=tp.id
$addJoin
where $orwhere $ordersql limit $limitstart,".$this->PageSize;
$this->dsql->SetQuery($query);
$this->dsql->Execute("al");
$artlist = "";
if($col>1)
{
$artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
}
$indtp = new DedeTagParse();
$indtp->SetNameSpace("field","[","]");
$indtp->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
for($i=0;$i<$this->PageSize;$i++)
{
if($col>1)
{
$artlist .= "<tr>\r\n";
}
for($j=0;$j<$col;$j++)
{
if($col>1)
{
$artlist .= "<td width='$colWidth'>\r\n";
}
if($row = $this->dsql->GetArray("al"))
{
$GLOBALS['autoindex']++;
//处理一些特殊字段
$row['id'] = $row['id'];
$row['arcurl'] = $this->GetArcUrl($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'],$row['typedir'],$row['isdefault'],$row['defaultname'],
$row['ispart'],$row['namerule2'],$row['siteurl'],$row['sitepath']);
if($ismake==0 && $GLOBALS['cfg_multi_site']=='Y')
{
if($row["siteurl"]=="")
{
$row["siteurl"] = $GLOBALS['cfg_mainsite'];
}
}
$row['description'] = substr($row['description'],$infolen);
if($row['litpic']=='')
{
$row['litpic'] = '/images/defaultpic.gif';
}
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['info'] = $row['description'];
$row['filename'] = $row['arcurl'];
$row['stime'] = GetDateMK($row['pubdate']);
$row['textlink'] = "<a href='".$row['filename']."' title='".str_replace("'","",$row['title'])."'>".$row['title']."</a>";
$row['typelink'] = "<a href='".$row['typeurl']."'>[".$row['typename']."]</a>";
$row['imglink'] = "<a href='".$row['filename']."'><img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'></a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".str_replace("'","",$row['title'])."'>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
$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>";
}
//编译附加表里的数据
if(is_object($this->ChannelUnit))
{
foreach($row as $k=>$v)
{
if(ereg("[A-Z]",$k))
{
$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($indtp->CTags))
{
foreach($indtp->CTags as $k=>$ctag)
{
$_f = $ctag->GetName();
if($_f=='array')
{
//传递整个数组,在runphp模式中有特殊作用
$indtp->Assign($k,$row);
}
else
{
if(isset($row[$_f]))
{
$indtp->Assign($k,$row[$_f]);
}
else
{
$indtp->Assign($k,"");
}
}
}
}
$artlist .= $indtp->GetResult();
}//if hasRow
else
{
$artlist .= "";
}
if($col>1)
{
$artlist .= " </td>\r\n";
}
}//Loop Col
if($col>1){
$i += $col - 1;
}
if($col>1)
{
$artlist .= " </tr>\r\n";
}
}//Loop Line
if($col>1)
{
$artlist .= "</table>\r\n";
}
$this->dsql->FreeResult("al");
return $artlist;
}
//获取静态的分页列表
function GetPageListST($list_len,$listitem="info,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 "共1页/".$this->TotalResult."条记录";
}
if($this->TotalResult == 0)
{
return "共0页/".$this->TotalResult."条记录";
}
$maininfo = " 共{$totalpage}页/".$this->TotalResult."条记录 ";
$purl = $this->GetCurUrl();
$tnamerule = $this->GetMakeFileRule();
$tnamerule = ereg_replace('^(.*)/','',$tnamerule);
//获得上一页和主页的链接
if($this->PageNo != 1)
{
$prepage.="<a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a>\r\n";
$indexpage="<a href='".str_replace("{page}",1,$tnamerule)."'>首页</a>\r\n";
}
else
{
$indexpage="<a href='#'>首页</a>\r\n";
}
//下一页,未页的链接
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a>\r\n";
$endpage="<a href='".str_replace("{page}",$totalpage,$tnamerule)."'>末页</a>\r\n";
}
else
{
$endpage="<a href='#'>末页</a>\r\n";
}
//option链接
$optionlen = strlen($totalpage);
$optionlen = $optionlen*20+18;
$optionlist = "<select name='sldd' style='width:$optionlen' 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>";
//获得数字链接
$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.= "<strong>{$j}</strong>\r\n";
}
else
{
$listdd.="<a href='".str_replace("{page}",$j,$tnamerule)."'>".$j."</a>\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")
{
$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 "共1页/".$this->TotalResult."条记录";
}
if($this->TotalResult == 0)
{
return "共0页/".$this->TotalResult."条记录";
}
$maininfo = "共{$totalpage}页/".$this->TotalResult."条记录";
$purl = $this->GetCurUrl();
$geturl = "lid=".$this->FreeID."&TotalResult=".$this->TotalResult."&";
$hidenform = "<input type='hidden' name='lid' value='".$this->FreeID."'>\r\n";
$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n";
$purl .= "?".$geturl;
//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="<a href='".$purl."PageNo=$prepagenum'>上一页</a>\r\n";
$indexpage="<a href='".$purl."PageNo=1'>首页</a>\r\n";
}
else
{
$indexpage="<a href='#'>首页</a>\r\n";
}
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<a href='".$purl."PageNo=$nextpagenum'>下一页</a>\r\n";
$endpage="<a href='".$purl."PageNo=$totalpage'>末页</a>\r\n";
}
else
{
$endpage="<a href='#'>末页</a>\r\n";
}
//获得数字链接
$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.= "<a href='#'>.$j.</a>\r\n";
}
else
{
$listdd.="<a href='".$purl."PageNo=$j'>".$j."</a>\r\n";
}
}
$plist = "<form name='pagelist' action='".$this->GetCurUrl()."'>$hidenform";
$plist .= $maininfo.$indexpage.$prepage.$listdd.$nextpage.$endpage;
if($totalpage>$total_list)
{
$plist.="<input type='text' name='PageNo' value='".$this->PageNo."'>\r\n";
$plist.="<input type='submit' name='plistgo' value='GO' >\r\n";
}
$plist .= "</form>\r\n";
return $plist;
}
//获得一个指定档案的链接
function GetArcUrl($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule='',$artdir='',
$money=0,$filename='',$moresite='',$siteurl='',$sitepath='')
{
return GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$artdir,
$money,$filename,$moresite,$siteurl,$sitepath);
}
//获得当前的页面文件的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 + -