#422 添加了单个文章多个UUID的选择功能
This commit is contained in:
parent
d312f8afe0
commit
cd070a7ca8
|
@ -180,7 +180,9 @@ class ArchivesController extends Zend_Controller_Action
|
|||
$time = date("Y-m-d H:i:s",time());
|
||||
|
||||
|
||||
$sql = "SELECT n.*,c.title as typename,c.code,u.realname as author,ct.uuid as mduuid 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_categorys." c ON ct.cid=c.id
|
||||
LEFT JOIN users u ON n.userid=u.id
|
||||
|
@ -199,9 +201,11 @@ class ArchivesController extends Zend_Controller_Action
|
|||
|
||||
if(!empty($row['mduuid']))
|
||||
{
|
||||
$sql = "SELECT uuid,title FROM metadata WHERE uuid='{$row['mduuid']}'";
|
||||
$sql = "SELECT md.uuid,md.title FROM ar_catalog ct
|
||||
LEFT JOIN metadata md ON ct.uuid=md.uuid
|
||||
WHERE ct.aid=$archive";
|
||||
$sth = $this->db->query($sql);
|
||||
$mdinfo = $sth->fetch();
|
||||
$mdinfo = $sth->fetchAll();
|
||||
}
|
||||
$this->view->mdinfo = $mdinfo;
|
||||
|
||||
|
|
|
@ -1267,12 +1267,15 @@ class AuthorController extends Zend_Controller_Action
|
|||
$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
|
||||
$sql = "SELECT arc.id,arc.title,arc.description,arc.ts_published
|
||||
,c.id as cid,u.realname
|
||||
,count(arc.id) as datacount
|
||||
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 metadata md ON ct.uuid=md.uuid
|
||||
$wheresql
|
||||
GROUP BY arc.id,c.id,u.realname
|
||||
ORDER BY arc.ts_published DESC";
|
||||
|
||||
|
||||
|
@ -1367,7 +1370,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
$data['title'] = trim($this->_request->getParam('title'));
|
||||
$data['keyword'] = trim($this->_request->getParam('keyword'));
|
||||
$data['body'] = trim($this->_request->getParam('body'));
|
||||
$uuid = trim($this->_request->getParam('uuid'));
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
|
||||
//对参数进行预处理
|
||||
foreach($data as $k=>$v)
|
||||
|
@ -1430,7 +1433,29 @@ class AuthorController extends Zend_Controller_Action
|
|||
return true;
|
||||
}
|
||||
|
||||
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))
|
||||
if(is_array($uuid))
|
||||
{
|
||||
if(count($uuid)<1)
|
||||
{
|
||||
$msg['status'] = 0;
|
||||
$msg['error'] = '参数错误,请重试';
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach($uuid as $v)
|
||||
{
|
||||
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}$/",$v))
|
||||
{
|
||||
$msg['status'] = 0;
|
||||
$msg['error'] = '参数错误,请重试';
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else 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))
|
||||
{
|
||||
$msg['status'] = 0;
|
||||
$msg['error'] = '参数错误,请重试';
|
||||
|
@ -1485,6 +1510,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
$updated = $News->updateArchive($aid,$data,$dataNewsCategoryID,$keyword,$uuid);
|
||||
if($updated)
|
||||
{
|
||||
|
|
|
@ -41,8 +41,9 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
|
|||
<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['source'];?></div>
|
||||
<?php if(!empty($this->mdinfo)){?>
|
||||
<div class="info">相关数据:《<a href="/data/<?= $this->mdinfo['uuid']?>"><?= $this->mdinfo['title']?></a>》</div>
|
||||
<?php } ?>
|
||||
<?php foreach($this->mdinfo as $v){ ?>
|
||||
<div class="info">相关数据:《<a href="/data/<?= $v['uuid']?>"><?= $v['title']?></a>》</div>
|
||||
<?php } } ?>
|
||||
<div class="archive_content">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
|
|
|
@ -42,18 +42,17 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
</p>
|
||||
<p>
|
||||
<label class="required" for="data">相关数据</label><br/>
|
||||
<select id="data" name="uuid">
|
||||
<option value="0">请选择相关数据</option>
|
||||
<ul style="height:100px;width:50%;overflow-y:scroll;">
|
||||
<?php
|
||||
if(!empty($this->md))
|
||||
{
|
||||
foreach($this->md as $v)
|
||||
{
|
||||
echo '<option value="'.$v['uuid'].'">'.$v['title'].'</option>';
|
||||
echo '<li><input type="checkbox" value="'.$v['uuid'].'" name="uuid[]" />'.$v['title'].'</li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</ul>
|
||||
<small>从数据中选择一条</small>
|
||||
</p>
|
||||
<p>
|
||||
|
|
|
@ -40,8 +40,7 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
</p>
|
||||
<p>
|
||||
<label class="required" for="data">相关数据</label><br/>
|
||||
<select id="data" name="uuid">
|
||||
<option value="0">请选择相关数据</option>
|
||||
<ul style="height:100px;width:50%;overflow-y:scroll;">
|
||||
<?php
|
||||
if(!empty($this->md))
|
||||
{
|
||||
|
@ -49,15 +48,14 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
{
|
||||
if($v['uuid'] == $this->uuid)
|
||||
{
|
||||
echo '<option value="'.$v['uuid'].'" selected="selected">'.$v['title'].'</option>';
|
||||
echo '<li><input type="checkbox" name="uuid[]" value="'.$v['uuid'].'" checked="checked" />'.$v['title'].'</li>';
|
||||
}else{
|
||||
echo '<option value="'.$v['uuid'].'">'.$v['title'].'</option>';
|
||||
echo '<li><input type="checkbox" name="uuid[]" value="'.$v['uuid'].'" />'.$v['title'].'</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<small>从数据中选择一条</small>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
<label class="required" for="producttitle">标签</label><br/>
|
||||
|
|
|
@ -44,7 +44,7 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
<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>》 |
|
||||
关联数据:<?php echo $item['datacount'];?>条 |
|
||||
操作:<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>
|
||||
|
|
|
@ -88,16 +88,49 @@ class Archive
|
|||
return false;
|
||||
}
|
||||
|
||||
//多个cid
|
||||
if(is_array($cid))
|
||||
{
|
||||
|
||||
foreach($cid as $v)
|
||||
{
|
||||
//多个UUID
|
||||
if(is_array($uuid))
|
||||
{
|
||||
foreach ($uuid as $vv)
|
||||
{
|
||||
$this->ToCatalog($aid,$v,$vv,$status);
|
||||
}
|
||||
}
|
||||
|
||||
//单个UUID
|
||||
else{
|
||||
$this->ToCatalog($aid,$v,$uuid,$status);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
//单个cid
|
||||
else{
|
||||
|
||||
//多个UUID
|
||||
if(is_array($uuid))
|
||||
{
|
||||
foreach($uuid as $v)
|
||||
{
|
||||
$this->ToCatalog($aid,$cid,$v,$status);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//单个cid和uuid
|
||||
else{
|
||||
return $this->ToCatalog($aid,$cid,$uuid,$status);
|
||||
}
|
||||
}
|
||||
}//AddToCatalog
|
||||
|
||||
|
||||
|
@ -140,7 +173,6 @@ class Archive
|
|||
{
|
||||
foreach($typeid as $v)
|
||||
{
|
||||
|
||||
if(!in_array($v,$types))
|
||||
{
|
||||
//添加一个栏目
|
||||
|
@ -157,6 +189,52 @@ class Archive
|
|||
|
||||
}//ChangeCatalog
|
||||
|
||||
//ChangeCatalogByUUID 根据UUID更改记录
|
||||
function ChangeCatalogByUUID($aid,$typeid,$uuid,$status=0)
|
||||
{
|
||||
|
||||
try{
|
||||
$sql = "SELECT * FROM ar_catalog WHERE aid=$aid";
|
||||
$sth = $this->db->query($sql);
|
||||
$rows = $sth->fetchAll();
|
||||
|
||||
$types = array();
|
||||
|
||||
foreach($rows as $k=>$v)
|
||||
{
|
||||
$types[] = $v['uuid'];
|
||||
if(is_array($uuid))
|
||||
{
|
||||
if(!in_array($v['uuid'],$uuid))
|
||||
{
|
||||
//删除一个栏目
|
||||
$this->DeleteCatalog($v['id']);
|
||||
}
|
||||
}else{
|
||||
$this->DeleteCatalog($v['id']);
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($uuid))
|
||||
{
|
||||
|
||||
foreach($uuid as $v)
|
||||
{
|
||||
if(!in_array($v,$types))
|
||||
{
|
||||
//添加一个记录
|
||||
$this->ToCatalog($aid,$typeid,$v,$status);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->ToCatalog($aid,$typeid,$uuid,$status);
|
||||
}
|
||||
return true;
|
||||
}catch(Exception $e){
|
||||
return $e->getMessage();
|
||||
}
|
||||
}//ChangeCatalogByUUID
|
||||
|
||||
//修改文档状态
|
||||
function ChangeStatus($aid,$pub){
|
||||
|
||||
|
@ -366,7 +444,13 @@ class Archive
|
|||
$this->DeleteTags($aid);
|
||||
$this->MakeTags($aid,$keyword);
|
||||
}
|
||||
if(!is_array($uuid))
|
||||
{
|
||||
$this->ChangeCatalog($aid,$typeid,$uuid);
|
||||
}
|
||||
else{
|
||||
$this->ChangeCatalogByUUID($aid,$typeid,$uuid);
|
||||
}
|
||||
return $aid;
|
||||
}else{
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue