add doi actions

This commit is contained in:
Li Jianxuan 2013-04-24 11:07:25 +00:00
parent bb4eacce87
commit a8cdafb719
5 changed files with 4075 additions and 4001 deletions

View File

@ -3582,25 +3582,59 @@ class Admin_DataController extends Zend_Controller_Action
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
'publisher'=>view::User('realname'),
);
}else{
$this->view->data['info'] = $doi->data_process_out($this->view->data);
}
}else{
$this->view->data = $doi->view($uuid);
$this->view->data['info'] = $doi->data_process_out($this->view->data);
}
}else{
$data = $doi->_getParams($this->_request);
if(!is_array($data))
{
$this->view->error = view::Error('alert-error',$data,-1);
$this->view->data = $data;
$info = $doi->checkinfo($data['info']);
if(!is_array($info)){
$this->view->error = view::Error('alert-error',$info,-1);
return true;
}else{
$data['info'] = $info;
$data['info'] = $doi->sksort($data['info'],"order",SORT_DESC);
}
if($doi->update($data,$uuid))
$state = $doi->update($data,$uuid);
if($state)
{
$this->view->msg = view::Msg('alert-success',"修改成功!",'/admin/data/doi/uuid/'.$uuid);
return false;
}else{
$this->view->error = view::Error('alert-error',"参数错误",-1);
$this->view->error = view::Error('alert-error',"修改失败",-1);
return false;
}
}
}//add
}//edit
if($ac == "del")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
if(empty($id))
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
if($doi->delete($id) == true)
{
$this->jsonexit(array('success'=>$id));
return true;
}else{
$this->jsonexit(array('error'=>'删除失败'));
return true;
}
}//del
}//doi

View File

@ -19,8 +19,6 @@ $this->theme->AppendPlus($this,'colorbox');
<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 }else{ ?>
<li class="active"><a href="/admin/data/doi/ac/add">添加新DOI</a></li>
<?php }?>
</ul>
</div>
@ -62,7 +60,7 @@ $this->theme->AppendPlus($this,'colorbox');
<input type="text" id="title" name="title" value="<?= isset($this->data['title']) ? $this->data['title']:"" ?>" />
</div>
</div>
<?php if(empty($this->data['info'])) {?>
<?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">
@ -72,7 +70,23 @@ $this->theme->AppendPlus($this,'colorbox');
</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">

View File

@ -20,7 +20,6 @@ table thead tr th {background:#EBF2F6;}
<div>
<ul class="nav nav-tabs">
<li class="active"><a href="/admin/data/doi">浏览所有</a></li>
<li><a href="/admin/data/doi/ac/add">添加新DOI</a></li>
</ul>
</div>
<div>
@ -57,7 +56,7 @@ table thead tr th {background:#EBF2F6;}
<td><?= $item['title'] ?></td>
<td><?= $item['doi'] ?></td>
<td>
<a href="/admin/data/fund/ac/edit/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/doi/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
</td>
</tr>

View File

@ -24,18 +24,20 @@ class Doi extends Zend_Controller_Plugin_Abstract
include_once("helper/dbh.php");
$dbh = new dbh($this->db);
$this->data_process_in($data);
include_once("helper/view.php");
view::Dump($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)
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/view.php");
//view::Dump($data);
include_once("helper/dbh.php");
$dbh = new dbh($this->db);
if(is_numeric($uuid))
@ -52,8 +54,6 @@ class Doi extends Zend_Controller_Plugin_Abstract
}else{
return $state;
}
}else{
$this->add($data);
}
}
@ -72,6 +72,27 @@ class Doi extends Zend_Controller_Plugin_Abstract
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))
@ -85,6 +106,16 @@ class Doi extends Zend_Controller_Plugin_Abstract
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(
@ -93,13 +124,8 @@ class Doi extends Zend_Controller_Plugin_Abstract
'publisher' => trim($request->getParam('publisher')),
'url' => trim($request->getParam('url')),
'title' => trim($request->getParam('title')),
'info'=>$this->checkinfo($_POST['info'])
'info'=>$_POST['info']
);
if(!is_array($data['info'])){
return $data['info'];
}else{
$data['info'] = $this->sksort($data['info'],"order",SORT_DESC);
}
return $data;
}

View File

@ -79,4 +79,5 @@ class view extends Zend_Controller_Plugin_Abstract
exit();
}
}
}