在数据页面添加了支持项目的显示
This commit is contained in:
parent
8122670e12
commit
33b75a2469
|
@ -190,18 +190,18 @@ class DataController extends Zend_Controller_Action
|
|||
function tagAction()
|
||||
{
|
||||
$id = (int)$this->_request->getParam('id');
|
||||
$key = $this->_request->getParam('key');
|
||||
$key = $this->_request->getParam('key');
|
||||
$keytype = $this->_request->getParam('keytype');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $page=1;
|
||||
$limit=10;
|
||||
$offset=$limit*($page-1);
|
||||
$sql='select keyword,count(*),keytype from keyword ';
|
||||
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'";
|
||||
$offset=$limit*($page-1);
|
||||
$sql='select keyword,count(*),keytype from keyword ';
|
||||
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'";
|
||||
$sql.=' group by keyword,keytype order by keytype,keyword,count desc';
|
||||
$state=$this->db->query($sql);
|
||||
$this->view->keywords=$state->fetchAll();
|
||||
|
||||
|
||||
if ($id>0 or !empty($key)) {
|
||||
if (empty($key)) {
|
||||
$where=$this->db->quoteInto('id = ?',$id);
|
||||
|
@ -209,7 +209,7 @@ class DataController extends Zend_Controller_Action
|
|||
$key=$row->name;
|
||||
}
|
||||
$this->view->codename=$key;
|
||||
$sql=$this->db->quoteInto('select count(m.id) from normalmetadata m,keyword k where m.id=k.id and k.keyword=?',$key);
|
||||
$sql=$this->db->quoteInto('select count(m.id) from normalmetadata m,keyword k where m.id=k.id and k.keyword=?',$key);
|
||||
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
|
@ -650,6 +650,10 @@ class DataController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
$this->view->data_archives = $data_archives;
|
||||
//支持项目
|
||||
include_once("data/Fund.php");
|
||||
$fund = new Fund($this->db);
|
||||
$this->view->fund = $fund->fetch($uuid);
|
||||
|
||||
//自动跳转
|
||||
$sql="select s.* from datasource d left join source s on d.sourceid=s.id where d.uuid=?";
|
||||
|
@ -1940,16 +1944,16 @@ class DataController extends Zend_Controller_Action
|
|||
public function jsonexit($data){
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
|
||||
return true;
|
||||
}
|
||||
function organizationAction()
|
||||
{
|
||||
$page = $this->_request->getParam('page');
|
||||
$name = $this->_request->getParam('name');
|
||||
$state=$this->db->query("select distinct responsible.organisation from responsible left join role on role.resid=responsible.id where role.role in ('pointOfContact','resourceProvider','owner')");
|
||||
$this->view->organisation=$state->fetchAll();
|
||||
if (!empty($name)) {
|
||||
$this->view->codename=$name;
|
||||
$sql="select distinct m.* from normalmetadata m left join role r on m.uuid=r.uuid left join responsible s on r.resid=s.id where r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";
|
||||
}
|
||||
function organizationAction()
|
||||
{
|
||||
$page = $this->_request->getParam('page');
|
||||
$name = $this->_request->getParam('name');
|
||||
$state=$this->db->query("select distinct responsible.organisation from responsible left join role on role.resid=responsible.id where role.role in ('pointOfContact','resourceProvider','owner')");
|
||||
$this->view->organisation=$state->fetchAll();
|
||||
if (!empty($name)) {
|
||||
$this->view->codename=$name;
|
||||
$sql="select distinct m.* from normalmetadata m left join role r on m.uuid=r.uuid left join responsible s on r.resid=s.id where r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($name));
|
||||
$rows = $sth->fetchAll();
|
||||
|
@ -1958,10 +1962,10 @@ class DataController extends Zend_Controller_Action
|
|||
$paginator->setItemCountPerPage(10);
|
||||
$paginator->setView($this->view);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$this->view->paginator=$paginator;
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
$this->view->paginator=$paginator;
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,9 +82,18 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
</ul>
|
||||
<hr />
|
||||
<?php }?>
|
||||
<?php if ($md->suppinfo) : ?>
|
||||
<?php if ($md->suppinfo || $this->fund) : ?>
|
||||
<h4><i class="icon-money text-info"></i>资助项目</h4>
|
||||
<?php if(!empty($md->suppinfo)) { ?>
|
||||
<?php echo '<p>'.str_replace(array("\r\n", "\n", "\r"),'</p><p>',$this->escape($md->suppinfo)).'</p>';?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->fund)) { ?>
|
||||
<?php foreach($this->fund as $k=>$v) { ?>
|
||||
<ul>
|
||||
<li><?= $v['title'] ?>(项目编号:<?= $v['fund_id']?>)</li>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<hr />
|
||||
<?php endif; ?>
|
||||
<?php if ($this->resources) : ?>
|
||||
|
|
|
@ -1,227 +1,227 @@
|
|||
<?php
|
||||
class Fund extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
public $tbl_fund = "fund"; //项目
|
||||
public $tbl_mdfund = "mdfund"; //对应表
|
||||
|
||||
private $fundFields;
|
||||
|
||||
function __construct($db,Zend_Auth $auth=NULL)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
function fetch($uuid = "",$include = true,$uid=0){
|
||||
if(empty($uuid))
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." ORDER BY id DESC";
|
||||
}else{
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid ORDER BY id DESC";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
}else{
|
||||
$wheresql = array();
|
||||
|
||||
if($include)
|
||||
{
|
||||
$wheresql[] = " mf.uuid='$uuid' ";
|
||||
}else{
|
||||
$fids = $this->getMdFunds($uuid);
|
||||
if(count($fids)>0)
|
||||
{
|
||||
$wheresql[] = ' f.id NOT IN ('.join(",",$fids).')';
|
||||
}
|
||||
}
|
||||
if(!empty($uid) && is_int($uid))
|
||||
{
|
||||
$wheresql[] = " f.userid='$uid' ";
|
||||
}
|
||||
|
||||
if(count($wheresql)>0)
|
||||
{
|
||||
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
||||
}else{
|
||||
$wheresql = "";
|
||||
}
|
||||
|
||||
if($include)
|
||||
{
|
||||
$sql = "SELECT f.*,mf.place,mf.id as mfid FROM ".$this->tbl_fund." f
|
||||
LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id
|
||||
$wheresql
|
||||
ORDER BY mf.place DESC";
|
||||
}else{
|
||||
$sql = "SELECT f.* FROM ".$this->tbl_fund." f $wheresql ORDER BY f.id DESC";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
function add($data)
|
||||
{
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
return $dbh->insert($this->tbl_fund,$data);
|
||||
}
|
||||
|
||||
function update($data,$id,$uid=0)
|
||||
{
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(!empty($uid))
|
||||
{
|
||||
if(!is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(empty($row['id']))
|
||||
{
|
||||
return "您无权修改这条记录";
|
||||
}
|
||||
$condition = " id=$id AND userid=$uid ";
|
||||
}else{
|
||||
$condition = " id=$id ";
|
||||
}
|
||||
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
|
||||
$state = $dbh->update($this->tbl_fund,$data,$condition,true);
|
||||
|
||||
if( $state == true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id,$uid=0){
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
if(!empty($uid))
|
||||
{
|
||||
if(!is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(empty($row['id']))
|
||||
{
|
||||
return "您无权修改这条记录";
|
||||
}
|
||||
$condition = " id=$id AND userid=$uid ";
|
||||
}else{
|
||||
$condition = " id=$id ";
|
||||
}
|
||||
$sql = "DELETE FROM ".$this->tbl_fund." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
function mfdelete($id){
|
||||
$sql = "DELETE FROM ".$this->tbl_mdfund." WHERE id=$id";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
function view($id){
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getMdFunds($uuid){
|
||||
$sql = "SELECT * FROM ".$this->tbl_mdfund." WHERE uuid='$uuid'";
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
|
||||
$fids = array();
|
||||
foreach($rows as $k=>$v)
|
||||
{
|
||||
$fids[] = $v['fid'];
|
||||
}
|
||||
return $fids;
|
||||
}
|
||||
|
||||
function addToMdfund($uuid,$id,$order){
|
||||
if(empty($order))
|
||||
{
|
||||
$order = 0;
|
||||
}
|
||||
$data = array(
|
||||
'uuid'=>$uuid,
|
||||
'fid'=>$id,
|
||||
'place'=>$order
|
||||
);
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
return $dbh->insert($this->tbl_mdfund,$data);
|
||||
}
|
||||
|
||||
function changeorder($id,$order){
|
||||
if(!is_numeric($id) || !is_numeric($order))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'place'=>$order
|
||||
);
|
||||
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
$state = $dbh->update($this->tbl_mdfund,$data,"id=$id",true);
|
||||
|
||||
if( $state == true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$page = $request->getParam('page');
|
||||
|
||||
$paginator = Zend_Paginator::factory($data);
|
||||
$paginator->setCurrentPageNumber($page);
|
||||
$paginator->setItemCountPerPage(12);
|
||||
$paginator->setView($ctl);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$ctl->paginator = $paginator;
|
||||
}
|
||||
|
||||
function _getParams(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$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')),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
class Fund extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
private $auth = NULL; //Zend_Auth 对象
|
||||
|
||||
public $tbl_fund = "fund"; //项目
|
||||
public $tbl_mdfund = "mdfund"; //对应表
|
||||
|
||||
private $fundFields;
|
||||
|
||||
function __construct($db,Zend_Auth $auth=NULL)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
function fetch($uuid = "",$include = true,$uid=0){
|
||||
if(empty($uuid))
|
||||
{
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." ORDER BY id DESC";
|
||||
}else{
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid ORDER BY id DESC";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
}else{
|
||||
$wheresql = array();
|
||||
|
||||
if($include)
|
||||
{
|
||||
$wheresql[] = " mf.uuid='$uuid' ";
|
||||
}else{
|
||||
$fids = $this->getMdFunds($uuid);
|
||||
if(count($fids)>0)
|
||||
{
|
||||
$wheresql[] = ' f.id NOT IN ('.join(",",$fids).')';
|
||||
}
|
||||
}
|
||||
if(!empty($uid) && is_int($uid))
|
||||
{
|
||||
$wheresql[] = " f.userid='$uid' ";
|
||||
}
|
||||
|
||||
if(count($wheresql)>0)
|
||||
{
|
||||
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
||||
}else{
|
||||
$wheresql = "";
|
||||
}
|
||||
|
||||
if($include)
|
||||
{
|
||||
$sql = "SELECT f.*,mf.place,mf.id as mfid FROM ".$this->tbl_fund." f
|
||||
LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id
|
||||
$wheresql
|
||||
ORDER BY mf.place DESC";
|
||||
}else{
|
||||
$sql = "SELECT f.* FROM ".$this->tbl_fund." f $wheresql ORDER BY f.id DESC";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll(PDO::FETCH_BOTH);
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
function add($data)
|
||||
{
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
return $dbh->insert($this->tbl_fund,$data);
|
||||
}
|
||||
|
||||
function update($data,$id,$uid=0)
|
||||
{
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
if(!empty($uid))
|
||||
{
|
||||
if(!is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(empty($row['id']))
|
||||
{
|
||||
return "您无权修改这条记录";
|
||||
}
|
||||
$condition = " id=$id AND userid=$uid ";
|
||||
}else{
|
||||
$condition = " id=$id ";
|
||||
}
|
||||
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
|
||||
$state = $dbh->update($this->tbl_fund,$data,$condition,true);
|
||||
|
||||
if( $state == true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
function delete($id,$uid=0){
|
||||
if(!is_numeric($id))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
if(!empty($uid))
|
||||
{
|
||||
if(!is_numeric($uid))
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if(empty($row['id']))
|
||||
{
|
||||
return "您无权修改这条记录";
|
||||
}
|
||||
$condition = " id=$id AND userid=$uid ";
|
||||
}else{
|
||||
$condition = " id=$id ";
|
||||
}
|
||||
$sql = "DELETE FROM ".$this->tbl_fund." WHERE $condition";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
function mfdelete($id){
|
||||
$sql = "DELETE FROM ".$this->tbl_mdfund." WHERE id=$id";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
function view($id){
|
||||
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE id=$id";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getMdFunds($uuid){
|
||||
$sql = "SELECT * FROM ".$this->tbl_mdfund." WHERE uuid='$uuid'";
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
|
||||
$fids = array();
|
||||
foreach($rows as $k=>$v)
|
||||
{
|
||||
$fids[] = $v['fid'];
|
||||
}
|
||||
return $fids;
|
||||
}
|
||||
|
||||
function addToMdfund($uuid,$id,$order){
|
||||
if(empty($order))
|
||||
{
|
||||
$order = 0;
|
||||
}
|
||||
$data = array(
|
||||
'uuid'=>$uuid,
|
||||
'fid'=>$id,
|
||||
'place'=>$order
|
||||
);
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
return $dbh->insert($this->tbl_mdfund,$data);
|
||||
}
|
||||
|
||||
function changeorder($id,$order){
|
||||
if(!is_numeric($id) || !is_numeric($order))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'place'=>$order
|
||||
);
|
||||
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
$state = $dbh->update($this->tbl_mdfund,$data,"id=$id",true);
|
||||
|
||||
if( $state == true)
|
||||
{
|
||||
return true;
|
||||
}else{
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$page = $request->getParam('page');
|
||||
|
||||
$paginator = Zend_Paginator::factory($data);
|
||||
$paginator->setCurrentPageNumber($page);
|
||||
$paginator->setItemCountPerPage(12);
|
||||
$paginator->setView($ctl);
|
||||
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
||||
$ctl->paginator = $paginator;
|
||||
}
|
||||
|
||||
function _getParams(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$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')),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue