Browse Source

TAG支持静态化简单支持

tags/6.0.0
tianya 3 years ago
parent
commit
ed53f461dd
8 changed files with 577 additions and 302 deletions
  1. +1
    -0
      src/dede/inc/inc_menu.php
  2. +1
    -1
      src/dede/makehtml_list_action.php
  3. +14
    -0
      src/dede/makehtml_taglist.php
  4. +83
    -0
      src/dede/makehtml_taglist_action.php
  5. +87
    -0
      src/dede/templets/makehtml_taglist.htm
  6. +351
    -252
      src/include/arc.taglist.class.php
  7. +1
    -1
      src/include/inc/inc_fun_funAdmin.php
  8. +39
    -48
      src/include/taglib/tag.lib.php

+ 1
- 0
src/dede/inc/inc_menu.php View File

@@ -147,6 +147,7 @@ $adminMenu1
<m:item name='更新RSS文件' link='makehtml_rss.php' rank='sys_MakeHtml' target='main' />
<m:item name='获取JS文件' link='makehtml_js.php' rank='sys_MakeHtml' target='main' />
<m:item name='更新专题HTML' link='makehtml_spec.php' rank='sys_MakeHtml' target='main' />
<m:item name='更新TAG HTML' link='makehtml_taglist.php' rank='sys_MakeHtml' target='main' />
</m:top>
<m:top item='6_' name='会员管理' display='none' rank='member_List,member_Type'>


+ 1
- 1
src/dede/makehtml_list_action.php View File

@@ -84,7 +84,7 @@ if(!empty($tid))
{
if(!isset($cfg_Cs[$tid]))
{
showmsg('没有该栏目数据, 可能缓存文件(/data/cache/inc_catalog_base.inc)没有更新, 请检查是否有写入权限');
ShowMsg('没有该栏目数据, 可能缓存文件(/data/cache/inc_catalog_base.inc)没有更新, 请检查是否有写入权限','javascript:;');
exit();
}
if($cfg_Cs[$tid][1]>0)


+ 14
- 0
src/dede/makehtml_taglist.php View File

@@ -0,0 +1,14 @@
<?php
/**
* 生成Tag
*
* @version $Id: makehtml_taglist.php 1 11:17 2020年8月19日Z tianya $
* @package DedeCMS.Administrator
* @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(dirname(__FILE__)."/config.php");
include DedeInclude('templets/makehtml_taglist.htm');

?>

+ 83
- 0
src/dede/makehtml_taglist_action.php View File

@@ -0,0 +1,83 @@
<?php

/**
* 生成Tag操作
*
* @version $Id: makehtml_taglist_action.php 1 11:17 2020年8月19日Z tianya $
* @package DedeCMS.Administrator
* @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(dirname(__FILE__) . "/config.php");
CheckPurview('sys_MakeHtml');
require_once(DEDEINC . "/arc.taglist.class.php");

if (empty($total)) $total = 0; // TAGS总数
if (empty($pageno)) $pageno = 0;
if (empty($mkpage)) $mkpage = 1;
if (empty($offset)) $offset = 0; // 当前位置
if (empty($maxpagesize)) $maxpagesize = 50;
$tagid = isset($tagid) ? intval($tagid) : 0;

if ($total == 0 && $tagid == 0) {
$total = $dsql->GetOne("SELECT count(*) as dd FROM `#@__tagindex`");
$total = intval($total['dd']);
}

$allfinish = false;

if ($offset < ($total - 1)) {
$tt = $dsql->GetOne("SELECT * FROM `#@__tagindex` LIMIT " . $offset . ",1;");
$tagid = $tt['id'];
$offset++;
} else {
$allfinish = true;
}

$tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$tagid' LIMIT 0,1;");

MkdirAll($cfg_basedir . "/a/tags", $cfg_dir_purview);

if (is_array($tag) && count($tag) > 0) {
$dlist = new TagList($tag['tag'], 'taglist.htm');
$dlist->CountRecord();
$ntotalpage = $dlist->TotalPage;

if ($ntotalpage <= $maxpagesize) {
$dlist->MakeHtml('', '');
$finishType = TRUE;
} else {
$reurl = $dlist->MakeHtml($mkpage, $maxpagesize);
$finishType = FALSE;
$mkpage = $mkpage + $maxpagesize;
if ($mkpage >= ($ntotalpage + 1)) $finishType = TRUE;
}

$nextpage = $pageno + 1;
if ($nextpage >= $ntotalpage && $finishType && !($offset < ($total - 1))) {
$dlist = new TagList('', 'tag.htm');
$dlist->MakeHtml(1, 10);
$reurl = '../a/tags/';
if ($total > 0) {
ShowMsg("完成TAG更新!<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
} else {
$reurl .= GetPinyin($tag['tag']);
ShowMsg("完成TAG更新:[" . $tag['tag'] . "]!<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
}
exit();
} else {
if ($finishType) {
if ($allfinish == true) {
$total = 0;
}
$gourl = "makehtml_taglist_action.php?maxpagesize=$maxpagesize&tagid=$tagid&pageno=$nextpage&total=$total&offset=$offset";
ShowMsg("成功生成TAG:[" . $tag['tag'] . "],继续进行操作!", $gourl, 0, 100);
exit();
} else {
$gourl = "makehtml_taglist_action.php?mkpage=$mkpage&maxpagesize=$maxpagesize&tagid=$tagid&pageno=$pageno&total=$total&offset=$offset";
ShowMsg("成功生成TAG:[" . $tag['tag'] . "],继续进行操作...", $gourl, 0, 100);
exit();
}
}
}

+ 87
- 0
src/dede/templets/makehtml_taglist.htm View File

@@ -0,0 +1,87 @@
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<title>更新TAG HTML</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
</head>

<body background='images/allbg.gif' leftmargin='8' topmargin='8'>
<table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D1DDAA" align="center">
<form name="form1" action="makehtml_tag_action_list.php" method="get" target='stafrm'>
<tr>
<td height="28" colspan="2" background='images/tbg.gif'>
<table width="98%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" height="18"><strong>更新TAG HTML</strong> </td>
<td width="70%" align="right">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="300" valign="top" bgcolor="#FFFFFF">选择TAG:</td>
<td width="377" valign="top" bgcolor="#FFFFFF">
<?php
$sql="select * from #@__tagindex order by tag asc";
$dsql->Execute('al',$sql);
echo "<select name='tagid' style='width:300px'>\r\n";
echo "<option value='0' selected='1'>更新所有TAG...</option>\r\n";
while($row=$dsql->GetObject('al')){
echo "<option value='".$row->id."'>".$row->tag."</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td height="20" valign="top" bgcolor="#FFFFFF">每次最大创建页数:</td>
<td height="20" valign="top" bgcolor="#FFFFFF"><input name="maxpagesize" type="text" id="maxpagesize" value="50"
size="10">
个文件 </td>
</tr>
<tr>
<td height="20" valign="top" bgcolor="#FFFFFF">说明:</td>
<td height="20" valign="top" bgcolor="#FFFFFF">
* TAG首页模板文件:<?php echo $cfg_templets_dir;?>/<?php echo $cfg_df_style?>/tag.htm<br>
* TAG列表页模板文件:<?php echo $cfg_templets_dir;?>/<?php echo $cfg_df_style?>/taglist.htm<br>
生成静态文件后,访问动态文件则直接跳转到静态文件,如果需要动态访问,删除对应文件即可。
</td>
</tr>
<tr>
<td height="20" colspan="2" bgcolor="#FAFAF1" align="center">
<input name="b112" type="button" class="coolbg np" value="生成TAG HTML"
onClick="document.form1.action='makehtml_taglist_action.php';document.form1.submit();" style="width:120px">
</td>
</tr>
</form>
<tr bgcolor="#F9FCEF">
<td height="20" colspan="2">
<table width="100%">
<tr>
<td width="74%">进行状态: </td>
<td width="26%" align="right">
<script language='javascript'>
function ResizeDiv(obj, ty) {
if (ty == "+") document.all[obj].style.pixelHeight += 50;
else if (document.all[obj].style.pixelHeight > 80) document.all[obj].style.pixelHeight = document.all[obj].style.pixelHeight - 50;
}
</script>
[<a href='#' onClick="ResizeDiv('mdv','+');">增大</a>] [<a href='#' onClick="ResizeDiv('mdv','-');">缩小</a>]
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" id="mtd">
<div id='mdv' style='width:100%;height:350px;'>
<iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe>
</div>
</td>
</tr>
</table>
</body>

</html>

+ 351
- 252
src/include/arc.taglist.class.php View File

@@ -1,4 +1,4 @@
<?php if(!defined('DEDEINC')) exit('Request Error!');
<?php if (!defined('DEDEINC')) exit('Request Error!');
/**
* Tag列表类
*
@@ -8,9 +8,9 @@
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(DEDEINC.'/channelunit.class.php');
require_once(DEDEINC.'/typelink.class.php');
require_once(DEDEINC . '/channelunit.class.php');
require_once(DEDEINC . '/typelink.class.php');
@set_time_limit(0);
/**
@@ -53,46 +53,47 @@ class TagList
$this->dsql = $dsql;
$this->dtp = new DedeTagParse();
$this->dtp->SetRefObj($this);
$this->dtp->SetNameSpace("dede","{","}");
$this->dtp->SetNameSpace("dede", "{", "}");
$this->dtp2 = new DedeTagParse();
$this->dtp2->SetNameSpace("field","[","]");
$this->dtp2->SetNameSpace("field", "[", "]");
$this->TypeLink = new TypeLink(0);
$this->Fields['tag'] = $keyword;
$this->Fields['title'] = $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;
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
//读取Tag信息
if($this->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";
if (!is_array($this->TagInfos)) {
$fullsearch = $GLOBALS['cfg_phpurl'] . "/search.php?keyword=" . $this->Tag . "&searchtype=titlekeyword";
$msg = "系统无此标签,可能已经移除!<br /><br />你还可以尝试通过搜索程序去搜索这个关键字:<a href='$fullsearch'>前往搜索&gt;&gt;</a>";
ShowMsg($msg,"-1");
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))
{
$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);
$this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
}
//php4构造函数
function TagList($keyword,$templet)
function TagList($keyword, $templet)
{
$this->__construct($keyword,$templet);
$this->__construct($keyword, $templet);
}
//关闭相关资源
@@ -112,20 +113,15 @@ class TagList
{
//统计数据库记录
$this->TotalResult = -1;
if(isset($GLOBALS['TotalResult']))
{
if (isset($GLOBALS['TotalResult'])) {
$this->TotalResult = $GLOBALS['TotalResult'];
}
if(isset($GLOBALS['PageNo']))
{
$this->PageNo = $GLOBALS['PageNo'];
}
else
{
if (isset($GLOBALS['PageNo'])) {
$this->PageNo = intval($GLOBALS['PageNo']);
} else {
$this->PageNo = 1;
}
if($this->TotalResult==-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'];
@@ -139,38 +135,29 @@ class TagList
$oneday = 24 * 3600;
//周统计
if(ceil( ($ntime - $this->TagInfos['weekup'])/$oneday ) > 7)
{
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)
{
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))
{
if (!is_object($ctag)) {
$ctag = $this->dtp->GetTag("list");
}
if(!is_object($ctag))
{
if (!is_object($ctag)) {
$this->PageSize = 25;
}
else
{
if($ctag->GetAtt("pagesize")!='')
{
} else {
if ($ctag->GetAtt("pagesize") != '') {
$this->PageSize = $ctag->GetAtt("pagesize");
}
else
{
} else {
$this->PageSize = 25;
}
}
$this->TotalPage = ceil($this->TotalResult/$this->PageSize);
$this->TotalPage = ceil($this->TotalResult / $this->PageSize);
}
/**
@@ -181,14 +168,20 @@ class TagList
*/
function Display()
{
if($this->Tag!='')
{
$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');
header('Location:a/tags/' . GetPinyin($this->Tag) . "/");
exit;
}
if ($this->Tag != '') {
$this->CountRecord();
}
$this->ParseTempletsFirst();
if($this->Tag!='')
{
$this->ParseDMFields($this->PageNo,0);
if ($this->Tag != '') {
$this->ParseDMFields($this->PageNo, 0);
}
$this->Close();
$this->dtp->Display();
@@ -202,7 +195,7 @@ class TagList
*/
function ParseTempletsFirst()
{
MakeOneTag($this->dtp,$this);
MakeOneTag($this->dtp, $this);
}
/**
@@ -213,58 +206,49 @@ class TagList
* @param int $ismake 是否编译
* @return string
*/
function ParseDMFields($PageNo, $ismake=1)
function ParseDMFields($PageNo, $ismake = 1)
{
foreach($this->dtp->CTags as $tagid=>$ctag){
if($ctag->GetName()=="list")
{
$limitstart = ($this->PageNo-1) * $this->PageSize;
if($limitstart<0)
{
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())=="")
{
if (trim($ctag->GetInnerText()) == "") {
$InnerText = GetSysTemplets("list_fulllist.htm");
}
else
{
} 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")
)
$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")
{
} 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=="")
{
$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));
// 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));
}
}
}
@@ -289,46 +273,54 @@ class TagList
* @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';
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."%";
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");
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']);
while ($row = $this->dsql->GetArray()) {
$idlists .= ($idlists == '' ? $row['aid'] : ',' . $row['aid']);
}
if($idlists=='') return '';
if ($idlists == '') return '';
//按不同情况设定SQL条件
$orwhere = " se.id IN($idlists) ";
//排序方式
if($orderby=="sortrank")
{
if ($orderby == "sortrank") {
$ordersql = " ORDER BY se.sortrank $orderWay";
}
else
{
$ordersql=" ORDER BY se.id $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 ";
@@ -339,88 +331,91 @@ class TagList
$artlist = '';
$this->dtp2->LoadSource($innertext);
$GLOBALS['autoindex'] = 0;
for($i=0; $i<$row; $i++)
{
if($col > 1)
{
for ($i = 0; $i < $row; $i++) {
if ($col > 1) {
$artlist .= "<div>\r\n";
}
for($j=0; $j<$col; $j++)
{
if($row = $this->dsql->GetArray("al"))
{
for ($j = 0; $j < $col; $j++) {
if ($row = $this->dsql->GetArray("al")) {
$GLOBALS['autoindex']++;
$ids[$row['id']] = $row['id'];
//处理一些特殊字段
$row['infos'] = cn_substr($row['description'],$infolen);
$row['infos'] = cn_substr($row['description'], $infolen);
$row['id'] = $row['id'];
$row['arcurl'] = GetFileUrl($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'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'],
$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
if($row['litpic'] == '-' || $row['litpic'] == '')
{
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/defaultpic.gif';
$row['arcurl'] = GetFileUrl(
$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'],
MfTypedir($row['typedir']),
$row['isdefault'],
$row['defaultname'],
$row['ispart'],
$row['namerule2'],
$row['moresite'],
$row['siteurl'],
$row['sitepath']
);
if ($row['litpic'] == '-' || $row['litpic'] == '') {
$row['litpic'] = $GLOBALS['cfg_cmspath'] . '/static/defaultpic.gif';
}
if(!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y')
{
$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
$row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
}
$row['picname'] = $row['litpic'];
$row['stime'] = GetDateMK($row['pubdate']);
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".preg_replace("/['><]/", "", $row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
$row['image'] = "<img src='" . $row['picname'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . preg_replace("/['><]/", "", $row['title']) . "'>";
$row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'],$titlelen);
if($row['color']!='')
{
$row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
$row['title'] = cn_substr($row['title'], $titlelen);
if ($row['color'] != '') {
$row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
}
if(preg_match('/c/', $row['flag']))
{
$row['title'] = "<b>".$row['title']."</b>";
if (preg_match('/c/', $row['flag'])) {
$row['title'] = "<b>" . $row['title'] . "</b>";
}
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
$row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
if(is_array($this->dtp2->CTags))
{
foreach($this->dtp2->CTags as $k=>$ctag)
{
if($ctag->GetName()=='array')
{
if (is_array($this->dtp2->CTags)) {
foreach ($this->dtp2->CTags as $k => $ctag) {
if ($ctag->GetName() == 'array') {
//传递整个数组,在runphp模式中有特殊作用
$this->dtp2->Assign($k,$row);
}
else
{
if(isset($row[$ctag->GetName()]))
{
$this->dtp2->Assign($k,$row[$ctag->GetName()]);
}
else
{
$this->dtp2->Assign($k,'');
$this->dtp2->Assign($k, $row);
} else {
if (isset($row[$ctag->GetName()])) {
$this->dtp2->Assign($k, $row[$ctag->GetName()]);
} else {
$this->dtp2->Assign($k, '');
}
}
}
}
$artlist .= $this->dtp2->GetResult();
}//if hasRow
} //if hasRow
}//Loop Col
} //Loop Col
if($col>1)
{
if ($col > 1) {
$i += $col - 1;
$artlist .= " </div>\r\n";
}
}//Loop Line
} //Loop Line
$this->dsql->FreeResult('al');
return $artlist;
@@ -434,108 +429,215 @@ class TagList
* @param string $listitem 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno")
function GetPageListDM($list_len, $listitem = "info,index,end,pre,next,pageno")
{
$prepage="";
$nextpage="";
$prepage = "";
$nextpage = "";
$prepagenum = $this->PageNo - 1;
$nextpagenum = $this->PageNo + 1;
if($list_len == "" || preg_match("/[^0-9]/", $list_len))
{
if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
$list_len = 3;
}
$totalpage = $this->TotalPage;
if($totalpage <= 1 && $this->TotalResult > 0)
{
return "<span class=\"pageinfo\">共1页/".$this->TotalResult."条</span>";
if ($totalpage <= 1 && $this->TotalResult > 0) {
return "<span class=\"pageinfo\">共1页/" . $this->TotalResult . "条</span>";
}
if($this->TotalResult == 0)
{
return "<span class=\"pageinfo\">共0页/".$this->TotalResult."条</span>";
if ($this->TotalResult == 0) {
return "<span class=\"pageinfo\">共0页/" . $this->TotalResult . "条</span>";
}
$maininfo = "<span class=\"pageinfo\">共{$totalpage}页/".$this->TotalResult."条</span>\r\n";
$maininfo = "<span class=\"pageinfo\">共{$totalpage}页/" . $this->TotalResult . "条</span>\r\n";
$purl = $this->GetCurUrl();
$purl .= "?/".urlencode($this->Tag);
$purl .= "?/" . urlencode($this->Tag);
//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="<li><a href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
$indexpage="<li><a href='".$purl."/1/'>首页</a></li>\r\n";
if ($this->PageNo != 1) {
$prepage .= "<li><a href='" . $purl . "/$prepagenum/'>上一页</a></li>\r\n";
$indexpage = "<li><a href='" . $purl . "/1/'>首页</a></li>\r\n";
} else {
$indexpage = "<li><a>首页</a></li>\r\n";
}
if ($this->PageNo != $totalpage && $totalpage > 1) {
$nextpage .= "<li><a href='" . $purl . "/$nextpagenum/'>下一页</a></li>\r\n";
$endpage = "<li><a href='" . $purl . "/$totalpage/'>末页</a></li>\r\n";
} else {
$endpage = "<li><a>末页</a></li>\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 .= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
} else {
$listdd .= "<li><a href='" . $purl . "/$j/'>" . $j . "</a></li>\r\n";
}
}
$plist = '';
if (preg_match('/info/i', $listitem)) {
$plist .= $maininfo . ' ';
}
if (preg_match('/index/i', $listitem)) {
$plist .= $indexpage . ' ';
}
if (preg_match('/pre/i', $listitem)) {
$plist .= $prepage . ' ';
}
else
{
$indexpage="<li><a>首页</a></li>\r\n";
if (preg_match('/pageno/i', $listitem)) {
$plist .= $listdd . ' ';
}
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<li><a href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
$endpage="<li><a href='".$purl."/$totalpage/'>末页</a></li>\r\n";
if (preg_match('/next/i', $listitem)) {
$plist .= $nextpage . ' ';
}
else
{
$endpage="<li><a>末页</a></li>\r\n";
if (preg_match('/end/i', $listitem)) {
$plist .= $endpage . ' ';
}
return $plist;
}
function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
{
$prepage = "";
$nextpage = "";
$prepagenum = intval($this->PageNo) - 1;
$nextpagenum = intval($this->PageNo) + 1;
if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
$list_len = 3;
}
$totalpage = $this->TotalPage;
if ($totalpage <= 1 && $this->TotalResult > 0) {
return "<span class=\"pageinfo\">共1页/" . $this->TotalResult . "条</span>";
}
if ($this->TotalResult == 0) {
return "<span class=\"pageinfo\">共0页/" . $this->TotalResult . "条</span>";
}
$maininfo = "<span class=\"pageinfo\">共{$totalpage}页/" . $this->TotalResult . "条</span>\r\n";
// $purl = $this->GetCurUrl();
$purl = "/a/tags/" . GetPinyin($this->Tag);
// var_dump($purl);
//获得上一页和下一页的链接
if ($this->PageNo != 1) {
$prepage .= "<li><a href='" . $purl . "/$prepagenum/'>上一页</a></li>\r\n";
$indexpage = "<li><a href='" . $purl . "/1/'>首页</a></li>\r\n";
} else {
$indexpage = "<li><a>首页</a></li>\r\n";
}
if ($this->PageNo != $totalpage && $totalpage > 1) {
$nextpage .= "<li><a href='" . $purl . "/$nextpagenum/'>下一页</a></li>\r\n";
$endpage = "<li><a href='" . $purl . "/$totalpage/'>末页</a></li>\r\n";
} else {
$endpage = "<li><a>末页</a></li>\r\n";
}
//获得数字链接
$listdd="";
$listdd = "";
$total_list = $list_len * 2 + 1;
if($this->PageNo >= $total_list)
{
if ($this->PageNo >= $total_list) {
$j = $this->PageNo - $list_len;
$total_list = $this->PageNo + $list_len;
if($total_list > $totalpage)
{
if ($total_list > $totalpage) {
$total_list = $totalpage;
}
}
else
{
$j=1;
if($total_list > $totalpage)
{
} else {
$j = 1;
if ($total_list > $totalpage) {
$total_list = $totalpage;
}
}
for($j; $j<=$total_list; $j++)
{
if($j == $this->PageNo)
{
$listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
}
else
{
$listdd.="<li><a href='".$purl."/$j/'>".$j."</a></li>\r\n";
for ($j; $j <= $total_list; $j++) {
if ($j == $this->PageNo) {
$listdd .= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
} else {
$listdd .= "<li><a href='" . $purl . "/$j/'>" . $j . "</a></li>\r\n";
}
}
$plist = '';
if(preg_match('/info/i', $listitem))
{
$plist .= $maininfo.' ';
if (preg_match('/info/i', $listitem)) {
$plist .= $maininfo . ' ';
}
if(preg_match('/index/i', $listitem))
{
$plist .= $indexpage.' ';
if (preg_match('/index/i', $listitem)) {
$plist .= $indexpage . ' ';
}
if(preg_match('/pre/i', $listitem))
{
$plist .= $prepage.' ';
if (preg_match('/pre/i', $listitem)) {
$plist .= $prepage . ' ';
}
if(preg_match('/pageno/i', $listitem))
{
$plist .= $listdd.' ';
if (preg_match('/pageno/i', $listitem)) {
$plist .= $listdd . ' ';
}
if(preg_match('/next/i', $listitem))
{
$plist .= $nextpage.' ';
if (preg_match('/next/i', $listitem)) {
$plist .= $nextpage . ' ';
}
if(preg_match('/end/i', $listitem))
{
$plist .= $endpage.' ';
if (preg_match('/end/i', $listitem)) {
$plist .= $endpage . ' ';
}
return $plist;
}
function GetTruePath()
{
$truepath = $GLOBALS["cfg_basedir"];
return $truepath;
}
// 生成静态Tag
function MakeHtml($startpage = 1, $makepagesize = 0)
{
global $cfg_dir_purview, $envs;
$envs['makeTag'] = 1;
if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
//初步给固定值的标记赋值
$this->ParseTempletsFirst();
if ($this->Tag == "") {
MkdirAll($this->GetTruePath() . "/a/tags/", $cfg_dir_purview);
$this->dtp->SaveTo($this->GetTruePath() . "/a/tags/index.html");
} else {
$totalpage = ceil($this->TotalResult / $this->PageSize);
if ($totalpage == 0) {
$totalpage = 1;
}
if ($makepagesize > 0) {
$endpage = $startpage + $makepagesize;
} else {
$endpage = ($totalpage + 1);
}
if ($endpage >= $totalpage + 1) {
$endpage = $totalpage + 1;
}
if ($endpage == 1) {
$endpage = 2;
}
$makeDir = $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/";
MkdirAll($makeDir, $cfg_dir_purview);
for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
$this->ParseDMFields($this->PageNo, 1);
$fileDir = $makeDir . "/" . $this->PageNo;
MkdirAll($fileDir, $cfg_dir_purview);
$this->dtp->SaveTo($fileDir . "/index.html");
}
if ($startpage == 1) {
$list_1 = $makeDir . "/1/index.html";
copy($list_1, $makeDir . "/index.html");
}
}
}
/**
* 获得一个指定的频道的链接
*
@@ -549,9 +651,9 @@ class TagList
* @param string $siteurl 站点地址
* @return string
*/
function GetListUrl($typeid,$typedir,$isdefault,$defaultname,$ispart,$namerule2,$siteurl="")
function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
{
return GetTypeUrl($typeid,MfTypedir($typedir),$isdefault,$defaultname,$ispart,$namerule2,$siteurl);
return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
}
/**
@@ -570,9 +672,9 @@ class TagList
* @param string $filename 文件名称
* @return string
*/
function GetArcUrl($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule="",$artdir="",$money=0,$filename='')
function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
{
return GetFileUrl($aid,$typeid,$timetag,$title,$ismake,$rank,$namerule,$artdir,$money,$filename);
return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
}
/**
@@ -583,14 +685,11 @@ class TagList
*/
function GetCurUrl()
{
if(!empty($_SERVER["REQUEST_URI"]))
{
if (!empty($_SERVER["REQUEST_URI"])) {
$nowurl = $_SERVER["REQUEST_URI"];
$nowurls = explode("?",$nowurl);
$nowurls = explode("?", $nowurl);
$nowurl = $nowurls[0];
}
else
{
} else {
$nowurl = $_SERVER["PHP_SELF"];
}
return $nowurl;


+ 1
- 1
src/include/inc/inc_fun_funAdmin.php View File

@@ -28,7 +28,7 @@ function SpGetPinyin($str, $ishead=0, $isclose=1)
{
return $str;
}
if(count($pinyins) == 0)
if(@count($pinyins) == 0)
{
$fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
while(!feof($fp))


+ 39
- 48
src/include/taglib/tag.lib.php View File

@@ -9,7 +9,7 @@
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
/*>>dede>>
<name>TAG调用</name>
<type>全局标记</type>
@@ -26,17 +26,17 @@
<iterm>getall:获取类型 0 为当前内容页TAG标记,1为获取全部TAG标记</iterm>
</attributes>
>>dede>>*/
function lib_tag(&$ctag,&$refObj)
function lib_tag(&$ctag, &$refObj)
{
global $dsql,$envs,$cfg_cmsurl;
global $dsql, $envs, $cfg_cmsurl;
//属性处理
$attlist="row|30,sort|new,getall|0,typeid|0";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
$attlist = "row|30,sort|new,getall|0,typeid|0";
FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$InnerText = $ctag->GetInnerText();
if(trim($InnerText)=='') $InnerText = GetSysTemplets('tag_one.htm');
if (trim($InnerText) == '') $InnerText = GetSysTemplets('tag_one.htm');
$revalue = '';
$ltype = $sort;
@@ -44,68 +44,59 @@ function lib_tag(&$ctag,&$refObj)
$addsql = '';
if($getall==0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid']))
{
if ($getall == 0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid'])) {
$dsql->SetQuery("SELECT tid FROM `#@__taglist` WHERE aid = '{$refObj->Fields['aid']}' ");
$dsql->Execute();
$ids = '';
while($row = $dsql->GetArray())
{
$ids .= ( $ids=='' ? $row['tid'] : ','.$row['tid'] );
while ($row = $dsql->GetArray()) {
$ids .= ($ids == '' ? $row['tid'] : ',' . $row['tid']);
}
if($ids != '')
{
if ($ids != '') {
$addsql = " WHERE id IN($ids) ";
}
if($addsql=='') return '';
}
else
{
if(!empty($typeid))
{
if ($addsql == '') return '';
} else {
if (!empty($typeid)) {
$addsql = " WHERE typeid='$typeid' ";
}
}
if($ltype=='rand') $orderby = 'rand() ';
else if($ltype=='week') $orderby=' weekcc DESC ';
else if($ltype=='month') $orderby=' monthcc DESC ';
else if($ltype=='hot') $orderby=' count DESC ';
else if($ltype=='total') $orderby=' total DESC ';
}
if ($ltype == 'rand') $orderby = 'rand() ';
else if ($ltype == 'week') $orderby = ' weekcc DESC ';
else if ($ltype == 'month') $orderby = ' monthcc DESC ';
else if ($ltype == 'hot') $orderby = ' count DESC ';
else if ($ltype == 'total') $orderby = ' total DESC ';
else $orderby = 'addtime DESC ';
$dsql->SetQuery("SELECT * FROM `#@__tagindex` $addsql ORDER BY $orderby LIMIT 0,$num");
$dsql->Execute();
$ctp = new DedeTagParse();
$ctp->SetNameSpace('field','[',']');
$ctp->SetNameSpace('field', '[', ']');
$ctp->LoadSource($InnerText);
while($row = $dsql->GetArray())
{
while ($row = $dsql->GetArray()) {
$row['keyword'] = $row['tag'];
$row['tag'] = dede_htmlspecialchars($row['tag']);
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
$row['highlight'] = 0;
if($row['monthcc']>1000 || $row['weekcc']>300 )
{
$row['highlight'] = mt_rand(3,4);
}
else if($row['count']>3000)
{
$row['highlight'] = mt_rand(5,6);
if (isset($envs['makeTag']) && $envs['makeTag'] == 1) {
$row['link'] = $cfg_cmsurl . "/a/tags/" . GetPinyin($row['keyword']) . "/";
} else {
$row['link'] = $cfg_cmsurl . "/tags.php?/" . urlencode($row['keyword']) . "/";
}
else
{
$row['highlight'] = mt_rand(1,2);
$row['highlight'] = 0;
if ($row['monthcc'] > 1000 || $row['weekcc'] > 300) {
$row['highlight'] = mt_rand(3, 4);
} else if ($row['count'] > 3000) {
$row['highlight'] = mt_rand(5, 6);
} else {
$row['highlight'] = mt_rand(1, 2);
}
foreach($ctp->CTags as $tagid=>$ctag)
{
if(isset($row[$ctag->GetName()]))
{
$ctp->Assign($tagid,$row[$ctag->GetName()]);
foreach ($ctp->CTags as $tagid => $ctag) {
if (isset($row[$ctag->GetName()])) {
$ctp->Assign($tagid, $row[$ctag->GetName()]);
}
}
$revalue .= $ctp->GetResult();
}
return $revalue;
}
}

Loading…
Cancel
Save