这篇文章给大家介绍如何进行dedecms 列表页支持noflag属性的分析,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
搜索 noflag 即可解决问题!
/**
* 文档列表类
*
* @version $Id: arc.listview.class.php 2 15:15 2010年7月7日Z tianya $
* @package DedeCMS.Libraries
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(DEDEINC.'/arc.partview.class.php');
require_once(DEDEINC.'/ftp.class.php');
helper('cache');
@set_time_limit(0);
/**
* 自由列表类
*
* @package ListView
* @subpackage DedeCMS.Libraries
* @link http://www.dedecms.com
*/
class ListView
{
var $dsql;
var $dtp;
var $dtp2;
var $TypeID;
var $TypeLink;
var $PageNo;
var $TotalPage;
var $TotalResult;
var $PageSize;
var $ChannelUnit;
var $ListType;
var $Fields;
var $PartView;
var $upPageType;
var $addSql;
var $IsError;
var $CrossID;
var $IsReplace;
var $ftp;
var $remoteDir;
var $noflag;
/**
* php5构造函数
*
* @access public
* @param int $typeid 栏目ID
* @param int $uppage 上一页
* @return string
*/
function __construct($typeid, $uppage=1)
{
global $dsql,$ftp;
$this->TypeID = $typeid;
$this->dsql = &$dsql;
$this->CrossID = '';
$this->IsReplace = false;
$this->IsError = false;
$this->dtp = new DedeTagParse();
$this->dtp->SetRefObj($this);
$this->dtp->SetNameSpace("dede", "{", "}");
$this->dtp2 = new DedeTagParse();
$this->dtp2->SetNameSpace("field","[","]");
$this->TypeLink = new TypeLink($typeid);
$this->upPageType = $uppage;
$this->ftp = &$ftp;
$this->remoteDir = '';
$this->noflag = '';
$this->TotalResult = is_numeric($this->TotalResult)? $this->TotalResult : "";
if(!is_array($this->TypeLink->TypeInfos))
{
$this->IsError = true;
}
if(!$this->IsError)
{
$this->ChannelUnit = new ChannelUnit($this->TypeLink->TypeInfos['channeltype']);
$this->Fields = $this->TypeLink->TypeInfos;
$this->Fields['id'] = $typeid;
$this->Fields['position'] = $this->TypeLink->GetPositionLink(true);
$this->Fields[&#39;title&#39;] = preg_replace("/[<>]/", " / ", $this->TypeLink->GetPositionLink(false));
//设置一些全局参数的值
foreach($GLOBALS[&#39;PubFields&#39;] as $k=>$v) $this->Fields[$k] = $v;
$this->Fields[&#39;rsslink&#39;] = $GLOBALS[&#39;cfg_cmsurl&#39;]."/data/rss/".$this->TypeID.".xml";
//设置环境变量
SetSysEnv($this->TypeID,$this->Fields[&#39;typename&#39;],0,&#39;&#39;,&#39;list&#39;);
$this->Fields[&#39;typeid&#39;] = $this->TypeID;
//获得交叉栏目ID
if($this->TypeLink->TypeInfos[&#39;cross&#39;]>0 && $this->TypeLink->TypeInfos[&#39;ispart&#39;]==0)
{
$selquery = &#39;&#39;;
if($this->TypeLink->TypeInfos[&#39;cross&#39;]==1)
{
$selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE &#39;{$this->Fields[&#39;typename&#39;]}&#39; AND id<>&#39;{$this->TypeID}&#39; AND topid<>&#39;{$this->TypeID}&#39; ";
}
else
{
$this->Fields[&#39;crossid&#39;] = preg_replace(&#39;/[^0-9,]/&#39;, &#39;&#39;, trim($this->Fields[&#39;crossid&#39;]));
if($this->Fields[&#39;crossid&#39;]!=&#39;&#39;)
{
$selquery = "SELECT id,topid FROM `#@__arctype` WHERE id in({$this->Fields[&#39;crossid&#39;]}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID} ";
}
}
if($selquery!=&#39;&#39;)
{
$this->dsql->SetQuery($selquery);
$this->dsql->Execute();
while($arr = $this->dsql->GetArray())
{
$this->CrossID .= ($this->CrossID==&#39;&#39; ? $arr[&#39;id&#39;] : &#39;,&#39;.$arr[&#39;id&#39;]);
}
}
}
}//!error
}
//php4构造函数
function ListView($typeid,$uppage=0){
$this->__construct($typeid,$uppage);
}
//关闭相关资源
function Close()
{
}
/**
* 统计列表里的记录
*
* @access public
* @param string
* @return string
*/
function CountRecord()
{
global $cfg_list_son,$cfg_need_typeid2,$cfg_cross_sectypeid;
if(empty($cfg_need_typeid2)) $cfg_need_typeid2 = &#39;N&#39;;
//统计数据库记录
$this->TotalResult = -1;
if(isset($GLOBALS[&#39;TotalResult&#39;])) $this->TotalResult = $GLOBALS[&#39;TotalResult&#39;];
if(isset($GLOBALS[&#39;PageNo&#39;])) $this->PageNo = $GLOBALS[&#39;PageNo&#39;];
else $this->PageNo = 1;
$this->addSql = " arc.arcrank > -1 ";
$typeid2like = " &#39;%,{$this->TypeID},%&#39; ";
if($cfg_list_son==&#39;N&#39;)
{
if($cfg_need_typeid2==&#39;N&#39;)
{
if($this->CrossID==&#39;&#39;) $this->addSql .= " AND (arc.typeid=&#39;".$this->TypeID."&#39;) ";
else $this->addSql .= " AND (arc.typeid in({$this->CrossID},{$this->TypeID})) ";
}
else
{
if($this->CrossID==&#39;&#39;)
{
$this->addSql .= " AND ( (arc.typeid=&#39;".$this->TypeID."&#39;) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like) ";
} else {
if($cfg_cross_sectypeid == &#39;Y&#39;)
{
$typeid2Clike = " &#39;%,{$this->CrossID},%&#39; ";
$this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2Clike)";
} else {
$this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like)";
}
}
}
}
else
{
$sOnids= GetSonIds($this->TypeID,$this->Fields[&#39;channeltype&#39;]);
if(!preg_match("/,/", $sonids)) {
$sOnidsCon= " arc.typeid = &#39;$sonids&#39; ";
}
else {
$sOnidsCon= " arc.typeid IN($sonids) ";
}
if($cfg_need_typeid2==&#39;N&#39;)
{
if($this->CrossID==&#39;&#39;) $this->addSql .= " AND ( $sonidsCon ) ";
else $this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) ) ";
}
else
{
if($this->CrossID==&#39;&#39;)
{
$this->addSql .= " AND ( $sonidsCon OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) like $typeid2like ) ";
} else {
if($cfg_cross_sectypeid == &#39;Y&#39;)
{
$typeid2Clike = " &#39;%,{$this->CrossID},%&#39; ";
$this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2Clike) ";
} else {
$this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(&#39;,&#39;, arc.typeid2, &#39;,&#39;) LIKE $typeid2like) ";
}
}
}
}
if($this->TotalResult==-1)
{
$cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql;
$row = $this->dsql->GetOne($cquery);
if(is_array($row))
{
$this->TotalResult = $row[&#39;dd&#39;];
}
else
{
$this->TotalResult = 0;
}
}
//初始化列表模板,并统计页面总数
$tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$this->TypeLink->TypeInfos[&#39;templist&#39;];
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile);
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos[&#39;nid&#39;], $tempfile);
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
if(!file_exists($tempfile))
{
$tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_default.htm";
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
}
if(!file_exists($tempfile)||!is_file($tempfile))
{
echo "模板文件不存在,无法解析文档!";
exit();
}
$this->dtp->LoadTemplate($tempfile);
$ctag = $this->dtp->GetTag("page");
if(!is_object($ctag))
{
$ctag = $this->dtp->GetTag("list");
}
if(!is_object($ctag))
{
$this->PageSize = 20;
}
else
{
if($ctag->GetAtt("pagesize")!="")
{
$this->PageSize = $ctag->GetAtt("pagesize");
}
else
{
$this->PageSize = 20;
}
}
$this->TotalPage = ceil($this->TotalResult/$this->PageSize);
}
/**
* 列表创建HTML
*
* @access public
* @param string $startpage 开始页面
* @param string $makepagesize 创建文件数目
* @param string $isremote 是否为远程
* @return string
*/
function MakeHtml($startpage=1, $makepagesize=0, $isremote=0)
{
global $cfg_remote_site;
if(empty($startpage))
{
$startpage = 1;
}
//创建封面模板文件
if($this->TypeLink->TypeInfos[&#39;isdefault&#39;]==-1)
{
echo &#39;这个类目是动态类目!&#39;;
return &#39;../plus/list.php?tid=&#39;.$this->TypeLink->TypeInfos[&#39;id&#39;];
}
//单独页面
else if($this->TypeLink->TypeInfos[&#39;ispart&#39;]>0)
{
$reurl = $this->MakePartTemplets();
return $reurl;
}
$this->CountRecord();
//初步给固定值的标记赋值
$this->ParseTempletsFirst();
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpage==0)
{
$totalpage = 1;
}
CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));
$murl = &#39;&#39;;
if($makepagesize > 0)
{
$endpage = $startpage+$makepagesize;
}
else
{
$endpage = ($totalpage+1);
}
if( $endpage >= $totalpage+1 )
{
$endpage = $totalpage+1;
}
if($endpage==1)
{
$endpage = 2;
}
for($this->PageNo=$startpage; $this->PageNo <$endpage; $this->PageNo++)
{
/*顾涛*/
if($this->PageNo>1){
$tempfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_article2.htm";
$this->dtp->LoadTemplate($tempfile);
$this->ParseTempletsFirst();
}
$this->ParseDMFields($this->PageNo,1);
$makeFile = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],&#39;list&#39;,$this->Fields[&#39;typedir&#39;],&#39;&#39;,$this->Fields[&#39;namerule2&#39;]);
$makeFile = str_replace("{page}", $this->PageNo, $makeFile);
$murl = $makeFile;
if(!preg_match("/^///", $makeFile))
{
$makeFile = "/".$makeFile;
}
$makeFile = $this->GetTruePath().$makeFile;
$makeFile = preg_replace("///{1,}/", "/", $makeFile);
$murl = $this->GetTrueUrl($murl);
$this->dtp->SaveTo($makeFile);
//如果启用远程发布则需要进行判断
if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)
{
//分析远程文件路径
$remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);
$localfile = &#39;..&#39;.$remotefile;
$remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);
//不相等则说明已经切换目录则可以创建镜像
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);
}
}
if($startpage==1)
{
//如果列表启用封面文件,复制这个文件第一页
if($this->TypeLink->TypeInfos[&#39;isdefault&#39;]==1
&& $this->TypeLink->TypeInfos[&#39;ispart&#39;]==0)
{
$Onlyrule= $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"list",$this->Fields[&#39;typedir&#39;],&#39;&#39;,$this->Fields[&#39;namerule2&#39;]);
$Onlyrule= str_replace("{page}","1",$onlyrule);
$list_1 = $this->GetTruePath().$onlyrule;
$murl = MfTypedir($this->Fields[&#39;typedir&#39;]).&#39;/&#39;.$this->Fields[&#39;defaultname&#39;];
//如果启用远程发布则需要进行判断
if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)
{
//分析远程文件路径
$remotefile = $murl;
$localfile = &#39;..&#39;.$remotefile;
$remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);
//不相等则说明已经切换目录则可以创建镜像
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);
}
$indexname = $this->GetTruePath().$murl;
copy($list_1,$indexname);
}
}
return $murl;
}
/**
* 显示列表
*
* @access public
* @return void
*/
function Display()
{
if($this->TypeLink->TypeInfos[&#39;ispart&#39;]>0)
{
$this->DisplayPartTemplets();
return ;
}
$this->CountRecord();
if((empty($this->PageNo) || $this->PageNo==1)
&& $this->TypeLink->TypeInfos[&#39;ispart&#39;]==1)
{
$tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];
$tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);
$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);
$tempfile = $tmpdir."/".$tempfile;
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
if(!file_exists($tempfile))
{
$tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
}
$this->dtp->LoadTemplate($tempfile);
}
/*顾涛*/
if($this->PageNo>1){
$tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/list_article2.htm";
$this->dtp->LoadTemplate($tempfile);
}
$this->ParseTempletsFirst();
$this->ParseDMFields($this->PageNo,0);
$this->dtp->Display();
}
/**
* 创建单独模板页面
*
* @access public
* @return string
*/
function MakePartTemplets()
{
$this->PartView = new PartView($this->TypeID,false);
$this->PartView->SetTypeLink($this->TypeLink);
$nmfa = 0;
$tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];
if($this->Fields[&#39;ispart&#39;]==1)
{
$tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);
$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);
$tempfile = $tmpdir."/".$tempfile;
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
if(!file_exists($tempfile))
{
$tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
}
$this->PartView->SetTemplet($tempfile);
}
else if($this->Fields[&#39;ispart&#39;]==2)
{
//跳转网址
return $this->Fields[&#39;typedir&#39;];
}
CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));
$makeUrl = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"index",MfTypedir($this->Fields[&#39;typedir&#39;]),$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]);
$makeUrl = preg_replace("///{1,}/", "/", $makeUrl);
$makeFile = $this->GetTruePath().$makeUrl;
if($nmfa==0)
{
$this->PartView->SaveToHtml($makeFile);
//如果启用远程发布则需要进行判断
if($GLOBALS[&#39;cfg_remote_site&#39;]==&#39;Y&#39;&& $isremote == 1)
{
//分析远程文件路径
$remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);
$localfile = &#39;..&#39;.$remotefile;
$remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);
//不相等则说明已经切换目录则可以创建镜像
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);
}
}
else
{
if(!file_exists($makeFile))
{
$this->PartView->SaveToHtml($makeFile);
//如果启用远程发布则需要进行判断
if($cfg_remote_site==&#39;Y&#39;&& $isremote == 1)
{
//分析远程文件路径
$remotefile = str_replace(DEDEROOT, &#39;&#39;,$makeFile);
$localfile = &#39;..&#39;.$remotefile;
$remotedir = preg_replace(&#39;/[^//]*/.html/&#39;, &#39;&#39;,$remotefile);
//不相等则说明已经切换目录则可以创建镜像
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, &#39;acii&#39;);
}
}
}
return $this->GetTrueUrl($makeUrl);
}
/**
* 显示单独模板页面
*
* @access public
* @param string
* @return string
*/
function DisplayPartTemplets()
{
$this->PartView = new PartView($this->TypeID,false);
$this->PartView->SetTypeLink($this->TypeLink);
$nmfa = 0;
$tmpdir = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;];
if($this->Fields[&#39;ispart&#39;]==1)
{
//封面模板
$tempfile = str_replace("{tid}",$this->TypeID,$this->Fields[&#39;tempindex&#39;]);
$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos[&#39;nid&#39;],$tempfile);
$tempfile = $tmpdir."/".$tempfile;
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
if(!file_exists($tempfile))
{
$tempfile = $tmpdir."/".$GLOBALS[&#39;cfg_df_style&#39;]."/index_default.htm";
if ( defined(&#39;DEDEMOB&#39;) )
{
$tempfile =str_replace(&#39;.htm&#39;,&#39;_m.htm&#39;,$tempfile);
}
}
$this->PartView->SetTemplet($tempfile);
}
else if($this->Fields[&#39;ispart&#39;]==2)
{
//跳转网址
$gotourl = $this->Fields[&#39;typedir&#39;];
header("Location:$gotourl");
exit();
}
CreateDir(MfTypedir($this->Fields[&#39;typedir&#39;]));
$makeUrl = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"index",MfTypedir($this->Fields[&#39;typedir&#39;]),$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]);
$makeFile = $this->GetTruePath().$makeUrl;
if($nmfa==0)
{
$this->PartView->Display();
}
else
{
if(!file_exists($makeFile))
{
$this->PartView->Display();
}
else
{
include($makeFile);
}
}
}
/**
* 获得站点的真实根路径
*
* @access public
* @return string
*/
function GetTruePath()
{
$truepath = $GLOBALS["cfg_basedir"];
return $truepath;
}
/**
* 获得真实连接路径
*
* @access public
* @param string $nurl 地址
* @return string
*/
function GetTrueUrl($nurl)
{
if($this->Fields[&#39;moresite&#39;]==1)
{
if($this->Fields[&#39;sitepath&#39;]!=&#39;&#39;)
{
$nurl = preg_replace("/^".$this->Fields[&#39;sitepath&#39;]."/", &#39;&#39;, $nurl);
}
$nurl = $this->Fields[&#39;siteurl&#39;].$nurl;
}
return $nurl;
}
/**
* 解析模板,对固定的标记进行初始给值
*
* @access public
* @return string
*/
function ParseTempletsFirst()
{
if(isset($this->TypeLink->TypeInfos[&#39;reid&#39;]))
{
$GLOBALS[&#39;envs&#39;][&#39;reid&#39;] = $this->TypeLink->TypeInfos[&#39;reid&#39;];
}
$GLOBALS[&#39;envs&#39;][&#39;typeid&#39;] = $this->TypeID;
$GLOBALS[&#39;envs&#39;][&#39;topid&#39;] = GetTopid($this->Fields[&#39;typeid&#39;]);
$GLOBALS[&#39;envs&#39;][&#39;cross&#39;] = 1;
MakeOneTag($this->dtp,$this);
}
/**
* 解析模板,对内容里的变动进行赋值
*
* @access public
* @param int $PageNo 页数
* @param int $ismake 是否编译
* @return string
*/
function ParseDMFields($PageNo,$ismake=1)
{
//替换第二页后的内容
if(($PageNo>1 || strlen($this->Fields[&#39;content&#39;])<10 ) && !$this->IsReplace)
{
$this->dtp->SourceString = str_replace(&#39;[cmsreplace]&#39;,&#39;display:none&#39;,$this->dtp->SourceString);
$this->IsReplace = true;
}
foreach($this->dtp->CTags as $tagid=>$ctag)
{
if($ctag->GetName()=="list")
{
$limitstart = ($this->PageNo-1) * $this->PageSize;
$row = $this->PageSize;
if(trim($ctag->GetInnerText())=="")
{
$InnerText = GetSysTemplets("list_fulllist.htm");
}
else
{
$InnerText = trim($ctag->GetInnerText());
}
$this->dtp->Assign($tagid,
$this->GetArcList(
$limitstart,
$row,
$ctag->GetAtt("col"),
$ctag->GetAtt("titlelen"),
$ctag->GetAtt("infolen"),
$ctag->GetAtt("imgwidth"),
$ctag->GetAtt("imgheight"),
$ctag->GetAtt("listtype"),
$ctag->GetAtt("orderby"),
$InnerText,
$ctag->GetAtt("tablewidth"),
$ismake,
$ctag->GetAtt("orderway"),
$ctag->GetAtt("noflag")
)
);
}
else if($ctag->GetName()=="pagelist")
{
$list_len = trim($ctag->GetAtt("listsize"));
$ctag->GetAtt("listitem")=="" ? $listitem="index,pre,pageno,next,end,option" : $listitem=$ctag->GetAtt("listitem");
if($list_len=="")
{
$list_len = 3;
}
if($ismake==0)
{
$this->dtp->Assign($tagid,$this->GetPageListDM($list_len,$listitem));
}
else
{
$this->dtp->Assign($tagid,$this->GetPageListST($list_len,$listitem));
}
}
else if($PageNo!=1 && $ctag->GetName()==&#39;field&#39; && $ctag->GetAtt(&#39;display&#39;)!=&#39;&#39;)
{
$this->dtp->Assign($tagid,&#39;&#39;);
}
}
}
/**
* 获得要创建的文件名称规则
*
* @access public
* @param int $typeid 栏目ID
* @param string $wname
* @param string $typedir 栏目目录
* @param string $defaultname 默认名称
* @param string $namerule2 栏目规则
* @return string
*/
function GetMakeFileRule($typeid,$wname,$typedir,$defaultname,$namerule2)
{
$typedir = MfTypedir($typedir);
if($wname==&#39;index&#39;)
{
return $typedir.&#39;/&#39;.$defaultname;
}
else
{
$namerule2 = str_replace(&#39;{tid}&#39;,$typeid,$namerule2);
$namerule2 = str_replace(&#39;{typedir}&#39;,$typedir,$namerule2);
return $namerule2;
}
}
/**
* 获得一个单列的文档列表
*
* @access public
* @param int $limitstart 限制开始
* @param int $row 行数
* @param int $col 列数
* @param int $titlelen 标题长度
* @param int $infolen 描述长度
* @param int $imgwidth 图片宽度
* @param int $imgheight 图片高度
* @param string $listtype 列表类型
* @param string $orderby 排列顺序
* @param string $innertext 底层模板
* @param string $tablewidth 表格宽度
* @param string $ismake 是否编译
* @param string $orderWay 排序方式
* @return string
*/
function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
$imgall",$orderby="default",$innertext="",$table,$ismake=1,$orderWay=&#39;desc&#39;,$noflag="")
{
global $cfg_list_son,$cfg_digg_update;
if($noflag!="")
{
$noflags = explode(&#39;,&#39;, $noflag);
$noflagsql = &#39;&#39;;
for($i=0;$i { $noflagsql .= "And arc.flag not like &#39;%{$noflags[$i]}%&#39; "; } } else { $noflagsql .= ""; } $typeid=$this->TypeID; if($row==&#39;&#39;) $row = 10; if($limitstart==&#39;&#39;) $limitstart = 0; if($titlelen==&#39;&#39;) $titlelen = 100; if($infolen==&#39;&#39;) $infolen = 250; if($imgwidth==&#39;&#39;) $imgwidth = 120; if($imgheight==&#39;&#39;) $imgheight = 120; if($listtype==&#39;&#39;) $listtype = &#39;all&#39;; if($orderWay==&#39;&#39;) $orderWay = &#39;desc&#39;; if($orderby==&#39;&#39;) { $orderby=&#39;default&#39;; } else { $orderby=strtolower($orderby); } $tablewidth = str_replace(&#39;%&#39;,&#39;&#39;,$tablewidth); if($tablewidth==&#39;&#39;) $tablewidth=100; if($col==&#39;&#39;) $col=1; $colWidth = ceil(100/$col); $tablewidth = $tablewidth.&#39;%&#39;; $colWidth = $colWidth.&#39;%&#39;; $innertext = trim($innertext); if($innertext==&#39;&#39;) { $innertext = GetSysTemplets(&#39;list_fulllist.htm&#39;); } //排序方式 $ordersql = &#39;&#39;; 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 if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; } else { $ordersql=" ORDER BY arc.sortrank $orderWay"; } //获得附加表的相关信息 $addtable = $this->ChannelUnit->ChannelInfos[&#39;addtable&#39;]; if($addtable!="") { $addJoin = " LEFT JOIN `$addtable` ON arc.id = ".$addtable.&#39;.aid &#39;; $addField = &#39;&#39;; $fields = explode(&#39;,&#39;,$this->ChannelUnit->ChannelInfos[&#39;listfields&#39;]); 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[&#39;rename&#39;])) { $addField .= &#39;,&#39;.$addtable.&#39;.&#39;.$k.&#39; as &#39;.$arr[&#39;rename&#39;]; } else { $addField .= &#39;,&#39;.$addtable.&#39;.&#39;.$k; } } } } } else { $addField = &#39;&#39;; $addJoin = &#39;&#39;; } //如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢) if(preg_match(&#39;/hot|click|weight|lastpost/&#39;, $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} $noflagsql $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[&#39;id&#39;]; } $idstr = join(&#39;,&#39;,$ids); if($idstr==&#39;&#39;) { return &#39;&#39;; } 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) $noflagsql $ordersql "; } $t2 = ExecTime(); //echo $t2-$t1; } $this->dsql->SetQuery($query); $this->dsql->Execute(&#39;al&#39;); $t2 = ExecTime(); //echo $t2-$t1; $artlist = &#39;&#39;; $this->dtp2->LoadSource($innertext); $GLOBALS[&#39;autoindex&#39;] = 0; for($i=0;$i<$row;$i++) { if($col>1) { $artlist .= "/r/n"; } }//Loop Line $t3 = ExecTime(); //echo ($t3-$t2); $this->dsql->FreeResult(&#39;al&#39;); return $artlist; } /** * 获取静态的分页列表 * * @access public * @param string $list_len 列表宽度 * @param string $list_len 列表样式 * @return string */ function GetPageListST($list_len,$listitem="index,end,pre,next,pageno") { $prepage = $nextpage = &#39;&#39;; $prepagenum = $this->PageNo-1; $nextpagenum = $this->PageNo+1; if($list_len==&#39;&#39; || preg_match("/[^0-9]/", $list_len)) { $list_len=3; } $totalpage = ceil($this->TotalResult/$this->PageSize); if($totalpage<=1 && $this->TotalResult>0) { return "共 1页".$this->TotalResult."条记录/r/n"; } if($this->TotalResult == 0) { return "共 0页".$this->TotalResult."条记录/r/n"; } $purl = $this->GetCurUrl(); $maininfo = "共 {$totalpage}页".$this->TotalResult."条/r/n"; $tnamerule = $this->GetMakeFileRule($this->Fields[&#39;id&#39;],"list",$this->Fields[&#39;typedir&#39;],$this->Fields[&#39;defaultname&#39;],$this->Fields[&#39;namerule2&#39;]); $tnamerule = preg_replace("/^(.*)///", &#39;&#39;, $tnamerule); //获得上一页和主页的链接 if($this->PageNo != 1) { $prepage.="上一页/r/n"; $indexpage="首页/r/n"; } else { $indexpage="首页/r/n"; } //下一页,未页的链接 if($this->PageNo!=$totalpage && $totalpage>1) { $nextpage.="下一页/r/n"; $endpage="末页/r/n"; } else { $endpage="末页/r/n"; } //option链接 $optiOnlist= &#39;&#39;; $optiOnlen= strlen($totalpage); $optiOnlen= $optionlen*12 + 18; if($optionlen <36) $optiOnlen= 36; if($optionlen > 100) $optiOnlen= 100; $optiOnlist= "/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.= "$j/r/n"; } else { $listdd.="".$j."/r/n"; } } $plist = &#39;&#39;; if(preg_match(&#39;/index/i&#39;, $listitem)) $plist .= $indexpage; if(preg_match(&#39;/pre/i&#39;, $listitem)) $plist .= $prepage; if(preg_match(&#39;/pageno/i&#39;, $listitem)) $plist .= $listdd; if(preg_match(&#39;/next/i&#39;, $listitem)) $plist .= $nextpage; if(preg_match(&#39;/end/i&#39;, $listitem)) $plist .= $endpage; if(preg_match(&#39;/option/i&#39;, $listitem)) $plist .= $optionlist; if(preg_match(&#39;/info/i&#39;, $listitem)) $plist .= $maininfo; return $plist; } /** * 获取动态的分页列表 * * @access public * @param string $list_len 列表宽度 * @param string $list_len 列表样式 * @return string */ function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno") { global $cfg_rewrite; $prepage = $nextpage = &#39;&#39;; $prepagenum = $this->PageNo-1; $nextpagenum = $this->PageNo+1; if($list_len==&#39;&#39; || preg_match("/[^0-9]/", $list_len)) { $list_len=3; } $totalpage = ceil($this->TotalResult/$this->PageSize); if($totalpage<=1 && $this->TotalResult>0) { return "共 1 页/".$this->TotalResult." 条记录/r/n"; } if($this->TotalResult == 0) { return "共 0 页/".$this->TotalResult." 条记录/r/n"; } $maininfo = "共 {$totalpage}页".$this->TotalResult."条/r/n"; $purl = $this->GetCurUrl(); // 如果开启为静态,则对规则进行替换 if($cfg_rewrite == &#39;Y&#39;) { $nowurls = preg_replace("//-/", ".php?", $purl); $nowurls = explode("?", $nowurls); $purl = $nowurls[0]; } $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; $purl .= &#39;?&#39;.$geturl; $optiOnlist= &#39;&#39;; //$hidenform = "TypeID."&#39;>/r/n"; //$hidenform .= "TotalResult."&#39;>/r/n"; //获得上一页和下一页的链接 if($this->PageNo != 1) { $prepage.="上一页/r/n"; $indexpage="首页/r/n"; } else { $indexpage="首页/r/n"; } if($this->PageNo!=$totalpage && $totalpage>1) { $nextpage.="下一页/r/n"; $endpage="末页/r/n"; } else { $endpage="末页/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.= "$j/r/n"; } else { $listdd.="".$j."/r/n"; } } $plist = &#39;&#39;; if(preg_match(&#39;/index/i&#39;, $listitem)) $plist .= $indexpage; if(preg_match(&#39;/pre/i&#39;, $listitem)) $plist .= $prepage; if(preg_match(&#39;/pageno/i&#39;, $listitem)) $plist .= $listdd; if(preg_match(&#39;/next/i&#39;, $listitem)) $plist .= $nextpage; if(preg_match(&#39;/end/i&#39;, $listitem)) $plist .= $endpage; if(preg_match(&#39;/option/i&#39;, $listitem)) $plist .= $optionlist; if(preg_match(&#39;/info/i&#39;, $listitem)) $plist .= $maininfo; if($cfg_rewrite == &#39;Y&#39;) { $plist = str_replace(&#39;.php?tid=&#39;, &#39;-&#39;, $plist); $plist = str_replace(&#39;&TotalResult=&#39;, &#39;-&#39;, $plist); $plist = preg_replace("/&PageNo=(/d+)/i",&#39;-//1.html&#39;,$plist); } return $plist; } /** * 获得当前的页面文件的url * * @access public * @return string */ function GetCurUrl() { if(!empty($_SERVER[&#39;REQUEST_URI&#39;])) { $nowurl = $_SERVER[&#39;REQUEST_URI&#39;]; $nowurls = explode(&#39;?&#39;, $nowurl); $nowurl = $nowurls[0]; } else { $nowurl = $_SERVER[&#39;PHP_SELF&#39;]; } return $nowurl; } }//End Class 关于如何进行dedecms 列表页支持noflag属性的分析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。