📄 inc_digglist_view.php
字号:
<?php
require_once(dirname(__FILE__)."/inc_arcpart_view.php");
require_once(dirname(__FILE__)."/inc_pubtag_make.php");
/******************************************************
//Copyright 2004-2006 by DedeCms.com itprato
//本类的用途是用于浏览频道列表或对内容列表生成HTML
******************************************************/
@set_time_limit(0);
class DiggList
{
var $dsql;
var $dtp;
var $dtp2;
var $TypeID;
var $TypeLink;
var $PageNo;
var $TotalPage;
var $TotalResult;
var $PageSize;
var $ListType;
var $Fields;
var $PartView;
var $SortType;
var $NameRule;
var $TempletsFile;
//-------------------------------
//php5构造函数
//-------------------------------
function __construct($typeid=0,$sorttype='time')
{
global $dsql;
$this->SortType = $sorttype;
$this->TypeID = $typeid;
$this->TempletsFile = '';
$this->NameRule = $GLOBALS['cfg_cmspath']."/digg/digg-{page}.html";
$this->dsql = new DedeSql(false);
$this->dtp = new DedeTagParse();
$this->dtp->SetNameSpace("dede","{","}");
$this->dtp2 = new DedeTagParse();
$this->dtp2->SetNameSpace("field","[","]");
$this->TypeLink = new TypeLink($typeid);
$this->Fields = $this->TypeLink->TypeInfos;
$this->Fields['id'] = $typeid;
$this->Fields['position'] = ' DIGG顶客 > ';
$this->Fields['title'] = " DIGG顶客 ";
//设置一些全局参数的值
foreach($GLOBALS['PubFields'] as $k=>$v) $this->Fields[$k] = $v;
$this->Fields['rsslink'] = "";
$this->PartView = new PartView($typeid);
}
//php4构造函数
//---------------------------
function DiggList($typeid=0,$sorttype='time'){
$this->__construct($typeid,$sorttype);
}
//---------------------------
//关闭相关资源
//---------------------------
function Close()
{
@$this->dsql->Close();
@$this->dsql = '';
@$this->TypeLink->Close();
@$this->PartView->Close();
}
//------------------
//统计列表里的记录
//------------------
function CountRecord()
{
global $cfg_list_son;
//统计数据库记录
$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)
{
$addSql = " arcrank > -1 ";
$cquery = "Select count(*) as dd From `#@__full_search` where $addSql";
$row = $this->dsql->GetOne($cquery);
if(is_array($row)) $this->TotalResult = $row['dd'];
else $this->TotalResult = 0;
}
//初始化列表模板,并统计页面总数
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style'].'/digg.htm';
if(!file_exists($tempfile)||!is_file($tempfile)){
echo "模板文件:'".$tempfile."' 不存在,无法解析文档!";
exit();
}
$this->dtp->LoadTemplate($tempfile);
$this->TempletsFile = ereg_replace("^".$GLOBALS['cfg_basedir'],'',$tempfile);
$ctag = $this->dtp->GetTag("page");
if(!is_object($ctag)){ $ctag = $this->dtp->GetTag("list"); }
if(!is_object($ctag)) $this->PageSize = 25;
else{
if($ctag->GetAtt("pagesize")!="") $this->PageSize = $ctag->GetAtt("pagesize");
else $this->PageSize = 25;
}
$this->TotalPage = ceil($this->TotalResult/$this->PageSize);
}
//------------------
//列表创建HTML
//------------------
function MakeHtml($startpage=1,$makepagesize=0)
{
if(empty($startpage)) $startpage = 1;
$this->CountRecord();
//初步给固定值的标记赋值
$this->ParseTempletsFirst();
CreateDir('/digg','','');
$murl = "";
if($makepagesize>0) $endpage = $startpage+$makepagesize;
else $endpage = ($this->TotalPage+1);
if($endpage>($this->TotalPage+1)) $endpage = $this->TotalPage;
//循环更新HTML
for($this->PageNo=$startpage;$this->PageNo<$endpage;$this->PageNo++)
{
$this->ParseDMFields($this->PageNo,1);
$makeFile = $this->NameRule;
$makeFile = str_replace("{page}",$this->PageNo,$makeFile);
$murl = $makeFile;
$makeFile = $this->GetTruePath().$makeFile;
$makeFile = ereg_replace("/{1,}","/",$makeFile);
$murl = $this->GetTrueUrl($murl);
$this->dtp->SaveTo($makeFile);
echo "成功创建:<a href='$murl' target='_blank'>$murl</a><br/>";
}
$this->Close();
return $murl;
}
//------------------
//显示列表
//------------------
function Display()
{
$this->CountRecord();
$this->ParseTempletsFirst();
$this->ParseDMFields($this->PageNo,0);
$this->Close();
$this->dtp->Display();
}
//----------------------------
//获得站点的真实根路径
//----------------------------
function GetTruePath(){
$truepath = $GLOBALS["cfg_basedir"];
return $truepath;
}
//----------------------------
//获得真实连接路径
//----------------------------
function GetTrueUrl($nurl){
if($this->Fields['moresite']==1){ $nurl = ereg_replace("/$","",$this->Fields['siteurl']).$nurl; }
return $nurl;
}
//--------------------------------
//解析模板,对固定的标记进行初始给值
//--------------------------------
function ParseTempletsFirst()
{
//对公用标记的解析,这里对对象的调用均是用引用调用的,因此运算后会自动改变传递的对象的值
MakePublicTag($this,$this->dtp,$this->PartView,$this->TypeLink,$this->TypeID,0,0);
}
//--------------------------------
//解析模板,对内容里的变动进行赋值
//--------------------------------
function ParseDMFields($PageNo,$ismake=1)
{
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_digglist.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"),
$this->SortType,
$InnerText,
$ctag->GetAtt("tablewidth"),
$ismake,
$ctag->GetAtt("orderway")
)
);
}
else if($ctag->GetName()=="pagelist"){
$list_len = trim($ctag->GetAtt("listsize"));
$ctag->GetAtt("listitem")=="" ? $listitem="info,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));
}
}
}
//----------------------------------
//获得一个单列的文档列表
//---------------------------------
function GetArcList($limitstart=0,$row=10,$col=1,$titlelen=30,$infolen=250,
$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$innertext="",$tablewidth="100",$ismake=1,$orderWay='desc')
{
global $cfg_list_son;
$t1 = ExecTime();
$typeid=$this->TypeID;
if($row=="") $row = 10;
if($limitstart=="") $limitstart = 0;
if($titlelen=="") $titlelen = 100;
if($infolen=="") $infolen = 250;
if($imgwidth=="") $imgwidth = 120;
if($imgheight=="") $imgheight = 120;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -