在后台DOI中添加了英文标题,英文发布者,作者英文,单位英文的填写

This commit is contained in:
Li Jianxuan 2013-05-02 09:54:38 +00:00
parent 1212fb9711
commit 4c6e4d5a91
3 changed files with 4107 additions and 4062 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,132 +1,150 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author); $this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
//$this->headLink()->appendStylesheet('/css/admin.css'); //$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>'); $this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('DOI'); $this->breadcrumb('DOI');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
?> ?>
<div class="row-fluid"> <div class="row-fluid">
<div class="span2"> <div class="span2">
<?= $this->partial('data/left.phtml'); ?> <?= $this->partial('data/left.phtml'); ?>
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li><a href="/admin/data/doi">浏览所有</a></li> <li><a href="/admin/data/doi">浏览所有</a></li>
<?php if(!empty($this->uuid)) {?> <?php if(!empty($this->uuid)) {?>
<li class="active"><a href="javascript:void(0);">编辑DOI</a></li> <li class="active"><a href="javascript:void(0);">编辑DOI</a></li>
<?php }?> <?php }?>
</ul> </ul>
</div> </div>
<div class=""> <div class="">
<?php if(!empty($this->error)) { ?> <?php if(!empty($this->error)) { ?>
<?= $this->error ?> <?= $this->error ?>
<?php } ?> <?php } ?>
<?php if(!empty($this->msg)) { ?> <?php if(!empty($this->msg)) { ?>
<?= $this->msg ?> <?= $this->msg ?>
<?php } else{ ?> <?php } else{ ?>
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<div class="control-group"> <div class="control-group">
<label class="control-label" for="doi">doi</label> <label class="control-label" for="doi">doi</label>
<div class="controls"> <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" ?>" /> <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> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="uuid">uuid</label> <label class="control-label" for="uuid">uuid</label>
<div class="controls"> <div class="controls">
<input type="text" id="uuid" name="uuid" value="<?= isset($this->data['uuid']) ? $this->data['uuid']:"" ?>" /> <input type="text" id="uuid" name="uuid" value="<?= isset($this->data['uuid']) ? $this->data['uuid']:"" ?>" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="publisher">发布者</label> <label class="control-label" for="publisher">发布者</label>
<div class="controls"> <div class="controls">
<input type="text" id="publisher" name="publisher" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>" /> <input type="text" id="publisher" name="publisher" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="url">url</label> <label class="control-label" for="url">url</label>
<div class="controls"> <div class="controls">
<input type="text" id="url" name="url" value="<?= isset($this->data['url']) ? $this->data['url']:"" ?>" /> <input type="text" id="url" name="url" value="<?= isset($this->data['url']) ? $this->data['url']:"" ?>" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="title">title</label> <label class="control-label" for="title">标题</label>
<div class="controls"> <div class="controls">
<input type="text" id="title" name="title" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" /> <input type="text" id="title" name="title" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" />
</div> </div>
</div> </div>
<?php if(empty($this->data['info']) || !is_array($this->data['info'])) {?> <div class="control-group">
<div class="control-group infocontrol" id="info1"> <label class="control-label" for="title_en">title_en</label>
<label class="control-label" for="">info</label> <div class="controls">
<div class="controls"> <input type="text" id="title_en" name="title_en" value="<?= isset($this->data['title_en']) ? $this->data['title_en']:"" ?>" />
<input type="text" name="info[1][author]" value="" placeholder="作者" /> </div>
<input type="text" name="info[1][organization]" value="" placeholder="单位" /> </div>
<input type="text" name="info[1][order]" value="" placeholder="排序" /> <div class="control-group">
</div> <label class="control-label" for="publisher_en">发布者英文</label>
</div> <div class="controls">
<?php }else{ ?> <input type="text" id="publisher_en" name="publisher_en" value="<?= isset($this->data['publisher_en']) ? $this->data['publisher_en']:"" ?>" />
<?php </div>
$index = 0; </div>
foreach($this->data['info'] as $k=>$v){ <?php if(empty($this->data['info']) || !is_array($this->data['info'])) {?>
$index ++; <div class="control-group infocontrol" id="info1">
?> <label class="control-label" for="">info</label>
<div class="control-group infocontrol"> <div class="controls">
<label class="control-label">info</label> <input type="text" name="info[1][author]" value="" placeholder="作者" />
<div class="controls"> <input type="text" name="info[1][organization]" value="" placeholder="单位" />
<input type="text" name="info[<?= $k ?>][author]" value="<?= $v['author'] ?>" placeholder="作者" /> <input type="text" name="info[1][author_en]" value="" placeholder="作者英文" />
<input type="text" name="info[<?= $k ?>][organization]" value="<?= $v['organization'] ?>" placeholder="单位" /> <input type="text" name="info[1][organization_en]" value="" placeholder="单位英文" />
<input type="text" name="info[<?= $k ?>][order]" value="<?= $v['order'] ?>" placeholder="排序" /> <input type="text" name="info[1][order]" value="" placeholder="排序" />
<?php if($index>1){ ?> </div>
<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a> </div>
<?php }?> <?php }else{ ?>
</div> <?php
</div> $index = 0;
<?php } ?> foreach($this->data['info'] as $k=>$v){
<?php } ?> $index ++;
<div class="control-group"> ?>
<div class="controls"> <div class="control-group infocontrol">
<a href="javascript:void(0);" onclick="addinput()">+添加一条</a> <label class="control-label">info</label>
</div> <div class="controls">
</div> <input type="text" name="info[<?= $k ?>][author]" value="<?= $v['author'] ?>" placeholder="作者" />
<div class="control-group"> <input type="text" name="info[<?= $k ?>][organization]" value="<?= $v['organization'] ?>" placeholder="单位" />
<div class="controls"> <input type="text" name="info[<?= $k ?>][author_en]" value="<?= $v['author_en'] ?>" placeholder="作者英文" />
<input type="hidden" name="submit" value="1" /> <input type="text" name="info[<?= $k ?>][organization_en]" value="<?= $v['organization_en'] ?>" placeholder="单位英文" />
<?php if(!empty($this->id)) { ?> <input type="text" name="info[<?= $k ?>][order]" value="<?= $v['order'] ?>" placeholder="排序" />
<input type="hidden" name="id" value=" <?=$this->id?> " /> <?php if($index>1){ ?>
<?php } ?> <a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>
<?php if(!empty($this->uuid)) { ?> <?php }?>
<input type="hidden" name="uuid" value=" <?=$this->uuid?>" /> </div>
<?php } ?> </div>
<button type="submit" class="btn btn-primary">提交</button> <?php } ?>
</div> <?php } ?>
</div> <div class="control-group">
</form> <div class="controls">
<?php } ?> <a href="javascript:void(0);" onclick="addinput()">+添加一条</a>
</div> </div>
</div> </div>
</div> <div class="control-group">
<script> <div class="controls">
function addinput(){ <input type="hidden" name="submit" value="1" />
var now_index = $('.infocontrol').length; <?php if(!empty($this->id)) { ?>
var index = now_index + 1; <input type="hidden" name="id" value=" <?=$this->id?> " />
html = '<div class="control-group infocontrol"><div class="controls">' <?php } ?>
+ '<input type="text" name="info[' + index + '][author]" placeholder="作者" /> ' <?php if(!empty($this->uuid)) { ?>
+ '<input type="text" name="info[' + index + '][organization]" placeholder="单位" /> ' <input type="hidden" name="uuid" value=" <?=$this->uuid?>" />
+ '<input type="text" name="info[' + index + '][order]" placeholder="排序" /> ' <?php } ?>
+ '<a href="javascript:void(0);" onclick="RmInput(this)"> -删除</a>' <button type="submit" class="btn btn-primary">提交</button>
+ '</div></div>'; </div>
now_index = null; </div>
index = null; </form>
$('.infocontrol').last().after(html); <?php } ?>
} </div>
function RmInput(e){ </div>
$e = $(e); </div>
$e.parent('div').parent('div.infocontrol').remove(); <script>
} function addinput(){
</script> 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>
<!-- //页面内容 --> <!-- //页面内容 -->

View File

@ -1,213 +1,238 @@
<?php <?php
class Doi extends Zend_Controller_Plugin_Abstract class Doi extends Zend_Controller_Plugin_Abstract
{ {
private $db; //传入PDO对象. private $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象 private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量 //使用到的公共变量
public $tbl_doi = "datadoi"; public $tbl_doi = "datadoi";
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
function fetch($uid=0) function fetch($uid=0)
{ {
if(empty($uid)) if(empty($uid))
{ {
$sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC"; $sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC";
}else{ }else{
$sql = "SELECT doi.* FROM ".$this->tbl_doi." doi $sql = "SELECT doi.* FROM ".$this->tbl_doi." doi
LEFT JOIN mdauthor a ON doi.uuid=a.uuid LEFT JOIN mdauthor a ON doi.uuid=a.uuid
WHERE a.userid=".$uid." AND a.status>0 WHERE a.userid=".$uid." AND a.status>0
ORDER BY ts_published desc,ts_submitted desc,ts_created DESC ORDER BY ts_published desc,ts_submitted desc,ts_created DESC
"; ";
} }
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
return $rows; return $rows;
} }
function add($data){ function add($data){
include_once("helper/dbh.php"); include_once("helper/dbh.php");
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
$this->data_process_in($data); $this->data_process_in($data);
//include_once("helper/view.php"); //include_once("helper/view.php");
//view::Dump($data); //view::Dump($data);
return $dbh->insert($this->tbl_doi,$data); return $dbh->insert($this->tbl_doi,$data);
} }
function update($data,$uuid,$uid=0){ function update($data,$uuid,$uid=0){
include_once("data/Author.php"); include_once("data/Author.php");
$author = new Author($this->db); $author = new Author($this->db);
if($author->checkAuthor($uuid,$uid)==false) if($author->checkAuthor($uuid,$uid)==false)
{ {
return "您没有权限"; return "您没有权限";
} }
$doi_info = $this->view($uuid); $doi_info = $this->view($uuid);
if($doi_info == false) if($doi_info == false)
{ {
return $this->add($data); return $this->add($data);
}else { }else {
$this->data_process_in($data); $this->data_process_in($data);
//include_once("helper/view.php"); //include_once("helper/view.php");
//view::Dump($data); //view::Dump($data);
include_once("helper/dbh.php"); include_once("helper/dbh.php");
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
if(is_numeric($uuid)) if(is_numeric($uuid))
{ {
$condition = " id=$uuid "; $condition = " id=$uuid ";
}else{ }else{
$condition = " uuid='$uuid' "; $condition = " uuid='$uuid' ";
} }
$state = $dbh->update($this->tbl_doi,$data,$condition,true); $state = $dbh->update($this->tbl_doi,$data,$condition,true);
if( $state == true) if( $state == true)
{ {
return true; return true;
}else{ }else{
return $state; return $state;
} }
} }
} }
function data_process_in(&$data){ function data_process_in(&$data){
$authors = array(); $authors = array();
$orgs = array(); $orgs = array();
foreach($data['info'] as $k=>$v) $authors_en = array();
{ $orgs_en = array();
$authors[$v['order']] = $v['author']; foreach($data['info'] as $k=>$v)
$orgs[$v['order']] = $v['organization']; {
} $authors[$v['order']] = $v['author'];
$authors = "{".join(",",$authors)."}"; $orgs[$v['order']] = $v['organization'];
$orgs = "{".join(",",$orgs)."}"; $authors_en[$v['order']] = $v['author_en'];
$data['authors'] = $authors; $orgs_en[$v['order']] = $v['organization_en'];
$data['organization'] = $orgs; }
unset($data['info']); $authors = "{".join(",",$authors)."}";
} $orgs = "{".join(",",$orgs)."}";
$authors_en = "{".join(",",$authors_en)."}";
function data_process_out(&$data){ $orgs_en = "{".join(",",$orgs_en)."}";
$authors = str_replace("{",'',$data['authors']); $data['authors'] = $authors;
$authors = str_replace("}",'',$authors); $data['organization'] = $orgs;
$authors = split(",",$authors); $data['author_en'] = $authors_en;
$orgs = str_replace("{",'',$data['organization']); $data['organization_en'] = $orgs_en;
$orgs = str_replace("}",'',$orgs); unset($data['info']);
$orgs = split(",",$orgs); }
$info = array();
foreach($authors as $k=>$v) function data_process_out(&$data){
{ $authors = $this->array_split($data['authors']);
$info[$k] = array( $orgs = $this->array_split($data['organization']);
'author'=>$authors[$k], $authors_en = $this->array_split($data['author_en']);
'organization'=>$orgs[$k], $orgs_en = $this->array_split($data['organization_en']);
'order'=> 5*count($authors)-($k*5) $info = array();
); foreach($authors as $k=>$v)
} {
//include_once("helper/view.php"); $info[$k] = array(
//view::Dump($info); 'author'=>$authors[$k],
return $info; 'organization'=>$orgs[$k],
} 'author_en'=>$authors_en[$k],
'organization_en'=>$orgs_en[$k],
function view($id) 'order'=> 5*count($authors)-($k*5)
{ );
if(is_numeric($id)) }
{ //include_once("helper/view.php");
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id"; //view::Dump($info);
}else{ return $info;
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'"; }
}
$rs = $this->db->query($sql); function array_split($a){
$row = $rs->fetch(); $a = str_replace("{",'',$a);
return $row; $a = str_replace("}",'',$a);
} $a = explode(",",$a);
return $a;
function delete($id,$uid=0){ }
if(!is_numeric($id))
{ function view($id)
return "参数错误"; {
} if(is_numeric($id))
if($uid != 0){ {
$sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id"; $sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id";
$rs = $this->db->query($sql); }else{
$row = $rs->fetch(); $sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'";
if(isset($row['uuid']) && !empty($row['uuid'])){ }
include_once("data/Author.php"); $rs = $this->db->query($sql);
$author = new Author($this->db); $row = $rs->fetch();
if($author->checkAuthor($row['uuid'],$uid)==false) return $row;
{ }
return "您没有权限";
} function delete($id,$uid=0){
$condition = " id=$id "; if(!is_numeric($id))
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition"; {
return $this->db->exec($sql); return "参数错误";
}else{ }
return "该记录不存在"; if($uid != 0){
} $sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id";
}else{ $rs = $this->db->query($sql);
$condition = " id=$id "; $row = $rs->fetch();
$sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition"; if(isset($row['uuid']) && !empty($row['uuid'])){
return $this->db->exec($sql); include_once("data/Author.php");
} $author = new Author($this->db);
} if($author->checkAuthor($row['uuid'],$uid)==false)
{
function _getParams(Zend_Controller_Request_Abstract $request) return "您没有权限";
{ }
$data = array( $condition = " id=$id ";
'doi' => trim($request->getParam('doi')), $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
'uuid' => trim($request->getParam('uuid')), return $this->db->exec($sql);
'publisher' => trim($request->getParam('publisher')), }else{
'url' => trim($request->getParam('url')), return "该记录不存在";
'title' => trim($request->getParam('title')), }
'info'=>$_POST['info'] }else{
); $condition = " id=$id ";
return $data; $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition";
} return $this->db->exec($sql);
}
function checkinfo($info){ }
if(!is_array($info)){
return NULL; function _getParams(Zend_Controller_Request_Abstract $request)
} {
foreach($info as $k=>$v) $data = array(
{ 'doi' => trim($request->getParam('doi')),
if(empty($v['author']) && empty($v['organization']) && empty($v['order'])) 'uuid' => trim($request->getParam('uuid')),
{ 'publisher' => trim($request->getParam('publisher')),
unset($info[$k]); 'url' => trim($request->getParam('url')),
}else{ 'title' => trim($request->getParam('title')),
if(empty($v['author'])) 'title_en' => trim($request->getParam('title_en')),
{ 'publisher_en' => trim($request->getParam('publisher_en')),
return "请输入 $k 中的作者"; 'info'=>$_POST['info']
} );
if(empty($v['organization'])) return $data;
{ }
return "请输入 $k 中的单位";
} function checkinfo($info){
if(empty($v['order'])) if(!is_array($info)){
{ return NULL;
return "请输入 $k 中的排序"; }
} foreach($info as $k=>$v)
} {
} if(empty($v['author']) && empty($v['organization']) && empty($v['order']) && empty($v['author_en']) && empty($v['organization_en']) )
return $info; {
} unset($info[$k]);
}else{
function sksort($array,$key,$type=SORT_DESC) { if(empty($v['author']))
$sortArray = array(); {
return "请输入 $k 中的作者";
foreach($array as $v){ }
foreach($v as $key=>$value){ if(empty($v['organization']))
if(!isset($sortArray[$key])){ {
$sortArray[$key] = array(); return "请输入 $k 中的单位";
} }
$sortArray[$key][] = $value; if(empty($v['author_en']))
} {
} return "请输入 $k 中的作者英文";
}
if(array_multisort($sortArray[$key],$type,$array)) if(empty($v['organization_en']))
{ {
return $array; return "请输入 $k 中的单位英文";
}else{ }
return $array; 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;
}
}
}