在后台DOI中添加了英文标题,英文发布者,作者英文,单位英文的填写
This commit is contained in:
parent
1212fb9711
commit
4c6e4d5a91
File diff suppressed because it is too large
Load Diff
|
@ -1,132 +1,150 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
//$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('DOI');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="/admin/data/doi">浏览所有</a></li>
|
||||
<?php if(!empty($this->uuid)) {?>
|
||||
<li class="active"><a href="javascript:void(0);">编辑DOI</a></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="">
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="doi">doi</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="doi" name="doi" value="<?= (isset($this->data['doi'])&&!empty($this->data['doi'])) ? $this->data['doi']:"doi:10.3972/westdc.x.2013.db" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="uuid">uuid</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="uuid" name="uuid" value="<?= isset($this->data['uuid']) ? $this->data['uuid']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="publisher">发布者</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="publisher" name="publisher" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="url">url</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="url" name="url" value="<?= isset($this->data['url']) ? $this->data['url']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="title">title</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="title" name="title" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($this->data['info']) || !is_array($this->data['info'])) {?>
|
||||
<div class="control-group infocontrol" id="info1">
|
||||
<label class="control-label" for="">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[1][author]" value="" placeholder="作者" />
|
||||
<input type="text" name="info[1][organization]" value="" placeholder="单位" />
|
||||
<input type="text" name="info[1][order]" value="" placeholder="排序" />
|
||||
</div>
|
||||
</div>
|
||||
<?php }else{ ?>
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach($this->data['info'] as $k=>$v){
|
||||
$index ++;
|
||||
?>
|
||||
<div class="control-group infocontrol">
|
||||
<label class="control-label">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[<?= $k ?>][author]" value="<?= $v['author'] ?>" placeholder="作者" />
|
||||
<input type="text" name="info[<?= $k ?>][organization]" value="<?= $v['organization'] ?>" placeholder="单位" />
|
||||
<input type="text" name="info[<?= $k ?>][order]" value="<?= $v['order'] ?>" placeholder="排序" />
|
||||
<?php if($index>1){ ?>
|
||||
<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<a href="javascript:void(0);" onclick="addinput()">+添加一条</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="hidden" name="submit" value="1" />
|
||||
<?php if(!empty($this->id)) { ?>
|
||||
<input type="hidden" name="id" value=" <?=$this->id?> " />
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->uuid)) { ?>
|
||||
<input type="hidden" name="uuid" value=" <?=$this->uuid?>" />
|
||||
<?php } ?>
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function addinput(){
|
||||
var now_index = $('.infocontrol').length;
|
||||
var index = now_index + 1;
|
||||
html = '<div class="control-group infocontrol"><div class="controls">'
|
||||
+ '<input type="text" name="info[' + index + '][author]" placeholder="作者" /> '
|
||||
+ '<input type="text" name="info[' + index + '][organization]" placeholder="单位" /> '
|
||||
+ '<input type="text" name="info[' + index + '][order]" placeholder="排序" /> '
|
||||
+ '<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>'
|
||||
+ '</div></div>';
|
||||
now_index = null;
|
||||
index = null;
|
||||
$('.infocontrol').last().after(html);
|
||||
}
|
||||
function RmInput(e){
|
||||
$e = $(e);
|
||||
$e.parent('div').parent('div.infocontrol').remove();
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
//$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('DOI');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="/admin/data/doi">浏览所有</a></li>
|
||||
<?php if(!empty($this->uuid)) {?>
|
||||
<li class="active"><a href="javascript:void(0);">编辑DOI</a></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="">
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="doi">doi</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="doi" name="doi" value="<?= (isset($this->data['doi'])&&!empty($this->data['doi'])) ? $this->data['doi']:"doi:10.3972/westdc.x.2013.db" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="uuid">uuid</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="uuid" name="uuid" value="<?= isset($this->data['uuid']) ? $this->data['uuid']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="publisher">发布者</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="publisher" name="publisher" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="url">url</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="url" name="url" value="<?= isset($this->data['url']) ? $this->data['url']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="title">标题</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="title" name="title" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="title_en">title_en</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="title_en" name="title_en" value="<?= isset($this->data['title_en']) ? $this->data['title_en']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="publisher_en">发布者英文</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="publisher_en" name="publisher_en" value="<?= isset($this->data['publisher_en']) ? $this->data['publisher_en']:"" ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($this->data['info']) || !is_array($this->data['info'])) {?>
|
||||
<div class="control-group infocontrol" id="info1">
|
||||
<label class="control-label" for="">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[1][author]" value="" placeholder="作者" />
|
||||
<input type="text" name="info[1][organization]" value="" placeholder="单位" />
|
||||
<input type="text" name="info[1][author_en]" value="" placeholder="作者英文" />
|
||||
<input type="text" name="info[1][organization_en]" value="" placeholder="单位英文" />
|
||||
<input type="text" name="info[1][order]" value="" placeholder="排序" />
|
||||
</div>
|
||||
</div>
|
||||
<?php }else{ ?>
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach($this->data['info'] as $k=>$v){
|
||||
$index ++;
|
||||
?>
|
||||
<div class="control-group infocontrol">
|
||||
<label class="control-label">info</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="info[<?= $k ?>][author]" value="<?= $v['author'] ?>" placeholder="作者" />
|
||||
<input type="text" name="info[<?= $k ?>][organization]" value="<?= $v['organization'] ?>" placeholder="单位" />
|
||||
<input type="text" name="info[<?= $k ?>][author_en]" value="<?= $v['author_en'] ?>" placeholder="作者英文" />
|
||||
<input type="text" name="info[<?= $k ?>][organization_en]" value="<?= $v['organization_en'] ?>" placeholder="单位英文" />
|
||||
<input type="text" name="info[<?= $k ?>][order]" value="<?= $v['order'] ?>" placeholder="排序" />
|
||||
<?php if($index>1){ ?>
|
||||
<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<a href="javascript:void(0);" onclick="addinput()">+添加一条</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="hidden" name="submit" value="1" />
|
||||
<?php if(!empty($this->id)) { ?>
|
||||
<input type="hidden" name="id" value=" <?=$this->id?> " />
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->uuid)) { ?>
|
||||
<input type="hidden" name="uuid" value=" <?=$this->uuid?>" />
|
||||
<?php } ?>
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function addinput(){
|
||||
var now_index = $('.infocontrol').length;
|
||||
var index = now_index + 1;
|
||||
html = '<div class="control-group infocontrol"><div class="controls">'
|
||||
+ '<input type="text" name="info[' + index + '][author]" placeholder="作者" /> '
|
||||
+ '<input type="text" name="info[' + index + '][organization]" placeholder="单位" /> '
|
||||
+ '<input type="text" name="info[' + index + '][author_en]" placeholder="作者英文" /> '
|
||||
+ '<input type="text" name="info[' + index + '][organization_en]" placeholder="单位英文" /> '
|
||||
+ '<input type="text" name="info[' + index + '][order]" placeholder="排序" /> '
|
||||
+ '<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>'
|
||||
+ '</div></div>';
|
||||
now_index = null;
|
||||
index = null;
|
||||
$('.infocontrol').last().after(html);
|
||||
}
|
||||
function RmInput(e){
|
||||
$e = $(e);
|
||||
$e.parent('div').parent('div.infocontrol').remove();
|
||||
}
|
||||
</script>
|
||||
<!-- //页面内容 -->
|
|
@ -1,213 +1,238 @@
|
|||
<?php
|
||||
class Doi extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
//使用到的公共变量
|
||||
public $tbl_doi = "datadoi";
|
||||
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
function fetch($uid=0)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
|
||||
}else{
|
||||
$sql = "SELECT doi.* FROM ".$this->tbl_doi." doi
|
||||
LEFT JOIN mdauthor a ON doi.uuid=a.uuid
|
||||
WHERE a.userid=".$uid." AND a.status>0
|
||||
ORDER BY ts_published desc,ts_submitted desc,ts_created 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,$uid=0){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($uuid,$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$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'=> 5*count($authors)-($k*5)
|
||||
);
|
||||
}
|
||||
//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,$uid=0){
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
if($uid != 0){
|
||||
$sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(isset($row['uuid']) && !empty($row['uuid'])){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($row['uuid'],$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$condition = " id=$id ";
|
||||
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}else{
|
||||
return "该记录不存在";
|
||||
}
|
||||
}else{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
class Doi extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
//使用到的公共变量
|
||||
public $tbl_doi = "datadoi";
|
||||
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
function fetch($uid=0)
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
|
||||
}else{
|
||||
$sql = "SELECT doi.* FROM ".$this->tbl_doi." doi
|
||||
LEFT JOIN mdauthor a ON doi.uuid=a.uuid
|
||||
WHERE a.userid=".$uid." AND a.status>0
|
||||
ORDER BY ts_published desc,ts_submitted desc,ts_created 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,$uid=0){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($uuid,$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$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();
|
||||
$authors_en = array();
|
||||
$orgs_en = array();
|
||||
foreach($data['info'] as $k=>$v)
|
||||
{
|
||||
$authors[$v['order']] = $v['author'];
|
||||
$orgs[$v['order']] = $v['organization'];
|
||||
$authors_en[$v['order']] = $v['author_en'];
|
||||
$orgs_en[$v['order']] = $v['organization_en'];
|
||||
}
|
||||
$authors = "{".join(",",$authors)."}";
|
||||
$orgs = "{".join(",",$orgs)."}";
|
||||
$authors_en = "{".join(",",$authors_en)."}";
|
||||
$orgs_en = "{".join(",",$orgs_en)."}";
|
||||
$data['authors'] = $authors;
|
||||
$data['organization'] = $orgs;
|
||||
$data['author_en'] = $authors_en;
|
||||
$data['organization_en'] = $orgs_en;
|
||||
unset($data['info']);
|
||||
}
|
||||
|
||||
function data_process_out(&$data){
|
||||
$authors = $this->array_split($data['authors']);
|
||||
$orgs = $this->array_split($data['organization']);
|
||||
$authors_en = $this->array_split($data['author_en']);
|
||||
$orgs_en = $this->array_split($data['organization_en']);
|
||||
$info = array();
|
||||
foreach($authors as $k=>$v)
|
||||
{
|
||||
$info[$k] = array(
|
||||
'author'=>$authors[$k],
|
||||
'organization'=>$orgs[$k],
|
||||
'author_en'=>$authors_en[$k],
|
||||
'organization_en'=>$orgs_en[$k],
|
||||
'order'=> 5*count($authors)-($k*5)
|
||||
);
|
||||
}
|
||||
//include_once("helper/view.php");
|
||||
//view::Dump($info);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function array_split($a){
|
||||
$a = str_replace("{",'',$a);
|
||||
$a = str_replace("}",'',$a);
|
||||
$a = explode(",",$a);
|
||||
return $a;
|
||||
}
|
||||
|
||||
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,$uid=0){
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
if($uid != 0){
|
||||
$sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(isset($row['uuid']) && !empty($row['uuid'])){
|
||||
include_once("data/Author.php");
|
||||
$author = new Author($this->db);
|
||||
if($author->checkAuthor($row['uuid'],$uid)==false)
|
||||
{
|
||||
return "您没有权限";
|
||||
}
|
||||
$condition = " id=$id ";
|
||||
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}else{
|
||||
return "该记录不存在";
|
||||
}
|
||||
}else{
|
||||
$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')),
|
||||
'title_en' => trim($request->getParam('title_en')),
|
||||
'publisher_en' => trim($request->getParam('publisher_en')),
|
||||
'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']) && empty($v['author_en']) && empty($v['organization_en']) )
|
||||
{
|
||||
unset($info[$k]);
|
||||
}else{
|
||||
if(empty($v['author']))
|
||||
{
|
||||
return "请输入 $k 中的作者";
|
||||
}
|
||||
if(empty($v['organization']))
|
||||
{
|
||||
return "请输入 $k 中的单位";
|
||||
}
|
||||
if(empty($v['author_en']))
|
||||
{
|
||||
return "请输入 $k 中的作者英文";
|
||||
}
|
||||
if(empty($v['organization_en']))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue