diff --git a/application/admin/views/scripts/data/doi.phtml b/application/admin/views/scripts/data/doi.phtml
index b9f6a989..7f0cc81e 100644
--- a/application/admin/views/scripts/data/doi.phtml
+++ b/application/admin/views/scripts/data/doi.phtml
@@ -1,80 +1,79 @@
-headTitle($this->config->title->site);
-$this->headTitle($this->config->title->author);
-$this->headTitle()->setSeparator(' - ');
-$this->breadcrumb('
首页');
-$this->breadcrumb('
数据管理');
-$this->breadcrumb('DOI');
-$this->breadcrumb()->setSeparator(' > ');
-$this->theme->AppendPlus($this,'colorbox');
-$this->theme->AppendPlus($this,'admin_plugin');
-?>
-
-
-
- = $this->partial('data/left.phtml'); ?>
-
-
-
-
- error)) { ?>
- = $this->error ?>
-
- msg)) { ?>
- = $this->msg ?>
-
-
- paginator)): ?>
-
-
-
- UUID |
- 元数据 |
- DOI |
- 操作 |
-
-
-
- paginator as $item):
- $autoindex++;?>
-
- = $item['uuid'] ?> |
- = $item['title'] ?> |
- = $item['doi'] ?> |
-
- 编辑
- 删除
- |
-
-
-
-
-
-
= $this->paginator; ?>
-
-
-
-
-
-
+headTitle($this->config->title->site);
+$this->headTitle($this->config->title->author);
+$this->headTitle()->setSeparator(' - ');
+$this->breadcrumb('
首页');
+$this->breadcrumb('
数据管理');
+$this->breadcrumb('DOI');
+$this->breadcrumb()->setSeparator(' > ');
+$this->theme->AppendPlus($this,'colorbox');
+$this->theme->AppendPlus($this,'admin_plugin');
+?>
+
+
+
+ = $this->partial('data/left.phtml'); ?>
+
+
+
+
+ error)) { ?>
+ = $this->error ?>
+
+ msg)) { ?>
+ = $this->msg ?>
+
+
+ paginator)): ?>
+
+
+
+ UUID |
+ 元数据 |
+ DOI |
+ 操作 |
+
+
+
+ paginator as $item):
+ $autoindex++;?>
+
+ = $item['uuid'] ?> |
+ = $item['title'] ?> |
+ = $item['doi'] ?> |
+
+ 编辑
+ 删除
+ |
+
+
+
+
+
+
= $this->paginator; ?>
+
+
+
+
+
+
diff --git a/application/models/data/Doi.php b/application/models/data/Doi.php
index 6225be06..b7216b5f 100644
--- a/application/models/data/Doi.php
+++ b/application/models/data/Doi.php
@@ -1,153 +1,179 @@
-db = $db;
- }
-
- function fetch()
- {
- $sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
- $rs = $this->db->query($sql);
- $rows = $rs->fetchAll();
- return $rows;
- }
-
- function add($data){
- include_once("helper/dbh.php");
- $dbh = new dbh($this->db);
- $this->data_process_in($data);
- include_once("helper/view.php");
- view::Dump($data);
- return $dbh->insert($this->tbl_doi,$data);
- }
-
- function update($data,$uuid){
- $doi_info = $this->view($uuid);
- if(!$doi_info)
- {
- $this->data_process_in($data);
- include_once("helper/view.php");
- view::Dump($data);
- include_once("helper/dbh.php");
- $dbh = new dbh($this->db);
- if(is_numeric($uuid))
- {
- $condition = " id=$uuid ";
- }else{
- $condition = " uuid='$uuid' ";
- }
- $state = $dbh->update($this->tbl_doi,$data,$condition,true);
-
- if( $state == true)
- {
- return true;
- }else{
- return $state;
- }
- }else{
- $this->add($data);
- }
- }
-
- function data_process_in(&$data){
- $authors = array();
- $orgs = array();
- foreach($data['info'] as $k=>$v)
- {
- $authors[$v['order']] = $v['author'];
- $orgs[$v['order']] = $v['organization'];
- }
- $authors = "{".join(",",$authors)."}";
- $orgs = "{".join(",",$orgs)."}";
- $data['authors'] = $authors;
- $data['organization'] = $orgs;
- unset($data['info']);
- }
-
- function view($id)
- {
- if(is_numeric($id))
- {
- $sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id";
- }else{
- $sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'";
- }
- $rs = $this->db->query($sql);
- $row = $rs->fetch();
- return $row;
- }
-
- function _getParams(Zend_Controller_Request_Abstract $request)
- {
- $data = array(
- 'doi' => trim($request->getParam('doi')),
- 'uuid' => trim($request->getParam('uuid')),
- 'publisher' => trim($request->getParam('publisher')),
- 'url' => trim($request->getParam('url')),
- 'title' => trim($request->getParam('title')),
- 'info'=>$this->checkinfo($_POST['info'])
- );
- if(!is_array($data['info'])){
- return $data['info'];
- }else{
- $data['info'] = $this->sksort($data['info'],"order",SORT_DESC);
- }
- return $data;
- }
-
- function checkinfo($info){
- if(!is_array($info)){
- return NULL;
- }
- foreach($info as $k=>$v)
- {
- if(empty($v['author']) && empty($v['organization']) && empty($v['order']))
- {
- unset($info[$k]);
- }else{
- if(empty($v['author']))
- {
- return "请输入 $k 中的作者";
- }
- if(empty($v['organization']))
- {
- return "请输入 $k 中的单位";
- }
- if(empty($v['order']))
- {
- return "请输入 $k 中的排序";
- }
- }
- }
- return $info;
- }
-
- function sksort($array,$key,$type=SORT_DESC) {
- $sortArray = array();
-
- foreach($array as $v){
- foreach($v as $key=>$value){
- if(!isset($sortArray[$key])){
- $sortArray[$key] = array();
- }
- $sortArray[$key][] = $value;
- }
- }
-
- if(array_multisort($sortArray[$key],$type,$array))
- {
- return $array;
- }else{
- return $array;
- }
- }
-
-}
+db = $db;
+ }
+
+ function fetch()
+ {
+ $sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
+ $rs = $this->db->query($sql);
+ $rows = $rs->fetchAll();
+ return $rows;
+ }
+
+ function add($data){
+ include_once("helper/dbh.php");
+ $dbh = new dbh($this->db);
+ $this->data_process_in($data);
+ //include_once("helper/view.php");
+ //view::Dump($data);
+ return $dbh->insert($this->tbl_doi,$data);
+ }
+
+ function update($data,$uuid){
+ $doi_info = $this->view($uuid);
+ if($doi_info == false)
+ {
+ return $this->add($data);
+ }else {
+ $this->data_process_in($data);
+ //include_once("helper/view.php");
+ //view::Dump($data);
+ include_once("helper/dbh.php");
+ $dbh = new dbh($this->db);
+ if(is_numeric($uuid))
+ {
+ $condition = " id=$uuid ";
+ }else{
+ $condition = " uuid='$uuid' ";
+ }
+ $state = $dbh->update($this->tbl_doi,$data,$condition,true);
+
+ if( $state == true)
+ {
+ return true;
+ }else{
+ return $state;
+ }
+ }
+ }
+
+ function data_process_in(&$data){
+ $authors = array();
+ $orgs = array();
+ foreach($data['info'] as $k=>$v)
+ {
+ $authors[$v['order']] = $v['author'];
+ $orgs[$v['order']] = $v['organization'];
+ }
+ $authors = "{".join(",",$authors)."}";
+ $orgs = "{".join(",",$orgs)."}";
+ $data['authors'] = $authors;
+ $data['organization'] = $orgs;
+ unset($data['info']);
+ }
+
+ function data_process_out(&$data){
+ $authors = str_replace("{",'',$data['authors']);
+ $authors = str_replace("}",'',$authors);
+ $authors = split(",",$authors);
+ $orgs = str_replace("{",'',$data['organization']);
+ $orgs = str_replace("}",'',$orgs);
+ $orgs = split(",",$orgs);
+ $info = array();
+ foreach($authors as $k=>$v)
+ {
+ $info[$k] = array(
+ 'author'=>$authors[$k],
+ 'organization'=>$orgs[$k],
+ 'order'=>0
+ );
+ }
+ //include_once("helper/view.php");
+ //view::Dump($info);
+ return $info;
+ }
+
+ function view($id)
+ {
+ if(is_numeric($id))
+ {
+ $sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id";
+ }else{
+ $sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'";
+ }
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+ return $row;
+ }
+
+ function delete($id){
+ if(!is_numeric($id))
+ {
+ return "参数错误";
+ }
+ $condition = " id=$id ";
+ $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
+ return $this->db->exec($sql);
+ }
+
+ function _getParams(Zend_Controller_Request_Abstract $request)
+ {
+ $data = array(
+ 'doi' => trim($request->getParam('doi')),
+ 'uuid' => trim($request->getParam('uuid')),
+ 'publisher' => trim($request->getParam('publisher')),
+ 'url' => trim($request->getParam('url')),
+ 'title' => trim($request->getParam('title')),
+ 'info'=>$_POST['info']
+ );
+ return $data;
+ }
+
+ function checkinfo($info){
+ if(!is_array($info)){
+ return NULL;
+ }
+ foreach($info as $k=>$v)
+ {
+ if(empty($v['author']) && empty($v['organization']) && empty($v['order']))
+ {
+ unset($info[$k]);
+ }else{
+ if(empty($v['author']))
+ {
+ return "请输入 $k 中的作者";
+ }
+ if(empty($v['organization']))
+ {
+ return "请输入 $k 中的单位";
+ }
+ if(empty($v['order']))
+ {
+ return "请输入 $k 中的排序";
+ }
+ }
+ }
+ return $info;
+ }
+
+ function sksort($array,$key,$type=SORT_DESC) {
+ $sortArray = array();
+
+ foreach($array as $v){
+ foreach($v as $key=>$value){
+ if(!isset($sortArray[$key])){
+ $sortArray[$key] = array();
+ }
+ $sortArray[$key][] = $value;
+ }
+ }
+
+ if(array_multisort($sortArray[$key],$type,$array))
+ {
+ return $array;
+ }else{
+ return $array;
+ }
+ }
+
+}
diff --git a/application/models/helper/view.php b/application/models/helper/view.php
index c264cda7..2a4f59b7 100644
--- a/application/models/helper/view.php
+++ b/application/models/helper/view.php
@@ -1,82 +1,83 @@
-db = $db;
- }
-
- static function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
- {
- $page = $request->getParam('page');
-
- $paginator = Zend_Paginator::factory($data);
- $paginator->setCurrentPageNumber($page);
- $paginator->setItemCountPerPage(12);
- $paginator->setView($ctl);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $ctl->paginator = $paginator;
- }
-
- static function Msg($type,$content,$url=''){
- $html = '
'."\r\n";
- $html.= '
×'."\r\n";
- $html.= $content."\r\n";
- $html.= '
'."\r\n";
- if(!empty($url))
- {
- if($url == -1){
- $html.= ''."\r\n";
- }else{
- $html.= ''."\r\n";
- }
- }
- return $html;
- }
-
- static function Error($type,$content,$url=''){
- if(empty($type))
- {
- $AlertType = "alert-error";
- }else{
- $AlertType = $type;
- }
- $html = '
'."\r\n";
- $html.= '
×'."\r\n";
- if(!is_array($content)) {
- $html.= '
'.$content.'
'."\r\n";
- }else{
- $html.= '
'."\r\n";
- foreach($content as $v) {
- $html.='- '.$v.'
'."\r\n";
- }
- $html.= '
'."\r\n";
- }
- $html.= '
'."\r\n";
- return $html;
- }
-
- static function User($param){
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity())
- {
- $user = $auth->getIdentity();
- return $user->$param;
- }else{
- return false;
- }
- }
-
- static function Dump($data,$exit = true){
- echo "
";
- var_dump($data);
- echo "
";
- if($exit)
- {
- exit();
- }
- }
+db = $db;
+ }
+
+ static function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
+ {
+ $page = $request->getParam('page');
+
+ $paginator = Zend_Paginator::factory($data);
+ $paginator->setCurrentPageNumber($page);
+ $paginator->setItemCountPerPage(12);
+ $paginator->setView($ctl);
+ Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
+ $ctl->paginator = $paginator;
+ }
+
+ static function Msg($type,$content,$url=''){
+ $html = '
'."\r\n";
+ $html.= '
×'."\r\n";
+ $html.= $content."\r\n";
+ $html.= '
'."\r\n";
+ if(!empty($url))
+ {
+ if($url == -1){
+ $html.= ''."\r\n";
+ }else{
+ $html.= ''."\r\n";
+ }
+ }
+ return $html;
+ }
+
+ static function Error($type,$content,$url=''){
+ if(empty($type))
+ {
+ $AlertType = "alert-error";
+ }else{
+ $AlertType = $type;
+ }
+ $html = '
'."\r\n";
+ $html.= '
×'."\r\n";
+ if(!is_array($content)) {
+ $html.= '
'.$content.'
'."\r\n";
+ }else{
+ $html.= '
'."\r\n";
+ foreach($content as $v) {
+ $html.='- '.$v.'
'."\r\n";
+ }
+ $html.= '
'."\r\n";
+ }
+ $html.= '
'."\r\n";
+ return $html;
+ }
+
+ static function User($param){
+ $auth = Zend_Auth::getInstance();
+ if($auth->hasIdentity())
+ {
+ $user = $auth->getIdentity();
+ return $user->$param;
+ }else{
+ return false;
+ }
+ }
+
+ static function Dump($data,$exit = true){
+ echo "
";
+ var_dump($data);
+ echo "
";
+ if($exit)
+ {
+ exit();
+ }
+ }
+
}
\ No newline at end of file