在数据页面添加了支持项目的显示

This commit is contained in:
Li Jianxuan 2013-04-22 02:35:32 +00:00
parent 8122670e12
commit 33b75a2469
3 changed files with 261 additions and 248 deletions

View File

@ -190,18 +190,18 @@ class DataController extends Zend_Controller_Action
function tagAction() function tagAction()
{ {
$id = (int)$this->_request->getParam('id'); $id = (int)$this->_request->getParam('id');
$key = $this->_request->getParam('key'); $key = $this->_request->getParam('key');
$keytype = $this->_request->getParam('keytype'); $keytype = $this->_request->getParam('keytype');
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$limit=10; $limit=10;
$offset=$limit*($page-1); $offset=$limit*($page-1);
$sql='select keyword,count(*),keytype from keyword '; $sql='select keyword,count(*),keytype from keyword ';
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" where keytype='".$keytype."'"; 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'; $sql.=' group by keyword,keytype order by keytype,keyword,count desc';
$state=$this->db->query($sql); $state=$this->db->query($sql);
$this->view->keywords=$state->fetchAll(); $this->view->keywords=$state->fetchAll();
if ($id>0 or !empty($key)) { if ($id>0 or !empty($key)) {
if (empty($key)) { if (empty($key)) {
$where=$this->db->quoteInto('id = ?',$id); $where=$this->db->quoteInto('id = ?',$id);
@ -209,7 +209,7 @@ class DataController extends Zend_Controller_Action
$key=$row->name; $key=$row->name;
} }
$this->view->codename=$key; $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); $state=$this->db->query($sql);
$row=$state->fetchAll(); $row=$state->fetchAll();
@ -650,6 +650,10 @@ class DataController extends Zend_Controller_Action
} }
} }
$this->view->data_archives = $data_archives; $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=?"; $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){ public function jsonexit($data){
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
return true; return true;
} }
function organizationAction() function organizationAction()
{ {
$page = $this->_request->getParam('page'); $page = $this->_request->getParam('page');
$name = $this->_request->getParam('name'); $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')"); $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(); $this->view->organisation=$state->fetchAll();
if (!empty($name)) { if (!empty($name)) {
$this->view->codename=$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=?"; $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 = $this->db->prepare($sql);
$sth->execute(array($name)); $sth->execute(array($name));
$rows = $sth->fetchAll(); $rows = $sth->fetchAll();
@ -1958,10 +1962,10 @@ class DataController extends Zend_Controller_Action
$paginator->setItemCountPerPage(10); $paginator->setItemCountPerPage(10);
$paginator->setView($this->view); $paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator; $this->view->paginator=$paginator;
} else { } else {
//提供全部分类列表 //提供全部分类列表
} }
} }
} }

View File

@ -82,9 +82,18 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
</ul> </ul>
<hr /> <hr />
<?php }?> <?php }?>
<?php if ($md->suppinfo) : ?> <?php if ($md->suppinfo || $this->fund) : ?>
<h4><i class="icon-money text-info"></i>资助项目</h4> <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 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 /> <hr />
<?php endif; ?> <?php endif; ?>
<?php if ($this->resources) : ?> <?php if ($this->resources) : ?>

View File

@ -1,227 +1,227 @@
<?php <?php
class Fund extends Zend_Controller_Plugin_Abstract class Fund extends Zend_Controller_Plugin_Abstract
{ {
private $db; //传入PDO对象. private $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象 private $auth = NULL; //Zend_Auth 对象
public $tbl_fund = "fund"; //项目 public $tbl_fund = "fund"; //项目
public $tbl_mdfund = "mdfund"; //对应表 public $tbl_mdfund = "mdfund"; //对应表
private $fundFields; private $fundFields;
function __construct($db,Zend_Auth $auth=NULL) function __construct($db,Zend_Auth $auth=NULL)
{ {
$this->db = $db; $this->db = $db;
$this->auth = $auth; $this->auth = $auth;
} }
function fetch($uuid = "",$include = true,$uid=0){ function fetch($uuid = "",$include = true,$uid=0){
if(empty($uuid)) if(empty($uuid))
{ {
if(empty($uid)) if(empty($uid))
{ {
$sql = "SELECT * FROM ".$this->tbl_fund." ORDER BY id DESC"; $sql = "SELECT * FROM ".$this->tbl_fund." ORDER BY id DESC";
}else{ }else{
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid ORDER BY id DESC"; $sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid ORDER BY id DESC";
} }
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
return $rows; return $rows;
}else{ }else{
$wheresql = array(); $wheresql = array();
if($include) if($include)
{ {
$wheresql[] = " mf.uuid='$uuid' "; $wheresql[] = " mf.uuid='$uuid' ";
}else{ }else{
$fids = $this->getMdFunds($uuid); $fids = $this->getMdFunds($uuid);
if(count($fids)>0) if(count($fids)>0)
{ {
$wheresql[] = ' f.id NOT IN ('.join(",",$fids).')'; $wheresql[] = ' f.id NOT IN ('.join(",",$fids).')';
} }
} }
if(!empty($uid) && is_int($uid)) if(!empty($uid) && is_int($uid))
{ {
$wheresql[] = " f.userid='$uid' "; $wheresql[] = " f.userid='$uid' ";
} }
if(count($wheresql)>0) if(count($wheresql)>0)
{ {
$wheresql = " WHERE ".join(" AND ",$wheresql); $wheresql = " WHERE ".join(" AND ",$wheresql);
}else{ }else{
$wheresql = ""; $wheresql = "";
} }
if($include) if($include)
{ {
$sql = "SELECT f.*,mf.place,mf.id as mfid FROM ".$this->tbl_fund." f $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 LEFT JOIN ".$this->tbl_mdfund." mf ON mf.fid=f.id
$wheresql $wheresql
ORDER BY mf.place DESC"; ORDER BY mf.place DESC";
}else{ }else{
$sql = "SELECT f.* FROM ".$this->tbl_fund." f $wheresql ORDER BY f.id DESC"; $sql = "SELECT f.* FROM ".$this->tbl_fund." f $wheresql ORDER BY f.id DESC";
} }
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll(PDO::FETCH_BOTH);
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);
return $dbh->insert($this->tbl_fund,$data); return $dbh->insert($this->tbl_fund,$data);
} }
function update($data,$id,$uid=0) function update($data,$id,$uid=0)
{ {
if(!is_numeric($id)) if(!is_numeric($id))
{ {
return "参数错误"; return "参数错误";
} }
if(!empty($uid)) if(!empty($uid))
{ {
if(!is_numeric($uid)) if(!is_numeric($uid))
{ {
return "参数错误"; return "参数错误";
} }
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id"; $sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();
if(empty($row['id'])) if(empty($row['id']))
{ {
return "您无权修改这条记录"; return "您无权修改这条记录";
} }
$condition = " id=$id AND userid=$uid "; $condition = " id=$id AND userid=$uid ";
}else{ }else{
$condition = " id=$id "; $condition = " id=$id ";
} }
include_once("helper/dbh.php"); include_once("helper/dbh.php");
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
$state = $dbh->update($this->tbl_fund,$data,$condition,true); $state = $dbh->update($this->tbl_fund,$data,$condition,true);
if( $state == true) if( $state == true)
{ {
return true; return true;
}else{ }else{
return $state; return $state;
} }
} }
function delete($id,$uid=0){ function delete($id,$uid=0){
if(!is_numeric($id)) if(!is_numeric($id))
{ {
return "参数错误"; return "参数错误";
} }
if(!empty($uid)) if(!empty($uid))
{ {
if(!is_numeric($uid)) if(!is_numeric($uid))
{ {
return "参数错误"; return "参数错误";
} }
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id"; $sql = "SELECT * FROM ".$this->tbl_fund." WHERE userid=$uid AND id=$id";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();
if(empty($row['id'])) if(empty($row['id']))
{ {
return "您无权修改这条记录"; return "您无权修改这条记录";
} }
$condition = " id=$id AND userid=$uid "; $condition = " id=$id AND userid=$uid ";
}else{ }else{
$condition = " id=$id "; $condition = " id=$id ";
} }
$sql = "DELETE FROM ".$this->tbl_fund." WHERE $condition"; $sql = "DELETE FROM ".$this->tbl_fund." WHERE $condition";
return $this->db->exec($sql); return $this->db->exec($sql);
} }
function mfdelete($id){ function mfdelete($id){
$sql = "DELETE FROM ".$this->tbl_mdfund." WHERE id=$id"; $sql = "DELETE FROM ".$this->tbl_mdfund." WHERE id=$id";
return $this->db->exec($sql); return $this->db->exec($sql);
} }
function view($id){ function view($id){
$sql = "SELECT * FROM ".$this->tbl_fund." WHERE id=$id"; $sql = "SELECT * FROM ".$this->tbl_fund." WHERE id=$id";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$row = $rs->fetch(); $row = $rs->fetch();
return $row; return $row;
} }
function getMdFunds($uuid){ function getMdFunds($uuid){
$sql = "SELECT * FROM ".$this->tbl_mdfund." WHERE uuid='$uuid'"; $sql = "SELECT * FROM ".$this->tbl_mdfund." WHERE uuid='$uuid'";
$rs = $this->db->query($sql); $rs = $this->db->query($sql);
$rows = $rs->fetchAll(); $rows = $rs->fetchAll();
$fids = array(); $fids = array();
foreach($rows as $k=>$v) foreach($rows as $k=>$v)
{ {
$fids[] = $v['fid']; $fids[] = $v['fid'];
} }
return $fids; return $fids;
} }
function addToMdfund($uuid,$id,$order){ function addToMdfund($uuid,$id,$order){
if(empty($order)) if(empty($order))
{ {
$order = 0; $order = 0;
} }
$data = array( $data = array(
'uuid'=>$uuid, 'uuid'=>$uuid,
'fid'=>$id, 'fid'=>$id,
'place'=>$order 'place'=>$order
); );
include_once("helper/dbh.php"); include_once("helper/dbh.php");
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
return $dbh->insert($this->tbl_mdfund,$data); return $dbh->insert($this->tbl_mdfund,$data);
} }
function changeorder($id,$order){ function changeorder($id,$order){
if(!is_numeric($id) || !is_numeric($order)) if(!is_numeric($id) || !is_numeric($order))
{ {
return false; return false;
} }
$data = array( $data = array(
'place'=>$order 'place'=>$order
); );
include_once("helper/dbh.php"); include_once("helper/dbh.php");
$dbh = new dbh($this->db); $dbh = new dbh($this->db);
$state = $dbh->update($this->tbl_mdfund,$data,"id=$id",true); $state = $dbh->update($this->tbl_mdfund,$data,"id=$id",true);
if( $state == true) if( $state == true)
{ {
return true; return true;
}else{ }else{
return $state; return $state;
} }
} }
function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request) function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
{ {
$page = $request->getParam('page'); $page = $request->getParam('page');
$paginator = Zend_Paginator::factory($data); $paginator = Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($page); $paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(12); $paginator->setItemCountPerPage(12);
$paginator->setView($ctl); $paginator->setView($ctl);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$ctl->paginator = $paginator; $ctl->paginator = $paginator;
} }
function _getParams(Zend_Controller_Request_Abstract $request) function _getParams(Zend_Controller_Request_Abstract $request)
{ {
$data = array( $data = array(
'title' => trim($request->getParam('title')), 'title' => trim($request->getParam('title')),
'fund_id' => trim($request->getParam('fund_id')), 'fund_id' => trim($request->getParam('fund_id')),
'fund_type' => trim($request->getParam('fund_type')), 'fund_type' => trim($request->getParam('fund_type')),
'title_en' => trim($request->getParam('title_en')), 'title_en' => trim($request->getParam('title_en')),
'fund_type_en' => trim($request->getParam('fund_type_en')), 'fund_type_en' => trim($request->getParam('fund_type_en')),
); );
return $data; return $data;
} }
} }