#422 重新编写了数据新闻功能,文档类中优化若干操作,添加单文档字段调用方法。处理文档控制器中的文档时间判断bug,增加数据新闻相关内容的元数据标题和链接展示
This commit is contained in:
parent
6384c029cb
commit
8ae51fb0fb
|
@ -177,10 +177,10 @@ class ArchivesController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->deepField = $category->DeepTitle;
|
$this->view->deepField = $category->DeepTitle;
|
||||||
|
|
||||||
$time = date("Y-m-d",time());
|
$time = date("Y-m-d H:i:s",time());
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT n.*,c.title as typename,c.code,u.realname as author FROM ".$News->tbl_archives." n
|
$sql = "SELECT n.*,c.title as typename,c.code,u.realname as author,ct.uuid as mduuid FROM ".$News->tbl_archives." n
|
||||||
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
||||||
left join ".$News->tbl_categorys." c ON ct.cid=c.id
|
left join ".$News->tbl_categorys." c ON ct.cid=c.id
|
||||||
LEFT JOIN users u ON n.userid=u.id
|
LEFT JOIN users u ON n.userid=u.id
|
||||||
|
@ -197,6 +197,14 @@ class ArchivesController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->infos = $row;
|
$this->view->infos = $row;
|
||||||
|
|
||||||
|
if(!empty($row['mduuid']))
|
||||||
|
{
|
||||||
|
$sql = "SELECT uuid,title FROM metadata WHERE uuid='{$row['mduuid']}'";
|
||||||
|
$sth = $this->db->query($sql);
|
||||||
|
$mdinfo = $sth->fetch();
|
||||||
|
}
|
||||||
|
$this->view->mdinfo = $mdinfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchAction()
|
function searchAction()
|
||||||
|
|
|
@ -15,7 +15,7 @@ class AuthorController extends Zend_Controller_Action
|
||||||
// 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱
|
// 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱
|
||||||
// 1 为开启
|
// 1 为开启
|
||||||
// 0 为关闭
|
// 0 为关闭
|
||||||
public $debug = 0;
|
public $debug = 1;
|
||||||
|
|
||||||
//调试模式邮箱地址
|
//调试模式邮箱地址
|
||||||
public $debug_email = "wangliangxu@lzb.ac.cn";
|
public $debug_email = "wangliangxu@lzb.ac.cn";
|
||||||
|
@ -1234,44 +1234,58 @@ class AuthorController extends Zend_Controller_Action
|
||||||
$u_id = $user->id;
|
$u_id = $user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$News = new Archive($this->db);
|
||||||
|
$category = new ArchiveCategory($this->db);
|
||||||
|
|
||||||
//新闻列表
|
//新闻列表
|
||||||
if(empty($ac) || $ac=="list")
|
if(empty($ac) || $ac=="list")
|
||||||
{
|
{
|
||||||
$keyword = $this->_request->getParam('q');
|
$keyword = $this->_request->getParam('q');
|
||||||
$uuid = $this->_request->getParam('uuid');
|
$uuid = $this->_request->getParam('uuid');
|
||||||
|
|
||||||
$wheresql = "";
|
$wheresql = array();
|
||||||
$join = "";
|
$join = "";
|
||||||
|
|
||||||
if(!empty($keyword))
|
if(!empty($keyword))
|
||||||
{
|
{
|
||||||
$this->view->q = $keyword;
|
$this->view->q = $keyword;
|
||||||
$search = new Search($keyword);
|
$search = new Search($keyword);
|
||||||
$wheresql = $search->sql_expr(array("arc.title","arc.description"));
|
$wheresql[] = $search->sql_expr(array("arc.title","arc.description"));
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($wheresql))
|
|
||||||
{
|
|
||||||
$wheresql = " AND ".$wheresql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($uuid) && preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
if(!empty($uuid) && preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||||
{
|
{
|
||||||
$join = "LEFT JOIN news_mdnews mdnews ON mdnews.aid=arc.id";
|
$wheresql[] = " ct.uuid='$uuid' ";
|
||||||
$wheresql .= " AND mdnews.uuid='$uuid'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT arc.id,arc.title,arc.ts_published,arc.description,u.realname FROM news_archives arc
|
$wheresql[] = " c.code='".$category->DataNewsCode."' ";
|
||||||
|
$wheresql[] = " ct.uuid IS NOT NULL ";
|
||||||
|
$wheresql[] = " arc.userid=$u_id";
|
||||||
|
|
||||||
|
if(count($wheresql)>0)
|
||||||
|
{
|
||||||
|
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT arc.*,c.id as cid,u.realname,md.title as mdtitle,md.uuid as mduuid FROM ".$News->tbl_archives." arc
|
||||||
|
LEFT JOIN ".$News->tbl_catalog." ct ON arc.id=ct.aid
|
||||||
|
LEFT JOIN ".$News->tbl_categorys." c ON ct.cid=c.id
|
||||||
LEFT JOIN users u ON arc.userid=u.id
|
LEFT JOIN users u ON arc.userid=u.id
|
||||||
$join
|
LEFT JOIN metadata md ON ct.uuid=md.uuid
|
||||||
WHERE arc.is_pub>0 AND arc.ts_published<'now()' $wheresql
|
$wheresql
|
||||||
ORDER BY arc.ts_published";
|
ORDER BY arc.ts_published DESC";
|
||||||
|
|
||||||
|
|
||||||
$sth = $this->db->prepare($sql);
|
$sth = $this->db->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
$rows = $sth->fetchAll();
|
$rows = $sth->fetchAll();
|
||||||
|
|
||||||
|
foreach($rows as $k=>$v)
|
||||||
|
{
|
||||||
|
$arcinfo = $News->getArchiveUrlByCid($v['id'],$v['cid']);
|
||||||
|
$rows[$k]['url'] = $arcinfo['archive_url'];
|
||||||
|
}
|
||||||
|
|
||||||
$paginator = Zend_Paginator::factory($rows);
|
$paginator = Zend_Paginator::factory($rows);
|
||||||
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
||||||
$paginator->setItemCountPerPage(10);
|
$paginator->setItemCountPerPage(10);
|
||||||
|
@ -1281,32 +1295,6 @@ class AuthorController extends Zend_Controller_Action
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ac == "view")
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->_helper->viewRenderer('news-view');
|
|
||||||
$aid = (int)$this->_request->getParam('aid');
|
|
||||||
|
|
||||||
if(empty($aid) || !is_numeric($aid))
|
|
||||||
{
|
|
||||||
$this->_redirect('/error/error');
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->exec("UPDATE news_archives arc SET click=click+1 WHERE arc.id=$aid");
|
|
||||||
$sql = "SELECT arc.*,u.realname FROM news_archives arc
|
|
||||||
LEFT JOIN users u ON u.id=arc.userid
|
|
||||||
WHERE arc.id=?";
|
|
||||||
$sth = $this->db->prepare($sql);
|
|
||||||
$sth -> execute(array($aid));
|
|
||||||
$row = $sth->fetch();
|
|
||||||
$this->view->info = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//新闻发布
|
//新闻发布
|
||||||
if($ac == "add")
|
if($ac == "add")
|
||||||
{
|
{
|
||||||
|
@ -1329,21 +1317,41 @@ class AuthorController extends Zend_Controller_Action
|
||||||
$this->_helper->viewRenderer('news-edit');
|
$this->_helper->viewRenderer('news-edit');
|
||||||
|
|
||||||
$aid = (int)$this->_request->getParam('aid');
|
$aid = (int)$this->_request->getParam('aid');
|
||||||
|
$uuid = $this->_request->getParam('uuid');
|
||||||
|
|
||||||
if(empty($aid) || !is_numeric($aid))
|
if(empty($aid) || !is_numeric($aid))
|
||||||
{
|
{
|
||||||
$this->_redirect('/error/error');
|
$this->_redirect('/error/error');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT arc.*,mdarc.uuid FROM news_archives arc
|
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||||
LEFT JOIN news_mdnews mdarc ON mdarc.aid = arc.id
|
{
|
||||||
|
$this->_redirect('/error/error');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->uuid = $uuid;
|
||||||
|
|
||||||
|
$sql = "SELECT arc.* FROM ".$News->tbl_archives." arc
|
||||||
WHERE id=?";
|
WHERE id=?";
|
||||||
$sth = $this->db->prepare($sql);
|
$sth = $this->db->prepare($sql);
|
||||||
$sth->execute(array($aid));
|
$sth->execute(array($aid));
|
||||||
$row = $sth->fetch();
|
$row = $sth->fetch();
|
||||||
|
|
||||||
|
$keywords = $News->GetTags($aid);
|
||||||
|
$row['keywords'] = join(",",$keywords);
|
||||||
|
|
||||||
$this->view->info = $row;
|
$this->view->info = $row;
|
||||||
|
|
||||||
|
$sql = "SELECT md.title,md.uuid FROM metadata md
|
||||||
|
LEFT JOIN mdauthor a ON a.uuid = md.uuid
|
||||||
|
WHERE a.userid=? AND a.status=1
|
||||||
|
";
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute(array($u_id));
|
||||||
|
$rows = $sth->fetchAll();
|
||||||
|
|
||||||
|
$this->view->md = $rows;
|
||||||
|
|
||||||
}//$ac == "edit"
|
}//$ac == "edit"
|
||||||
|
|
||||||
//新闻发布的ajax动作
|
//新闻发布的ajax动作
|
||||||
|
@ -1436,47 +1444,28 @@ class AuthorController extends Zend_Controller_Action
|
||||||
|
|
||||||
//默认填充数据
|
//默认填充数据
|
||||||
$data['source'] = "西部数据中心";
|
$data['source'] = "西部数据中心";
|
||||||
$data['typeid'] = 0;
|
|
||||||
$data['userid'] = $u_id;
|
$data['userid'] = $u_id;
|
||||||
$data['keyword'] = str_replace(",",",",$data['keyword']);
|
$keyword = str_replace(",",",",$data['keyword']);
|
||||||
|
$data['ts_published'] = date("Y-m-d H:i:s",time());
|
||||||
|
$data['is_pub'] = true;
|
||||||
|
$data['image'] = "";
|
||||||
|
|
||||||
|
unset($data['keyword']);
|
||||||
|
|
||||||
|
$dataNewsCategory = $category->GetOne('datanews');
|
||||||
|
$dataNewsCategoryID = $dataNewsCategory['id'];
|
||||||
|
|
||||||
//新闻添加
|
//新闻添加
|
||||||
if(empty($aid))
|
if(empty($aid))
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO news_archives
|
$newAid = $News->addArchive($data,$dataNewsCategoryID,$keyword,$uuid);
|
||||||
(userid,title,keywords,description,image,source,ts_published,is_pub,body)
|
|
||||||
VALUES
|
|
||||||
(?,?,?,?,?,?,?,?,?)
|
|
||||||
RETURNING id
|
|
||||||
";
|
|
||||||
$sth = $this->db->prepare($sql);
|
|
||||||
$ex = $sth -> execute(array($data['userid'],$data['title'],$data['keyword'],$data['description'],'',$data['source'],'now()',1,$data['body']));
|
|
||||||
|
|
||||||
//添加成功
|
//添加成功
|
||||||
if($ex)
|
if($newAid>0)
|
||||||
{
|
|
||||||
//写入文章ID对应UUID的表
|
|
||||||
$archive = $sth->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$aid = $archive['id'];
|
|
||||||
|
|
||||||
$sql = "INSERT INTO news_mdnews (aid,uuid) VALUES (?,?)";
|
|
||||||
$sth = $this->db->prepare($sql);
|
|
||||||
$uuidex = $sth->execute(array($aid,$uuid));
|
|
||||||
|
|
||||||
if($uuidex)
|
|
||||||
{
|
{
|
||||||
$msg['status'] = 1;
|
$msg['status'] = 1;
|
||||||
$msg['outstring'] = "新闻添加成功";
|
$msg['outstring'] = "新闻添加成功";
|
||||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
||||||
return true;
|
return true;
|
||||||
}else{
|
|
||||||
$sql = "DELETE FROM news_archives WHERE id=$aid";
|
|
||||||
@$this->db->exec($sql); //如果新闻添加失败就删除原新闻,否则产生重复错误
|
|
||||||
$msg['status'] = 0;
|
|
||||||
$msg['error'] = "新闻添加失败,请重试";
|
|
||||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//添加失败
|
//添加失败
|
||||||
}else{
|
}else{
|
||||||
$msg['status'] = 0;
|
$msg['status'] = 0;
|
||||||
|
@ -1489,11 +1478,15 @@ class AuthorController extends Zend_Controller_Action
|
||||||
//新闻修改
|
//新闻修改
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = "UPDATE news_archives SET title=?,keywords=?,description=?,body=? WHERE id=? AND userid=?";
|
if($u_id != $News->getArchiveField($aid,"userid"))
|
||||||
$sth = $this->db->prepare($sql);
|
{
|
||||||
$ex = $sth -> execute(array($data['title'],$data['keyword'],$data['description'],$data['body'],$aid,$data['userid']));
|
$msg['status'] = 0;
|
||||||
|
$msg['outstring'] = "新闻编辑失败,您没有权限";
|
||||||
if($ex)
|
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$updated = $News->updateArchive($aid,$data,$dataNewsCategoryID,$keyword,$uuid);
|
||||||
|
if($updated)
|
||||||
{
|
{
|
||||||
$msg['status'] = 1;
|
$msg['status'] = 1;
|
||||||
$msg['outstring'] = "新闻编辑成功";
|
$msg['outstring'] = "新闻编辑成功";
|
||||||
|
@ -1526,7 +1519,35 @@ class AuthorController extends Zend_Controller_Action
|
||||||
}//catch end
|
}//catch end
|
||||||
}//$ac = 'newsadd' endif;
|
}//$ac = 'newsadd' endif;
|
||||||
|
|
||||||
|
if($ac == "del")
|
||||||
|
{
|
||||||
|
$this->_helper->layout->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
|
$aid = $this->_getParam('aid');
|
||||||
|
if(!is_numeric($aid))
|
||||||
|
{
|
||||||
|
$this->jsonexit(array("error"=>"参数错误"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$News = new Archive($this->db);
|
||||||
|
|
||||||
|
if($u_id != $News->getArchiveField($aid,"userid"))
|
||||||
|
{
|
||||||
|
$this->jsonexit(array("error"=>"您没有权限"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($News->DeleteArchives($aid))
|
||||||
|
{
|
||||||
|
$this->jsonexit(array("deleted"=>$aid));
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
$this->jsonexit(array("error"=>"删除失败",'aid'=>$aid));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}//newsAction() 数据新闻
|
}//newsAction() 数据新闻
|
||||||
|
|
||||||
function viewauthorsAction(){
|
function viewauthorsAction(){
|
||||||
|
|
|
@ -40,6 +40,9 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
|
||||||
|
|
||||||
<div class="title"><?php echo $this->infos['title'];?></div>
|
<div class="title"><?php echo $this->infos['title'];?></div>
|
||||||
<div class="info">时间 : <?php echo date("Y-m-d H:i",strtotime($this->infos['ts_published']));?> 作者 : <?php echo $this->infos['author'];?> 来源 : <?php echo $this->infos['source'];?></div>
|
<div class="info">时间 : <?php echo date("Y-m-d H:i",strtotime($this->infos['ts_published']));?> 作者 : <?php echo $this->infos['author'];?> 来源 : <?php echo $this->infos['source'];?></div>
|
||||||
|
<?php if(!empty($this->mdinfo)){?>
|
||||||
|
<div class="info">相关数据:《<a href="/data/<?= $this->mdinfo['uuid']?>"><?= $this->mdinfo['title']?></a>》</div>
|
||||||
|
<?php } ?>
|
||||||
<div class="archive_content">
|
<div class="archive_content">
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -38,6 +38,27 @@ $this->breadcrumb()->setSeparator(' > ');
|
||||||
<input type="text" id="producttitle" class="half" value="<?php echo $this->info['title'];?>" name="title" maxlength="100"/>
|
<input type="text" id="producttitle" class="half" value="<?php echo $this->info['title'];?>" name="title" maxlength="100"/>
|
||||||
<small>请准确概况新闻内容</small>
|
<small>请准确概况新闻内容</small>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label class="required" for="data">相关数据</label><br/>
|
||||||
|
<select id="data" name="uuid">
|
||||||
|
<option value="0">请选择相关数据</option>
|
||||||
|
<?php
|
||||||
|
if(!empty($this->md))
|
||||||
|
{
|
||||||
|
foreach($this->md as $v)
|
||||||
|
{
|
||||||
|
if($v['uuid'] == $this->uuid)
|
||||||
|
{
|
||||||
|
echo '<option value="'.$v['uuid'].'" selected="selected">'.$v['title'].'</option>';
|
||||||
|
}else{
|
||||||
|
echo '<option value="'.$v['uuid'].'">'.$v['title'].'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<small>从数据中选择一条</small>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label class="required" for="producttitle">标签</label><br/>
|
<label class="required" for="producttitle">标签</label><br/>
|
||||||
<input type="text" id="keyword" class="half" value="<?php echo $this->info['keywords'];?>" name="keyword"/>
|
<input type="text" id="keyword" class="half" value="<?php echo $this->info['keywords'];?>" name="keyword"/>
|
||||||
|
|
|
@ -4,6 +4,8 @@ $this->headTitle($this->config->title->author);
|
||||||
$this->headTitle()->setSeparator(' - ');
|
$this->headTitle()->setSeparator(' - ');
|
||||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||||
$this->headLink()->appendStylesheet('/css/author.css');
|
$this->headLink()->appendStylesheet('/css/author.css');
|
||||||
|
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||||
|
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||||
$this->breadcrumb('<a href="/">首页</a>');
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
$this->breadcrumb('<a href="/author">数据作者</a>');
|
$this->breadcrumb('<a href="/author">数据作者</a>');
|
||||||
$this->breadcrumb('数据新闻');
|
$this->breadcrumb('数据新闻');
|
||||||
|
@ -37,9 +39,14 @@ $this->breadcrumb()->setSeparator(' > ');
|
||||||
foreach ($this->paginator as $item):
|
foreach ($this->paginator as $item):
|
||||||
$autoindex++;
|
$autoindex++;
|
||||||
?>
|
?>
|
||||||
<li>
|
<li id="item_<?= $item['id'] ?>">
|
||||||
<p><a href="/author/news/ac/view/aid/<?php echo $item['id'];?>" class="title"><?php echo $item['title'];?></a></p>
|
<p><a href="<?php echo $item['url'];?>" class="title"><?php echo $item['title'];?></a></p>
|
||||||
<p>作者:<?php echo $item['realname'];?> 发布时间:<?php echo date("Y-m-d",strtotime($item['ts_published']));?></p>
|
<p>
|
||||||
|
作者:<?php echo $item['realname'];?> |
|
||||||
|
发布时间:<?php echo date("Y-m-d",strtotime($item['ts_published']));?> |
|
||||||
|
关联数据:《<a href="/data/<?= $item['mduuid'] ?>"><?php echo $item['mdtitle'];?></a>》 |
|
||||||
|
操作:<a href="/author/news/ac/edit/aid/<?= $item['id']?>/uuid/<?= $item['mduuid'] ?>">编辑</a> ·
|
||||||
|
<a href="javascript:;" onclick="del(<?= $item['id'] ?>)" id="delBtn_<?= $item['id'] ?>">删除</a></p>
|
||||||
<p><?php echo $item['description'];?></p>
|
<p><?php echo $item['description'];?></p>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
|
@ -52,5 +59,34 @@ $this->breadcrumb()->setSeparator(' > ');
|
||||||
<!-- //页面内容 -->
|
<!-- //页面内容 -->
|
||||||
<script>
|
<script>
|
||||||
$('#wapper').width($('body').width()-300);
|
$('#wapper').width($('body').width()-300);
|
||||||
|
function del(id){
|
||||||
|
var dom = "#delBtn_"+id;
|
||||||
|
var html = $(dom).html();
|
||||||
|
$.ajax({
|
||||||
|
'type':"POST",
|
||||||
|
'url':'/author/news/ac/del',
|
||||||
|
'data':'aid='+id,
|
||||||
|
'success':function(data){
|
||||||
|
if (typeof(data)=='object')
|
||||||
|
{
|
||||||
|
if(typeof(data.error)!='undefined')
|
||||||
|
{Alert(data.error);return false;}
|
||||||
|
if(typeof(data.msg)!='undefined')
|
||||||
|
{Alert(data.msg);}
|
||||||
|
if(typeof(data.deleted)!='undefined')
|
||||||
|
{$('#item_'+id).fadeOut(function(){$(this).remove();});}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Alert('出现错误,请稍后再试');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'timeout': 30000,
|
||||||
|
'error': function(){Alert('处理中出现错误,请刷新页面后重试');},
|
||||||
|
'beforeSend':function(){$(dom).html('<img src="/images/ajax-load-small.gif" />');$(dom).attr("disabled","disabled")},
|
||||||
|
'complete':function(){$(dom).html(html);$(dom).removeAttr("disabled");dom = null;}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function Alert(html){
|
||||||
|
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
|
@ -124,22 +124,32 @@ class Archive
|
||||||
foreach($rows as $k=>$v)
|
foreach($rows as $k=>$v)
|
||||||
{
|
{
|
||||||
$types[] = $v['cid'];
|
$types[] = $v['cid'];
|
||||||
|
if(is_array($typeid))
|
||||||
|
{
|
||||||
if(!in_array($v['cid'],$typeid))
|
if(!in_array($v['cid'],$typeid))
|
||||||
{
|
{
|
||||||
//删除一个栏目
|
//删除一个栏目
|
||||||
$this->DeleteCatalog($v['id']);
|
$this->DeleteCatalog($v['id']);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$this->DeleteCatalog($v['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_array($typeid))
|
||||||
|
{
|
||||||
foreach($typeid as $v)
|
foreach($typeid as $v)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!in_array($v,$types))
|
if(!in_array($v,$types))
|
||||||
{
|
{
|
||||||
//添加一个栏目
|
//添加一个栏目
|
||||||
$this->ToCatalog($aid,$v);
|
$this->ToCatalog($aid,$v,$uuid,$status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$this->ToCatalog($aid,$typeid,$uuid,$status);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
|
@ -204,7 +214,7 @@ class Archive
|
||||||
{
|
{
|
||||||
$tag = explode(",",$keywords);
|
$tag = explode(",",$keywords);
|
||||||
}else{
|
}else{
|
||||||
if($this->db->insert($this->tbl_tag,array("id"=>$aid,"tag"=>$tag)))
|
if($this->db->insert($this->tbl_tag,array("id"=>$aid,"tag"=>$keywords)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
@ -275,7 +285,7 @@ class Archive
|
||||||
*
|
*
|
||||||
* @return int;
|
* @return int;
|
||||||
*/
|
*/
|
||||||
function addArchive($data,$typeid,$keyword='')
|
function addArchive($data,$typeid,$keyword='',$uuid='')
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = $this->scanField($data);
|
$data = $this->scanField($data);
|
||||||
|
@ -303,7 +313,7 @@ class Archive
|
||||||
{
|
{
|
||||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$newAid = $temp['id'];
|
$newAid = $temp['id'];
|
||||||
$this->AddToCatalog($newAid,$typeid);
|
$this->AddToCatalog($newAid,$typeid,$uuid);
|
||||||
if(!empty($keyword))
|
if(!empty($keyword))
|
||||||
{
|
{
|
||||||
$this->MakeTags($newAid,$keyword);
|
$this->MakeTags($newAid,$keyword);
|
||||||
|
@ -325,7 +335,7 @@ class Archive
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function updateArchive($aid,$data,$typeid,$keyword='')
|
function updateArchive($aid,$data,$typeid,$keyword='',$uuid='')
|
||||||
{
|
{
|
||||||
if(!is_numeric($aid))
|
if(!is_numeric($aid))
|
||||||
{
|
{
|
||||||
|
@ -356,7 +366,7 @@ class Archive
|
||||||
$this->DeleteTags($aid);
|
$this->DeleteTags($aid);
|
||||||
$this->MakeTags($aid,$keyword);
|
$this->MakeTags($aid,$keyword);
|
||||||
}
|
}
|
||||||
$this->ChangeCatalog($aid,$typeid);
|
$this->ChangeCatalog($aid,$typeid,$uuid);
|
||||||
return $aid;
|
return $aid;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -503,4 +513,25 @@ class Archive
|
||||||
$rows=$sth->fetch();
|
$rows=$sth->fetch();
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getArchiveField() 读取某个文档的某个字段
|
||||||
|
*
|
||||||
|
* @param int $aid
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getArchiveField($aid,$field)
|
||||||
|
{
|
||||||
|
if(!is_numeric($aid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT $field as output_string FROM ".$this->tbl_archives." WHERE id=$aid";
|
||||||
|
$sth = $this->db->query($sql);
|
||||||
|
$row = $sth->fetch();
|
||||||
|
|
||||||
|
return $row['output_string'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,12 +241,12 @@ class ArchiveCategory
|
||||||
|
|
||||||
if(is_numeric($tid))
|
if(is_numeric($tid))
|
||||||
{
|
{
|
||||||
$wehresql = "id=$tid";
|
$wheresql = "id=$tid";
|
||||||
}else{
|
}else{
|
||||||
$wheresql = "code='$tid'";
|
$wheresql = "code='$tid'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM ".$this->CategoryTable." WHERE id=$tid";
|
$sql = "SELECT * FROM ".$this->CategoryTable." WHERE $wheresql";
|
||||||
$sth = $this->db->query($sql);
|
$sth = $this->db->query($sql);
|
||||||
return $sth->fetch();
|
return $sth->fetch();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue