diff --git a/application/default/controllers/ArchivesController.php b/application/default/controllers/ArchivesController.php index 43916d26..6b8241c4 100644 --- a/application/default/controllers/ArchivesController.php +++ b/application/default/controllers/ArchivesController.php @@ -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; diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index bcbd311a..3f860399 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -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) { diff --git a/application/default/views/scripts/archives/archive.phtml b/application/default/views/scripts/archives/archive.phtml index b568f6a8..bae635c4 100644 --- a/application/default/views/scripts/archives/archive.phtml +++ b/application/default/views/scripts/archives/archive.phtml @@ -41,8 +41,9 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
infos['title'];?>
时间 : infos['ts_published']));?>  来源 : infos['source'];?>
mdinfo)){?> -
相关数据:《mdinfo['title']?>
- + mdinfo as $v){ ?> +
相关数据:《
+
diff --git a/application/default/views/scripts/author/news-add.phtml b/application/default/views/scripts/author/news-add.phtml index bae71c47..d6fe0203 100644 --- a/application/default/views/scripts/author/news-add.phtml +++ b/application/default/views/scripts/author/news-add.phtml @@ -42,18 +42,17 @@ $this->breadcrumb()->setSeparator(' > ');


- '.$v['title'].''; } } ?> - + 从数据中选择一条

diff --git a/application/default/views/scripts/author/news-edit.phtml b/application/default/views/scripts/author/news-edit.phtml index 3ba60960..9ab0c160 100644 --- a/application/default/views/scripts/author/news-edit.phtml +++ b/application/default/views/scripts/author/news-edit.phtml @@ -40,8 +40,7 @@ $this->breadcrumb()->setSeparator(' > ');


- '.$v['title'].''; }else{ - echo ''; + echo '

  • '.$v['title'].'
  • '; } } } ?> - - 从数据中选择一条 +


    diff --git a/application/default/views/scripts/author/news.phtml b/application/default/views/scripts/author/news.phtml index ef0ed7f4..037f3960 100644 --- a/application/default/views/scripts/author/news.phtml +++ b/application/default/views/scripts/author/news.phtml @@ -44,7 +44,7 @@ $this->breadcrumb()->setSeparator(' > ');

    作者: | 发布时间: | - 关联数据:《》 | + 关联数据:条 | 操作:编辑 · 删除

    diff --git a/application/models/Archive.php b/application/models/Archive.php index 26a2c3e0..7db90630 100644 --- a/application/models/Archive.php +++ b/application/models/Archive.php @@ -88,15 +88,48 @@ class Archive return false; } + //多个cid if(is_array($cid)) { + foreach($cid as $v) { - $this->ToCatalog($aid,$v,$uuid,$status); + //多个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{ - return $this->ToCatalog($aid,$cid,$uuid,$status); + + } + + //单个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); } - $this->ChangeCatalog($aid,$typeid,$uuid); + if(!is_array($uuid)) + { + $this->ChangeCatalog($aid,$typeid,$uuid); + } + else{ + $this->ChangeCatalogByUUID($aid,$typeid,$uuid); + } return $aid; }else{ return 0;