@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
return array (
|
||||
'name' => '标签',
|
||||
'version' => '1.2',
|
||||
'desc' => '标签',
|
||||
'url' => 'http://www.thinksaas.cn',
|
||||
'email' => 'thinksaas@qq.com',
|
||||
'author' => '邱君',
|
||||
'author_url' => 'http://www.thinksaas.cn',
|
||||
'isoption' => '1',
|
||||
'isinstall' => '1',
|
||||
'issql' => '1',
|
||||
'issystem' => '1',
|
||||
'isappnav' => '0',
|
||||
'ismy'=>'0'
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
switch($ts){
|
||||
case "":
|
||||
|
||||
$objname = tsFilter($_GET['objname']);
|
||||
$idname = tsFilter($_GET['idname']);
|
||||
$objid = tsIntval($_GET['objid']);
|
||||
|
||||
include template("add_ajax");
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
$objname = tsFilter($_POST['objname']);
|
||||
$idname = tsFilter($_POST['idname']);
|
||||
$objid = tsIntval($_POST['objid']);
|
||||
$tags = t($_POST['tags']);
|
||||
|
||||
$new['tag']->addTag($objname,$idname,$objid,$tags);
|
||||
|
||||
tsNotice('标签添加成功!');
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
switch($ts){
|
||||
case "":
|
||||
|
||||
$objname = tsUrlCheck($_GET['objname']);
|
||||
$idname = tsUrlCheck($_GET['idname']);
|
||||
$objid = tsIntval($_GET['objid']);
|
||||
|
||||
include template("add_ajax");
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
$objname = tsUrlCheck($_POST['objname']);
|
||||
$idname = tsUrlCheck($_POST['idname']);
|
||||
$objid = tsIntval($_POST['objid']);
|
||||
$tags = t($_POST['tags']);
|
||||
|
||||
$new['tag']->addTag($objname,$idname,$objid,$tags);
|
||||
|
||||
echo "<script language=JavaScript>parent.window.location.reload();</script>";
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
//管理入口
|
||||
|
||||
if(is_file('app/'.$app.'/action/admin/'.$mg.'.php')){
|
||||
include_once 'app/'.$app.'/action/admin/'.$mg.'.php';
|
||||
}else{
|
||||
qiMsg('sorry:no index!');
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch ($ts){
|
||||
|
||||
//添加标签
|
||||
case "adddo":
|
||||
|
||||
$tag = tsTrim($_POST['tag']);
|
||||
if($tag==''){
|
||||
qiMsg('标签不能为空');
|
||||
}
|
||||
|
||||
if($new['tag']->isTag($tag)==true) qiMsg('标签已存在,无需添加!');
|
||||
|
||||
$new['tag']->create('tag',array(
|
||||
'tagname'=>$tag,
|
||||
'uptime'=>time(),
|
||||
));
|
||||
|
||||
header('Location: '.SITE_URL.'index.php?app=tag&ac=admin&mg=list');
|
||||
|
||||
break;
|
||||
|
||||
//审核
|
||||
case "isaudit":
|
||||
$tagid = tsIntval($_GET['tagid']);
|
||||
$isaudit = tsIntval($_GET['isaudit']);
|
||||
|
||||
$db->query("update ".dbprefix."tag set `isaudit`='$isaudit' where tagid = '$tagid'");
|
||||
|
||||
qiMsg("设置成功!");
|
||||
|
||||
break;
|
||||
|
||||
//删除
|
||||
case "del":
|
||||
$tagid = tsIntval($_GET['tagid']);
|
||||
$page = tsIntval($_GET['page']);
|
||||
|
||||
$new['tag']->delete('tag',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_article_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_bang_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_group_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_photo_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_study_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_topic_index',array('tagid'=>$tagid));
|
||||
$new['tag']->delete('tag_user_index',array('tagid'=>$tagid));
|
||||
|
||||
header('Location: '.SITE_URL.'index.php?app=tag&ac=admin&mg=list&page='.$page);
|
||||
|
||||
break;
|
||||
|
||||
//优化标签
|
||||
case "opt":
|
||||
$tagid = tsIntval($_GET['tagid']);
|
||||
$strTag = $new['tag']->getOneTag($tagid);
|
||||
|
||||
$tagname = t($strTag['tagname']);
|
||||
|
||||
$tagNum = $db->once_fetch_assoc("select count(*) from ".dbprefix."tag where `tagname`='$tagname'");
|
||||
|
||||
if($tagNum['count(*)']==0){
|
||||
$db->query("update ".dbprefix."tag set `tagname`='$tagname' where `tagid`='$tagid'");
|
||||
}elseif($tagNum['count(*)']==1){
|
||||
|
||||
}else{
|
||||
$arrTags = $db->fetch_all_assoc("select * from ".dbprefix."tag where `tagname`='$tagname'");
|
||||
foreach($arrTags as $item){
|
||||
$tagids = $item['tagid'];
|
||||
//先更新索引
|
||||
$db->query("update ".dbpreifx."tag_topic_index set `tagid`='$tagid' where `tagid`='$tagids'");
|
||||
$db->query("update ".dbpreifx."tag_article_index set `tagid`='$tagid' where `tagid`='$tagids'");
|
||||
$db->query("update ".dbpreifx."tag_user_index set `tagid`='$tagid' where `tagid`='$tagids'");
|
||||
|
||||
//再进行删除
|
||||
$db->query("delete from ".dbprefix."tag where `tagid`='$tagids'");
|
||||
|
||||
//最后更新tag
|
||||
$db->query("update ".dbprefix."tag set `tagname`='$tagname' where `tagid`='$tagid'");
|
||||
}
|
||||
}
|
||||
|
||||
qiMsg("优化成功!");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
|
||||
|
||||
$page = tsIntval($_GET['page'],1);
|
||||
|
||||
$url = 'index.php?app=tag&ac=admin&mg=list&page=';
|
||||
|
||||
$sLimit = $page*10-10;
|
||||
|
||||
$arrTags = $db->fetch_all_assoc("select * from ".dbprefix."tag order by uptime desc limit $sLimit,10");
|
||||
|
||||
$tagNum = $db->once_num_rows("select * from ".dbprefix."tag");
|
||||
|
||||
$pageUrl = pagination($tagNum, 10, $page, $url);
|
||||
|
||||
include template("admin/list");
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
switch($ts){
|
||||
case "":
|
||||
$strOption = getAppOptions('tag');
|
||||
include template("admin/options");
|
||||
break;
|
||||
|
||||
case "do":
|
||||
|
||||
$arrOption = $_POST['option'];
|
||||
#更新app配置选项
|
||||
upAppOptions('tag',$arrOption);
|
||||
|
||||
qiMsg('修改成功!');
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
class tag extends tsApp{
|
||||
|
||||
//构造函数
|
||||
public function __construct($db){
|
||||
$tsAppDb = array();
|
||||
include 'app/tag/config.php';
|
||||
//判断APP是否采用独立数据库
|
||||
if($tsAppDb){
|
||||
$db = new MySql($tsAppDb);
|
||||
}
|
||||
|
||||
parent::__construct($db);
|
||||
}
|
||||
|
||||
//添加多个标签
|
||||
function addTag($objname,$idname,$objid,$tags){
|
||||
|
||||
$isaudit = 0;
|
||||
|
||||
$strOption = getAppOptions('tag');
|
||||
|
||||
if($strOption && $strOption['isaudit']==1){
|
||||
$isaudit = 1;
|
||||
}
|
||||
|
||||
$objname = tsUrlCheck($objname);
|
||||
$idname = tsUrlCheck($idname);
|
||||
$objid = tsIntval($objid);
|
||||
|
||||
if($objname != '' && $idname != '' && $objid!=0 && $tags!=''){
|
||||
$tags = str_replace ( ',', ',', $tags );
|
||||
$arrTag = explode(',',$tags);
|
||||
foreach($arrTag as $item){
|
||||
$tagname = t($item);
|
||||
if(strlen($tagname) < '32' && $tagname != ''){
|
||||
$uptime = time();
|
||||
|
||||
$tagcount = $this->findCount('tag',array(
|
||||
'tagname'=>$tagname,
|
||||
));
|
||||
|
||||
if($tagcount == '0'){
|
||||
|
||||
$tagid = $this->create('tag',array(
|
||||
'tagname'=>$tagname,
|
||||
'isaudit'=>$isaudit,
|
||||
'uptime'=>$uptime,
|
||||
));
|
||||
|
||||
$tagIndexCount = $this->findCount('tag_'.$objname.'_index',array(
|
||||
$idname=>$objid,
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
|
||||
if($tagIndexCount == '0'){
|
||||
|
||||
$this->create("tag_".$objname."_index",array(
|
||||
$idname=>$objid,
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
$tagIdCount = $this->findCount("tag_".$objname."_index",array(
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
|
||||
$count_obj = "count_".$objname;
|
||||
|
||||
$this->update('tag',array(
|
||||
'tagid'=>$tagid,
|
||||
),array(
|
||||
$count_obj=>$tagIdCount,
|
||||
));
|
||||
|
||||
}else{
|
||||
|
||||
$tagData = $this->find('tag',array(
|
||||
'tagname'=>$tagname,
|
||||
));
|
||||
|
||||
$tagIndexCount = $this->findCount("tag_".$objname."_index",array(
|
||||
$idname=>$objid,
|
||||
'tagid'=>$tagData['tagid'],
|
||||
));
|
||||
|
||||
if($tagIndexCount == '0'){
|
||||
|
||||
$this->create("tag_".$objname."_index",array(
|
||||
|
||||
$idname=>$objid,
|
||||
'tagid'=>$tagData['tagid'],
|
||||
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
$tagIdCount = $this->findCount("tag_".$objname."_index",array(
|
||||
'tagid'=>$tagData['tagid'],
|
||||
));
|
||||
|
||||
$count_obj = "count_".$objname;
|
||||
|
||||
$this->update('tag',array(
|
||||
'tagid'=>$tagData['tagid'],
|
||||
),array(
|
||||
$count_obj=>$tagIdCount,
|
||||
'uptime'=>$uptime,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//通过topic获取tag
|
||||
function getObjTagByObjid($objname,$idname,$objid){
|
||||
|
||||
$arrTagIndex = $this->findAll("tag_".$objname."_index",array(
|
||||
$idname=>$objid,
|
||||
));
|
||||
|
||||
$arrTag = array();
|
||||
|
||||
if($arrTagIndex){
|
||||
foreach($arrTagIndex as $item){
|
||||
$arrTagId[] = $item['tagid'];
|
||||
}
|
||||
|
||||
$tagids = arr2str($arrTagId);
|
||||
|
||||
$arrTag = $this->findAll('tag',"`tagid` in ($tagids) and `isaudit`=0");
|
||||
}
|
||||
|
||||
return $arrTag;
|
||||
|
||||
}
|
||||
|
||||
//通过tagid获得tagname
|
||||
function getOneTag($tagid){
|
||||
|
||||
$strTag = $this->find('tag',array(
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
|
||||
if($strTag=='') ts404();
|
||||
|
||||
if($strTag['isaduit']==1) tsNotice('标签审核中...');
|
||||
|
||||
return $strTag;
|
||||
}
|
||||
|
||||
//通过tagname获取tag
|
||||
function getTagByName($tagname){
|
||||
$strTag = $this->find('tag',array(
|
||||
'tagname'=>$tagname,
|
||||
));
|
||||
if($strTag=='') ts404();
|
||||
if($strTag['isaudit']==1) tsNotice('标签审核中...');
|
||||
return $strTag;
|
||||
}
|
||||
|
||||
//统计标签
|
||||
function countObjTag($objname,$tagid){
|
||||
$countObj = $this->findCount("tag_".$objname."_index",array(
|
||||
'tagid'=>$tagid,
|
||||
));
|
||||
$this->update('tag',array(
|
||||
'tagid'=>$tagid,
|
||||
),array(
|
||||
'count_'.$objname=>$countObj,
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
//删除项目ID所有标签
|
||||
function delIndextag($objname,$idname,$objid){
|
||||
$this->delete("tag_".$objname."_index",array(
|
||||
$idname=>$objid,
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
//tag是否存在
|
||||
public function isTag($tagname){
|
||||
$countTag = $this->findCount('tag',array(
|
||||
'tagname'=>$tagname,
|
||||
));
|
||||
if($countTag>0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
defined('IN_TS') or die('Access Denied.');
|
||||
|
||||
$TS_APP['appname'] = '标签';
|
||||
@@ -0,0 +1,39 @@
|
||||
{php include pubTemplate("header_admin")}
|
||||
|
||||
<div class="midder">
|
||||
|
||||
{php include template("admin/menu");}
|
||||
|
||||
<div><form method="post" action="{SITE_URL}index.php?app=tag&ac=admin&mg=do&ts=adddo"><input type="text" name="tag" /><input type="submit" value="添加标签" /></form></div>
|
||||
|
||||
<div class="page">{$pageUrl}</div>
|
||||
|
||||
<table class="table table-hover">
|
||||
|
||||
|
||||
<thead class="thead-light">
|
||||
<tr><th>ID</th><th>标签名字</th><th>创建时间</th><th>操作</th></tr>
|
||||
</thead>
|
||||
|
||||
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
{loop $arrTags $key $item}
|
||||
<tr><td>{$item[tagid]}</td><td>{$item[tagname]}</td><td>{php echo date('Y-m-d H:i:s',$item[uptime])}</td><td>
|
||||
|
||||
<a href="{SITE_URL}index.php?app=tag&ac=admin&mg=do&ts=opt&tagid={$item[tagid]}">[优化]</a>
|
||||
|
||||
<a href="{SITE_URL}index.php?app=tag&ac=admin&mg=do&ts=isaudit&tagid={$item[tagid]}&isaudit=<!--{if $item[isaudit]=='0'}-->1<!--{else}-->0<!--{/if}-->"><!--{if $item[isaudit]=='0'}-->[取消审核]<!--{else}--><font color="red">[审核]</font><!--{/if}--></a> <a href="{SITE_URL}index.php?app=tag&ac=admin&mg=do&ts=del&tagid={$item[tagid]}&page=$page">[删除]</a></td></tr>
|
||||
{/loop}
|
||||
|
||||
|
||||
</tbody>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
{php include pubTemplate("footer_admin")}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
<div class="tabnav">
|
||||
<h6>标签管理</h6>
|
||||
<ul>
|
||||
<li {if $mg=='options'}class="select"{/if}><a href="{SITE_URL}index.php?app=tag&ac=admin&mg=options">标签配置</a></li>
|
||||
<li {if $mg=='list'}class="select"{/if}><a href="{SITE_URL}index.php?app=tag&ac=admin&mg=list">全部标签</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div style="height: 100px;"></div>
|
||||
@@ -0,0 +1,30 @@
|
||||
{php include pubTemplate("header_admin")}
|
||||
|
||||
<div class="midder">
|
||||
{php include template("admin/menu");}
|
||||
|
||||
|
||||
|
||||
|
||||
<form method="POST" action="index.php?app={$app}&ac=admin&mg=options&ts=do">
|
||||
<table class="table table-hover">
|
||||
|
||||
<tr><td width="150">APP名称:</td><td><input style="width:300px;" name="option[appname]" value="{$strOption[appname]}" /></td></tr>
|
||||
|
||||
<tr><td>APP介绍:</td><td><textarea style="width:300px;" name="option[appdesc]">{$strOption[appdesc]}</textarea></td></tr>
|
||||
|
||||
<tr><td>APP关键词:</td><td><input style="width:300px;" name="option[appkey]" value="{$strOption[appkey]}" /></td></tr>
|
||||
|
||||
<tr><td>标签是否审核显示:</td><td><input type="radio" name="option[isaudit]" value="0" {if $strOption['isaudit']=='0'}checked{/if} />不审核 <input type="radio" name="option[isaudit]" value="1" {if $strOption['isaudit']=='1'}checked{/if} />审核</td></tr>
|
||||
|
||||
<tr><td></td><td>
|
||||
<input type="hidden" name="token" value="{$_SESSION['token']}" />
|
||||
<input class="btn btn-primary" type="submit" value="提交修改" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{php include pubTemplate("footer_admin")}
|
||||
Reference in New Issue
Block a user