Templet = $templet;
$this->Tag = $keyword;
$this->dsql = $dsql;
$this->dtp = new DedeTagParse();
$this->dtp->SetRefObj($this);
$this->dtp->SetNameSpace("dede", "{", "}");
$this->dtp2 = new DedeTagParse();
$this->dtp2->SetNameSpace("field", "[", "]");
$this->TypeLink = new TypeLink(0);
$this->Fields['tag'] = $keyword;
if (empty($keyword)) {
$this->Fields['title'] = "TAGS列表";
} else {
$this->Fields['title'] = $keyword;
}
$this->TempletsFile = '';
//设置一些全局参数的值
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
//读取Tag信息
if ($this->Tag != '') {
$this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where tag like '{$this->Tag}' ");
if (!is_array($this->TagInfos)) {
$fullsearch = $GLOBALS['cfg_phpurl'] . "/search.php?keyword=" . $this->Tag . "&searchtype=titlekeyword";
$msg = "系统无此标签,可能已经移除!
你还可以尝试通过搜索程序去搜索这个关键字:前往搜索>>";
ShowMsg($msg, "-1");
exit();
}
}
//初始化模板
$tempfile = $GLOBALS['cfg_basedir'] . $GLOBALS['cfg_templets_dir'] . "/" . $GLOBALS['cfg_df_style'] . '/' . $this->Templet;
if (!file_exists($tempfile) || !is_file($tempfile)) {
echo "模板文件不存在,无法解析文档!";
exit();
}
$this->dtp->LoadTemplate($tempfile);
$this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
}
//php4构造函数
function TagList($keyword, $templet)
{
$this->__construct($keyword, $templet);
}
//关闭相关资源
function Close()
{
@$this->dsql->Close();
@$this->TypeLink->Close();
}
/**
* 统计列表里的记录
*
* @access private
* @return void
*/
function CountRecord()
{
//统计数据库记录
$this->TotalResult = -1;
if (isset($GLOBALS['TotalResult'])) {
$this->TotalResult = $GLOBALS['TotalResult'];
}
if (isset($GLOBALS['PageNo'])) {
$this->PageNo = intval($GLOBALS['PageNo']);
} else {
$this->PageNo = 1;
}
if ($this->TotalResult == -1) {
$cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
$row = $this->dsql->GetOne($cquery);
$this->TotalResult = $row['dd'];
//更新Tag信息
$ntime = time();
//更新浏览量和记录数
$upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
$this->dsql->ExecuteNoneQuery($upquery);
$oneday = 24 * 3600;
//周统计
if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
$this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
}
//月统计
if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
$this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
}
}
$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);
}
/**
* 显示列表
*
* @access public
* @return void
*/
function Display()
{
$makeDir = empty($this->Tag) ? $this->GetTruePath() . "/a/tags/index.html" : $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/index.html";
if (file_exists($makeDir)) {
header('HTTP/1.1 301 Moved Permanently');
if (!empty($this->Tag)) {
header('Location:a/tags/' . GetPinyin($this->Tag) . "/");
} else {
header('Location:a/tags/');
}
exit;
}
if ($this->Tag != '') {
$this->CountRecord();
}
$this->ParseTempletsFirst();
if ($this->Tag != '') {
$this->ParseDMFields($this->PageNo, 0);
}
$this->Close();
$this->dtp->Display();
}
/**
* 解析模板,对固定的标记进行初始给值
*
* @access private
* @return void
*/
function ParseTempletsFirst()
{
MakeOneTag($this->dtp, $this);
}
/**
* 解析模板,对内容里的变动进行赋值
*
* @access public
* @param int $PageNo 页码
* @param int $ismake 是否编译
* @return string
*/
function ParseDMFields($PageNo, $ismake = 1)
{
foreach ($this->dtp->CTags as $tagid => $ctag) {
if ($ctag->GetName() == "list") {
$limitstart = (intval($this->PageNo) - 1) * $this->PageSize;
if ($limitstart < 0) {
$limitstart = 0;
}
$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")
)
);
} 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;
}
// var_dump($ismake);
if ($ismake == 0) {
$this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
} else {
$this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
}
}
}
}
/**
* 获得一个单列的文档列表
*
* @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,
$imgwidth = 120,
$imgheight = 90,
$listtype = "all",
$orderby = "default",
$innertext = "",
$tablewidth = "100",
$ismake = 1,
$orderWay = 'desc'
) {
$getrow = ($row == '' ? 10 : $row);
if ($limitstart == '') $limitstart = 0;
if ($titlelen == '') $titlelen = 100;
if ($infolen == '') $infolen = 250;
if ($imgwidth == '') $imgwidth = 120;
if ($imgheight == '') $imgheight = 120;
if ($listtype == '') $listtype = 'all';
$orderby = ($orderby == '' ? 'default' : 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");
$idlists = $ordersql = '';
$this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT $limitstart,$getrow");
$this->dsql->Execute();
while ($row = $this->dsql->GetArray()) {
$idlists .= ($idlists == '' ? $row['aid'] : ',' . $row['aid']);
}
if ($idlists == '') return '';
//按不同情况设定SQL条件
$orwhere = " se.id IN($idlists) ";
//排序方式
if ($orderby == "sortrank") {
$ordersql = " ORDER BY se.sortrank $orderWay";
} else {
$ordersql = " ORDER BY se.id $orderWay";
}
$query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
FROM `#@__archives` se LEFT JOIN `#@__arctype` tp ON se.typeid=tp.id WHERE $orwhere $ordersql ";
$this->dsql->SetQuery($query);
$this->dsql->Execute('al');
$row = $this->PageSize / $col;
$artlist = '';
$this->dtp2->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
for ($i = 0; $i < $row; $i++) {
if ($col > 1) {
$artlist .= "