📄 arc.specview.class.php
字号:
<?php
if(!defined('DEDEINC'))
{
exit("Request Error!");
}
require_once(DEDEINC."/typelink.class.php");
require_once(DEDEINC."/channelunit.class.php");
@set_time_limit(0);
class SpecView
{
var $dsql;
var $dtp;
var $dtp2;
var $TypeID;
var $TypeLink;
var $PageNo;
var $TotalPage;
var $TotalResult;
var $PageSize;
var $ChannelUnit;
var $ListType;
var $TempInfos;
var $Fields;
var $StartTime;
//php5构造函数
function __construct($starttime=0)
{
$this->TypeID = 0;
$this->dsql = $GLOBALS['dsql'];
$this->dtp = new DedeTagParse();
$this->dtp->refObj = $this;
$this->dtp->SetNameSpace("dede","{","}");
$this->dtp2 = new DedeTagParse();
$this->dtp2->SetNameSpace("field","[","]");
$this->TypeLink = new TypeLink(0);
$this->ChannelUnit = new ChannelUnit(-1);
//设置一些全局参数的值
foreach($GLOBALS['PubFields'] as $k=>$v)
{
$this->Fields[$k] = $v;
}
if($starttime==0)
{
$this->StartTime = 0;
}
else
{
$this->StartTime = GetMkTime($starttime);
}
$this->CountRecord();
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_spec.htm";
if(!file_exists($tempfile)||!is_file($tempfile))
{
echo "模板文件不存在,无法解析文档!";
exit();
}
$this->dtp->LoadTemplate($tempfile);
$this->TempInfos['tags'] = $this->dtp->CTags;
$this->TempInfos['source'] = $this->dtp->SourceString;
$ctag = $this->dtp->GetTag("page");
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);
}
//php4构造函数
function SpecView($starttime=0)
{
$this->__construct($starttime);
}
//关闭相关资源
function Close()
{
}
//统计列表里的记录
function CountRecord()
{
$this->TotalResult = -1;
if(isset($GLOBALS['TotalResult']))
{
$this->TotalResult = $GLOBALS['TotalResult'];
}
if(isset($GLOBALS['PageNo']))
{
$this->PageNo = $GLOBALS['PageNo'];
}
else
{
$this->PageNo = 1;
}
if($this->TotalResult==-1)
{
if($this->StartTime>0)
{
$timesql = " And #@__archives.senddate>'".$this->StartTime."'";
}
else
{
$timesql = "";
}
$row = $this->dsql->GetOne("Select count(*) as dd From #@__archives where #@__archives.arcrank > -1 And channel=-1 $timesql");
if(is_array($row))
{
$this->TotalResult = $row['dd'];
}
else
{
$this->TotalResult = 0;
}
}
}
//显示列表
function Display()
{
if($this->TypeLink->TypeInfos['ispart']==1
||$this->TypeLink->TypeInfos['ispart']==2)
{
$this->DisplayPartTemplets();
}
$this->ParseTempletsFirst();
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"))
);
}
else if($ctag->GetName()=="pagelist")
{
$list_len = trim($ctag->GetAtt("listsize"));
if($list_len=="")
{
$list_len = 3;
}
$this->dtp->Assign($tagid,$this->GetPageListDM($list_len));
}
}
$this->dtp->Display();
}
//开始创建列表
function MakeHtml()
{
//初步给固定值的标记赋值
$this->ParseTempletsFirst();
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpage==0)
{
$totalpage = 1;
}
CreateDir($GLOBALS['cfg_special']);
$murl = "";
for($this->PageNo=1;$this->PageNo<=$totalpage;$this->PageNo++)
{
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("spec_list.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"),
"spec",
$ctag->GetAtt("orderby"),
$InnerText,
$ctag->GetAtt("tablewidth"))
);
}
else if($ctag->GetName()=="pagelist")
{
$list_len = trim($ctag->GetAtt("listsize"));
if($list_len=="")
{
$list_len = 3;
}
$this->dtp->Assign($tagid,$this->GetPageListST($list_len));
}
}//End foreach
$makeFile = $GLOBALS['cfg_special']."/spec_".$this->PageNo.$GLOBALS['art_shortname'];
$murl = $makeFile;
$makeFile = $GLOBALS['cfg_basedir'].$makeFile;
$this->dtp->SaveTo($makeFile);
echo "成功创建:$murl<br/>";
}
copy($GLOBALS['cfg_basedir'].$GLOBALS['cfg_special']."/spec_1".$GLOBALS['art_shortname'],$GLOBALS['cfg_basedir'].$GLOBALS['cfg_special']."/index.html");
$murl = $GLOBALS['cfg_special']."/index.html";
return $murl;
}
//解析模板,对固定的标记进行初始给值
function ParseTempletsFirst()
{
MakeOneTag($this->dtp,$this);
}
//获取内容列表
function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100")
{
$typeid=$this->TypeID;
if($row=="")
{
$row = 10;
}
if($limitstart=="")
{
$limitstart = 0;
}
if($titlelen=="")
{
$titlelen = 30;
}
if($infolen=="")
{
$infolen = 250;
}
if($imgwidth=="")
{
$imgwidth = 120;
}
if($imgheight=="")
{
$imgheight = 120;
}
if($listtype=="")
{
$listtype = "all";
}
if($orderby=="")
{
$orderby="default";
}
else
{
$orderby=strtolower($orderby);
}
$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("spec_list.htm");
}
//按不同情况设定SQL条件
$orwhere = " arc.arcrank > -1 And arc.channel = -1 ";
if($this->StartTime>0)
{
$orwhere .= " And arc.senddate>'".$this->StartTime."'";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -