参考后台文献管理的方法,重新实现了支持项目的管理

This commit is contained in:
wlx 2014-05-18 04:56:23 +00:00
parent ad9d92de67
commit 8517e3426e
16 changed files with 1185 additions and 400 deletions

View File

@ -5,6 +5,7 @@ use Reference\Ris;
use Reference\RisOutput; use Reference\RisOutput;
use Helpers\dbh; use Helpers\dbh;
use \Files\Files; use \Files\Files;
use Fund\Fund;
class Admin_DataController extends Zend_Controller_Action class Admin_DataController extends Zend_Controller_Action
{ {
@ -1168,7 +1169,7 @@ class Admin_DataController extends Zend_Controller_Action
$this->view->years = $reference->countByYear(); $this->view->years = $reference->countByYear();
return true; return true;
} }
else if (!empty($uuid)) else if (empty($ac) && !empty($uuid))
{ {
$sql="select * from metadata where uuid='$uuid'"; $sql="select * from metadata where uuid='$uuid'";
$this->view->md=$this->db->fetchRow($sql); $this->view->md=$this->db->fetchRow($sql);
@ -1180,7 +1181,7 @@ class Admin_DataController extends Zend_Controller_Action
view::addPaginator($reference->fetchReferencesByUUID($uuid),$this, $this->view->pagelimit); view::addPaginator($reference->fetchReferencesByUUID($uuid),$this, $this->view->pagelimit);
} else { } else {
$this->_helper->viewRenderer('ref-data-search'); $this->_helper->viewRenderer('ref-data-search');
view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit); view::addPaginator($reference->fetchReferencesWithUUID($uuid),$this, $this->view->pagelimit);
} }
return true; return true;
} }
@ -3734,238 +3735,169 @@ class Admin_DataController extends Zend_Controller_Action
public function fundAction() public function fundAction()
{ {
$this->_helper->layout->setLayout('administry'); $fund = new Fund($this->db);
$this->view->ac = $ac = $this->_getParam('ac');
$submit = $this->_getParam('submit');
$keyword = $this->view->q = trim($this->_getParam('q'));
$order = $this->view->search_order = trim($this->_getParam('order'));
$sort = $this->view->search_sort = trim($this->_getParam('sort'));
$field = $this->view->search_field = $this->_getParam('field');
$this->view->uuid = $uuid = $this->_getParam('uuid');
if(!empty($keyword))
{
$fund->keyword = $keyword;
}
if(!empty($field))
{
$fund->field = $field;
}
if(!empty($order))
{
$fund->order = $order;
}
if(!empty($sort))
{
$fund->sort = $sort;
}
$this->view->fund = $fund;
$this->view->page = $this->_getParam('page');
$this->view->pagelimit = 10;
$ac = $this->_getParam('ac'); $ac = $this->_getParam('ac');
$submit = $this->_getParam('submit'); $submit = $this->_getParam('submit');
$this->view->q = $keyword = $this->_getParam('q'); $this->view->q = $keyword = $this->_getParam('q');
include_once("helper/view.php"); //所有项目
include_once("data/Fund.php"); if(empty($ac) && empty($uuid))
$fund = new Fund($this->db);
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{ {
$user = $auth->getIdentity(); view::addPaginator($fund->fetchFunds(),$this, $this->view->pagelimit);
$uid = $user->id; return true;
} }
//单条数据
if($ac=='index' || empty($ac)) else if (empty($ac) && !empty($uuid))
{ {
$uuid = $this->_getParam('uuid'); $sql="select * from metadata where uuid='$uuid'";
if(empty($uuid)) $this->view->md=$this->db->fetchRow($sql);
if (empty($keyword))
{ {
$rows = $fund->fetch(NULL,true,0,$keyword); $this->_helper->viewRenderer('fund-data-add');
view::addPaginator($rows,$this,10); unset($fund->keyword);
view::addPaginator($fund->fetchFundsByUUID($uuid),$this, $this->view->pagelimit);
} else { } else {
include('data/Metadata.php'); $this->_helper->viewRenderer('fund-data-search');
$md = new Metadata($this->db); view::addPaginator($fund->fetchFundsWithUUID($uuid),$this, $this->view->pagelimit);
$this->view->md = $md->view($uuid);
$rows = $fund->fetch($uuid);
view::addPaginator($rows,$this,10);
} }
return true; return true;
} }
//数据相关项目
if($ac == 'datalist') else if ($ac == "datalist")
{ {
$this->_helper->viewRenderer('fund-data-list'); $this->_helper->viewRenderer('fund-data-list');
$this->view->q = $q = $this->_getParam('q'); view::addPaginator($fund->fetchDataFunds(),$this,$this->view->pagelimit);
$rows = $fund->fetchFromData(true,0,$q);
view::addPaginator($rows,$this,10);
return true; return true;
} }
//无数据的项目
if($ac == 'dataview') else if ($ac == "nodata")
{ {
$this->_helper->viewRenderer('fund-data-view'); view::addPaginator($fund->fetchNoDataFunds(),$this,$this->view->pagelimit);
$this->view->q = $q = $this->_getParam('q');
$id = $this->_getParam('id');
$this->view->fund = $fund->view($id);
$rows = $fund->fetchFromData($id,0,$q);
view::addPaginator($rows,$this,10);
return true; return true;
} }
//删除项目
if($ac == "add") else if($ac == "delete")
{ {
$this->_helper->viewRenderer('fund-add'); if($fund->delete($this->_getParam('id')))
if(!empty($submit))
{ {
$data = $fund->_getParams($this->_request); view::Post($this,"删除项目信息成功!",-1);
$data['userid'] = $uid; }else{
view::Post($this,"删除项目信息失败!",-1);
if($fund->add($data) == true) }
return true;
}
//删除项目和数据对应关系
else if($ac == "remove")
{ {
$this->view->AlertType = "alert-success"; if($fund->remove($this->_getParam('id')))
$this->view->msg = "添加成功!"; {
$this->view->jump_url = "/admin/data/fund/"; view::Post($this,"移除数据-项目信息成功!",-1);
}else{
view::Post($this,"移除数据-项目信息失败!",-1);
}
return true;
}
//添加数据项目对应
else if($ac == "mdfund" && view::isXmlHttpRequest($this))
{
$mdfundid = $this->_getParam('id');
$status = $fund->makeMdfund($mdfundid);
if($status !== true)
{
$this->jsonexit(array('error'=>$status));
}else{
$this->jsonexit(array('success' => 1));
}
return true;
}
//相关数据
else if($ac == "data")
{
$fid = $this->view->fid = $this->_getParam('id');
$this->view->info=$fund->getOneFund($fid);
if(view::isXmlHttpRequest($this)){
$this->jsonexit($fund->getDataByFund($fid));
return true; return true;
}else{ }else{
$this->view->data = $data; $this->_helper->viewRenderer('fund-data');
$this->view->error = "添加失败,请重试"; view::addPaginator($fund->getDataByFund($fid),$this,$this->view->pagelimit);
return true; return true;
} }
} }
return true; //添加或编辑项目
}//add else if($ac == "add")
if($ac == "edit")
{ {
$this->_helper->viewRenderer('fund-add'); $this->_helper->viewRenderer('fund-add');
$id = $this->_getParam('id'); $id = $this->_getParam('id');
if(empty($id))
{
$this->view->AlertType = "alert-error";
$this->view->msg = "参数错误";
$this->view->jump_url = "/admin/data/fund/";
}
if(!empty($submit)) if(!empty($submit))
{ {
$data = $fund->_getParams($this->_request); $this->view->data = $fund->getFundParam();
$data['userid'] = $uid;
if($fund->update($data,$id) == true) if(empty($id) || !is_numeric($id))
{ {
$this->view->AlertType = "alert-success"; $status = $fund->fund();
$this->view->msg = "修改成功!";
$this->view->jump_url = "/admin/data/fund/";
return true;
}else{ }else{
$this->view->data = $data; $status = $fund->fund($id);
$this->view->error = "修改失败,请重试";
return true;
} }
if($status !== true)
{
$this->view->error = view::Error($status);
}else{ }else{
$this->view->data = $fund->view($id);
}
return true;
}//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($fund->delete($id) == true)
{
$this->jsonexit(array('success'=>$id));
return true;
}else{
$this->jsonexit(array('error'=>'删除失败'));
return true;
}
}//del
if($ac == "formd")
{
$uuid = $this->_getParam('uuid');
if(empty($uuid))
{
$this->view->AlertType = "alert-error";
$this->view->msg = "参数错误";
$this->view->jump_url = "/admin/data/fund/";
}
$id = $this->_getParam('id');
$order = $this->_getParam('order');
if(!empty($id)) if(!empty($id))
{ {
if($fund->addToMdfund($uuid,$id,$order)) $msg = "项目修改成功!";
{ view::Post($this,$msg,-2);
$this->view->AlertType = "alert-success";
$this->view->error = "添加成功!可以继续选择并添加";
}else{
$this->view->AlertType = "alert-error";
$this->view->error = "添加失败!该数据可能已被添加";
}
}
$mfid = $this->_getParam('mfid');
if(!empty($mfid))
{
if($fund->changeorder($mfid,$order))
{
$this->view->AlertType = "alert-success";
$this->view->error = "排序修改成功!";
}else{
$this->view->AlertType = "alert-error";
$this->view->error = "排序修改失败!";
}
$rows = $fund->fetch($uuid);
}else{
$this->view->ct = "ct";
$rows = $fund->fetch($uuid,false,0,$this->_getParam('q'));
}
include('data/Metadata.php');
$md = new Metadata($this->db);
$this->view->md = $md->view($uuid);
view::addPaginator($rows,$this,10);
return true;
}//formd
if($ac == "mdfunddel")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
if(empty($id))
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
if($fund->mfdelete($id) == true)
{
$this->jsonexit(array('success'=>$id));
return true; return true;
}else{ }else{
$this->jsonexit(array('error'=>'删除失败')); $msg = "项目添加成功!";
view::Post($this,$msg,"/admin/data/ref/ac/add");
return true; return true;
} }
}//mdfunddel }
if($ac == "data")
{
$this->_helper->viewRenderer('fund-data');
$id = $this->_getParam('id');
$del = $this->_getParam('del');
$this->view->info = $fund->view($id);
if(!empty($del))
{
$s = $fund->dataRelationDelete($del);
if($s)
{
$this->view->error = view::Error("删除成功!","alert-sccuess");
}else{ }else{
$this->view->error = view::Error("删除失败!","alert-error"); $this->view->data = array();
if(!empty($id) && is_numeric($id))
{
$this->view->data = $fund->getOneFund($id);
} }
} }
$rows = $fund->getData($id,$keyword); return true;
view::addPaginator($rows,$this,10);
} }
}//fund }//fund
public function doiAction() public function doiAction()

View File

@ -15,11 +15,7 @@ $this->theme->AppendPlus($this,'colorbox');
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<li><a href="/admin/data/fund/ac/datalist">数据相关</a></li>
<li><a href="/admin/data/fund/">所有项目</a></li>
<li class="active"><a href="/admin/data/fund/ac/add">添加新项目</a></li>
</ul>
</div> </div>
<div class=""> <div class="">
<?php if(!empty($this->error)) { ?> <?php if(!empty($this->error)) { ?>

View File

@ -0,0 +1,107 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('项目管理');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin');
$this->theme->AppendModel($this,'admin-data-fund');
?>
<style>
table thead tr th {background:#EBF2F6;}
</style>
<div class="row-fluid">
<div class="span2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span10">
<div>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</div>
<div>
<h3><?php echo $this->md['title']; ?> <a href="/data/<?php echo $this->uuid; ?>">查看</a></h3>
<div class="input-append">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索项目(数据外搜索,可以添加到数据)</button>
</form>
</div>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目名称
<a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>编号
<a href="?order=fund_id&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_id&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>类型
<a href="?order=fund_type&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文标题
<a href="?order=title_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文类型
<a href="?order=fund_type_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th></th>
<th width="60">操作</th>
</tr>
</thead>
<tbody>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['mfid']?>">
<td>
[<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?> <a href="/admin/data/fund/ac/add/id/<?= $item['id']?>">项目编辑</a>
<a href="/admin/data/fund/ac/data/id/<?= $item['id'] ?>">数据</a>
</td>
<td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td>
<td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td>
<td><?= $item['place'] ?></td>
<td>
<a href="javascript:void(0);" onclick="$('#mdfund')[0].reset();mdfund.edit(<?= $item['mfid']?>,<?= $item['id']?>,'<?= $this->uuid ?>',<?= $item['place']?>)">编辑</a>
<a href="/admin/data/fund/ac/remove/id/<?= $item['mfid']?>">移除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<?= $this->partial('data/fund-mdfund-form.phtml'); ?>

View File

@ -17,24 +17,8 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<li class="active"><a href="/admin/data/fund/ac/data">数据相关</a></li>
<li><a href="/admin/data/fund/">所有项目</a></li>
<li><a href="/admin/data/fund/ac/add">添加新项目</a></li>
</ul>
</div> </div>
<?php if(!empty($this->md)) { ?>
<div>
<?php if(empty($this->ct)) { ?>
<a class="btn btn-primary pull-right" href="/author/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>"><i class="icon-plus"></i>为此数据添加项目</a>
<?php }else{ ?>
<a class="pull-right btn" href="/author/fund/uuid/<?= $this->md['uuid'] ?>">返回</a>
<div class="pull-right label label-info">点击“添加此项目”即可将项目添加到元数据</div>
<?php } ?>
<h3><?= $this->md['title'] ?>》 的支持项目</h3>
<hr />
</div>
<?php } ?>
<div> <div>
<div class="input-append"> <div class="input-append">
<form id="datasearch" class="search_form" action=""> <form id="datasearch" class="search_form" action="">
@ -70,28 +54,54 @@ table thead tr th {background:#EBF2F6;}
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>名称</th> <th>项目名称
<th>项目编号</th> <a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<th>项目类型</th> <a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
<th>数据个数</th> </th>
<th width="70">操作</th> <th>编号
<a href="?order=fund_id&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_id&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>类型
<a href="?order=fund_type&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文标题
<a href="?order=title_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文类型
<a href="?order=fund_type_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th></th>
<th width="100">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $autoindex=0; <?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>"> <tr id="DataLine_<?= $item['mfid']?>">
<?php }?> <td>
<td><?= $item['title'] ?></td> [<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?>
</td>
<td><?= $item['fund_id'] ?></td> <td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td> <td><?= $item['fund_type'] ?></td>
<th><?= $item['mds'] ?></th> <td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td>
<td><?= $item['mdcount'] ?></td>
<td> <td>
<a href="/data/fund/ac/dataview/id/<?= $item['id'] ?>">查看数据</a> <a href="/admin/data/fund/ac/data/id/<?= $item['id'] ?>">数据</a>
<a href="/admin/data/fund/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/fund/ac/delete/id/<?= $item['id']?>">删除</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@ -104,10 +114,3 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
</div> </div>
<!-- //页面内容 --> <!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/author/fund/ac/mdfunddel/uuid/<?= $this->md['uuid'] ?>"
}
</script>

View File

@ -0,0 +1,107 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('项目管理');
$this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin');
$this->theme->AppendModel($this,'admin-data-fund');
?>
<style>
table thead tr th {background:#EBF2F6;}
</style>
<div class="row-fluid">
<div class="span2">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span10">
<div>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</div>
<div>
<h3><?php echo $this->md['title']; ?> <a href="/data/<?php echo $this->uuid; ?>">查看</a></h3>
<div class="input-append">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索项目(数据外搜索,可以添加到数据)</button>
</form>
</div>
</div>
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>项目名称
<a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>编号
<a href="?order=fund_id&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_id&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>类型
<a href="?order=fund_type&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文标题
<a href="?order=title_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文类型
<a href="?order=fund_type_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th></th>
<th width="60">操作</th>
</tr>
</thead>
<tbody>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['mfid']?>">
<td>
[<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?> <a href="/admin/data/fund/ac/add/id/<?= $item['id']?>">项目编辑</a>
<a href="/admin/data/fund/ac/data/id/<?= $item['id'] ?>">数据</a>
</td>
<td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td>
<td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td>
<td><?= $item['place'] ?></td>
<td>
<a href="javascript:void(0);" onclick="$('#mdfund')[0].reset();mdfund.edit('<?= $item['mfid'] ?>',<?= $item['id']?>,'<?= $this->uuid ?>','<?= $item['place']?>')"><?= ($item['mfid'])?'编辑':'添加' ?></a>
<a href="/admin/data/fund/ac/remove/id/<?= $item['mfid']?>">移除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<?= $this->partial('data/fund-mdfund-form.phtml'); ?>

View File

@ -1,13 +1,14 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$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('支持项目'); $this->breadcrumb('项目管理');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin'); $this->theme->AppendPlus($this,'admin_plugin');
$this->theme->AppendModel($this,'admin-data-fund');
?> ?>
<style> <style>
table thead tr th {background:#EBF2F6;} table thead tr th {background:#EBF2F6;}
@ -18,11 +19,7 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<li><a href="/admin/data/fund/">所有项目</a></li>
<li><a href="/admin/data/fund/ac/add">添加新项目</a></li>
<li class="active"><a href="/admin/data/fund/ac/data/id/<?= $this->id ?>">相关数据</a></li>
</ul>
</div> </div>
<div> <div>
<div class="input-append"> <div class="input-append">
@ -35,7 +32,7 @@ table thead tr th {background:#EBF2F6;}
<?php if(!empty($this->error)) { ?> <?php if(!empty($this->error)) { ?>
<?= $this->error ?> <?= $this->error ?>
<?php } ?> <?php } ?>
<h3><?= $this->info['title'] ?> 的相关数据</h3> <h3><?= $this->info['title'] ?> [<?= $this->info['fund_id'] ?>]</h3>
<hr /> <hr />
<div id="datalist"> <div id="datalist">
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
@ -43,21 +40,18 @@ table thead tr th {background:#EBF2F6;}
<thead> <thead>
<tr> <tr>
<th>名称</th> <th>名称</th>
<th width="70">操作</th> <th width="100">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $autoindex=0; <?php $autoindex=0;
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>"> <tr id="DataLine_<?= $item['id']?>">
<?php }else{?> <td>[<?= $autoindex ?>]&nbsp;<a href="/data/<?= $item['uuid'] ?>"><?= $item['title'] ?></a></td>
<tr id="DataLine_<?= $item['mfid']?>">
<?php }?>
<td><?= $item['title'] ?></td>
<td> <td>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a> <a href="/admin/data/fund/uuid/<?= $item['uuid'] ?>">其他项目</a>
<a href="/admin/data/fund/ac/remove/id/<?= $item['mfid']?>">移除</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
@ -69,10 +63,3 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
</div> </div>
<!-- //页面内容 --> <!-- //页面内容 -->
<script>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/fund/ac/mdfunddel/"
}
</script>

View File

@ -0,0 +1,38 @@
<div class="modal hide fade" id="mdfund-form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>数据和项目的关联</h3>
</div>
<div class="modal-body">
<form id="mdfund" method="post" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputRefid">项目ID</label>
<div class="controls">
<input type="text" name="fid" id="inputfid" placeholder="项目ID" value="<?= empty($this->fid) ? "":$this->fid ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputUuid">元数据UUID</label>
<div class="controls">
<input type="text" name="uuid" id="inputUuid" placeholder="UUID">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPlace">排序数值(数字)</label>
<div class="controls">
<input type="text" name="place" id="inputPlace" placeholder="排序">
</div>
</div>
<input type="hidden" name="id" value="" />
</form>
</div>
<div id="alert-info"></div>
<div class="modal-footer">
<div class="progress progress-striped active" id="submit-loading" style="display:none;">
<div class="bar" style="width:100%;"></div>
</div>
<button onclick="$('#mdfund')[0].reset();" class="btn">Reset</button>
<button onclick="$('#mdfund-form').modal('hide');" class="btn">Close</button>
<button onclick="mdfund.create()" class="btn btn-primary" id="submit_btn">Save changes</button>
</div>
</div>

View File

@ -0,0 +1,12 @@
<ul class="nav nav-tabs">
<?php if (!empty($this->uuid)) : ?>
<li class="active"><a href="/admin/data/fund/uuid/<?= $this->uuid ?>">数据的项目</a></li>
<?php endif; ?>
<li <?= empty($this->ac) && empty($this->uuid) ? 'class="active"':"" ?>><a href="/admin/data/fund">所有项目</a></li>
<li <?= $this->ac=="datalist" ? 'class="active"':"" ?>><a href="/admin/data/fund/ac/datalist">数据相关的项目</a></li>
<li <?= $this->ac=="nodata" ? 'class="active"':"" ?>><a href="/admin/data/fund/ac/nodata">数据不相关的项目</a></li>
<li <?= $this->ac=="add" ? 'class="active"':"" ?>><a href="/admin/data/fund/ac/add">添加新项目</a></li>
<?php if ($this->ac=='data') : ?>
<li class="active"><a href="#">项目相关的数据</a></li>
<?php endif; ?>
</ul>

View File

@ -1,13 +1,14 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$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('支持项目'); $this->breadcrumb('项目管理');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
$this->theme->AppendPlus($this,'colorbox'); $this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendPlus($this,'admin_plugin'); $this->theme->AppendPlus($this,'admin_plugin');
$this->theme->AppendModel($this,'admin-data-fund');
?> ?>
<style> <style>
table thead tr th {background:#EBF2F6;} table thead tr th {background:#EBF2F6;}
@ -18,122 +19,81 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
<div class="span10"> <div class="span10">
<div> <div>
<ul class="nav nav-tabs"> <?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<li><a href="/admin/data/fund/ac/datalist">数据相关</a></li>
<li <?php if(empty($this->md)) { ?>class="active"<?php } ?>><a href="/admin/data/fund/">所有项目</a></li>
<li><a href="/admin/data/fund/ac/add">添加新项目</a></li>
<?php if(!empty($this->md)) { ?>
<li class="active"><a href="/admin/data/fund/">按数据查看</a></li>
<?php } ?>
</ul>
</div> </div>
<?php if(!empty($this->md)) { ?>
<div>
<?php if(empty($this->ct)) { ?>
<a class="btn btn-primary pull-right" href="/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>"><i class="icon-plus"></i>为此数据添加项目</a>
<?php }else{ ?>
<a class="pull-right btn" href="/admin/data/fund/uuid/<?= $this->md['uuid'] ?>">返回</a>
<div class="pull-right label label-info">点击“添加此项目”即可将项目添加到元数据</div>
<?php } ?>
<h3><?= $this->md['title'] ?>》 的支持项目</h3>
<hr />
</div>
<?php } ?>
<div> <div>
<div class="input-append"> <div class="input-append">
<form id="datasearch" class="search_form" action=""> <form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" /> <input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<input type="hidden" name="order" value="<?php if(!empty($this->search_order)) echo $this->search_order; ?>" />
<input type="hidden" name="sort" value="<?php if(!empty($this->search_sort)) echo $this->search_sort; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button> <button type="submit" class="btn" id="search_btn">搜索</button>
</form> </form>
</div> </div>
</div> </div>
<?php if(!empty($this->error)) { ?> <?php if(!empty($this->error)) { ?>
<?php if(empty($this->AlertType)) $AlertType = "alert-error";else $AlertType = $this->AlertType;?> <?= $this->error ?>
<div class="alert alert-block fade in <?= $AlertType ?>" id="Alert-error-box">
<a class="close" data-dismiss="alert" href="#">×</a>
<?php if(!is_array($this->error)) { ?><h4 class="alert-heading"><?= $this->error ?></h4><?php } else { ?>
<ul>
<?php foreach($this->error as $v) { ?>
<li><?= $v ?></li>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?> <?php } ?>
<?php if(!empty($this->msg)) { ?> <?php if(!empty($this->msg)) { ?>
<div class="alert <?= $this->AlertType;?>"> <?= $this->msg ?>
<a data-dismiss="alert" class="close">×</a>
<?php echo $this->msg ?>
</div>
<?php if(!empty($this->jump_url)) { ?>
<script language="javascript">setTimeout("self.location='<?php echo $this->jump_url ?>'",3000);</script>
<?php } ?>
<?php } else{ ?> <?php } else{ ?>
<div id="datalist"> <div id="datalist">
<?php if (count($this->paginator)): ?> <?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
<tr> <tr>
<th>名称</th> <th>项目名称
<th>编号</th> <a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<th>类型</th> <a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
<?php if($this->md) { ?> </th>
<th width="80">排序</th> <th>编号
<?php }else{ ?> <a href="?order=fund_id&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<th>英文标题</th> <a href="?order=fund_id&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
<th>英文类型</th> </th>
<?php } ?> <th>类型
<?php if($this->ct) { ?> <a href="?order=fund_type&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<th>添加</th> <a href="?order=fund_type&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
<?php } ?> </th>
<th width="100">操作</th> <th>英文标题
<a href="?order=title_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>英文类型
<a href="?order=fund_type_en&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=fund_type_en&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th width="110">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $autoindex=0; <?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item): foreach ($this->paginator as $item):
$autoindex++;?> $autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>"> <tr id="DataLine_<?= $item['mfid']?>">
<?php }?> <td>
<td><?= $item['title'] ?></td> [<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?>
</td>
<td><?= $item['fund_id'] ?></td> <td><?= $item['fund_id'] ?></td>
<td><?= $item['fund_type'] ?></td> <td><?= $item['fund_type'] ?></td>
<?php if($this->md) { ?>
<?php if($this->ct) { ?>
<td><input type="text" name="order" id="order_<?= $item['id']?>" class="span12" /></td>
<?php }else{ ?>
<td><input type="text" name="order" id="order_<?= $item['mfid']?>" class="span12" value="<?= $item['place'] ?>" /></td>
<?php }?>
<?php }else{ ?>
<td><?= $item['title_en'] ?></td> <td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td> <td><?= $item['fund_type_en'] ?></td>
<?php } ?>
<?php if($this->ct) { ?>
<td><a href="javascript:void(0);" class="addtomd" rel="<?= $item['id']?>">添加此项目</a></td>
<?php } ?>
<td> <td>
<?php if(empty($this->md)) { ?> <a href="/admin/data/fund/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/fund/ac/data/id/<?= $item['id']?>">数据</a> <a href="/admin/data/fund/ac/data/id/<?= $item['id'] ?>">数据</a>(<a href="javascript:void(0);" onclick="$('#mdfund')[0].reset();mdfund.edit('',<?= $item['id']?>,'',0,0)">+</a>)
<a href="/admin/data/fund/ac/edit/id/<?= $item['id']?>">编辑</a> <a href="/admin/data/fund/ac/delete/id/<?= $item['id']?>">删除</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<?php }else{ ?>
<?php if(empty($this->ct)) { ?><a href="javascript:void(0);" class="changeorder" rel="<?= $item['mfid']?>">排序</a> <?php } ?>
<a href="javascript:void(0);" onclick="onedel(<?= $item['mfid']?>)" id="delbtn_<?= $item['mfid']?>">移除</a>
<?php } ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php else: ?>
<?php if(!empty($this->md)) { ?>
暂无数据,点击标题右侧添加按钮为此数据添加项目
<?php }else{ ?>
暂无数据
<?php } ?>
<?php endif; ?> <?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div> <div class="pagenavi"><?= $this->paginator; ?></div>
</div> </div>
@ -141,35 +101,4 @@ table thead tr th {background:#EBF2F6;}
</div> </div>
</div> </div>
<!-- //页面内容 --> <!-- //页面内容 -->
<script> <?= $this->partial('data/fund-mdfund-form.phtml'); ?>
<?php if(!empty($this->ct)) { ?>
$('.addtomd').each(function(index, element) {
$(this).click(function(){
id = $(this).attr('rel');
order = $('#order_'+id).val();
self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/id/'+id+'/order/'+ order
});
});
<?php }else{ ?>
$('.changeorder').each(function(index, element) {
$(this).click(function(){
id = $(this).attr('rel');
order = $('#order_'+id).val();
self.location='/admin/data/fund/ac/formd/uuid/<?= $this->md['uuid'] ?>/mfid/'+id+'/order/'+ order
});
});
<?php } ?>
<?php if(empty($this->md)) { ?>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/fund/ac/del"
}
<?php }else{ ?>
var info = {
btn_prefix : "delbtn_",
item_prefix : "DataLine_",
url : "/admin/data/fund/ac/mdfunddel/uuid/<?= $this->md['uuid'] ?>"
}
<?php } ?>
</script>

View File

@ -60,12 +60,13 @@ table thead tr th {background:#EBF2F6;}
年份 年份
<a href="?order=year&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a> <a href="?order=year&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=year&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a> <a href="?order=year&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th> 记录创建
<th>记录创建
<a href="?order=ts_created&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a> <a href="?order=ts_created&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=ts_created&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a> <a href="?order=ts_created&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th> </th>
<th width="40">操作</th> <th>类型</th>
<th></th>
<th width="70">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -93,9 +94,12 @@ table thead tr th {background:#EBF2F6;}
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a>  <a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a> 
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a> <a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>
</td> </td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td> <td><?= ($item['reftype']>-1)?$this->referenceType[$item['reftype']]:'' ?></td>
<td><?= $item['place'] ?></td>
<td> <td>
<a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit('',<?= $item['id']?>,'<?= $this->uuid ?>',0,0)">添加</a> <a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit('<?= $item['mrid'] ?>',<?= $item['id']?>,'<?= $this->uuid ?>','<?= $item['reftype'] ?>','<?= $item['place'] ?>')">
<?= ($item['mrid'])?'编辑':'添加' ?></a>
<a href="/admin/data/ref/ac/deletemdref/mrid/<?= $item['mrid']?>">移除</a>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -0,0 +1,15 @@
<?php
namespace Fund\Event;
interface FundEvent
{
public function checkFundParam(\Zend_EventManager_Event $e);
public function processFundData(\Zend_EventManager_Event $e);
public function insertToFundTable(\Zend_EventManager_Event $e);
public function checkMdfundParam(\Zend_EventManager_Event $e);
public function processMdfundData(\Zend_EventManager_Event $e);
}

View File

@ -0,0 +1,456 @@
<?php
namespace Fund;
use \Helpers\View as view;
use \Helpers\dbh;
use \Fund\Listener\FundListener;
use \Files\Files;
class Fund
{
private $db; //传入PDO对象.
private $config; //站点设置
protected $events = NULL;
public $table;
public $keyword;
public $order;
public $sort = "DESC";
public $field;
function __construct($db = NULL,$mail = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$Listener = new FundListener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
public function events(\Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new \Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
public function fund($id = 0)
{
$data = $this->getFundParam();
$params = compact('data');
$results = $this->events()->trigger('submit.checkParam', $this, $params);
$cache_data = $results->bottom();
if($cache_data !== true)
{
return $cache_data;
}
$results = $this->events()->trigger('submit.processData', $this, $params);
$data = $results->bottom();
unset($data['submit']);
$dbh = new dbh();
if(empty($id))
{
$id = $dbh->insert($this->table->fund,$data,true);
}else{
if(!$dbh->update($this->table->fund,$data," id=$id ",true))
{
return "修改失败!请重试";
}
}
if(!empty($id) && is_numeric($id))
{
return true;
}else{
return "修改失败";
}
}
//获得参数
public function getFundParam(\Zend_Controller_Request_Abstract $request = NULL)
{
$request = new \Zend_Controller_Request_Http();
$data = array(
'title' => trim($request->getParam('title')),
'fund_id' => trim($request->getParam('fund_id')),
'fund_type' => trim($request->getParam('fund_type')),
'title_en' => trim($request->getParam('title_en')),
'fund_type_en' => trim($request->getParam('fund_type_en')),
'userid' => (int)$request->getParam('userid'),
);
return $data;
}
//所有项目
public function fetchFunds()
{
$wheresql = array();
if(!empty($this->keyword))
{
$wheresql[] = " ({$this->table->fund}.title LIKE '%{$this->keyword}%' OR {$this->table->fund}.fund_id LIKE '%{$this->keyword}%') ";
}
if(!empty($this->field))
{
foreach($this->field as $k=>$v)
{
if(!empty($v))
{
if(!is_numeric($v)) $v="'{$v}'";
$wheresql[] = " ({$this->table->fund}.{$k}={$v} ) ";
}else{
if(is_numeric($v))
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL OR {$this->table->fund}.{$k}=0 ) ";
else
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL ) ";
}//if(empty($v)
}//foreach
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "{$this->table->fund}.title";
}else{
$order = "{$this->table->fund}.{$this->order}";
}
$sql = "SELECT {$this->table->fund}.* FROM
{$this->table->fund}
$wheresql
ORDER BY $order {$this->sort}";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
//Get references by data UUID
public function fetchFundsByUUID($uuid)
{
$wheresql = array();
$wheresql[]=" mf.uuid='$uuid' ";
if(!empty($this->keyword))
{
$wheresql[] = " (f.title iLIKE '%{$this->keyword}%' OR f.fund_id iLIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "f.title";
}else{
$order = "f.{$this->order} {$this->sort}";
}
$sql="select distinct f.*,mf.place,mf.id as mfid from {$this->table->fund} f left join {$this->table->metadata_fund} mf on f.id=mf.fid
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//Get references with data UUID
//包含mdfund的对应信息
public function fetchFundsWithUUID($uuid)
{
$wheresql = array();
//$wheresql[]=" mf.uuid='$uuid' ";
if(!empty($this->keyword))
{
$wheresql[] = " (f.title LIKE '%{$this->keyword}%' OR f.fund_id iLIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "f.title";
}else{
$order = "f.{$this->order} {$this->sort}";
}
$sql="select distinct f.*,mf.place,mf.id as mfid from {$this->table->fund} f left join
(select * from {$this->table->metadata_fund} where uuid='$uuid') mf on f.id=mf.fid
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//数据相关的项目(已和数据进行关联)
public function fetchDataFunds()
{
$wheresql = array();
if(!empty($this->keyword))
{
$wheresql[] = " ({$this->table->fund}.title LIKE '%{$this->keyword}%' OR {$this->table->fund}.fund_id LIKE '%{$this->keyword}%') ";
}
if(!empty($this->field))
{
foreach($this->field as $k=>$v)
{
if(!empty($v))
{
if(!is_numeric($v)) $v="'{$v}'";
$wheresql[] = " ({$this->table->fund}.{$k}={$v} ) ";
}else{
if(is_numeric($v))
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL OR {$this->table->fund}.{$k}=0 ) ";
else
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL ) ";
}//if(empty($v)
}//foreach
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "{$this->table->fund}.title";
}else{
$order = "{$this->table->fund}.{$this->order}";
}
$sql = "SELECT {$this->table->fund}.*,count({$this->table->metadata_fund}.uuid) as mdcount FROM
{$this->table->fund} left join {$this->table->metadata_fund}
on {$this->table->fund}.id={$this->table->metadata_fund}.fid
$wheresql
group by {$this->table->fund}.id
ORDER BY $order {$this->sort}";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
//数据不相关的项目(没有和数据进行关联)
public function fetchNoDataFunds()
{
$wheresql = array();
$wheresql[] = " id not in (select fid from {$this->table->metadata_fund}) ";
if(!empty($this->keyword))
{
$wheresql[] = " ({$this->table->fund}.title LIKE '%{$this->keyword}%' OR {$this->table->fund}.fund_id LIKE '%{$this->keyword}%') ";
}
if(!empty($this->field))
{
foreach($this->field as $k=>$v)
{
if(!empty($v))
{
if(!is_numeric($v)) $v="'{$v}'";
$wheresql[] = " ({$this->table->fund}.{$k}={$v} ) ";
}else{
if(is_numeric($v))
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL OR {$this->table->fund}.{$k}=0 ) ";
else
$wheresql[] = " ({$this->table->fund}.{$k} IS NULL ) ";
}//if(empty($v)
}//foreach
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "{$this->table->fund}.title";
}else{
$order = "{$this->table->fund}.{$this->order}";
}
$sql = "SELECT {$this->table->fund}.* FROM
{$this->table->fund}
$wheresql
ORDER BY $order {$this->sort}";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
//单个项目的信息
public function getOneFund($id)
{
if(empty($id) || !is_numeric($id))
{
return false;
}
$sql = "SELECT * FROM {$this->table->fund} WHERE id=$id LIMIT 1";
$rs = $this->db->query($sql);
$row = $rs->fetch();
return $row;
}
//建立项目与数据的关系
public function createRelationFromFundToData($fid,$uuid,$place,$id = NULL)
{
if(empty($fid) || !is_numeric($fid))
{
return "参数错误";
}
if(!view::isUuid($uuid))
{
return "参数错误";
}
$data = array(
'uuid'=>$uuid,
'fid'=>$fid,
'place'=>$place
);
$dbh = new dbh();
if(empty($id))
{
$id = $dbh->insert($this->table->metadata_fund,$data,true);
if(is_numeric($id))
{
return $id;
}else{
return "关系写入失败,请检查是否已经存在";
}
}else{
$status = $dbh->update($this->table->metadata_fund,$data," id=$id ");
if($status === true)
{
return $id;
}else{
return "修改失败";
}
}
}
//获得某个项目关联的数据
public function getDataByFund($id)
{
if(empty($id) || !is_numeric($id))
{
return "参数错误";
}
$sql = "SELECT mr.id,mr.fid,mr.place,md.title,md.uuid FROM {$this->table->metadata_fund} mr
LEFT JOIN {$this->table->metadata} md ON mr.uuid=md.uuid
WHERE mr.fid=$id
ORDER BY mr.place ASC";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//数据项目参数
public function getMdfundParam(\Zend_Controller_Request_Abstract $request = NULL)
{
$request = new \Zend_Controller_Request_Http();
$data = array(
'uuid' => trim($request->getParam('uuid')),
'fid' => (int)$request->getParam('fid'),
'place' => (int)$request->getParam('place'),
);
return $data;
}
//写入项目信息
public function makeMdfund($id = NULL)
{
$data = $this->getMdfundParam();
$results = $this->events()->trigger('mdfund.checkParam', $this, compact('data'));
$cache_data = $results->bottom();
if($cache_data !== true)
{
return $cache_data;
}
$results = $this->events()->trigger('mdfund.processData', $this, compact('data'));
$data = $results->bottom();
$id = $this->createRelationFromFundToData($data['fid'],$data['uuid'],$data['place'],$id);
if(is_numeric($id))
{
return true;
}else{
return $id;
}
}
//删除项目以及项目和数据的关联(彻底删除)
public function delete($id)
{
if(empty($id) || !is_numeric($id))
{
return false;
}
$sql = "DELETE FROM {$this->table->fund} WHERE id=$id";
@$this->db->exec($sql);
$sql = "DELETE FROM {$this->table->metadata_fund} WHERE fid=$id";
@$this->db->exec($sql);
return true;
}
//移除数据和项目的关联
public function remove($id)
{
if(empty($id) || !is_numeric($id))
{
return "参数错误";
}
$sql = "DELETE FROM {$this->table->metadata_fund} WHERE id=$id";
if($this->db->exec($sql))
{
return true;
}else{
return "删除失败";
}
}
}

View File

@ -0,0 +1,106 @@
<?php
namespace Fund\Handler;
use \Helpers\View as view;
use \Helpers\dbh;
use \Helpers\Table;
use \Files\Files;
use \Fund\Reference;
//事件中存在的操作
class FundHandler implements \Fund\Event\FundEvent
{
private $db; //传入PDO对象误
private $config; //全局配置
public $table;
public $tbl_maillog = ""; //邮件日志表
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->table = new Table();
}
public function checkFundParam(\Zend_EventManager_Event $e)
{
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data["title"]))
{
return "请输入标题";
}
return true;
}
public function processFundData(\Zend_EventManager_Event $e)
{
$data = $e->getParam('data');
return $data;
}
public function insertToFundTable(\Zend_EventManager_Event $e)
{
return true;
}
public function checkMdfundParam(\Zend_EventManager_Event $e)
{
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data["fid"]))
{
return "请填写项目ID";
}
if(empty($data['uuid']))
{
return "请填写UUID";
}
if(!view::isUuid($data['uuid']))
{
return "UUID格式不正确";
}
return true;
}
public function processMdfundData(\Zend_EventManager_Event $e)
{
$data = $e->getParam('data');
if(empty($data['place']))
{
$data['place'] = 0;
}
if(!is_numeric($data['place']))
{
$data['place'] = 0;
}
return $data;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Fund\Listener;
use Fund\Handler\FundHandler;
class FundListener implements \Zend_EventManager_ListenerAggregate
{
private $event;
function __construct()
{
$this->event = new \Zend_EventManager_EventManager();
}
public function attach(\Zend_EventManager_EventCollection $events)
{
$Handler = new FundHandler();
$events->attach('submit.checkParam', array($Handler, 'checkFundParam'), 100);
$events->attach('submit.processData', array($Handler, 'processFundData'), 100);
$events->attach('upload.insertToFundTable', array($Handler, 'insertToFundTable'), 100);
$events->attach('mdfund.checkParam', array($Handler, 'checkMdfundParam'), 100);
$events->attach('mdfund.processData', array($Handler, 'processMdfundData'), 100);
}
public function detach(\Zend_EventManager_EventCollection $events)
{
}
}

View File

@ -12,6 +12,10 @@ class Table
public $reference_author = "ref_author"; public $reference_author = "ref_author";
public $reference_tag = "ref_tag"; public $reference_tag = "ref_tag";
//支持项目
public $fund='fund';
public $metadata_fund='mdfund';
//数据申请 //数据申请
public $offlineapp = "offlineapp"; public $offlineapp = "offlineapp";

View File

@ -0,0 +1,60 @@
var mdfund = {
create : function(){
data = $('#mdfund').serialize();
$.ajax({
'type':"POST",
'url':"/admin/data/fund/ac/mdfund/",
'data':data,
'success':mdfund.onsuccessed,
'timeout': 30000,
'error': function(){
$("#alert-info").attr('class','alert alert-error');
$("#alert-info").html("出现错误,请稍后重试");
$('#submit-loading').hide();
return false;
},
'beforeSend': function(){
$("#submit_btn").addClass('disabled');
$("#submit_btn").attr('disabled','disabled');
$('#submit-loading').show();
},
'complete': function(){
$("#submit_btn").removeClass('disabled');
$("#submit_btn").removeAttr('disabled');
$('#submit-loading').hide();
}
});
},
onsuccessed : function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{
$("#alert-info").attr('class','alert alert-error');
$("#alert-info").html(data.error);
return false;
}
if(typeof(data.success)!='undefined')
{
$("#alert-info").attr('class','alert alert-success');
$("#alert-info").html("添加成功!");
setTimeout("$('#mdfund-form').modal('hide');",1000);
setTimeout("window.location.href = window.location.href",2000);
return false;
}
}
else{
$("#alert-info").attr('class','alert alert-error');
$("#alert-info").html('请求中发生错误,请重试');
return false;
}
},
edit : function(id,fid,uuid,place)
{
$('#mdfund input[name=id]').val(id);
$('#mdfund input[name=fid]').val(fid);
$('#mdfund input[name=uuid]').val(uuid);
$('#mdfund input[name=place]').val(place);
$('#mdfund-form').modal('show');
}
}