Browse Source

完善Tags的生成功能

tags/6.0.2
tianya 3 years ago
parent
commit
1c39e29834
9 changed files with 181 additions and 91 deletions
  1. +6
    -2
      src/dede/makehtml_taglist_action.php
  2. +50
    -70
      src/dede/tags_main.php
  3. +3
    -1
      src/dede/templets/makehtml_taglist.htm
  4. +85
    -9
      src/dede/templets/tags_main.htm
  5. BIN
      src/favicon.ico
  6. +18
    -1
      src/include/arc.taglist.class.php
  7. +2
    -2
      src/include/common.func.php
  8. +12
    -1
      src/install/v57sp2_to_v6.txt
  9. +5
    -5
      src/static/js/dede.js

+ 6
- 2
src/dede/makehtml_taglist_action.php View File

@@ -76,8 +76,12 @@ if (is_array($tag) && count($tag) > 0) {
} else {
$query = "UPDATE `#@__tagindex` SET mktime=uptime WHERE id='$ctagid' ";
$dsql->ExecuteNoneQuery($query);
$reurl .= GetPinyin($tag['tag']);

if (empty($tag['tag_pinyin'])) {
$tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;");
}

$reurl .= $tag['tag_pinyin'];
ShowMsg("完成TAG更新:[" . $tag['tag'] . "]!<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
}
exit();


+ 50
- 70
src/dede/tags_main.php View File

@@ -1,4 +1,5 @@
<?php
/**
* 获取TAGS管理
*
@@ -8,17 +9,16 @@
* @license https://www.dedebiz.com/license
* @link https://www.dedebiz.com
*/
require_once(dirname(__FILE__).'/config.php');
require_once(dirname(__FILE__) . '/config.php');
CheckPurview('sys_Keyword');
require_once(DEDEINC.'/datalistcp.class.php');
require_once(DEDEINC . '/datalistcp.class.php');
$timestamp = time();
if(empty($tag)) $tag = '';
if (empty($tag)) $tag = '';
if(empty($action))
{
if (empty($action)) {
$orderby = empty($orderby) ? 'id' : preg_replace("#[^a-z]#i", '', $orderby);
$orderway = isset($orderway) && $orderway == 'asc' ? 'asc' : 'desc';
if(!empty($tag)) $where = " where tag like '%$tag%'";
if (!empty($tag)) $where = " where tag like '%$tag%'";
else $where = '';
$neworderway = ($orderway == 'desc' ? 'asc' : 'desc');
@@ -29,21 +29,18 @@ if(empty($action))
$dlist->SetParameter("orderway", $orderway);
$dlist->SetParameter("orderby", $orderby);
$dlist->pageSize = 20;
$dlist->SetTemplet(DEDEADMIN."/templets/tags_main.htm");
$dlist->SetTemplet(DEDEADMIN . "/templets/tags_main.htm");
$dlist->SetSource($query);
$dlist->Display();
exit();
}
/*
function update()
*/
else if($action == 'update')
{
$tid = (empty($tid) ? 0 : intval($tid) );
$count = (empty($count) ? 0 : intval($count) );
if(empty($tid))
{
ShowMsg('没有选择要删除的tag!','-1');
*/ else if ($action == 'update') {
$tid = (empty($tid) ? 0 : intval($tid));
$count = (empty($count) ? 0 : intval($count));
if (empty($tid)) {
ShowMsg('没有选择要删除的tag!', '-1');
exit();
}
$query = "UPDATE `#@__tagindex` SET `count`='$count' WHERE id='$tid' ";
@@ -53,101 +50,85 @@ else if($action == 'update')
}
/*
function delete()
*/
else if($action == 'delete')
{
if(@is_array($ids))
{
*/ else if ($action == 'delete') {
if (@is_array($ids)) {
$stringids = implode(',', $ids);
}
else if(!empty($ids))
{
} else if (!empty($ids)) {
$stringids = $ids;
}
else
{
ShowMsg('没有选择要删除的tag','-1');
} else {
ShowMsg('没有选择要删除的tag', '-1');
exit();
}
$query = "DELETE FROM `#@__tagindex` WHERE id IN ($stringids)";
if($dsql->ExecuteNoneQuery($query))
{
if ($dsql->ExecuteNoneQuery($query)) {
$query = "DELETE FROM `#@__taglist` WHERE tid IN ($stringids)";
$dsql->ExecuteNoneQuery($query);
ShowMsg("删除tags[ $stringids ]成功", 'tags_main.php');
}
else
{
} else {
ShowMsg("删除tags[ $stringids ]失败", 'tags_main.php');
}
exit();
} else if ($action == 'get_one') {
$tid = (empty($tid) ? 0 : intval($tid));
$row = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id = $tid");
echo json_encode($row);
exit;
} else if ($action == 'set_one') {
$tid = (empty($tid) ? 0 : intval($tid));
$title = empty($title) ? "" : HtmlReplace($title, 0);
$kw = empty($kw) ? "" : HtmlReplace($kw, 0);
$des = empty($des) ? "" : HtmlReplace($des, 0);
$dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET title='{$title}',keywords='{$kw}',`description`='{$des}' WHERE id = {$tid}");
echo json_encode(array('code' => 200, 'result' => true));
}
/*
function fetch()
*/
else if($action == 'fetch')
{
*/ else if ($action == 'fetch') {
$wheresql = '';
$start = isset($start) && is_numeric($start) ? $start : 0;
$where = array();
if(isset($startaid) && is_numeric($startaid) && $startaid > 0)
{
if (isset($startaid) && is_numeric($startaid) && $startaid > 0) {
$where[] = " id>=$startaid ";
}
else
{
} else {
$startaid = 0;
}
if(isset($endaid) && is_numeric($endaid) && $endaid > 0)
{
if (isset($endaid) && is_numeric($endaid) && $endaid > 0) {
$where[] = " id<=$endaid ";
}
else
{
} else {
$endaid = 0;
}
if(!empty($where))
{
$wheresql = " WHERE arcrank>-1 AND ".implode(' AND ', $where);
if (!empty($where)) {
$wheresql = " WHERE arcrank>-1 AND " . implode(' AND ', $where);
}
$query = "SELECT id as aid,arcrank,typeid,keywords FROM `#@__archives` $wheresql LIMIT $start, 100";
$dsql->SetQuery($query);
$dsql->Execute();
$complete = true;
$now = time();
while($row = $dsql->GetArray())
{
while ($row = $dsql->GetArray()) {
$aid = $row['aid'];
$typeid = $row['typeid'];
$arcrank = $row['arcrank'];
$row['keywords'] = trim($row['keywords']);
if($row['keywords']!='' && !preg_match("#,#", $row['keywords']))
{
if ($row['keywords'] != '' && !preg_match("#,#", $row['keywords'])) {
$keyarr = explode(' ', $row['keywords']);
}
else
{
} else {
$keyarr = explode(',', $row['keywords']);
}
foreach($keyarr as $keyword)
{
foreach ($keyarr as $keyword) {
$keyword = trim($keyword);
if($keyword != '' && strlen($keyword)<13 )
{
if ($keyword != '' && strlen($keyword) < 13) {
$keyword = addslashes($keyword);
$row = $dsql->GetOne("SELECT id,total FROM `#@__tagindex` WHERE tag LIKE '$keyword'");
if(is_array($row))
{
if (is_array($row)) {
$tid = $row['id'];
$trow = $dsql->GetOne("SELECT COUNT(*) as dd FROM `#@__taglist` WHERE tag LIKE '$keyword'");
if (intval($trow['dd']) != $row['total'] ) {
$query = "UPDATE `#@__tagindex` SET `total`=".$trow['dd'].",uptime=$now WHERE id='$tid' ";
if (intval($trow['dd']) != $row['total']) {
$query = "UPDATE `#@__tagindex` SET `total`=" . $trow['dd'] . ",uptime=$now WHERE id='$tid' ";
$dsql->ExecuteNoneQuery($query);
}
}
else
{
} else {
$query = " INSERT INTO `#@__tagindex`(`tag`,`count`,`total`,`weekcc`,`monthcc`,`weekup`,`monthup`,`addtime`,`uptime`) VALUES('$keyword','0','1','0','0','$timestamp','$timestamp','$timestamp','$now');";
$dsql->ExecuteNoneQuery($query);
$tid = $dsql->GetLastID();
@@ -158,8 +139,7 @@ else if($action == 'fetch')
}
$complete = FALSE;
}
if($complete)
{
if ($complete) {
ShowMsg("tags获取完成", 'tags_main.php');
exit();
}
@@ -167,4 +147,4 @@ else if($action == 'fetch')
$goto = "tags_main.php?action=fetch&startaid=$startaid&endaid=$endaid&start=$start";
ShowMsg('继续获取tags ...', $goto, 0, 500);
exit();
}
}

+ 3
- 1
src/dede/templets/makehtml_taglist.htm View File

@@ -9,7 +9,8 @@
</head>

<body background='images/allbg.gif' leftmargin='8' topmargin='8'>
<table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D1DDAA" align="center" class="table maintable table-bordered mt-3">
<table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D1DDAA" align="center"
class="table maintable table-bordered mt-3">
<form name="form1" action="makehtml_tag_action_list.php" method="get" target='stafrm'>
<tr>
<td height="28" colspan="2" background='images/tbg.gif'>
@@ -28,6 +29,7 @@
<td width="377" valign="top" bgcolor="#FFFFFF">
<?php
$dd = $dsql->GetOne("SELECT ROUND(AVG(total)) as tt FROM `#@__tagindex`"); // 取一个平均
$dd['tt'] = ($dd['tt'] > 5)? $dd['tt'] : 0;
$sql="select * from #@__tagindex where total > {$dd['tt']} order by tag asc";
$dsql->Execute('al',$sql);
echo "<select name='tagid' style='width:300px'>\r\n";


+ 85
- 9
src/dede/templets/tags_main.htm View File

@@ -5,9 +5,17 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<title>tags管理</title>
<script src="../static/js/jquery.js" language="javascript" type="text/javascript"></script>
<script src="/static/js/bootstrap.bundle.js"></script>
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<script src="../static/js/dede.js"></script>
<link href="../static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="css/base.css" rel="stylesheet" type="text/css" />
<style>
.col-form-label {
padding-top: 0;
}
</style>
<script language="javascript">
function checkall(form, prefix, checkall) {
var checkall = checkall ? checkall : 'all';
@@ -24,6 +32,67 @@
function DeleteOne(tid) {
location = "tags_main.php?action=delete&ids=" + tid;
}
function UpdateKwDes(tid, tag) {
$.get("tags_main.php?action=get_one&tid=" + tid, function (data) {
let rs = JSON.parse(data);
let title = rs.title ? rs.title : "";
let keywords = rs.keywords ? rs.keywords : "";
let description = rs.description ? rs.description : "";
ShowMsg(`
<div class="form-group row">
<label for="iptTitle" class="col-sm-3 col-form-label">标签</label>
<div class="col-sm-9">
<input name="title" type="text" class="form-control" disabled
value="${tag}">
</div>
</div>
<div class="form-group row">
<label for="iptKw" class="col-sm-3 col-form-label">标题</label>
<div class="col-sm-9">
<input name="title" type="text" class="form-control" id="iptTitle"
placeholder="例如:DedeBIZ织梦商业组件" value="${title}">
</div>
</div>
<div class="form-group row">
<label for="iptKw" class="col-sm-3 col-form-label">关键词</label>
<div class="col-sm-9">
<input name="kw" type="text" class="form-control" id="iptKw"
placeholder="例如:DedeBIZ 织梦 Dede商业" value="${keywords}">
</div>
</div>
<div class="form-group row">
<label for="iptDes" class="col-sm-3 col-form-label">描述</label>
<div class="col-sm-9">
<textarea id="iptDes" name="des" class="form-control" row=3
placeholder="例如:国内流行的内容管理系统(CMS)多端全媒体解决方案">${description}</textarea>
</div>
</div>
`, {
footer: `<button type="button" class="btn btn-outline-success" onclick="UpdateKwDesDo(${tid}, '~modalID~')">设置</button>`,
});
})
}
function UpdateKwDesDo(tid, mdlID) {
let title = $("#iptTitle").val();
let kw = $("#iptKw").val();
let des = $("#iptDes").val();
$.post("tags_main.php?action=set_one", {
tid: tid,
title: title,
kw: kw,
des: des,
}, function (data) {
let rs = JSON.parse(data);
if (rs.code === 200) {
location.reload();
}
})
}
</script>
</head>
@@ -34,7 +103,8 @@
</div>
<div class="main">
<form name='form1' action="tags_main.php?action=fetch" method="post" style="margin-bottom:6px;">
<table width="98%" border="0" cellspacing="1" align="center" class="table maintable" style="background:#CFCFCF;">
<table width="98%" border="0" cellspacing="1" align="center" class="table maintable"
style="background:#CFCFCF;">
<tr>
<td height="20" align="left" bgcolor="#F0FBBD" background="images/wbg.gif"
style="padding-left:10px;"><strong>提取Tag</strong></td>
@@ -52,11 +122,12 @@
</tr>
</table>
</form>
<table width="98%" border="0" cellpadding="1" cellspacing="1" align="center" class="table maintable table-bordered"
style="background:#CFCFCF;">
<table width="98%" border="0" cellpadding="1" cellspacing="1" align="center"
class="table maintable table-bordered" style="background:#CFCFCF;">
<tr>
<td height="20" colspan="7" bgcolor="#F0F0F0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table-borderless">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
class="table-borderless">
<tr>
<td align="left" style="padding-left:10px;"><strong>Tag维护</strong></td>
<form name='form2' action="tags_main.php">
@@ -64,7 +135,8 @@
搜索:
<input type='text' name='tag' size='10' value="<?php echo $tag;?>">
<button type='submit' name='sb' class="btn btn-secondary btn-sm">确定</button>
&nbsp; <a href="makehtml_taglist.php" name='sb' class="btn btn-secondary btn-sm">更新Tag HTML</a>
&nbsp; <a href="makehtml_taglist.php" name='sb'
class="btn btn-secondary btn-sm">更新Tag HTML</a>
</td>
</form>
@@ -118,10 +190,14 @@
<?php echo $fields['uptime']; ?>
</td>
<td>
<a href='javascript:UpdateOne(<?php echo $fields['id']; ?>);' class="btn btn-secondary btn-sm">更新</a>
<a href='makehtml_taglist.php?tid=<?php echo $fields['id'];?>' class="btn btn-secondary btn-sm">生成HTML</a>
<a href='javascript:DeleteOne(<?php echo $fields['id']; ?>);' class="btn btn-secondary btn-sm">删</a>
<a href='javascript:UpdateKwDes(<?php echo $fields['id']; ?>, "<?php echo $fields['tag']; ?>");'
class="btn btn-secondary btn-sm">关键词描述</a>
<a href='javascript:UpdateOne(<?php echo $fields['id']; ?>);'
class="btn btn-secondary btn-sm">更新</a>
<a href='makehtml_taglist.php?tid=<?php echo $fields['id'];?>'
class="btn btn-secondary btn-sm">生成HTML</a>
<a href='javascript:DeleteOne(<?php echo $fields['id']; ?>);'
class="btn btn-secondary btn-sm">删</a>
</td>
</tr>
{/dede:datalist}


BIN
src/favicon.ico View File

Before After

+ 18
- 1
src/include/arc.taglist.class.php View File

@@ -78,6 +78,15 @@ class TagList
ShowMsg($msg, "-1");
exit();
}
// 确定是否存在tag_pinyin
if (empty($this->TagInfos['tag_pinyin'])) {
$this->TagInfos['tag_pinyin'] = $this->TagPinyinExists($this->Tag) ? GetPinyin($this->Tag) . $this->TagInfos['id'] : GetPinyin($this->Tag);
$this->dsql->ExecNoneQuery("UPDATE `#@__tagindex` SET tag_pinyin = '{$this->TagInfos['tag_pinyin']}' WHERE tag LIKE '{$this->Tag}'");
}
$this->Fields['title'] = empty($this->TagInfos['title']) ? $this->Fields['title'] : $this->TagInfos['title'];
$this->Fields['keywords'] = empty($this->TagInfos['keywords']) ? $this->Fields['keywords'] : $this->TagInfos['keywords'];
$this->Fields['description'] = empty($this->TagInfos['description']) ? $this->Fields['description'] : $this->TagInfos['description'];
}
//初始化模板
@@ -90,6 +99,13 @@ class TagList
$this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
}
function TagPinyinExists($tag)
{
$tag_py = GetPinyin($tag);
$row = $this->dsql->GetOne("Select count(*) as dd From `#@__tagindex` where tag_pinyin like '{$tag_py}' ");
return $row['dd'] > 0;
}
//php4构造函数
function TagList($keyword, $templet)
{
@@ -627,7 +643,8 @@ class TagList
if ($endpage == 1) {
$endpage = 2;
}
$makeDir = $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/";
$makeDir = $this->GetTruePath() . "/a/tags/" . $this->TagInfos['tag_pinyin'] . "/";
MkdirAll($makeDir, $cfg_dir_purview);
for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
$this->ParseDMFields($this->PageNo, 1);


+ 2
- 2
src/include/common.func.php View File

@@ -209,7 +209,7 @@ function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
global $cfg_soft_lang, $cfg_cmsurl;
if (empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..';

$htmlhead = "<html>\r\n<head>\r\n<title>DedeCMS提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$cfg_soft_lang}\" />\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">";
$htmlhead = "<html>\r\n<head>\r\n<title>DedeBIZ提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$cfg_soft_lang}\" />\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">";
$htmlhead .= "<link rel=\"stylesheet\" href=\"{$cfg_cmsurl}/static/css/bootstrap.min.css\"><style>.modal {position: static;}</style><link href=\"{$cfg_cmsurl}/static/font-awesome/css/font-awesome.min.css\" rel=\"stylesheet\">";
$htmlhead .= "<base target='_self'/></head>\r\n<body leftmargin='0' topmargin='0' bgcolor='#FFFFFF'>" . (isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '') . "\r\n<center>\r\n<script>\r\n";
$htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
@@ -238,7 +238,7 @@ function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
}\r\n";
$rmsg = $func;
$rmsg .= "document.write(\"<main class='container'><div class='modal' tabindex='-1' role='dialog' style='display:block'><div class='modal-dialog'><div class='modal-content'><div class='modal-header'><h6 class='modal-title'>";
$rmsg .= "DedeCMS 提示信息!</h6></div><div class='modal-body'>\");\r\n";
$rmsg .= "DedeBIZ 提示信息!</h6></div><div class='modal-body'>\");\r\n";
$rmsg .= "document.write(\"" . str_replace("\"", "“", $msg) . "\");\r\n";
$rmsg .= "document.write(\"";



+ 12
- 1
src/install/v57sp2_to_v6.txt View File

@@ -1,3 +1,5 @@
-- 6.0.0

ALTER TABLE `#@__tagindex`
ADD COLUMN `uptime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `addtime`,
ADD COLUMN `mktime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `uptime`;
@@ -27,4 +29,13 @@ CREATE TABLE `#@__search_limits` (
`ip` VARCHAR(200) NOT NULL,
`searchtime` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`ip`)
) TYPE=MyISAM;
) TYPE=MyISAM;

-- 6.0.2
ALTER TABLE `#@__tagindex` ADD COLUMN `keywords` VARCHAR(255) NULL DEFAULT NULL AFTER `tag`;

ALTER TABLE `#@__tagindex` ADD COLUMN `description` VARCHAR(255) NULL DEFAULT NULL AFTER `keywords`;

ALTER TABLE `#@__tagindex` ADD COLUMN `title` VARCHAR(255) NULL DEFAULT NULL AFTER `description`;

ALTER TABLE `#@__tagindex` ADD COLUMN `tag_pinyin` VARCHAR(255) NULL DEFAULT NULL AFTER `title`;

+ 5
- 5
src/static/js/dede.js View File

@@ -44,16 +44,16 @@ function guid() {
// args是以下结构体
/*
args = {
title : "", // 标题,默认是MuEMS
footer : "", // 底部按钮,可以自定义按钮
noClose : false, // 是否显示右上角关闭按钮,默认显示
title : "", // 标题,默认是MuEMS
footer : "", // 底部按钮,可以自定义按钮
noClose : false, // 是否显示右上角关闭按钮,默认显示
}
*/
// 函数会返回一个modalID,通过这个ID可自已定义一些方法
// 这里用到了一个展开语法
// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax
function ShowMsg(content, ...args) {
title = "DedeCMS信息提示";
title = "DedeBIZ信息提示";
if (typeof content == "undefined") content = "";
modalID = guid();
var footer = `<button type="button" class="btn btn-outline-success" onClick="CloseModal(\'DedeModal${modalID}\')">确定</button>`;
@@ -71,7 +71,7 @@ function ShowMsg(content, ...args) {
noClose = true;
}
}
String.prototype.replaceAll = function (s1, s2) {
return this.replace(new RegExp(s1, "gm"), s2);
}


Loading…
Cancel
Save