merge heihedata branch from r4487-4579 into trunk

This commit is contained in:
wlx 2014-06-06 01:02:29 +00:00
parent 44ec14a878
commit e04d016145
56 changed files with 5079 additions and 2793 deletions

View File

@ -5,6 +5,7 @@ use Reference\Ris;
use Reference\RisOutput;
use Helpers\dbh;
use \Files\Files;
use Fund\Fund;
class Admin_DataController extends Zend_Controller_Action
{
@ -469,10 +470,12 @@ class Admin_DataController extends Zend_Controller_Action
if(!empty($keyword))
{
$sql = "select m.*,md.viewed,g.id as gid, ds.id as datasetid from metadata m
$sql = "select m.*,md.viewed,g.id as gid,gen.id as genid,st.status as mdstatus, ds.id as datasetid from metadata m
left join mdstat md on m.uuid=md.uuid
left join geonetworkmetadata g on g.uuid=m.uuid
left join dataset ds on m.uuid=ds.uuid
LEFT JOIN mdstatus st ON md.uuid=st.uuid
left join en.geonetworkmetadata gen on gen.uuid=md.uuid
where m.title like '%$keyword%'
order by m.id desc
";
@ -496,11 +499,12 @@ class Admin_DataController extends Zend_Controller_Action
}//search
else{
$sql = "SELECT md.*,s.viewed,g.id as gid,st.status as mdstatus,ds.id as datasetid FROM metadata md
$sql = "SELECT md.*,s.viewed,g.id as gid,gen.id as genid,st.status as mdstatus,ds.id as datasetid FROM metadata md
LEFT JOIN mdstat s ON md.uuid=s.uuid
LEFT JOIN geonetworkmetadata g ON g.uuid=md.uuid
LEFT JOIN mdstatus st ON md.uuid=st.uuid
LEFT JOIN dataset ds ON md.uuid=ds.uuid
left join en.geonetworkmetadata gen on gen.uuid=md.uuid
ORDER BY md.id DESC";
$sth = $this->db->prepare($sql);
$sth->execute();
@ -1130,6 +1134,7 @@ class Admin_DataController extends Zend_Controller_Action
$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');
$reference = new Reference();
@ -1158,13 +1163,29 @@ class Admin_DataController extends Zend_Controller_Action
$this->view->pagelimit = 12;
//文献首页
if(empty($ac))
if(empty($ac) && empty($uuid))
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit);
$this->view->years = $reference->countByYear();
return true;
}
else if (empty($ac) && !empty($uuid))
{
$sql="select * from metadata where uuid='$uuid'";
$this->view->md=$this->db->fetchRow($sql);
$this->view->referenceType = $reference->referenceType();
if (empty($keyword))
{
$this->_helper->viewRenderer('ref-data-add');
unset($reference->keyword);
view::addPaginator($reference->fetchReferencesByUUID($uuid),$this, $this->view->pagelimit);
} else {
$this->_helper->viewRenderer('ref-data-search');
view::addPaginator($reference->fetchReferencesWithUUID($uuid),$this, $this->view->pagelimit);
}
return true;
}
else if ($ac == "water")
{
$this->view->referenceType = $reference->referenceType();
@ -1183,6 +1204,13 @@ class Admin_DataController extends Zend_Controller_Action
view::addPaginator($reference->fetchTodoReferences(),$this,$this->view->pagelimit);
return true;
}
//数据作者文献缺少RIS
else if ($ac=="author")
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchAuthorReferences(),$this,$this->view->pagelimit);
return true;
}
unset($this->view->reference);
unset($this->view->page);
@ -1293,6 +1321,17 @@ class Admin_DataController extends Zend_Controller_Action
}
return true;
}
//删除文献数据对应关系
if($ac == "deletemdref")
{
if($reference->delMdref($this->_getParam('mrid')))
{
view::Post($this,"删除成功!",-1);
}else{
view::Post($this,"删除失败!",-1);
}
return true;
}
//相关数据
if($ac == "data")
@ -3018,6 +3057,19 @@ class Admin_DataController extends Zend_Controller_Action
}//ajax 添加作者
else if ($ac=='delegate' && !empty($uuid))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$sql="update mdstatus set status=7 where status in (5,6) and uuid='$uuid' and uuid in (select uuid from metadata m where datatype=1)";
if ($this->db->query($sql))
{
echo '<h1>成功将该离线数据委托给数据中心进行审核!</h1>';
} else {
echo '<h1>发生错误!请检查。</h1>';
}
return;
}
else if(($ac == "edit" || $ac=="") && !empty($uuid))
{
@ -3201,7 +3253,9 @@ class Admin_DataController extends Zend_Controller_Action
//查看所有的未提交数据列表
else if((empty($ac) && empty($uuid))|| $ac=='list')
{
$sql = "SELECT (regexp_matches(gn.data,'<resTitle>(.*)</resTitle>'))[1] as title,gn.id,gn.uuid,u.username,u.realname FROM geonetworkmetadata gn left join users u on gn.owner=u.id
$sql = "SELECT (regexp_matches(gn.data,'<resTitle>(.*)</resTitle>'))[1] as title,gn.id,gn.uuid,u.username,u.realname,t.count as version_count
FROM geonetworkmetadata gn left join users u on gn.owner=u.id
left join (select count(*),uuid from mdversion group by uuid) t on t.uuid=gn.uuid
WHERE gn.uuid not in (select uuid from metadata)
order by gn.id desc
";
@ -3704,238 +3758,169 @@ class Admin_DataController extends Zend_Controller_Action
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');
$submit = $this->_getParam('submit');
$this->view->q = $keyword = $this->_getParam('q');
include_once("helper/view.php");
include_once("data/Fund.php");
$fund = new Fund($this->db);
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
//所有项目
if(empty($ac) && empty($uuid))
{
$user = $auth->getIdentity();
$uid = $user->id;
view::addPaginator($fund->fetchFunds(),$this, $this->view->pagelimit);
return true;
}
if($ac=='index' || empty($ac))
//单条数据
else if (empty($ac) && !empty($uuid))
{
$uuid = $this->_getParam('uuid');
if(empty($uuid))
$sql="select * from metadata where uuid='$uuid'";
$this->view->md=$this->db->fetchRow($sql);
if (empty($keyword))
{
$this->_helper->viewRenderer('fund-data-add');
unset($fund->keyword);
view::addPaginator($fund->fetchFundsByUUID($uuid),$this, $this->view->pagelimit);
} else {
$this->_helper->viewRenderer('fund-data-search');
view::addPaginator($fund->fetchFundsWithUUID($uuid),$this, $this->view->pagelimit);
}
return true;
}
//数据相关项目
else if ($ac == "datalist")
{
$this->_helper->viewRenderer('fund-data-list');
view::addPaginator($fund->fetchDataFunds(),$this,$this->view->pagelimit);
return true;
}
//无数据的项目
else if ($ac == "nodata")
{
view::addPaginator($fund->fetchNoDataFunds(),$this,$this->view->pagelimit);
return true;
}
//删除项目
else if($ac == "delete")
{
if($fund->delete($this->_getParam('id')))
{
$rows = $fund->fetch(NULL,true,0,$keyword);
view::addPaginator($rows,$this,10);
view::Post($this,"删除项目信息成功!",-1);
}else{
include('data/Metadata.php');
$md = new Metadata($this->db);
$this->view->md = $md->view($uuid);
$rows = $fund->fetch($uuid);
view::addPaginator($rows,$this,10);
view::Post($this,"删除项目信息失败!",-1);
}
return true;
}
if($ac == 'datalist')
//删除项目和数据对应关系
else if($ac == "remove")
{
$this->_helper->viewRenderer('fund-data-list');
$this->view->q = $q = $this->_getParam('q');
$rows = $fund->fetchFromData(true,0,$q);
view::addPaginator($rows,$this,10);
return true;
}
if($ac == 'dataview')
{
$this->_helper->viewRenderer('fund-data-view');
$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;
}
if($ac == "add")
{
$this->_helper->viewRenderer('fund-add');
if(!empty($submit))
{
$data = $fund->_getParams($this->_request);
$data['userid'] = $uid;
if($fund->add($data) == true)
{
$this->view->AlertType = "alert-success";
$this->view->msg = "添加成功!";
$this->view->jump_url = "/admin/data/fund/";
return true;
}else{
$this->view->data = $data;
$this->view->error = "添加失败,请重试";
return true;
}
if($fund->remove($this->_getParam('id')))
{
view::Post($this,"移除数据-项目信息成功!",-1);
}else{
view::Post($this,"移除数据-项目信息失败!",-1);
}
return true;
}//add
if($ac == "edit")
}
//添加数据项目对应
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;
}else{
$this->_helper->viewRenderer('fund-data');
view::addPaginator($fund->getDataByFund($fid),$this,$this->view->pagelimit);
return true;
}
}
//添加或编辑项目
else if($ac == "add")
{
$this->_helper->viewRenderer('fund-add');
$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))
{
$data = $fund->_getParams($this->_request);
$data['userid'] = $uid;
if($fund->update($data,$id) == true)
$this->view->data = $fund->getFundParam();
if(empty($id) || !is_numeric($id))
{
$this->view->AlertType = "alert-success";
$this->view->msg = "修改成功!";
$this->view->jump_url = "/admin/data/fund/";
return true;
$status = $fund->fund();
}else{
$this->view->data = $data;
$this->view->error = "修改失败,请重试";
return true;
$status = $fund->fund($id);
}
if($status !== true)
{
$this->view->error = view::Error($status);
}else{
if(!empty($id))
{
$msg = "项目修改成功!";
view::Post($this,$msg,-2);
return true;
}else{
$msg = "项目添加成功!";
view::Post($this,$msg,"/admin/data/ref/ac/add");
return true;
}
}
}else{
$this->view->data = $fund->view($id);
$this->view->data = array();
if(!empty($id) && is_numeric($id))
{
$this->view->data = $fund->getOneFund($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($fund->addToMdfund($uuid,$id,$order))
{
$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;
}else{
$this->jsonexit(array('error'=>'删除失败'));
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{
$this->view->error = view::Error("删除失败!","alert-error");
}
}
$rows = $fund->getData($id,$keyword);
view::addPaginator($rows,$this,10);
}
}//fund
public function doiAction()
@ -4164,7 +4149,29 @@ class Admin_DataController extends Zend_Controller_Action
$mail->send();
}
}//发送邀请邮件
//导出元数据到英文版本
public function gnenexportAction()
{
$uuid = $this->_getParam('uuid');
$sql="select id,data,owner,source from geonetworkmetadata where uuid='$uuid'";
$rs=$this->db->fetchRow($sql);
$sql="insert into en.geonetworkmetadata (uuid,source,owner,data) values('".$uuid."','".$rs['source']."',".$rs['owner'].",".$this->db->quote($rs['data']).")";
$this->db->exec($sql);
$sql="select id from en.geonetworkmetadata where uuid='$uuid'";
$rs1=$this->db->fetchRow($sql);
$shell="#!/bin/bash\n";
$shell.='cp -r /var/www/westdc.westgis.ac.cn/geonetwork/data/';
$shell.=sprintf('%05d',floor(($rs['id']+0.1)/100)*100).'-'.sprintf('%05d',ceil(($rs['id']+0.1)/100)*100-1)."/".$rs['id'];
$shell.=' /var/www/card.westgis.ac.cn/geonetwork/data/'.sprintf('%05d',floor(($rs1['id']+0.1)/100)*100).'-'.sprintf('%05d',ceil(($rs1['id']+0.1)/100)*100-1)."/".$rs1['id'];
$shell.="\nchown -R tomcat7:www-data /var/www/card.westgis.ac.cn/geonetwork/data/".sprintf('%05d',floor(($rs1['id']+0.1)/100)*100).'-'.sprintf('%05d',ceil(($rs1['id']+0.1)/100)*100-1)."/".$rs1['id'];
$shell.="\n";
$filename='/var/www/westdc.westgis.ac.cn/tools/sync-gn-thumbnail.sh';
file_put_contents($filename, $shell);
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
echo '<h1>成功导入英文版!</h1>';
}
/*
获得单个文件的信息
return array row

View File

@ -15,11 +15,7 @@ $this->theme->AppendPlus($this,'colorbox');
</div>
<div class="span10">
<div>
<ul class="nav nav-tabs">
<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>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</div>
<div class="">
<?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 class="span10">
<div>
<ul class="nav nav-tabs">
<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>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</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 class="input-append">
<form id="datasearch" class="search_form" action="">
@ -68,33 +52,59 @@ table thead tr th {background:#EBF2F6;}
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<thead>
<tr>
<th>名称</th>
<th>项目编号</th>
<th>项目类型</th>
<th>数据个数</th>
<th width="70">操作</th>
<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="100">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>">
<?php }?>
<td><?= $item['title'] ?></td>
<td><?= $item['fund_id'] ?></td>
<td>
[<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?>
</td>
<td><?= $item['fund_id'] ?></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>
<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>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
@ -103,11 +113,4 @@ table thead tr th {background:#EBF2F6;}
<?php } ?>
</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
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('支持项目');
$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;}
@ -18,11 +19,7 @@ table thead tr th {background:#EBF2F6;}
</div>
<div class="span10">
<div>
<ul class="nav nav-tabs">
<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>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</div>
<div>
<div class="input-append">
@ -35,7 +32,7 @@ table thead tr th {background:#EBF2F6;}
<?php if(!empty($this->error)) { ?>
<?= $this->error ?>
<?php } ?>
<h3><?= $this->info['title'] ?> 的相关数据</h3>
<h3><?= $this->info['title'] ?> [<?= $this->info['fund_id'] ?>]</h3>
<hr />
<div id="datalist">
<?php if (count($this->paginator)): ?>
@ -43,21 +40,18 @@ table thead tr th {background:#EBF2F6;}
<thead>
<tr>
<th>名称</th>
<th width="70">操作</th>
<th width="100">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
foreach ($this->paginator as $item):
$autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>">
<?php }?>
<td><?= $item['title'] ?></td>
<td>[<?= $autoindex ?>]&nbsp;<a href="/data/<?= $item['uuid'] ?>"><?= $item['title'] ?></a></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>
</tr>
<?php endforeach; ?>
@ -68,11 +62,4 @@ table thead tr th {background:#EBF2F6;}
</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
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('支持项目');
$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;}
@ -18,122 +19,81 @@ table thead tr th {background:#EBF2F6;}
</div>
<div class="span10">
<div>
<ul class="nav nav-tabs">
<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>
<?= $this->partial('data/fund-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</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 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)) { ?>
<?php if(empty($this->AlertType)) $AlertType = "alert-error";else $AlertType = $this->AlertType;?>
<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>
<?= $this->error ?>
<?php } ?>
<?php if(!empty($this->msg)) { ?>
<div class="alert <?= $this->AlertType;?>">
<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 } ?>
<?= $this->msg ?>
<?php } else{ ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>名称</th>
<th>编号</th>
<th>类型</th>
<?php if($this->md) { ?>
<th width="80">排序</th>
<?php }else{ ?>
<th>英文标题</th>
<th>英文类型</th>
<?php } ?>
<?php if($this->ct) { ?>
<th>添加</th>
<?php } ?>
<th width="100">操作</th>
<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 width="110">操作</th>
</tr>
</thead>
<tbody>
<?php $autoindex=0;
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<?php if(empty($this->md)) { ?>
<tr id="DataLine_<?= $item['id']?>">
<?php }else{?>
<tr id="DataLine_<?= $item['mfid']?>">
<?php }?>
<td><?= $item['title'] ?></td>
<td><?= $item['fund_id'] ?></td>
<td>
[<?= $autoindex ?>]&nbsp;
<?= $item['title'] ?>
</td>
<td><?= $item['fund_id'] ?></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['fund_type_en'] ?></td>
<?php } ?>
<?php if($this->ct) { ?>
<td><a href="javascript:void(0);" class="addtomd" rel="<?= $item['id']?>">添加此项目</a></td>
<?php } ?>
<td><?= $item['title_en'] ?></td>
<td><?= $item['fund_type_en'] ?></td>
<td>
<?php if(empty($this->md)) { ?>
<a href="/admin/data/fund/ac/data/id/<?= $item['id']?>">数据</a>
<a href="/admin/data/fund/ac/edit/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 } ?>
<a href="/admin/data/fund/ac/add/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/delete/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<?php if(!empty($this->md)) { ?>
暂无数据,点击标题右侧添加按钮为此数据添加项目
<?php }else{ ?>
暂无数据
<?php } ?>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
@ -141,35 +101,4 @@ table thead tr th {background:#EBF2F6;}
</div>
</div>
<!-- //页面内容 -->
<script>
<?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>
<?= $this->partial('data/fund-mdfund-form.phtml'); ?>

View File

@ -5,7 +5,7 @@
<li><a href="/admin/data/author">数据作者管理</a></li>
<li><a href="/admin/data/version">数据版本管理</a></li>
<li><a href="/admin/data/comment">数据反馈管理</a></li>
<li><a href="/admin/data/reference">数据文献管理</a></li>
<!--<li><a href="/admin/data/reference">数据文献管理</a></li>-->
<li><a href="/admin/data/ref">文献管理</a></li>
<li><a href="/admin/data/attachments">数据附件管理</a></li>
<!--

View File

@ -46,10 +46,12 @@
<p>大小:<?= $item['filesize']; ?>M创建时间<?= date('Y-m-d',strtotime($item['ts_created'])); ?>,查看:<?= $item['viewed']; ?>次。</p>
<p>
操作:
<a href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a> |
<?php if ($item['gid']>0) : ?>
<a href="/service/geonetwork?url=metadata.edit?id=<?= $item['gid']; ?>" target="_blank">编辑</a> |
<?php endif; ?>
<a href="/admin/data/md/delete/<?= $item['uuid']; ?>">删除</a> |
<a href="/admin/data/sync/uuid/<?= $item['uuid']; ?>">同步</a> |
<a href="/admin/data/reference/show/<?php echo $item['uuid'];?>">文献管理</a> |
<!-- <a href="/admin/data/sync/uuid/<?= $item['uuid']; ?>">同步</a> | -->
<a href="/admin/data/ref/uuid/<?php echo $item['uuid'];?>">文献管理</a> |
<a href="/admin/data/md/att/1/uuid/<?php echo $item['uuid'];?>">附件管理</a> |
<a href="/admin/data/comment/uuid/<?php echo $item['uuid'];?>">反馈管理</a> |
<a href="/admin/data/author/uuid/<?php echo $item['uuid'];?>">作者管理</a> |
@ -57,7 +59,7 @@
<?php if (@!is_numeric($item['mdstatus'])) : ?>
<a href="/admin/review/addon/uuid/<?php echo $item['uuid'];?>">放入元数据评审</a> |
<?php endif; ?>
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">数据来源</a> |
<?php if(!empty($item['datasetid'])):?>
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">数据路径</a> |
<a href="/admin/data/dataset/ac/import/uuid/<?php echo $item['uuid'];?>" class="iframe">重新导入数据目录</a> |
@ -67,6 +69,12 @@
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a> |
<a href="/admin/data/fund/uuid/<?php echo $item['uuid'];?>">支持项目</a> |
<a href="/admin/data/doi/uuid/<?php echo $item['uuid'];?>">DOI</a>
<?php if ($item['datatype']==1 && ($item['mdstatus']==5 || $item['mdstatus']==6)) :?>
| <a href="/admin/data/author/ac/delegate/uuid/<?php echo $item['uuid'];?>" class="iframe">委托数据中心管理</a>
<?php endif; ?>
<?php if (!isset($item['genid']) || !$item['genid']>0) : ?>
| <a href="/admin/data/gnenexport/uuid/<?php echo $item['uuid'];?>" class="iframe">导入英文版</a>
<?php endif; ?>
</p>
<?php if($item['author']) :?>
<p>数据贡献者:<?= $item['author']; ?></p>

View File

@ -45,6 +45,7 @@ $this->breadcrumb()->setSeparator(' > ');
| <a href="/service/geonetwork?url=metadata.delete?id=<?php echo $item['id']; ?>" target="_blank">删除此条数据</a>
| <a onclick="validate(<?php echo $item['id'];?>);" class="more inline">检查元数据错误</a>
| <a onclick="$('#commit_submit').attr('onclick','commit(\'<?php echo $item['id'];?>\');');" href="#commitform" class="more inline">提交评审发布</a>
| 版本数:<?= $item['version_count'] ?>
</p>
</li>
<?php

View File

@ -137,7 +137,7 @@ $(function() {
'uploader' : '/admin/data/ref/ac/pdfupload',
'multi' : false,
'auto' : true,
'fileTypeExts' : '*.pdf',
'fileTypeExts' : '*.pdf;*.caj',
'onUploadSuccess' : function(file, data, response) {
upload.onsuccess(file, data, response);
},

View File

@ -0,0 +1,116 @@
<?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-ref');
?>
<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/ref-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{ ?>
<?php if($this->ac == 'westdc'){ ?>
<button type="button" class="btn btn-success" onclick="$('#mdref')[0].reset();mdref.edit('','','e31f5ea7-a4af-4ae3-9ac1-1a84132c4338',0,0)">添加数据中心文献</button>
<?php } ?>
<?php if(!empty($this->years)) { ?>
<?php foreach($this->years as $k=>$v){ ?>
<a class="btn btn-info" href="?field[year]=<?= $v['year'] ?>"><?= empty($v['year']) ? "未知":$v['year'] ?>(<?= $v['num'] ?>)</a>
<?php } ?>
<?php } ?>
<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>
年份
<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>
</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=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>类型</th>
<th></th>
<th width="40">操作</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['id']?>">
<td>
[<?= $autoindex ?>]&nbsp;
<?php if ($item['ris']) :
echo $item['reference'];
else :
?>
{<?php $authors = $this->reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'<font color="#CC0000">未知作者</font>'; ?>}&nbsp;
{<?= empty($item['title']) ? '<font color="#CC0000">未知标题</font>':$item['title'] ?>}&nbsp;
{<?= empty($item['publisher']) ? '<font color="#CC0000">未知期刊</font>':$item['publisher'] ?>}&nbsp;
{<?= empty($item['year']) ? '<font color="#CC0000">未知年份</font>':$item['year'] ?>}&nbsp;
<?php endif; ?>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a> 
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>
</td>
<td><?= date("Y-m-d",strtotime($item['ts_created'])) ?></td>
<td><?= $this->referenceType[$item['reftype']] ?></td>
<td><?= $item['place'] ?></td>
<td>
<a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit(<?= $item['mrid']?>,<?= $item['id']?>,'<?= $this->uuid; ?>',<?= $item['reftype']?>,<?= $item['place']?>)">编辑</a>
<a href="/admin/data/ref/ac/deletemdref/mrid/<?= $item['mrid']?>">移除</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<?= $this->partial('data/ref-mdref-form.phtml',array('referenceType'=>$this->referenceType)); ?>

View File

@ -0,0 +1,115 @@
<?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-ref');
?>
<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/ref-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{ ?>
<?php if($this->ac == 'westdc'){ ?>
<button type="button" class="btn btn-success" onclick="$('#mdref')[0].reset();mdref.edit('','','e31f5ea7-a4af-4ae3-9ac1-1a84132c4338',0,0)">添加数据中心文献</button>
<?php } ?>
<?php if(!empty($this->years)) { ?>
<?php foreach($this->years as $k=>$v){ ?>
<a class="btn btn-info" href="?field[year]=<?= $v['year'] ?>"><?= empty($v['year']) ? "未知":$v['year'] ?>(<?= $v['num'] ?>)</a>
<?php } ?>
<?php } ?>
<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>
年份
<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=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>
</th>
<th>类型</th>
<th></th>
<th width="70">操作</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['id']?>">
<td>
[<?= $autoindex ?>]&nbsp;
<?php if ($item['ris']) :
echo $item['reference'];
else :
?>
{<?php $authors = $this->reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'<font color="#CC0000">未知作者</font>'; ?>}&nbsp;
{<?= empty($item['title']) ? '<font color="#CC0000">未知标题</font>':$item['title'] ?>}&nbsp;
{<?= empty($item['publisher']) ? '<font color="#CC0000">未知期刊</font>':$item['publisher'] ?>}&nbsp;
{<?= empty($item['year']) ? '<font color="#CC0000">未知年份</font>':$item['year'] ?>}&nbsp;
<?php endif; ?>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a> 
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>
</td>
<td><?= ($item['reftype']>-1)?$this->referenceType[$item['reftype']]:'' ?></td>
<td><?= $item['place'] ?></td>
<td>
<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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
<?= $this->partial('data/ref-mdref-form.phtml',array('referenceType'=>$this->referenceType)); ?>

View File

@ -44,7 +44,7 @@ table thead tr th {background:#EBF2F6;}
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<td><?= $item['title'] ?></td>
<td><?= $item['title'] ?> <a href="/data/<?= $item['uuid'] ?>" target="_blank">查看</a></td>
<td><?= isset($this->referenceType[$item['reftype']]) ? $this->referenceType[$item['reftype']]:"" ?></td>
<td><?= $item['place'] ?></td>
<td>

View File

@ -59,7 +59,7 @@ $(function() {
'uploader' : '/admin/data/ref/ac/pdfupload',
'multi' : true,
'auto' : true,
'fileTypeExts' : '*.pdf',
'fileTypeExts' : '*.pdf;*.caj',
'onUploadSuccess' : function(file, data, response) {
upload.onsuccess(file, data, response);
},

View File

@ -1,8 +1,12 @@
<ul class="nav nav-tabs">
<li <?= empty($this->ac) ? 'class="active"':"" ?>><a href="/admin/data/ref">浏览所有</a></li>
<?php if (!empty($this->uuid)) : ?>
<li class="active"><a href="/admin/data/ref/uuid/<?= $this->uuid ?>">数据文献</a></li>
<?php endif; ?>
<li <?= empty($this->ac) && empty($this->uuid) ? 'class="active"':"" ?>><a href="/admin/data/ref">浏览所有</a></li>
<li <?= $this->ac=="water" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/water">WATER文献</a></li>
<li <?= $this->ac=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</a></li>
<li <?= $this->ac=="todo" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/todo">待处理文献</a></li>
<li <?= $this->ac=="todo" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/todo">无数据文献</a></li>
<li <?= $this->ac=="author" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/author">数据作者文献</a></li>
<li <?= $this->ac=="add" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/add">单篇添加</a></li>
<li <?= $this->ac=="multiupload" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/multiupload">批量上传</a></li>
<li <?= $this->ac=="files" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/files">文件管理</a></li>

View File

@ -19,7 +19,7 @@ table thead tr th {background:#EBF2F6;}
</div>
<div class="span10">
<div>
<?= $this->partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?>
<?= $this->partial('data/ref-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
</div>
<div>
<div class="input-append">

View File

@ -167,7 +167,7 @@ $(document).ready(function(){
<div class="column width3">
<p>
<input type="checkbox" id="pubtimeturn" name="pubtimer" value="1" /><label id="pubtimelable" for="productcat">定时发布?</label><br/>
<input type="checkbox" id="pubtimeturn" name="pubtimer" value="1" <?php if($this->ev['is_pub']==true && !empty($this->ev['ts_published'])) echo 'checked="checked"'; ?>/><label id="pubtimelable" for="productcat">定时发布?</label><br/>
<input type="text" name="pubtime" id="pubtime" value="<?php echo date("Y-m-d H:i",strtotime($this->ev['ts_published']));?>" readonly="readonly" />
<small>e.g. 2011-10-28 9:35 or 2011-10-28 21:35</small>
</p>

View File

@ -7,7 +7,9 @@
@link http://
*/
use data\DataService;
use Helpers\View as view;
use Reference\Reference;
use Reference\Ris;
include_once("data/Author.php");
class AuthorController extends Zend_Controller_Action
{
@ -2564,12 +2566,13 @@ class AuthorController extends Zend_Controller_Action
}
//新建元数据
//文献管理
function literatureAction()
{
$ac = $this->_request->getParam('ac');
//文献管理
function literatureAction()
{
$this->view->ac= $ac = $this->_request->getParam('ac');
$this->view->uuid = $uuid = $this->_request->getParam('uuid');
$id = $this->_request->getParam('id');
$id = (int)$this->_request->getParam('id');
$keyword = $this->view->q = trim($this->_getParam('q'));
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
@ -2578,71 +2581,70 @@ class AuthorController extends Zend_Controller_Action
$u_id = $user->id;
}
include_once("helper/view.php");
//安全考虑
if (!empty($uuid) && !view::isUuid($uuid)) die();
//include_once("helper/view.php");
include_once("data/Author.php");
$author = new Author($this->db);
$author->Literature = new Literature($this->db);
//查看单条数据的所有文献
if (!empty($uuid) && empty($ac))
{
$rows = $author->Literature->byuuid($uuid);
@$this->view->mdtitle=$rows[0]['title'];
view::addPaginator($rows,$this->view,$this->_request);
$this->_helper->viewRenderer('literature-viewdata');
}
//编辑单条文献
if($ac == "edit")
{
$reference = new Reference();
if(!empty($keyword))
{
$reference->keyword = $keyword;
}
$this->view->reference = $reference;
$this->view->page = $this->_getParam('page');
$this->view->pagelimit = 10;
//文献首页:逐数据浏览
if(empty($ac) && empty($uuid))
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->getReferencesByAuthor($u_id),$this, $this->view->pagelimit);
return true;
}
//逐文献浏览
else if ($ac=="byliter")
{
$this->_helper->viewRenderer('literature-byliter');
view::addPaginator($reference->getReferencesByAuthor($u_id,1,0),$this, $this->view->pagelimit);
return true;
}
//浏览数据的文献
else if (!empty($uuid) && empty($ac))
{
$this->view->referenceType = $reference->referenceType();
if (empty($keyword))
{
$this->_helper->viewRenderer('literature-viewdata');
view::addPaginator($reference->getReferencesByAuthorUUID($u_id,$uuid,0),$this, $this->view->pagelimit);
} else {
$this->_helper->viewRenderer('literature-refsearch');
$sql="select title from metadata where uuid='$uuid'";
$rs=$this->db->fetchRow($sql);
$this->view->mdtitle=$rs['title'];
view::addPaginator($reference->fetchReferencesWithUUID($uuid),$this, $this->view->pagelimit);
}
return true;
}
//浏览作者的所有施引文献
else if ($ac=="cited")
{
$this->view->referenceType = $reference->referenceType();
$this->_helper->viewRenderer('literature-cited');
view::addPaginator($reference->getReferencesByAuthor($u_id,1,1),$this, $this->view->pagelimit);
return true;
}
//修改排序
else if($ac == "order")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
$refid = $this->_getParam('refid');
$content = $this->_getParam('content');
$link = $this->_getParam('link');
$reftype = $this->_getParam('reftype');
$uuid = $this->_getParam('uuid');
if(empty($id) || empty($uuid))
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
if(empty($content))
{
$this->jsonexit(array('error'=>'请输入内容'));
return true;
}
if(empty($reftype))
{
$this->jsonexit(array('error'=>'请选择文献类型'));
return true;
}
$s = $author->Literature->edit($id,$refid,$uuid,$content,$link,$reftype);
if($s !== true)
{
$this->jsonexit(array('error'=>'出现错误'));
return true;
}else{
$this->jsonexit(array('success'=>'修改成功!'));
return true;
}
}
//修改排序
if($ac == "order")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
$order = (int)$this->_getParam('order');
if(empty($id))
@ -2657,7 +2659,7 @@ class AuthorController extends Zend_Controller_Action
return true;
}
$s = $author->Literature->order($id,$order);
$s = $reference->changeOrderByAuthor($u_id,$id,$order);
if($s !== true)
{
$this->jsonexit(array('error'=>'出现错误'));
@ -2666,295 +2668,178 @@ class AuthorController extends Zend_Controller_Action
$this->jsonexit(array('success'=>'修改成功!'));
return true;
}
}
}
//查看单条文献的所有数据
if (!empty($id) && empty($ac))
{
$sql = "SELECT md.title,md.uuid,r.id,r.reference,r.link,(a.userid-?) as isauthor FROM mdref mr
LEFT JOIN metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id
WHERE md.title IS NOT NULL AND mr.refid=? AND a.status=1
order by md.ts_created desc
";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id,$id));
$rows = $sth->fetchAll();
@$this->view->mdtitle=$rows[0]['reference'];
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('literature-viewliter');
}
//查看所有文献列表
else if((empty($ac) && empty($uuid)) && empty($id))
{
$keywords = $this->_request->getParam('q');
$sql = "SELECT md.title,md.uuid,r.reference,r.id,mr.id as mrid FROM mdref mr
LEFT JOIN metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference r on mr.refid=r.id
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
if(!empty($keywords))
$this->view->q = $keywords;
if(!empty($keywords))
{
$search=new SimpleSearch($keywords);
$where=$search->sql_expr(array("r.reference","md.title","md.description"));
$sql.=' and '.$where;
}
$sql.=" order by md.ts_created desc";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(15);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
//按文献浏览
else if($ac=="byliter")
{
$keywords = $this->_request->getParam('q');
if(!empty($keywords))
$this->view->q = $keywords;
$sql = "SELECT count(md.uuid) as c,r.reference,r.id FROM reference r
left join mdref mr on r.id=mr.refid
LEFT JOIN metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
WHERE md.title IS NOT NULL AND a.userid=? AND a.status=1";
if(!empty($keywords))
{
$search=new SimpleSearch($keywords);
$where=$search->sql_expr(array("r.reference"));
$sql.=' and '.$where;
}
$sql.=" group by r.reference,r.id";
$sth = $this->db->prepare($sql);
$sth->execute(array($u_id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->_helper->viewRenderer('literature-byliter');
}
//单条文献的信息
else if ($ac == "get")
{
//移除文献对应关系
else if($ac == "remove")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$id = $this->_getParam('id');
$data = $author->Literature->getOne($id);
$this->jsonexit($data);
return true;
}
//按数据浏览
else if($ac=="bydata")
{
$keywords = $this->_request->getParam('q');
if(!empty($keywords))
if(empty($uuid) || !is_numeric($id))
{
$lit = $author->Literature->bydata($keywords);
$this->view->q = $keywords;
}else{
$lit = $author->Literature->bydata();
$this->jsonexit(array("error"=>"参数错误"));
return true;
}
$ex=$reference->removeReferenceByAuthor($u_id,$id);
if($ex)
{
$this->jsonexit(array("remove"=>$id.$uuidå));
return true;
}else{
$this->jsonexit(array("error"=>$this->alertbox('error','移除失败,请确认权限后重试')));
return true;
}
}
view::addPaginator($lit,$this->view,$this->_request);
$this->_helper->viewRenderer('literature-bydata');
}
//添加文献信息
else if($ac == "add")
{
//添加数据文献对应关系
else if($ac == "insert")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$order = (int)$this->_getParam('order');
if(empty($id))
{
$this->jsonexit(array('error'=>'参数错误'));
return true;
}
if(empty($order))
{
$this->jsonexit(array('error'=>'请输入排序数字除0以外'));
return true;
}
$s = $reference->insertMdrefByAuthor($u_id,$id,$uuid,$order);
if($s !== true)
{
$this->jsonexit(array('error'=>'出现错误'));
return true;
}else{
$this->jsonexit(array('success'=>'修改成功!'));
return true;
}
}
//添加文献信息
else if($ac == "add")
{
$submit = $this->_request->getParam('submit');
if(!empty($submit))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = "";
try{
$uuid = $this->_request->getParam('uuid');
$ref=$this->_request->getParam('ref');
$reftype=$this->_request->getParam('reftype');
$url = $this->_request->getParam('url');
$ref=$this->_request->getParam('ref');
$reftype=(int)$this->_request->getParam('reftype');
$url = $this->_request->getParam('url');
$attid = (int)$this->_request->getParam('attid');
$order=(int)$this->_request->getParam('order_input');
if(empty($uuid) || empty($ref) || !is_numeric($reftype))
{
$data = array("error"=>"参数错误");
$this->jsonexit($data);
return true;
}
$author = new Author($this->db);
if(!$author->checkAuthor($uuid))
{
$data = array("error"=>$this->alertbox('warning','您不是该数据作者,无法添加对应文献信息。'));
$this->jsonexit($data);
return true;
}
$sql="select id from reference where reference=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($ref));
$row = $sth->fetch();
if(empty($row['id']))
{
$sql="insert into reference (reference,link) values(?,?)";
$sth = $this->db->prepare($sql);
$sth->execute(array(trim($ref),$url));
if(empty($uuid) || empty($ref) || !is_numeric($reftype))
{
$data = array("error"=>"参数错误");
$this->jsonexit($data);
return true;
}
$sql="select * from mdauthor where status=1 and userid=$u_id and uuid='$uuid'";
$rs=$this->db->fetchRow($sql);
if (!$rs)
{
$data = array("error"=>$this->alertbox('warning','您不是该数据作者,无法添加对应文献信息。'));
$this->jsonexit($data);
return true;
}
$sql="select id from reference where reference=?";
$sth = $this->db->prepare($sql);
$sth->execute(array(trim($ref)));
$row = $sth->fetch();
}
$sql="insert into mdref (uuid,refid,reftype) values(?,?,?)";
$sth = $this->db->prepare($sql);
$ex=$sth->execute(array($uuid,$row['id'],$reftype));
if($ex)
{
$data = array("commited"=>1,"error"=>$this->alertbox('ok','成功添加文献!'));
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>$this->alertbox('error','提交失败,请确认权限后重试'));
$this->jsonexit($data);
return true;
}
}catch(Exception $e) {
$msg = "提交失败,您提交的数据可能已经存在";
if($this->debug>0)
{$msg .= $e->getMessage();}
$data = array("error"=>$this->alertbox('error',$msg));
$this->jsonexit($data);
return true;
}
}else{
$this->_helper->layout->disableLayout();
if(empty($row['id']))
{
$sql="insert into reference (reference,attid) values(?,?)";
$sth = $this->db->prepare($sql);
$sth->execute(array(trim($ref),$attid));
$sql="select id from reference where reference=?";
$sth = $this->db->prepare($sql);
$sth->execute(array(trim($ref)));
$row = $sth->fetch();
}
$sql="insert into mdref (uuid,refid,reftype,place) values(?,?,?,?)";
$sth = $this->db->prepare($sql);
$ex=$sth->execute(array($uuid,$row['id'],0,$order));
if($ex)
{
$data = array("commited"=>1,"error"=>$this->alertbox('ok','成功添加文献!'));
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>$this->alertbox('error','提交失败,请确认权限后重试'));
$this->jsonexit($data);
return true;
}
}catch(Exception $e) {
$msg = "提交失败,您提交的数据可能已经存在";
if($this->debug>0)
{$msg .= $e->getMessage();}
$data = array("error"=>$this->alertbox('error',$msg));
$this->jsonexit($data);
return true;
}
}else{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer('literature-add');
$this->view->uuid = $this->_request->getParam('uuid');
}
}//添加文献
}
}//添加文献
//删除某个文献
else if($ac=="delete")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$data = "";
$id = $this->_request->getParam('id');
$uuid = $this->_request->getParam('uuid');
if(empty($uuid) || !is_numeric($id))
{
$data = array("error"=>"参数错误");
$this->jsonexit($data);
return true;
}
try{
$sql = "DELETE FROM mdref r
USING mdauthor a
WHERE r.uuid=a.uuid and r.refid=? and r.uuid=? AND a.userid=? AND a.status=1";
$sth = $this->db->prepare($sql);
$ex = $sth -> execute(array($id,$uuid,$u_id));
if($ex)
{
$data = array("deleted"=>$id.$uuid,"error"=>$this->alertbox('ok','删除成功'));
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>$this->alertbox('error','删除失败,请确认权限后重试'));
$this->jsonexit($data);
return true;
}
}catch(Exception $e) {
$msg = "删除失败,请确认权限后重试";
if($this->debug>0)
{$msg .= $e->getMessage();}
$data = array("error"=>$this->alertbox('error',$msg));
$this->jsonexit($data);
return true;
}
}
//文献附件上传
else if($ac=='upload')
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//文献附件上传
else if($ac=='upload')
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_getParam('uuid');
try{
try{
$files=new files();
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'literature');
$files=new files();
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'literature');
if(empty($msg['error']))
{
$msg['error']="";
$filename = $msg['db_path'];
$filesize = $msg['file_size'];
$filedesc = $this->_request->getParam('filedesc');
$filetype = $msg['file_type'];
$realname = $msg['realname'];
if(empty($msg['error']))
{
$msg['error']="";
$filename = $msg['db_path'];
$filesize = $msg['file_size'];
$filedesc = $this->_request->getParam('filedesc');
$filetype = $msg['file_type'];
$realname = $msg['realname'];
$sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','$filetype','$filedesc','$u_id','$filesize','$realname') RETURNING id";
$sth = $this->db->prepare($sql);
$sth->execute();
$att = $sth->fetch(PDO::FETCH_ASSOC);
$msg['attid'] = $attid = $att['id'];
$sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','$filetype','$filedesc','$u_id','$filesize','$realname') RETURNING id";
$sth = $this->db->prepare($sql);
$sth->execute();
$att = $sth->fetch(PDO::FETCH_ASSOC);
$msg['attid'] = $attid = $att['id'];
$msg['html'] = $realname.'['. round($filesize/1024,2) .' kb]<input type="hidden" name="url" value="/service/attach/id/'.$attid.'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$attid.'" title="删除该文件"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
echo Zend_Json::encode($msg);
exit();
}else{
$msg['error'] = '附件上传失败:'.$msg['error'];
@unlink($filename);
echo Zend_Json::encode($msg);
exit();
}
}catch(Exception $e){
$msg['error'] = "错误:".$e->getMessage();
$msg['html'] = $realname.'['. round($filesize/1024,2) .' kb]<input type="hidden" name="attid" value="'.$attid.'" /><input type="hidden" name="url" value="/service/attach/id/'.$attid.'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$attid.'" title="删除该文件"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
echo Zend_Json::encode($msg);
exit();
}else{
$msg['error'] = '附件上传失败:'.$msg['error'];
@unlink($filename);
echo Zend_Json::encode($msg);
exit();
}
}//文件上传
}catch(Exception $e){
$msg['error'] = "错误:".$e->getMessage();
echo Zend_Json::encode($msg);
exit();
}
}//文件上传
}//文献管理
}//文献管理
//文档管理
function documentAction(){

View File

@ -116,22 +116,22 @@ class HiwaterController extends DataController
}
function lidarAction()
{
$this->getmdlimited('激光雷达','航空遥感');
$this->getmdlimited('激光雷达','航空遥感',array('CCD'));
$this->_helper->viewRenderer('base');
}
function ccdlidarAction()
{
$this->getmdlimited('CCD','航空遥感',"激光雷达");
$this->getmdrestricted(array('CCD','航空遥感',"激光雷达"));
$this->_helper->viewRenderer('base');
}
function widasAction()
{
$this->getmdlimited('WIDAS','航空遥感');
$this->getmdlimited('WIDAS','航空遥感',array('CCD'));
$this->_helper->viewRenderer('base');
}
function ccdwidasAction()
{
$this->getmdlimited('CCD','航空遥感','WIDAS');
$this->getmdrestricted(array('CCD','航空遥感','WIDAS'));
$this->_helper->viewRenderer('base');
}
function nearvisAction()
@ -147,38 +147,38 @@ class HiwaterController extends DataController
function airborneAction()
{
$this->getmd(array('航空遥感产品','种植结构图','植被类型图','植被结构参数','数字高程模型','数字表面模型','地表温度','地表土壤水文'));
$this->getmdlimited(array('DEM','DSM','DOM','地表反照率','地表反射率','植被类型','植被结构参数','土壤水分','地表温度'),'航空遥感产品');
$this->_helper->viewRenderer('base');
}
function demdsmAction()
{
$this->getmdlimited(array('DEM','DSM','DOM'),"数据产品");
$this->getmdlimited(array('DEM','DSM','DOM'),"航空遥感产品");
$this->_helper->viewRenderer('base');
}
function reflectanceAction()
{
$this->getmdlimited(array('地表反照率','地表反射率'),"数据产品");
$this->getmdlimited(array('地表反照率','地表反射率'),"航空遥感产品");
$this->_helper->viewRenderer('base');
}
function vegtypeairAction()
{
$this->getmdlimited(array('植被类型',''),'数据产品');
$this->getmdlimited(array('植被类型'),'航空遥感产品');
$this->_helper->viewRenderer('base');
}
function vegparamAction()
{
$this->getmdlimited(array("",'植被结构参数'),"数据产品");
$this->getmdlimited(array("",'植被结构参数'),"航空遥感产品");
$this->_helper->viewRenderer('base');
}
function soilmoistureAction()
{
$this->getmdlimited(array('','土壤水分'),"数据产品");
$this->getmdlimited(array('','土壤水分'),"航空遥感产品");
$this->_helper->viewRenderer('base');
}
function temperatureAction()
{
$this->getmdlimited(array('','地表温度'),"数据产品");
$this->getmdlimited(array('','地表温度'),"航空遥感产品");
$this->_helper->viewRenderer('base');
}
@ -336,7 +336,7 @@ class HiwaterController extends DataController
function rsproductAction()
{
$this->getmdlimited(array('DEM','DOM','降水','土壤水分','积雪','植被类型','植被覆盖度','物候期','NPP'),'数据产品');
$this->getmdlimited(array('DEM','DOM','降水','土壤水分','积雪','植被类型','植被覆盖度','物候期','NPP'),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
@ -353,32 +353,32 @@ class HiwaterController extends DataController
}
function smAction()
{
$this->getmdlimited(array('土壤水分',"卫星遥感"),'数据产品');
$this->getmdlimited(array('土壤水分',""),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
function snowAction()
{
$this->getmdlimited(array('积雪',"卫星遥感"),'数据产品');
$this->getmdlimited(array('积雪',""),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
function vegtypeAction()
{
$this->getmdlimited(array('植被类型','卫星遥感'),'数据产品');
$this->getmdlimited(array('植被类型',''),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
function vegcovAction()
{
$this->getmdlimited(array('植被覆盖度','卫星遥感'),'数据产品');
$this->getmdlimited(array('植被覆盖度',''),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
function phenologyAction()
{
$this->getmdlimited(array('物候期','卫星遥感'),'数据产品');
$this->getmdlimited(array('物候期',''),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
function nppAction()
{
$this->getmdlimited(array('NPP','卫星遥感'),'数据产品');
$this->getmdlimited(array('NPP',''),'卫星遥感产品');
$this->_helper->viewRenderer('base');
}
@ -528,7 +528,8 @@ class HiwaterController extends DataController
//获取多项条件并列关系的数据并必须满足limited条件
//$keyword:字符串或字符串数组
//$limited:限制字符串
private function getmdlimited($keyword,$limited)
//$without:明确不包含的字符串数组
private function getmdlimited($keyword,$limited,$without='')
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
@ -546,11 +547,68 @@ class HiwaterController extends DataController
$key.=")";
$keyword=$key;
$state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='hiwater' and m.id in (select id from keyword where keyword='".$limited."') and m.id in (select id from keyword where keyword in ".$keyword.")");
if (!empty($without))
{
if (!is_array($without))
{
$without=array($without);
}
$withoutkey="(";
foreach ($without as $wo)
{
$withoutkey.="'".$wo."',";
}
$withoutkey=substr($withoutkey,0,-1);
$withoutkey.=")";
}
$sql="select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id
where s.code='hiwater' and m.id in (select id from keyword where keyword='".$limited."')
and m.id in (select id from keyword where keyword in ".$keyword.")";
if (!empty($without)) $sql.=" and m.id not in (select id from keyword where keyword in $withoutkey)";
$state=$this->db->query($sql);
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and id in (select id from keyword where keyword='".$limited."') and id in (select id from keyword where keyword in ".$keyword.") order by title limit ? offset ?";
$sql="select uuid,title from normalmetadata where
uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater')
and id in (select id from keyword where keyword='".$limited."')
and id in (select id from keyword where keyword in ".$keyword.")";
if (!empty($without)) $sql.=" and id not in (select id from keyword where keyword in $withoutkey)";
$sql.=" order by title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
}
//获取多项必须满足的条件
//$keyword:字符串或字符串数组
private function getmdrestricted($keyword)
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
if (!is_array($keyword))
{
$keyword=array($keyword);
}
$key="(";
foreach($keyword as $k)
{
$key.="m.id in (select id from keyword where keyword='".$k."') and ";
}
$key=substr($key,0,-4);
$key.=")";
$keyword=$key;
$state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='hiwater' and $keyword");
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from normalmetadata m where m.uuid in
(select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater')
and $keyword
order by title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;

View File

@ -23,12 +23,9 @@
<form id="literature-add">
<p>
<label>文献引用信息:</label><br />
<textarea class="full" style="height:40px;" id="ref" name="ref"></textarea><br />
<textarea class="full" rows="3" id="ref" name="ref" placeholder="标准文献引用格式"></textarea><br />
<input type="hidden" name="uuid" value="<?php echo $this->uuid;?>" />
<input type="radio" id="reftype" name="reftype" value="0" checked />数据作者的文献
<input type="radio" id="reftype" name="reftype" value="1" />数据用户的文献
<input type="radio" id="reftype" name="reftype" value="2" />数据的直接参考文献
<input type="radio" id="reftype" name="reftype" value="3" />作者要求的多篇引用文献<br />
请输入排序数字 <input type="text" name="order_input" id="order_input" value="1"/><br />
<label>数据上传:</label>
<div><input id="file_upload" name="Filedata" type="file" /></div>
<div id="datalist"></div>
@ -46,37 +43,35 @@
</div>
<script>
$(document).ready(function() {
$('#file_upload').uploadify({
$('#file_upload').uploadify({
'uploader' : '/static/js/uploadify/uploadify.swf',
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>','uuid':'<?php echo $this->uuid;?>','submit':'1'},
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>','uuid':'<?php echo $this->uuid;?>','submit':'1'},
'script' : '/author/literature/ac/upload',
'cancelImg' : '/static/js/uploadify/cancel.png',
'folder' : '/uploads',
'sizeLimit' : 52428800,
'queueSizeLimit' : 1,
'multi' : false,
'sizeLimit' : 52428800,
'queueSizeLimit' : 1,
'multi' : false,
'auto' : false,
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
if(obj.error=='')
{
html = obj.html;
}
else{html=uploadError(obj.error,obj.attid);}
$('<li/>', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
$('#deletebtn_'+obj.attid).bind('click', function() {
deleteatt(obj.attid);
});
},
'onError' : function (event,ID,fileObj,errorObj) {
'displayData' : 'speed',
'buttonImg' : '/static/js/uploadify/selectfile.gif',
'onComplete' : function(event, ID, fileObj, response, data) {
var obj = jQuery.parseJSON(response);
if(obj.error=='')
{
html = obj.html;
}
else{html=uploadError(obj.error,obj.attid);}
$('<li/>', {
"id":'uploadedItem_'+obj.attid,
"class":'uploadifyQueueItem',
"html": html
}).appendTo('#datalist');
$('#deletebtn_'+obj.attid).bind('click', function() {
deleteatt(obj.attid);
});
},
'onError' : function (event,ID,fileObj,errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
}
});
@ -131,5 +126,4 @@ function uploadError(msg,id){
}
</script>
</body>
</html>
</html>

View File

@ -3,6 +3,7 @@ $this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/author.css');
$this->theme->AppendPlus($this,'colorbox');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据文献管理');
@ -13,32 +14,33 @@ $this->breadcrumb()->setSeparator(' > ');
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<div>
<ul class="nav nav-pills">
<li class=""><a class="text-shadow" href="/author/literature/">所有文献概况</a></li>
<li class="active"><a class="text-shadow" href="/author/literature/ac/byliter">逐文献浏览</a></li>
<li class=""><a class="text-shadow" href="/author/literature/ac/bydata">逐数据浏览</a></li>
</ul>
</div>
<p>请输入元数据或文献标题关键字进行搜索</p>
<?= $this->partial('author/literature-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<p>请输入文献标题关键字进行搜索</p>
<div class="input-append">
<form id="datasearch" class="search_form" action="/author/literature/ac/bydata">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
<div>
<?php
if (count($this->paginator)):
echo '<ul class="unstyled">';
$autoindex=0;
<?php if (count($this->paginator)): ?>
<ul class='unstyled'>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
$autoindex++;
?>
<li class="well">
<h4><a href="/author/literature/id/<?php echo $item['id'];?>"><?php echo $item['reference'];?></a></h4>
<p>共有<?php echo $item['c'];?>条数据使用此文献。
<a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a></p>
<p><?= $autoindex ?>. <?php echo $item['reference'];?></p>
<p>共有<?php echo $item['c'];?>条数据推荐此文献。
<a href="/knowledge/paper/id/<?php echo $item['id'];?>">查看</a>
| <a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>文献对应数据</a>
</p>
</li>
<?php endforeach;
echo "</ul>";
@ -48,4 +50,17 @@ $this->breadcrumb()->setSeparator(' > ');
</div>
</div>
</div>
<script>
function showdata(id,page){
var url="/service/refdatalist/id/"+id;
$.ajax({
'type':"GET",
'url':url,
'data':'page='+page,
'dataType':'html',
'success':function(html){$.colorbox({'html':html,'innerHeight':230});}
});
}
$(".iframe").colorbox({iframe:true, width:"60%", height:"80%"});
</script>

View File

@ -0,0 +1,66 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/author.css');
$this->theme->AppendPlus($this,'colorbox');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据文献管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<div class="row">
<div class="span3">
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<?= $this->partial('author/literature-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<p>请输入文献标题关键字进行搜索</p>
<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; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
<div>
<?php if (count($this->paginator)): ?>
<ul class='unstyled'>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;
?>
<li class="well">
<p><?= $autoindex ?>. <?php echo $item['reference'];?></p>
<p>此文献共施引了我的<?php echo $item['c'];?>条数据。
<a href="/knowledge/paper/id/<?php echo $item['id'];?>">查看</a>
| <a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>文献对应数据</a>
</p>
</li>
<?php endforeach;
echo "</ul>";
endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
</div>
</div>
<script>
function showdata(id,page){
var url="/service/refdatalist/id/"+id;
$.ajax({
'type':"GET",
'url':url,
'data':'page='+page,
'dataType':'html',
'success':function(html){$.colorbox({'html':html,'innerHeight':230});}
});
}
$(".iframe").colorbox({iframe:true, width:"60%", height:"80%"});
</script>

View File

@ -0,0 +1,8 @@
<ul class="nav nav-tabs">
<?php if (!empty($this->uuid)) : ?>
<li class="active"><a href="/author/literature/uuid/<?= $this->uuid ?>">数据文献</a></li>
<?php endif; ?>
<li <?= empty($this->ac) && empty($this->uuid) ? 'class="active"':"" ?>><a href="/author/literature">逐数据浏览</a></li>
<li <?= $this->ac=="byliter" ? 'class="active"':"" ?>><a href="/author/literature/ac/byliter">逐文献浏览</a></li>
<li <?= $this->ac=="cited" ? 'class="active"':"" ?>><a href="/author/literature/ac/cited">施引文献</a></li>
</ul>

View File

@ -0,0 +1,113 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->theme->AppendPlus($this,'colorbox');
$this->theme->AppendModel($this,"author-literature");
$this->headLink()->appendStylesheet('/css/author.css');
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
$this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('数据文献管理');
$this->breadcrumb()->setSeparator(' > ');
?>
<div class="row">
<div class="span3">
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<?= $this->partial('author/literature-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<h4>数据标题:<a href="/data/<?= $this->uuid ?>"><?= $this->mdtitle ?></a></h4>
<p>请输入文献标题关键字进行搜索添加 或 <a href="/author/literature/ac/add/uuid/<?php echo $this->uuid;?>" class="more iframe btn">直接添加新文献</a></p>
<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; ?>" />
<button type="submit" class="btn" id="search_btn">搜索文献进行添加</button>
</form>
</div>
<div>
<?php if (count($this->paginator)): ?>
<ul class='unstyled'>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;
?>
<li class="well" id="list_<?php echo $item['id'].$item['uuid'];?>">
<p>
<?PHP if (!is_null($item['reftype'])) :?>
<strong><?= $this->referenceType[$item['reftype']] ?></strong>
<?php endif; ?>
<?= $autoindex ?>. <?php echo $item['reference'];?></p>
<p>
<a href="/knowledge/paper/id/<?php echo $item['id'];?>">查看</a>
| <a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>文献对应数据</a>
<?php if ($item['reftype']===0) :?>
| <a href="javascript:void(0);" class="order" rel="<?= $item['mrid'];?>" rev="<?= $item['place']?>">排序</a>
| <a onclick="return confirm('是否确定移除该文献?');" href="javascript:action('remove&id=<?php echo $item['mrid'];?>','<?= $this->uuid ?>');" class="more">移除</a>
<?php else :?>
| <a href="javascript:void(0);" class="insert" rev="1" rel="<?php echo $item['id'];?>" uuid="<?= $this->uuid ?>">添加为本数据的推荐文献</a>
<?php endif; ?>
</p>
</li>
<?php endforeach;
echo "</ul>";
endif; ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div>
</div>
</div>
<script>
function showdata(id,page){
var url="/service/refdatalist/id/"+id;
$.ajax({
'type':"GET",
'url':url,
'data':'page='+page,
'dataType':'html',
'success':function(html){$.colorbox({'html':html,'innerHeight':230});}
});
}
function action(ac,uuid){
$.ajax({
'type':"POST",
'url':'/author/literature/',
'data':'ac='+ ac +'&uuid='+uuid,
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{$.colorbox({'innerWidth':'50%','html':data.error});}
if(typeof(data.remove)!='undefined')
{window.location.reload();}
if(typeof(data.commited)!='undefined')
{window.location.reload();}
}
else{
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_warning.png" /><h4>出现错误,请稍候再试</h4>'});
}
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
}
});
}
$(".iframe").colorbox({iframe:true, width:"60%", height:"80%"});
$(".inline").colorbox({inline:true, width:"50%"});
function commit(id){
action('add&ref='+$('#ref').val()+'&reftype='+$('#reftype').val(),id);
}
</script>
<div class="colorbox" style="display:none;">
<div class="error"><img src="/images/alert_big_error.png" /><span></span></div>
<div class="ok"><img src="/images/alert_big_ok.png" /><span></span></div>
<div class="warning"><img src="/images/alert_big_warning.png" /><span></span></div>
</div>

View File

@ -18,30 +18,37 @@ $this->breadcrumb()->setSeparator(' > ');
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<div>
<ul class="nav nav-pills">
<li class=""><a href="/author/literature/">所有文献概况</a></li>
<li class=""><a href="/author/literature/ac/byliter">逐文献浏览</a></li>
<li class=""><a href="/author/literature/ac/bydata">逐数据浏览</a></li>
<li class="active"><a href="javascript:;">查看单个数据的文献</a></li>
</ul>
<?= $this->partial('author/literature-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<h4>数据标题:<a href="/data/<?= $this->uuid ?>"><?= $this->paginator->getItem(0)['mdtitle'] ?></a></h4>
<p>请输入文献标题关键字进行搜索添加 或 <a href="/author/literature/ac/add/uuid/<?php echo $this->uuid;?>" class="more iframe btn">直接添加新文献</a></p>
<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; ?>" />
<button type="submit" class="btn" id="search_btn">搜索文献进行添加</button>
</form>
</div>
<div>
<?php
if (count($this->paginator)):
if ($this->mdtitle) echo "<h4>元数据:".$this->mdtitle."</h4>";
echo '<ul class="unstyled">';
$autoindex=0;
<?php if (count($this->paginator)): ?>
<ul class='unstyled'>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
$autoindex++;
?>
<li class="well" id="list_<?php echo $item['id'].$item['uuid'];?>">
<p><?php echo $item['reference'];?></p>
<p><strong><?= $this->referenceType[$item['reftype']] ?></strong> <?= $autoindex ?>. <?php echo $item['reference'];?></p>
<p>
<a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a>
| <a href="javascript:void(0);" class="edit" rel="<?= $item['mrid'];?>" rev="<?= $item['uuid']?>">编辑</a>
<a href="/knowledge/paper/id/<?php echo $item['id'];?>">查看</a>
| <a href="javascript:;" onclick="showdata('<?php echo $item['id'];?>',0)"><i class="icon-external-link text-success"></i>文献对应数据</a>
<?php if ($item['reftype']==0) :?>
| <a href="javascript:void(0);" class="order" rel="<?= $item['mrid'];?>" rev="<?= $item['place']?>">排序</a>
| <a onclick="return confirm('是否确定删除该文献?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
| <a href="/author/literature/ac/add/uuid/<?php echo $item['uuid'];?>" class="more iframe">添加文献</a>
| <a onclick="return confirm('是否确定移除该文献?');" href="javascript:action('remove&id=<?php echo $item['mrid'];?>','<?php echo $item['uuid'];?>');" class="more">移除</a>
<?php endif; ?>
</p>
</li>
<?php endforeach;
@ -52,6 +59,16 @@ $this->breadcrumb()->setSeparator(' > ');
</div>
</div>
<script>
function showdata(id,page){
var url="/service/refdatalist/id/"+id;
$.ajax({
'type':"GET",
'url':url,
'data':'page='+page,
'dataType':'html',
'success':function(html){$.colorbox({'html':html,'innerHeight':230});}
});
}
function action(ac,uuid){
$.ajax({
'type':"POST",

View File

@ -17,40 +17,34 @@ $this->breadcrumb()->setSeparator(' > ');
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<div>
<ul class="nav nav-pills">
<li class="active"><a href="/author/literature/">所有文献概况</a></li>
<li><a href="/author/literature/ac/byliter">逐文献浏览</a></li>
<li><a href="/author/literature/ac/bydata">逐数据浏览</a></li>
</ul>
</div>
<p>请输入元数据或文献标题关键字进行搜索</p>
<?= $this->partial('author/literature-nav.phtml',array('ac'=>$this->ac,'uuid'=>$this->uuid)); ?>
<p>请输入元数据关键字进行搜索</p>
<div class="input-append">
<form id="datasearch" class="search_form" action="/author/literature/ac/bydata">
<form id="datasearch" class="search_form" action="">
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
<button type="submit" class="btn" id="search_btn">搜索</button>
</form>
</div>
<div>
<?php
if (count($this->paginator)):
echo "<ul class='unstyled'>";
$autoindex=0;
<?php if (count($this->paginator)): ?>
<ul class='unstyled'>
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<li class="well" id="list_<?php echo $item['id'].$item['uuid'];?>">
<h4><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></h4>
<a href="/author/literature/uuid/<?php echo $item['uuid'];?>">查看详细</a>
|
$autoindex++;
?>
<li class="well" id="list_<?php echo $item['uuid'];?>">
<h4><?= $autoindex ?>. <a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a></h4>
【 共推荐文献<?php echo $item['c'];?>篇 |
<?php if ($item['c']>0) :?><a href="/author/literature/uuid/<?php echo $item['uuid'];?>">查看相关文献</a>
| <?php endif; ?>
<a href="/author/literature/ac/add/uuid/<?php echo $item['uuid'];?>" class="more iframe">添加文献</a>
</p>
</p>
<p><?php echo $item['reference'];?>
<a href="/author/literature/id/<?php echo $item['id'];?>">查看详细</a>
|
<a onclick="return confirm('是否确定删除该文献?');" href="javascript:action('delete&id=<?php echo $item['id'];?>','<?php echo $item['uuid'];?>');" class="more">删除</a>
</p>
</li>
<?php endforeach;
echo "</ul>";

View File

@ -66,7 +66,7 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi;
echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']';
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
<?php endif; if ($this->ref) : ?>
<?php endif; endif; if ($this->ref) : ?>
<hr />
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
<ol>
@ -333,7 +333,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span><?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span><a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>
<hr />

View File

@ -333,7 +333,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>

View File

@ -334,7 +334,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span><?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span><a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>
<hr />

View File

@ -336,7 +336,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>

View File

@ -341,7 +341,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>

View File

@ -315,7 +315,7 @@ foreach($this->keys as $cg) :
endforeach;
?></ul>
<?php if ($md->doi) : ?>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <?php echo $md->doi; ?></li></ul>
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI</span> <a href="http://dx.doi.org/<?php echo $md->doi; ?>"><?php echo $md->doi; ?></a></li></ul>
<?php endif; ?>
<div>
<hr />

View File

@ -400,10 +400,10 @@ class ISO19115
{
$this->author[$k]['individual']=$author->getElementsByTagName('rpIndName')->item(0)->nodeValue;
$this->author[$k]['organisation']=$author->getElementsByTagName('rpOrgName')->item(0)->nodeValue;
$this->author[$k]['position']=$author->getElementsByTagName('rpPosName')->item(0)->nodeValue;
$this->author[$k]['delivery']=$author->getElementsByTagName('delPoint')->item(0)->nodeValue;
$this->author[$k]['phone']=$author->getElementsByTagName('voiceNum')->item(0)->nodeValue;
$this->author[$k]['email']=$author->getElementsByTagName('eMailAdd')->item(0)->nodeValue;
@$this->author[$k]['position']=$author->getElementsByTagName('rpPosName')->item(0)->nodeValue;
@$this->author[$k]['delivery']=$author->getElementsByTagName('delPoint')->item(0)->nodeValue;
@$this->author[$k]['phone']=$author->getElementsByTagName('voiceNum')->item(0)->nodeValue;
@$this->author[$k]['email']=$author->getElementsByTagName('eMailAdd')->item(0)->nodeValue;
$this->author[$k]['postal']=$author->getElementsByTagName('postCode')->item(0)->nodeValue;
$this->author[$k]['city']=$author->getElementsByTagName('city')->item(0)->nodeValue;
$this->author[$k]['administrative']=$author->getElementsByTagName('adminArea')->item(0)->nodeValue;
@ -416,7 +416,7 @@ class ISO19115
{
$this->author[$cnt+$j]['individual']=$author->getElementsByTagName('rpIndName')->item(0)->nodeValue;
$this->author[$cnt+$j]['organisation']=$author->getElementsByTagName('rpOrgName')->item(0)->nodeValue;
$this->author[$cnt+$j]['position']=$author->getElementsByTagName('rpPosName')->item(0)->nodeValue;
@$this->author[$cnt+$j]['position']=$author->getElementsByTagName('rpPosName')->item(0)->nodeValue;
$this->author[$cnt+$j]['delivery']=$author->getElementsByTagName('delPoint')->item(0)->nodeValue;
$this->author[$cnt+$j]['phone']=$author->getElementsByTagName('voiceNum')->item(0)->nodeValue;
$this->author[$cnt+$j]['email']=$author->getElementsByTagName('eMailAdd')->item(0)->nodeValue;

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

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

View File

@ -221,14 +221,14 @@ class Reference
public function fetchThemeReferences($code)
{
$wheresql = array();
$wheresql[] = " s.code='$code' ";
//$wheresql[] = " s.code='$code' ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
$wheresql[] = " (ref.title iLIKE '%{$this->keyword}%' OR ref.reference iLIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
$wheresql = " and ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
@ -240,9 +240,10 @@ class Reference
$order = "ref.{$this->order} {$this->sort}";
}
$sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
$sql="select distinct ref.* from {$this->table->reference} ref where ref.id in (select r.refid from mdref r
left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid
$wheresql
where s.code='$code')
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
@ -308,6 +309,98 @@ class Reference
return $rs->fetchAll();
}
//Get data author references which need to deal with
public function fetchAuthorReferences()
{
$wheresql = array();
$wheresql[] = " ref.ris is NULL ";
$wheresql[]=" ref.id in (select distinct refid from mdref where reftype=0) ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "ref.year,ref.title";
}else{
$order = "ref.{$this->order} {$this->sort}";
}
$sql="select distinct ref.* from {$this->table->reference} ref
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//Get references by data UUID
public function fetchReferencesByUUID($uuid)
{
$wheresql = array();
$wheresql[]=" r.uuid='$uuid' ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "ref.year,ref.title";
}else{
$order = "ref.{$this->order} {$this->sort}";
}
$sql="select distinct ref.*,r.reftype,r.place,r.id as mrid from {$this->table->reference} ref left join {$this->table->metadata_reference} r on ref.id=r.refid
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//Get references with data UUID
public function fetchReferencesWithUUID($uuid)
{
$wheresql = array();
//$wheresql[]=" r.uuid='$uuid' ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(empty($this->order))
{
$order = "ref.year,ref.title";
}else{
$order = "ref.{$this->order} {$this->sort}";
}
$sql="select distinct ref.*,r.reftype,r.place,r.id as mrid from {$this->table->reference} ref left join
(select * from {$this->table->metadata_reference} r where uuid='$uuid') r on ref.id=r.refid
$wheresql
ORDER BY $order";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//单条文献的信息
public function getOneReferenceData($id)
{
@ -597,4 +690,123 @@ class Reference
return;
}
//Get data author references
//$ordertype 0: by data, 1: by literature
public function getReferencesByAuthor($uid,$ordertype=0,$reftype=0)
{
$wheresql = array();
$wheresql[] = " a.userid=$uid ";
$wheresql[] = " a.status=1 ";
if(!empty($this->keyword))
{
if($ordertype==0)
{
$wheresql[] = " (md.title LIKE '%{$this->keyword}%' OR md.description LIKE '%{$this->keyword}%') ";
}else{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if($ordertype==0)
{
$order = "md.title";
$sql="SELECT md.title,md.uuid,count(mr.id) as c FROM metadata md
LEFT JOIN (select * from mdref where reftype=$reftype) mr ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference ref on mr.refid=ref.id
$wheresql
group by md.title,md.uuid
ORDER BY c desc,$order";
}else{
$order = "ref.title";
$sql="SELECT ref.*,count(mr.uuid) as c FROM metadata md
LEFT JOIN mdref mr ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference ref on mr.refid=ref.id
$wheresql and mr.reftype=$reftype
group by ref.id
ORDER BY c desc,$order";
}
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//Get author references by data uuid
public function getReferencesByAuthorUUID($uid,$uuid)
{
$wheresql = array();
$wheresql[] = " a.userid=$uid ";
$wheresql[] = " a.status=1 ";
$wheresql[] = " mr.uuid='$uuid' ";
if(!empty($this->keyword))
{
$wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
$order = "ref.title";
$sql="SELECT md.title as mdtitle,md.uuid,ref.id,ref.reference,ref.link,mr.place,mr.id as mrid,mr.reftype FROM mdref mr
LEFT JOIN metadata md ON md.uuid=mr.uuid
LEFT JOIN mdauthor a ON md.uuid=a.uuid
left join reference ref on mr.refid=ref.id
$wheresql
order by mr.reftype,mr.place ASC,ref.id DESC,md.ts_created desc";
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
//数据作者修改推荐文献的排序
public function changeOrderByAuthor($uid,$id,$order)
{
$sql="update mdref set place=$order where id=$id and uuid in
(select uuid from mdauthor where status=1 and userid=$uid)";
if($this->db->exec($sql))
{
return true;
}else{
return false;
}
}
//数据作者移除推荐文献
public function removeReferenceByAuthor($uid,$id)
{
$sql = "DELETE FROM mdref WHERE id=$id and uuid in (select uuid from mdauthor where userid=$uid AND status=1)";
if($this->db->exec($sql))
{
return true;
}else{
return false;
}
}
//数据作者添加推荐文献
public function insertMdrefByAuthor($uid,$refid,$uuid,$place,$reftype=0)
{
$sql="select * from mdauthor where status=1 and uuid='$uuid' and userid=$uid";
$rs=$this->db->fetchRow($sql);
if ($rs)
{
$id = $this->createRelationFromReferenceToData($refid,$uuid,$reftype,$place);
if(is_numeric($id))
{
return true;
}else{
return $id;
}
} else {
return false;
}
}
}

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');
}
}

View File

@ -5,6 +5,9 @@ $(document).ready(function(e) {
$('.order').click(function(e) {
$(this).litorder({'id':$(this).attr('rel')});
});
$('.insert').click(function(e) {
$(this).litinsert({'id':$(this).attr('rel'),'uuid':$(this).attr('uuid')});
});
});
// JavaScript Document
(function( $ ){
@ -189,5 +192,86 @@ $(document).ready(function(e) {
methods.edit(settings.id);
});
};
})( jQuery );
(function( $ ){
$.fn.litinsert = function( options ) {
var settings = $.extend( {
id:'',
order : '',
uuid:'',
}, options);
var methods = {
edit : function(id,uuid)
{
methods.creatWindow(id,uuid);
},
creatWindow : function(id,uuid){
$.colorbox({
initialHeight: '0',
initialWidth: '0',
html: methods.dialog,
opacity: '0.3',
onComplete: function(){
$('.confirm_yes').click(function(e){
e.preventDefault();
methods.submited(id,uuid);
$.colorbox.close();
});
$('.confirm_no').click(function(e){
e.preventDefault();
$.colorbox.close();
});
}
});
},
submited : function(id,uuid){
$.ajax({
'type':"POST",
'url':'/author/literature/',
'data':'ac=insert&id='+id+'&uuid='+uuid+'&order='+$('#order_input').val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{alert(data.error);}
if(typeof(data.success)!='undefined')
{
window.location.reload();
}
}
else{
alert('出现错误,请稍候再试');
}
},
'timeout': 30000,
'error': function(){
alert('出现错误,请刷新后重试');
}
});
},
dialog : function(content){
HTML = '<div class=""><div class="modal-header"><h3>添加文献并修改排序</h3></div>'
+ '<div class="modal-body">数字越小排序越靠前<br />'
+ '请输入排序数字<input type="text" id="order_input" value="'+settings.order+'"/></div>'
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
return HTML;
}
}
this.each(function() {
if( settings.id == '')
{
alert('参数错误');
}
settings.order = $(this).attr('rev');
settings.uuid = $(this).attr('uuid');
methods.edit(settings.id,settings.uuid);
});
};
})( jQuery );

View File

@ -2,7 +2,7 @@ function extractPageName(hrefString)
{
var arr = hrefString.split('/');
var result=(arr.length<3) ? hrefString : arr[3].toLowerCase();
if (result=='water' || result=='heihe' || result=='glacier' || result=='yrnmr' || result=='hiwater') result='data';
if (result=='search' || result=='water' || result=='heihe' || result=='glacier' || result=='yrnmr' || result=='hiwater') result='data';
if (result=='admin' && arr.length>=4) result+="/"+arr[4];
return result;
}

2
htdocs/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent:*
Disallow:

View File

@ -1,8 +1,8 @@
<?php
//
// FPDI - Version 1.4.2
// FPDI - Version 1.5.1
//
// Copyright 2004-2011 Setasign - Jan Slabon
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,85 +17,98 @@
// limitations under the License.
//
if (!defined('ORD_z'))
define('ORD_z',ord('z'));
if (!defined('ORD_exclmark'))
define('ORD_exclmark', ord('!'));
if (!defined('ORD_u'))
define('ORD_u', ord('u'));
if (!defined('ORD_tilde'))
define('ORD_tilde', ord('~'));
/**
* Class FilterASCII85
*/
class FilterASCII85
{
/**
* Decode ASCII85 encoded string
*
* @param string $in
* @return string
* @throws Exception
*/
public function decode($in)
{
$ord = array(
'~' => ord('~'),
'z' => ord('z'),
'u' => ord('u'),
'z' => ord('z'),
'!' => ord('!')
);
if (!class_exists('FilterASCII85', false)) {
$out = '';
$state = 0;
$chn = null;
class FilterASCII85 {
function error($msg) {
die($msg);
}
function decode($in) {
$out = '';
$state = 0;
$chn = null;
$l = strlen($in);
for ($k = 0; $k < $l; ++$k) {
$ch = ord($in[$k]) & 0xff;
if ($ch == ORD_tilde) {
break;
}
if (preg_match('/^\s$/',chr($ch))) {
continue;
}
if ($ch == ORD_z && $state == 0) {
$out .= chr(0) . chr(0) . chr(0) . chr(0);
continue;
}
if ($ch < ORD_exclmark || $ch > ORD_u) {
return $this->error('Illegal character in ASCII85Decode.');
}
$chn[$state++] = $ch - ORD_exclmark;
if ($state == 5) {
$state = 0;
$r = 0;
for ($j = 0; $j < 5; ++$j)
$r = $r * 85 + $chn[$j];
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
$out .= chr($r);
}
$l = strlen($in);
for ($k = 0; $k < $l; ++$k) {
$ch = ord($in[$k]) & 0xff;
if ($ch == $ord['~']) {
break;
}
$r = 0;
if ($state == 1)
return $this->error('Illegal length in ASCII85Decode.');
if ($state == 2) {
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
$out .= chr($r >> 24);
if (preg_match('/^\s$/',chr($ch))) {
continue;
}
else if ($state == 3) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
if ($ch == $ord['z'] && $state == 0) {
$out .= chr(0) . chr(0) . chr(0) . chr(0);
continue;
}
else if ($state == 4) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ;
if ($ch < $ord['!'] || $ch > $ord['u']) {
throw new Exception('Illegal character in ASCII85Decode.');
}
$chn[$state++] = $ch - $ord['!'];
if ($state == 5) {
$state = 0;
$r = 0;
for ($j = 0; $j < 5; ++$j)
$r = $r * 85 + $chn[$j];
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
$out .= chr($r);
}
return $out;
}
function encode($in) {
return $this->error("ASCII85 encoding not implemented.");
$r = 0;
if ($state == 1) {
throw new Exception('Illegal length in ASCII85Decode.');
}
if ($state == 2) {
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
$out .= chr($r >> 24);
} else if ($state == 3) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
} else if ($state == 4) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
}
return $out;
}
}
/**
* NOT IMPLEMENTED
*
* @param string $in
* @return string
* @throws LogicException
*/
public function encode($in)
{
throw new LogicException("ASCII85 encoding not implemented.");
}
}

View File

@ -0,0 +1,52 @@
<?php
//
// FPDI - Version 1.5.1
//
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
* Class FilterASCIIHexDecode
*/
class FilterASCIIHexDecode
{
/**
* Converts an ASCII hexadecimal encoded string into it's binary representation.
*
* @param string $data The input string
* @return string
*/
public function decode($data)
{
$data = preg_replace('/[^0-9A-Fa-f]/', '', rtrim($data, '>'));
if ((strlen($data) % 2) == 1) {
$data .= '0';
}
return pack('H*', $data);
}
/**
* Converts a string into ASCII hexadecimal representation.
*
* @param string $data The input string
* @param boolean $leaveEOD
* @return string
*/
public function encode($data, $leaveEOD = false)
{
return current(unpack('H*', $data)) . ($leaveEOD ? '' : '>');
}
}

View File

@ -1,8 +1,8 @@
<?php
//
// FPDI - Version 1.4.2
// FPDI - Version 1.5.1
//
// Copyright 2004-2011 Setasign - Jan Slabon
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,141 +17,157 @@
// limitations under the License.
//
if (!class_exists('FilterLZW', false)) {
/**
* Class FilterLZW
*/
class FilterLZW
{
protected $_sTable = array();
protected $_data = null;
protected $_dataLength = 0;
protected $_tIdx;
protected $_bitsToGet = 9;
protected $_bytePointer;
protected $_bitPointer;
protected $_nextData = 0;
protected $_nextBits = 0;
protected $_andTable = array(511, 1023, 2047, 4095);
class FilterLZW {
var $sTable = array();
var $data = null;
var $dataLength = 0;
var $tIdx;
var $bitsToGet = 9;
var $bytePointer;
var $bitPointer;
var $nextData = 0;
var $nextBits = 0;
var $andTable = array(511, 1023, 2047, 4095);
function error($msg) {
die($msg);
/**
* Decodes LZW compressed data.
*
* @param string $data The compressed data.
* @throws Exception
* @return string
*/
public function decode($data)
{
if ($data[0] == 0x00 && $data[1] == 0x01) {
throw new Exception('LZW flavour not supported.');
}
/**
* Method to decode LZW compressed data.
*
* @param string data The compressed data.
*/
function decode($data) {
if($data[0] == 0x00 && $data[1] == 0x01) {
$this->error('LZW flavour not supported.');
}
$this->initsTable();
$this->data = $data;
$this->dataLength = strlen($data);
// Initialize pointers
$this->bytePointer = 0;
$this->bitPointer = 0;
$this->nextData = 0;
$this->nextBits = 0;
$oldCode = 0;
$string = '';
$uncompData = '';
while (($code = $this->getNextCode()) != 257) {
if ($code == 256) {
$this->initsTable();
$code = $this->getNextCode();
if ($code == 257) {
break;
}
$uncompData .= $this->sTable[$code];
$this->_initsTable();
$this->_data = $data;
$this->_dataLength = strlen($data);
// Initialize pointers
$this->_bytePointer = 0;
$this->_bitPointer = 0;
$this->_nextData = 0;
$this->_nextBits = 0;
$oldCode = 0;
$unCompData = '';
while (($code = $this->_getNextCode()) != 257) {
if ($code == 256) {
$this->_initsTable();
$code = $this->_getNextCode();
if ($code == 257) {
break;
}
if (!isset($this->_sTable[$code])) {
throw new Exception('Error while decompression LZW compressed data.');
}
$unCompData .= $this->_sTable[$code];
$oldCode = $code;
} else {
if ($code < $this->_tIdx) {
$string = $this->_sTable[$code];
$unCompData .= $string;
$this->_addStringToTable($this->_sTable[$oldCode], $string[0]);
$oldCode = $code;
} else {
if ($code < $this->tIdx) {
$string = $this->sTable[$code];
$uncompData .= $string;
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
$oldCode = $code;
} else {
$string = $this->sTable[$oldCode];
$string = $string . $string[0];
$uncompData .= $string;
$this->addStringToTable($string);
$oldCode = $code;
}
$string = $this->_sTable[$oldCode];
$string = $string . $string[0];
$unCompData .= $string;
$this->_addStringToTable($string);
$oldCode = $code;
}
}
return $uncompData;
}
/**
* Initialize the string table.
*/
function initsTable() {
$this->sTable = array();
for ($i = 0; $i < 256; $i++)
$this->sTable[$i] = chr($i);
$this->tIdx = 258;
$this->bitsToGet = 9;
}
/**
* Add a new string to the string table.
*/
function addStringToTable ($oldString, $newString='') {
$string = $oldString.$newString;
// Add this new String to the table
$this->sTable[$this->tIdx++] = $string;
if ($this->tIdx == 511) {
$this->bitsToGet = 10;
} else if ($this->tIdx == 1023) {
$this->bitsToGet = 11;
} else if ($this->tIdx == 2047) {
$this->bitsToGet = 12;
}
}
// Returns the next 9, 10, 11 or 12 bits
function getNextCode() {
if ($this->bytePointer == $this->dataLength) {
return 257;
}
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
if ($this->nextBits < $this->bitsToGet) {
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
}
$code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet-9];
$this->nextBits -= $this->bitsToGet;
return $code;
}
function encode($in) {
$this->error("LZW encoding not implemented.");
return $unCompData;
}
/**
* Initialize the string table.
*/
protected function _initsTable()
{
$this->_sTable = array();
for ($i = 0; $i < 256; $i++)
$this->_sTable[$i] = chr($i);
$this->_tIdx = 258;
$this->_bitsToGet = 9;
}
/**
* Add a new string to the string table.
*/
protected function _addStringToTable($oldString, $newString = '')
{
$string = $oldString . $newString;
// Add this new String to the table
$this->_sTable[$this->_tIdx++] = $string;
if ($this->_tIdx == 511) {
$this->_bitsToGet = 10;
} else if ($this->_tIdx == 1023) {
$this->_bitsToGet = 11;
} else if ($this->_tIdx == 2047) {
$this->_bitsToGet = 12;
}
}
}
/**
* Returns the next 9, 10, 11 or 12 bits
*
* @return int
*/
protected function _getNextCode()
{
if ($this->_bytePointer == $this->_dataLength) {
return 257;
}
$this->_nextData = ($this->_nextData << 8) | (ord($this->_data[$this->_bytePointer++]) & 0xff);
$this->_nextBits += 8;
if ($this->_nextBits < $this->_bitsToGet) {
$this->_nextData = ($this->_nextData << 8) | (ord($this->_data[$this->_bytePointer++]) & 0xff);
$this->_nextBits += 8;
}
$code = ($this->_nextData >> ($this->_nextBits - $this->_bitsToGet)) & $this->_andTable[$this->_bitsToGet-9];
$this->_nextBits -= $this->_bitsToGet;
return $code;
}
/**
* NOT IMPLEMENTED
*
* @param string $in
* @return string
* @throws LogicException
*/
public function encode($in)
{
throw new LogicException("LZW encoding not implemented.");
}
}

View File

@ -1,409 +1,555 @@
<?php
//
// FPDF_TPL - Version 1.1.3
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends PDF_Unicode {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x=null, $y=null, $w=null, $h=null) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x+$this->lMargin, $y+$this->tMargin);
$this->SetRightMargin($this->w-$w+$this->rMargin);
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if (!isset($this->tpls[$tplidx]))
$this->error("Template does not exist!");
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w/$w),
'scaleY' => ($_h/$h),
'tx' => $_x,
'ty' => ($this->h-$_y-$_h),
'lty' => ($this->h-$_y-$_h) - ($this->h-$h) * ($_h/$h)
);
$this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array("w" => $_w, "h" => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w=0, $_h=0) {
if (!$this->tpls[$tplidx])
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w==0)
$_w = $_h*$w/$h;
if($_h==0)
$_h = $_w*$h/$w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function SetFont($family, $style='', $size=0, $fontfile='') {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 3) {
$this->Error('More than 3 arguments for the SetFont method are only available in TCPDF.');
}
/**
* force the resetting of font changes in a template
*/
if ($this->_intpl)
$this->FontFamily = '';
parent::SetFont($family, $style, $size, $fontfile);
$fontkey = $this->FontFamily.$this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
}
parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation='', $format='') {
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces=0) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) {
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link, $spaces);
}
function AddLink() {
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y=0, $page=-1) {
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'],
// lly
-$tpl['y'],
// urx
($tpl['w']+$tpl['x'])*$this->k,
// ury
($tpl['h']-$tpl['y'])*$this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x']*$this->k*2, $tpl['y']*$this->k*2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length '.strlen($p).' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state==2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
} else {
parent::_out($s);
}
}
}
<?php
//
// FPDI - Version 1.5.1
//
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
require_once('fpdi_bridge.php');
/**
* Class FPDF_TPL
*/
class FPDF_TPL extends fpdi_bridge
{
/**
* Array of template data
*
* @var array
*/
protected $_tpls = array();
/**
* Current Template-Id
*
* @var int
*/
public $tpl = 0;
/**
* "In Template"-Flag
*
* @var boolean
*/
protected $_inTpl = false;
/**
* Name prefix of templates used in Resources dictionary
*
* @var string A String defining the Prefix used as Template-Object-Names. Have to begin with an /
*/
public $tplPrefix = "/TPL";
/**
* Resources used by templates and pages
*
* @var array
*/
protected $_res = array();
/**
* Last used template data
*
* @var array
*/
public $lastUsedTemplateData = array();
/**
* Start a template.
*
* This method starts a template. You can give own coordinates to build an own sized
* template. Pay attention, that the margins are adapted to the new template size.
* If you want to write outside the template, for example to build a clipped template,
* you have to set the margins and "cursor"-position manual after beginTemplate()-call.
*
* If no parameter is given, the template uses the current page-size.
* The method returns an id of the current template. This id is used later for using this template.
* Warning: A created template is saved in the resulting PDF at all events. Also if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The id of new created template
* @throws LogicException
*/
public function beginTemplate($x = null, $y = null, $w = null, $h = null)
{
if (is_subclass_of($this, 'TCPDF')) {
throw new LogicException('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
}
if ($this->page <= 0) {
throw new LogicException("You have to add at least a page first!");
}
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->_tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'o_FontFamily' => $this->FontFamily,
'o_FontStyle' => $this->FontStyle,
'o_FontSizePt' => $this->FontSizePt,
'o_FontSize' => $this->FontSize,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate correct positions
$this->h = $h;
$this->w = $w;
$this->_inTpl = true;
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
$this->SetRightMargin($this->w - $w + $this->rMargin);
if ($this->CurrentFont) {
$fontKey = $this->FontFamily . $this->FontStyle;
if ($fontKey) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontKey] =& $this->fonts[$fontKey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
}
return $this->tpl;
}
/**
* End template.
*
* This method ends a template and reset initiated variables collected in {@link beginTemplate()}.
*
* @return int|boolean If a template is opened, the id is returned. If not a false is returned.
*/
public function endTemplate()
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
}
if ($this->_inTpl) {
$this->_inTpl = false;
$tpl = $this->_tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize'];
$fontKey = $this->FontFamily . $this->FontStyle;
if ($fontKey)
$this->CurrentFont =& $this->fonts[$fontKey];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a template in current page or other template.
*
* You can use a template in a page or in another template.
* You can give the used template a new size.
* All parameters are optional. The width or height is calculated automatically
* if one is given. If no parameter is given the origin size as defined in
* {@link beginTemplate()} method is used.
*
* The calculated or used width and height are returned as an array.
*
* @param int $tplIdx A valid template-id
* @param int $x The x-position
* @param int $y The y-position
* @param int $w The new width of the template
* @param int $h The new height of the template
* @return array The height and width of the template (array('w' => ..., 'h' => ...))
* @throws LogicException|InvalidArgumentException
*/
public function useTemplate($tplIdx, $x = null, $y = null, $w = 0, $h = 0)
{
if ($this->page <= 0) {
throw new LogicException('You have to add at least a page first!');
}
if (!isset($this->_tpls[$tplIdx])) {
throw new InvalidArgumentException('Template does not exist!');
}
if ($this->_inTpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplIdx] =& $this->_tpls[$tplIdx];
}
$tpl = $this->_tpls[$tplIdx];
$_w = $tpl['w'];
$_h = $tpl['h'];
if ($x == null) {
$x = 0;
}
if ($y == null) {
$y = 0;
}
$x += $tpl['x'];
$y += $tpl['y'];
$wh = $this->getTemplateSize($tplIdx, $w, $h);
$w = $wh['w'];
$h = $wh['h'];
$tplData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $w,
'h' => $h,
'scaleX' => ($w / $_w),
'scaleY' => ($h / $_h),
'tx' => $x,
'ty' => ($this->h - $y - $h),
'lty' => ($this->h - $y - $h) - ($this->h - $_h) * ($h / $_h)
);
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm',
$tplData['scaleX'], $tplData['scaleY'], $tplData['tx'] * $this->k, $tplData['ty'] * $this->k)
); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplPrefix, $tplIdx));
$this->lastUsedTemplateData = $tplData;
return array('w' => $w, 'h' => $h);
}
/**
* Get the calculated size of a template.
*
* If one size is given, this method calculates the other one.
*
* @param int $tplIdx A valid template-id
* @param int $w The width of the template
* @param int $h The height of the template
* @return array The height and width of the template (array('w' => ..., 'h' => ...))
*/
public function getTemplateSize($tplIdx, $w = 0, $h = 0)
{
if (!isset($this->_tpls[$tplIdx]))
return false;
$tpl = $this->_tpls[$tplIdx];
$_w = $tpl['w'];
$_h = $tpl['h'];
if ($w == 0 && $h == 0) {
$w = $_w;
$h = $_h;
}
if ($w == 0)
$w = $h * $_w / $_h;
if($h == 0)
$h = $w * $_h / $_w;
return array("w" => $w, "h" => $h);
}
/**
* Sets the font used to print character strings.
*
* See FPDF/TCPDF documentation.
*
* @see http://fpdf.org/en/doc/setfont.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#afd56e360c43553830d543323e81bc045
*/
public function SetFont($family, $style = '', $size = null, $fontfile = '', $subset = 'default', $out = true)
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
}
parent::SetFont($family, $style, $size);
$fontkey = $this->FontFamily . $this->FontStyle;
if ($this->_inTpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* Puts an image.
*
* See FPDF/TCPDF documentation.
*
* @see http://fpdf.org/en/doc/image.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#a714c2bee7d6b39d4d6d304540c761352
*/
public function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
)
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
}
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
if ($this->_inTpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
* Adds a new page to the document.
*
* See FPDF/TCPDF documentation.
*
* This method cannot be used if you'd started a template.
*
* @see http://fpdf.org/en/doc/addpage.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#a5171e20b366b74523709d84c349c1ced
*/
public function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false)
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
}
if ($this->_inTpl) {
throw new LogicException('Adding pages in templates is not possible!');
}
parent::AddPage($orientation, $format);
}
/**
* Puts a link on a rectangular area of the page.
*
* Overwritten because adding links in a template will not work.
*
* @see http://fpdf.org/en/doc/link.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#ab87bf1826384fbfe30eb499d42f1d994
*/
public function Link($x, $y, $w, $h, $link, $spaces = 0)
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
}
if ($this->_inTpl) {
throw new LogicException('Using links in templates is not posible!');
}
parent::Link($x, $y, $w, $h, $link);
}
/**
* Creates a new internal link and returns its identifier.
*
* Overwritten because adding links in a template will not work.
*
* @see http://fpdf.org/en/doc/addlink.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#a749522038ed7786c3e1701435dcb891e
*/
public function AddLink()
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
}
if ($this->_inTpl) {
throw new LogicException('Adding links in templates is not possible!');
}
return parent::AddLink();
}
/**
* Defines the page and position a link points to.
*
* Overwritten because adding links in a template will not work.
*
* @see http://fpdf.org/en/doc/setlink.htm
* @see http://www.tcpdf.org/doc/code/classTCPDF.html#ace5be60e7857953ea5e2b89cb90df0ae
*/
public function SetLink($link, $y = 0, $page = -1)
{
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
}
if ($this->_inTpl) {
throw new LogicException('Setting links in templates is not possible!');
}
parent::SetLink($link, $y, $page);
}
/**
* Writes the form XObjects to the PDF document.
*/
protected function _putformxobjects()
{
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->_tpls);
foreach($this->_tpls AS $tplIdx => $tpl) {
$this->_newobj();
$this->_tpls[$tplIdx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'] * $this->k,
// lly
-$tpl['y'] * $this->k,
// urx
($tpl['w'] + $tpl['x']) * $this->k,
// ury
($tpl['h'] - $tpl['y']) * $this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplIdx])) {
$res = $this->_res['tpl'][$tplIdx];
if (isset($res['fonts']) && count($res['fonts'])) {
$this->_out('/Font <<');
foreach($res['fonts'] as $font) {
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
}
$this->_out('>>');
}
if(isset($res['images']) || isset($res['tpls'])) {
$this->_out('/XObject <<');
if (isset($res['images'])) {
foreach($res['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($res['tpls'])) {
foreach($res['tpls'] as $i => $_tpl)
$this->_out($this->tplPrefix . $i . ' ' . $_tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
}
$this->_out('>>');
$buffer = ($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_out('/Length ' . strlen($buffer) . ' >>');
$this->_putstream($buffer);
$this->_out('endobj');
}
}
/**
* Output images.
*
* Overwritten to add {@link _putformxobjects()} after _putimages().
*/
public function _putimages()
{
parent::_putimages();
$this->_putformxobjects();
}
/**
* Writes the references of XObject resources to the document.
*
* Overwritten to add the the templates to the XObject resource dictionary.
*/
public function _putxobjectdict()
{
parent::_putxobjectdict();
foreach($this->_tpls as $tplIdx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplPrefix, $tplIdx, $tpl['n']));
}
}
/**
* Writes bytes to the resulting document.
*
* Overwritten to delegate the data to the template buffer.
*
* @param string $s
*/
public function _out($s)
{
if ($this->state == 2 && $this->_inTpl) {
$this->_tpls[$this->tpl]['buffer'] .= $s . "\n";
} else {
parent::_out($s);
}
}
}

View File

@ -1,8 +1,8 @@
<?php
//
// FPDI - Version 1.4.2
// FPDI - Version 1.5.1
//
// Copyright 2004-2011 Setasign - Jan Slabon
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,78 +17,101 @@
// limitations under the License.
//
define('FPDI_VERSION', '1.4.2');
// Check for TCPDF and remap TCPDF to FPDF
if (class_exists('TCPDF', false)) {
require_once('fpdi2tcpdf_bridge.php');
}
require_once('fpdf_tpl.php');
require_once('fpdi_pdf_parser.php');
/**
* Class FPDI
*/
class FPDI extends FPDF_TPL
{
/**
* FPDI version
*
* @string
*/
const VERSION = '1.5.1';
class FPDI extends FPDF_TPL {
/**
* Actual filename
*
* @var string
*/
var $current_filename;
public $currentFilename;
/**
* Parser-Objects
* @var array
*
* @var fpdi_pdf_parser[]
*/
var $parsers;
public $parsers = array();
/**
* Current parser
* @var object
*
* @var fpdi_pdf_parser
*/
var $current_parser;
public $currentParser;
/**
* object stack
* The name of the last imported page box
*
* @var string
*/
public $lastUsedPageBox;
/**
* Object stack
*
* @var array
*/
var $_obj_stack;
protected $_objStack;
/**
* done object stack
* Done object stack
*
* @var array
*/
var $_don_obj_stack;
protected $_doneObjStack;
/**
* Current Object Id.
*
* @var integer
*/
var $_current_obj_id;
/**
* The name of the last imported page box
* @var string
*/
var $lastUsedPageBox;
protected $_currentObjId;
/**
* Cache for imported pages/template ids
*
* @var array
*/
var $_importedPages = array();
protected $_importedPages = array();
/**
* Set a source-file
* Set a source-file.
*
* @param string $filename a valid filename
* @return int number of available pages
* Depending on the PDF version of the used document the PDF version of the resulting document will
* be adjusted to the higher version.
*
* @param string $filename A valid path to the PDF document from which pages should be imported from
* @return int The number of pages in the document
*/
function setSourceFile($filename) {
$this->current_filename = $filename;
public function setSourceFile($filename)
{
$_filename = realpath($filename);
if (false !== $_filename)
$filename = $_filename;
$this->currentFilename = $filename;
if (!isset($this->parsers[$filename]))
if (!isset($this->parsers[$filename])) {
$this->parsers[$filename] = $this->_getPdfParser($filename);
$this->current_parser =& $this->parsers[$filename];
$this->setPdfVersion(
max($this->getPdfVersion(), $this->parsers[$filename]->getPdfVersion())
);
}
$this->currentParser =& $this->parsers[$filename];
return $this->parsers[$filename]->getPageCount();
}
@ -99,53 +122,80 @@ class FPDI extends FPDF_TPL {
* @param string $filename
* @return fpdi_pdf_parser
*/
function _getPdfParser($filename) {
return new fpdi_pdf_parser($filename, $this);
protected function _getPdfParser($filename)
{
require_once('fpdi_pdf_parser.php');
return new fpdi_pdf_parser($filename);
}
/**
* Get the current PDF version
* Get the current PDF version.
*
* @return string
*/
function getPDFVersion() {
public function getPdfVersion()
{
return $this->PDFVersion;
}
/**
* Set the PDF version
* Set the PDF version.
*
* @return string
* @param string $version
*/
function setPDFVersion($version = '1.3') {
public function setPdfVersion($version = '1.3')
{
$this->PDFVersion = $version;
}
/**
* Import a page
* Import a page.
*
* @param int $pageno pagenumber
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
* The second parameter defines the bounding box that should be used to transform the page into a
* form XObject.
*
* Following values are available: MediaBox, CropBox, BleedBox, TrimBox, ArtBox.
* If a box is not especially defined its default box will be used:
*
* <ul>
* <li>CropBox: Default -> MediaBox</li>
* <li>BleedBox: Default -> CropBox</li>
* <li>TrimBox: Default -> CropBox</li>
* <li>ArtBox: Default -> CropBox</li>
* </ul>
*
* It is possible to get the used page box by the {@link getLastUsedPageBox()} method.
*
* @param int $pageNo The page number
* @param string $boxName The boundary box to use when transforming the page into a form XObject
* @param boolean $groupXObject Define the form XObject as a group XObject to support transparency (if used)
* @return int An id of the imported page/template to use with e.g. fpdf_tpl::useTemplate()
* @throws LogicException|InvalidArgumentException
* @see getLastUsedPageBox()
*/
function importPage($pageno, $boxName = '/CropBox') {
if ($this->_intpl) {
return $this->error('Please import the desired pages before creating a new template.');
public function importPage($pageNo, $boxName = 'CropBox', $groupXObject = true)
{
if ($this->_inTpl) {
throw new LogicException('Please import the desired pages before creating a new template.');
}
$fn = $this->current_filename;
// check if page already imported
$pageKey = $fn . '-' . ((int)$pageno) . $boxName;
if (isset($this->_importedPages[$pageKey]))
return $this->_importedPages[$pageKey];
$parser =& $this->parsers[$fn];
$parser->setPageno($pageno);
$fn = $this->currentFilename;
$boxName = '/' . ltrim($boxName, '/');
if (!in_array($boxName, $parser->availableBoxes))
return $this->Error(sprintf('Unknown box: %s', $boxName));
// check if page already imported
$pageKey = $fn . '-' . ((int)$pageNo) . $boxName;
if (isset($this->_importedPages[$pageKey])) {
return $this->_importedPages[$pageKey];
}
$parser = $this->parsers[$fn];
$parser->setPageNo($pageNo);
if (!in_array($boxName, $parser->availableBoxes)) {
throw new InvalidArgumentException(sprintf('Unknown box: %s', $boxName));
}
$pageboxes = $parser->getPageBoxes($pageno, $this->k);
$pageBoxes = $parser->getPageBoxes($pageNo, $this->k);
/**
* MediaBox
@ -154,35 +204,39 @@ class FPDI extends FPDF_TPL {
* TrimBox: Default -> CropBox
* ArtBox: Default -> CropBox
*/
if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox'))
if (!isset($pageBoxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox'))
$boxName = '/CropBox';
if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox')
if (!isset($pageBoxes[$boxName]) && $boxName == '/CropBox')
$boxName = '/MediaBox';
if (!isset($pageboxes[$boxName]))
if (!isset($pageBoxes[$boxName]))
return false;
$this->lastUsedPageBox = $boxName;
$box = $pageboxes[$boxName];
$box = $pageBoxes[$boxName];
$this->tpl++;
$this->tpls[$this->tpl] = array();
$tpl =& $this->tpls[$this->tpl];
$tpl['parser'] =& $parser;
$this->_tpls[$this->tpl] = array();
$tpl =& $this->_tpls[$this->tpl];
$tpl['parser'] = $parser;
$tpl['resources'] = $parser->getPageResources();
$tpl['buffer'] = $parser->getContent();
$tpl['box'] = $box;
$tpl['groupXObject'] = $groupXObject;
if ($groupXObject) {
$this->setPdfVersion(max($this->getPdfVersion(), 1.4));
}
// To build an array that can be used by PDF_TPL::useTemplate()
$this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box);
$this->_tpls[$this->tpl] = array_merge($this->_tpls[$this->tpl], $box);
// An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects()
// An imported page will start at 0,0 all the time. Translation will be set in _putformxobjects()
$tpl['x'] = 0;
$tpl['y'] = 0;
// handle rotated pages
$rotation = $parser->getPageRotation($pageno);
$rotation = $parser->getPageRotation($pageNo);
$tpl['_rotationAngle'] = 0;
if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) {
$steps = $angle / 90;
@ -204,18 +258,41 @@ class FPDI extends FPDF_TPL {
}
/**
* Returns the last used page box
* Returns the last used page boundary box.
*
* @return string
* @return string The used boundary box: MediaBox, CropBox, BleedBox, TrimBox or ArtBox
*/
function getLastUsedPageBox() {
public function getLastUsedPageBox()
{
return $this->lastUsedPageBox;
}
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false) {
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
$size = $this->getTemplateSize($tplidx, $_w, $_h);
/**
* Use a template or imported page in current page or other template.
*
* You can use a template in a page or in another template.
* You can give the used template a new size. All parameters are optional.
* The width or height is calculated automatically if one is given. If no
* parameter is given the origin size as defined in beginTemplate() or of
* the imported page is used.
*
* The calculated or used width and height are returned as an array.
*
* @param int $tplIdx A valid template-id
* @param int $x The x-position
* @param int $y The y-position
* @param int $w The new width of the template
* @param int $h The new height of the template
* @param boolean $adjustPageSize If set to true the current page will be resized to fit the dimensions
* of the template
*
* @return array The height and width of the template (array('w' => ..., 'h' => ...))
* @throws LogicException|InvalidArgumentException
*/
public function useTemplate($tplIdx, $x = null, $y = null, $w = 0, $h = 0, $adjustPageSize = false)
{
if ($adjustPageSize == true && is_null($x) && is_null($y)) {
$size = $this->getTemplateSize($tplIdx, $w, $h);
$orientation = $size['w'] > $size['h'] ? 'L' : 'P';
$size = array($size['w'], $size['h']);
@ -224,22 +301,21 @@ class FPDI extends FPDF_TPL {
} else {
$size = $this->_getpagesize($size);
if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
{
if($orientation != $this->CurOrientation ||
$size[0] != $this->CurPageSize[0] ||
$size[1] != $this->CurPageSize[1]
) {
// New size or orientation
if($orientation=='P')
{
if ($orientation=='P') {
$this->w = $size[0];
$this->h = $size[1];
}
else
{
} else {
$this->w = $size[1];
$this->h = $size[0];
}
$this->wPt = $this->w*$this->k;
$this->hPt = $this->h*$this->k;
$this->PageBreakTrigger = $this->h-$this->bMargin;
$this->wPt = $this->w * $this->k;
$this->hPt = $this->h * $this->k;
$this->PageBreakTrigger = $this->h - $this->bMargin;
$this->CurOrientation = $orientation;
$this->CurPageSize = $size;
$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
@ -248,54 +324,53 @@ class FPDI extends FPDF_TPL {
}
$this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
$s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
$size = parent::useTemplate($tplIdx, $x, $y, $w, $h);
$this->_out('Q');
return $s;
return $size;
}
/**
* Private method, that rebuilds all needed objects of source files
* Copy all imported objects to the resulting document.
*/
function _putimportedobjects() {
if (is_array($this->parsers) && count($this->parsers) > 0) {
foreach($this->parsers AS $filename => $p) {
$this->current_parser =& $this->parsers[$filename];
if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
while(($n = key($this->_obj_stack[$filename])) !== null) {
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c, $this->_obj_stack[$filename][$n][1]);
$this->_newobj($this->_obj_stack[$filename][$n][0]);
if ($nObj[0] == PDF_TYPE_STREAM) {
$this->pdf_write_value($nObj);
} else {
$this->pdf_write_value($nObj[1]);
}
$this->_out('endobj');
$this->_obj_stack[$filename][$n] = null; // free memory
unset($this->_obj_stack[$filename][$n]);
reset($this->_obj_stack[$filename]);
}
protected function _putimportedobjects()
{
foreach($this->parsers AS $filename => $p) {
$this->currentParser =& $p;
if (!isset($this->_objStack[$filename]) || !is_array($this->_objStack[$filename])) {
continue;
}
while(($n = key($this->_objStack[$filename])) !== null) {
$nObj = $this->currentParser->resolveObject($this->_objStack[$filename][$n][1]);
$this->_newobj($this->_objStack[$filename][$n][0]);
if ($nObj[0] == pdf_parser::TYPE_STREAM) {
$this->_writeValue($nObj);
} else {
$this->_writeValue($nObj[1]);
}
$this->_out("\nendobj");
$this->_objStack[$filename][$n] = null; // free memory
unset($this->_objStack[$filename][$n]);
reset($this->_objStack[$filename]);
}
}
}
/**
* Private Method that writes the form xobjects
* Writes the form XObjects to the PDF document.
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$cN = $this->n; // TCPDF/Protection: rem current "n"
protected function _putformxobjects()
{
$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->_tpls);
foreach($this->_tpls AS $tplIdx => $tpl) {
$this->_newobj();
$currentN = $this->n; // TCPDF/Protection: rem current "n"
$this->tpls[$tplidx]['n'] = $this->n;
$this->_tpls[$tplIdx]['n'] = $this->n;
$this->_out('<<' . $filter . '/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
@ -318,8 +393,8 @@ class FPDI extends FPDF_TPL {
if ($tpl['_rotationAngle'] <> 0) {
$angle = $tpl['_rotationAngle'] * M_PI/180;
$c=cos($angle);
$s=sin($angle);
$c = cos($angle);
$s = sin($angle);
switch($tpl['_rotationAngle']) {
case -90:
@ -353,87 +428,107 @@ class FPDI extends FPDF_TPL {
$this->_out('/Resources ');
if (isset($tpl['resources'])) {
$this->current_parser =& $tpl['parser'];
$this->pdf_write_value($tpl['resources']); // "n" will be changed
$this->currentParser = $tpl['parser'];
$this->_writeValue($tpl['resources']); // "n" will be changed
} else {
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
if (isset($this->_res['tpl'][$tplIdx])) {
$res = $this->_res['tpl'][$tplIdx];
if (isset($res['fonts']) && count($res['fonts'])) {
$this->_out('/Font <<');
foreach ($res['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
if (isset($res['images']) && count($res['images']) ||
isset($res['tpls']) && count($res['tpls']))
{
$this->_out('/XObject <<');
if (isset($res['images'])) {
foreach ($res['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($res['tpls'])) {
foreach ($res['tpls'] as $i => $_tpl)
$this->_out($this->tplPrefix . $i . ' ' . $_tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
}
$this->_out('>>');
}
}
$nN = $this->n; // TCPDF: rem new "n"
$this->n = $cN; // TCPDF: reset to current "n"
if (isset($tpl['groupXObject']) && $tpl['groupXObject']) {
$this->_out('/Group <</Type/Group/S/Transparency>>');
}
$newN = $this->n; // TCPDF: rem new "n"
$this->n = $currentN; // TCPDF: reset to current "n"
$buffer = ($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
if (is_subclass_of($this, 'TCPDF')) {
$p = $this->_getrawstream($p);
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_out("stream\n" . $p . "\nendstream");
$buffer = $this->_getrawstream($buffer);
$this->_out('/Length ' . strlen($buffer) . ' >>');
$this->_out("stream\n" . $buffer . "\nendstream");
} else {
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p);
$this->_out('/Length ' . strlen($buffer) . ' >>');
$this->_putstream($buffer);
}
$this->_out('endobj');
$this->n = $nN; // TCPDF: reset to new "n"
$this->n = $newN; // TCPDF: reset to new "n"
}
$this->_putimportedobjects();
}
/**
* Creates and optionally write the object definition to the document.
*
* Rewritten to handle existing own defined objects
*
* @param bool $objId
* @param bool $onlyNewObj
* @return bool|int
*/
function _newobj($obj_id = false, $onlynewobj = false) {
if (!$obj_id) {
$obj_id = ++$this->n;
public function _newobj($objId = false, $onlyNewObj = false)
{
if (!$objId) {
$objId = ++$this->n;
}
//Begin a new object
if (!$onlynewobj) {
$this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
$this->_out($obj_id . ' 0 obj');
$this->_current_obj_id = $obj_id; // for later use with encryption
if (!$onlyNewObj) {
$this->offsets[$objId] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
$this->_out($objId . ' 0 obj');
$this->_currentObjId = $objId; // for later use with encryption
}
return $obj_id;
return $objId;
}
/**
* Writes a value
* Writes a PDF value to the resulting document.
*
* Needed to rebuild the source document
*
* @param mixed $value A PDF-Value. Structure of values see cases in this method
*/
function pdf_write_value(&$value)
protected function _writeValue(&$value)
{
if (is_subclass_of($this, 'TCPDF')) {
parent::pdf_write_value($value);
parent::_prepareValue($value);
}
switch ($value[0]) {
case PDF_TYPE_TOKEN:
case pdf_parser::TYPE_TOKEN:
$this->_straightOut($value[1] . ' ');
break;
case PDF_TYPE_NUMERIC:
case PDF_TYPE_REAL:
case pdf_parser::TYPE_NUMERIC:
case pdf_parser::TYPE_REAL:
if (is_float($value[1]) && $value[1] != 0) {
$this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' ');
} else {
@ -441,20 +536,20 @@ class FPDI extends FPDF_TPL {
}
break;
case PDF_TYPE_ARRAY:
case pdf_parser::TYPE_ARRAY:
// An array. Output the proper
// structure and move on.
$this->_straightOut('[');
for ($i = 0; $i < count($value[1]); $i++) {
$this->pdf_write_value($value[1][$i]);
$this->_writeValue($value[1][$i]);
}
$this->_out(']');
break;
case PDF_TYPE_DICTIONARY:
case pdf_parser::TYPE_DICTIONARY:
// A dictionary.
$this->_straightOut('<<');
@ -463,55 +558,54 @@ class FPDI extends FPDF_TPL {
while (list($k, $v) = each($value[1])) {
$this->_straightOut($k . ' ');
$this->pdf_write_value($v);
$this->_writeValue($v);
}
$this->_straightOut('>>');
break;
case PDF_TYPE_OBJREF:
case pdf_parser::TYPE_OBJREF:
// An indirect object reference
// Fill the object stack if needed
$cpfn =& $this->current_parser->filename;
if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
$cpfn =& $this->currentParser->filename;
if (!isset($this->_doneObjStack[$cpfn][$value[1]])) {
$this->_newobj(false, true);
$this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
$this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
$this->_objStack[$cpfn][$value[1]] = array($this->n, $value);
$this->_doneObjStack[$cpfn][$value[1]] = array($this->n, $value);
}
$objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
$objId = $this->_doneObjStack[$cpfn][$value[1]][0];
$this->_out($objid . ' 0 R');
$this->_out($objId . ' 0 R');
break;
case PDF_TYPE_STRING:
case pdf_parser::TYPE_STRING:
// A string.
$this->_straightOut('(' . $value[1] . ')');
break;
case PDF_TYPE_STREAM:
case pdf_parser::TYPE_STREAM:
// A stream. First, output the
// stream dictionary, then the
// stream data itself.
$this->pdf_write_value($value[1]);
$this->_writeValue($value[1]);
$this->_out('stream');
$this->_out($value[2][1]);
$this->_out('endstream');
$this->_straightOut("endstream");
break;
case PDF_TYPE_HEX:
case pdf_parser::TYPE_HEX:
$this->_straightOut('<' . $value[1] . '>');
break;
case PDF_TYPE_BOOLEAN:
case pdf_parser::TYPE_BOOLEAN:
$this->_straightOut($value[1] ? 'true ' : 'false ');
break;
case PDF_TYPE_NULL:
case pdf_parser::TYPE_NULL:
// The null object.
$this->_straightOut('null ');
@ -521,51 +615,77 @@ class FPDI extends FPDF_TPL {
/**
* Modified so not each call will add a newline to the output.
* Modified _out() method so not each call will add a newline to the output.
*/
function _straightOut($s) {
protected function _straightOut($s)
{
if (!is_subclass_of($this, 'TCPDF')) {
if($this->state==2)
if ($this->state == 2) {
$this->pages[$this->page] .= $s;
else
} else {
$this->buffer .= $s;
}
} else {
if ($this->state == 2) {
if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
if ($this->inxobj) {
// we are inside an XObject template
$this->xobjects[$this->xobjid]['outdata'] .= $s;
} else if ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
// puts data before page footer
$page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
$footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
$this->setPageBuffer($this->page, $page . ' ' . $s . "\n" . $footer);
$pagebuff = $this->getPageBuffer($this->page);
$page = substr($pagebuff, 0, -$this->footerlen[$this->page]);
$footer = substr($pagebuff, -$this->footerlen[$this->page]);
$this->setPageBuffer($this->page, $page . $s . $footer);
// update footer position
$this->footerpos[$this->page] += strlen($s);
} else {
// set page data
$this->setPageBuffer($this->page, $s, true);
}
} else {
} else if ($this->state > 0) {
// set general data
$this->setBuffer($s);
}
}
}
/**
* rewritten to close opened parsers
* Ends the document
*
* Overwritten to close opened parsers
*/
function _enddoc() {
public function _enddoc()
{
parent::_enddoc();
$this->_closeParsers();
}
/**
* close all files opened by parsers
* Close all files opened by parsers.
*
* @return boolean
*/
function _closeParsers() {
if ($this->state > 2 && count($this->parsers) > 0) {
foreach ($this->parsers as $k => $_){
$this->parsers[$k]->closeFile();
$this->parsers[$k] = null;
unset($this->parsers[$k]);
}
protected function _closeParsers()
{
if ($this->state > 2) {
$this->cleanUp();
return true;
}
return false;
}
/**
* Removes cycled references and closes the file handles of the parser objects.
*/
public function cleanUp()
{
while (($parser = array_pop($this->parsers)) !== null) {
/**
* @var fpdi_pdf_parser $parser
*/
$parser->closeFile();
}
}
}

View File

@ -0,0 +1,215 @@
<?php
//
// FPDI - Version 1.5.1
//
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
* This file is used as a bridge between TCPDF or FPDF
* It will dynamically create the class extending the available
* class FPDF or TCPDF.
*
* This way it is possible to use FPDI for both FPDF and TCPDF with one FPDI version.
*/
if (!class_exists('TCPDF', false)) {
/**
* Class fpdi_bridge
*/
class fpdi_bridge extends PDF_Unicode
{
// empty body
}
} else {
/**
* Class fpdi_bridge
*/
class fpdi_bridge extends TCPDF
{
/**
* Array of Tpl-Data
*
* @var array
*/
protected $_tpls = array();
/**
* Name-prefix of Templates used in Resources-Dictionary
*
* @var string A String defining the Prefix used as Template-Object-Names. Have to begin with an /
*/
public $tplPrefix = "/TPL";
/**
* Current Object Id.
*
* @var integer
*/
protected $_currentObjId;
/**
* Return XObjects Dictionary.
*
* Overwritten to add additional XObjects to the resources dictionary of TCPDF
*
* @return string
*/
protected function _getxobjectdict()
{
$out = parent::_getxobjectdict();
foreach ($this->_tpls as $tplIdx => $tpl) {
$out .= sprintf('%s%d %d 0 R', $this->tplPrefix, $tplIdx, $tpl['n']);
}
return $out;
}
/**
* Writes a PDF value to the resulting document.
*
* Prepares the value for encryption of imported data by FPDI
*
* @param array $value
*/
protected function _prepareValue(&$value)
{
switch ($value[0]) {
case pdf_parser::TYPE_STRING:
if ($this->encrypted) {
$value[1] = $this->_unescape($value[1]);
$value[1] = $this->_encrypt_data($this->_currentObjId, $value[1]);
$value[1] = TCPDF_STATIC::_escape($value[1]);
}
break;
case pdf_parser::TYPE_STREAM:
if ($this->encrypted) {
$value[2][1] = $this->_encrypt_data($this->_currentObjId, $value[2][1]);
$value[1][1]['/Length'] = array(
pdf_parser::TYPE_NUMERIC,
strlen($value[2][1])
);
}
break;
case pdf_parser::TYPE_HEX:
if ($this->encrypted) {
$value[1] = $this->hex2str($value[1]);
$value[1] = $this->_encrypt_data($this->_currentObjId, $value[1]);
// remake hexstring of encrypted string
$value[1] = $this->str2hex($value[1]);
}
break;
}
}
/**
* Un-escapes a PDF string
*
* @param string $s
* @return string
*/
protected function _unescape($s)
{
$out = '';
for ($count = 0, $n = strlen($s); $count < $n; $count++) {
if ($s[$count] != '\\' || $count == $n-1) {
$out .= $s[$count];
} else {
switch ($s[++$count]) {
case ')':
case '(':
case '\\':
$out .= $s[$count];
break;
case 'f':
$out .= chr(0x0C);
break;
case 'b':
$out .= chr(0x08);
break;
case 't':
$out .= chr(0x09);
break;
case 'r':
$out .= chr(0x0D);
break;
case 'n':
$out .= chr(0x0A);
break;
case "\r":
if ($count != $n-1 && $s[$count+1] == "\n")
$count++;
break;
case "\n":
break;
default:
// Octal-Values
if (ord($s[$count]) >= ord('0') &&
ord($s[$count]) <= ord('9')) {
$oct = ''. $s[$count];
if (ord($s[$count+1]) >= ord('0') &&
ord($s[$count+1]) <= ord('9')) {
$oct .= $s[++$count];
if (ord($s[$count+1]) >= ord('0') &&
ord($s[$count+1]) <= ord('9')) {
$oct .= $s[++$count];
}
}
$out .= chr(octdec($oct));
} else {
$out .= $s[$count];
}
}
}
}
return $out;
}
/**
* Hexadecimal to string
*
* @param string $data
* @return string
*/
public function hex2str($data)
{
$data = preg_replace('/[^0-9A-Fa-f]/', '', rtrim($data, '>'));
if ((strlen($data) % 2) == 1) {
$data .= '0';
}
return pack('H*', $data);
}
/**
* String to hexadecimal
*
* @param string $str
* @return string
*/
public function str2hex($str)
{
return current(unpack('H*', $str));
}
}
}

View File

@ -1,8 +1,8 @@
<?php
//
// FPDI - Version 1.4.2
// FPDI - Version 1.5.1
//
// Copyright 2004-2011 Setasign - Jan Slabon
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -19,313 +19,255 @@
require_once('pdf_parser.php');
class fpdi_pdf_parser extends pdf_parser {
/**
* Class fpdi_pdf_parser
*/
class fpdi_pdf_parser extends pdf_parser
{
/**
* Pages
* Index beginns at 0
*
* Index begins at 0
*
* @var array
*/
var $pages;
protected $_pages;
/**
* Page count
*
* @var integer
*/
var $page_count;
protected $_pageCount;
/**
* actual page number
* Current page number
*
* @var integer
*/
var $pageno;
public $pageNo;
/**
* PDF Version of imported Document
* PDF version of imported document
*
* @var string
*/
var $pdfVersion;
/**
* FPDI Reference
* @var object
*/
var $fpdi;
public $_pdfVersion;
/**
* Available BoxTypes
*
* @var array
*/
var $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox');
public $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox');
/**
* Constructor
* The constructor.
*
* @param string $filename Source-Filename
* @param object $fpdi Object of type fpdi
* @param string $filename The source filename
*/
function fpdi_pdf_parser($filename, &$fpdi) {
$this->fpdi =& $fpdi;
parent::pdf_parser($filename);
public function __construct($filename)
{
parent::__construct($filename);
// resolve Pages-Dictonary
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
$pages = $this->resolveObject($this->_root[1][1]['/Pages']);
// Read pages
$this->read_pages($this->c, $pages, $this->pages);
$this->_readPages($pages, $this->_pages);
// count pages;
$this->page_count = count($this->pages);
$this->_pageCount = count($this->_pages);
}
/**
* Overwrite parent::error()
*
* @param string $msg Error-Message
*/
function error($msg) {
$this->fpdi->error($msg);
}
/**
* Get pagecount from sourcefile
* Get page count from source file.
*
* @return int
*/
function getPageCount() {
return $this->page_count;
public function getPageCount()
{
return $this->_pageCount;
}
/**
* Set pageno
* Set the page number.
*
* @param int $pageno Pagenumber to use
* @param int $pageNo Page number to use
* @throws InvalidArgumentException
*/
function setPageno($pageno) {
$pageno = ((int) $pageno) - 1;
public function setPageNo($pageNo)
{
$pageNo = ((int) $pageNo) - 1;
if ($pageno < 0 || $pageno >= $this->getPageCount()) {
$this->fpdi->error('Pagenumber is wrong!');
if ($pageNo < 0 || $pageNo >= $this->getPageCount()) {
throw new InvalidArgumentException('Invalid page number!');
}
$this->pageno = $pageno;
$this->pageNo = $pageNo;
}
/**
* Get page-resources from current page
*
* @return array
* @return array|boolean
*/
function getPageResources() {
return $this->_getPageResources($this->pages[$this->pageno]);
public function getPageResources()
{
return $this->_getPageResources($this->_pages[$this->pageNo]);
}
/**
* Get page-resources from /Page
* Get page-resources from a /Page dictionary.
*
* @param array $obj Array of pdf-data
* @return array|boolean
*/
function _getPageResources ($obj) { // $obj = /Page
$obj = $this->pdf_resolve_object($this->c, $obj);
protected function _getPageResources($obj)
{
$obj = $this->resolveObject($obj);
// If the current object has a resources
// dictionary associated with it, we use
// it. Otherwise, we move back to its
// parent object.
if (isset ($obj[1][1]['/Resources'])) {
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
if ($res[0] == PDF_TYPE_OBJECT)
if (isset($obj[1][1]['/Resources'])) {
$res = $this->resolveObject($obj[1][1]['/Resources']);
if ($res[0] == pdf_parser::TYPE_OBJECT)
return $res[1];
return $res;
} else {
if (!isset ($obj[1][1]['/Parent'])) {
return false;
} else {
$res = $this->_getPageResources($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
}
if (!isset($obj[1][1]['/Parent'])) {
return false;
}
$res = $this->_getPageResources($obj[1][1]['/Parent']);
if ($res[0] == pdf_parser::TYPE_OBJECT)
return $res[1];
return $res;
}
/**
* Get content of current page
* Get content of current page.
*
* If more /Contents is an array, the streams are concated
* If /Contents is an array, the streams are concatenated
*
* @return string
*/
function getContent() {
public function getContent()
{
$buffer = '';
if (isset($this->pages[$this->pageno][1][1]['/Contents'])) {
$contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
foreach($contents AS $tmp_content) {
$buffer .= $this->_rebuildContentStream($tmp_content) . ' ';
if (isset($this->_pages[$this->pageNo][1][1]['/Contents'])) {
$contents = $this->_getPageContent($this->_pages[$this->pageNo][1][1]['/Contents']);
foreach ($contents AS $tmpContent) {
$buffer .= $this->_unFilterStream($tmpContent) . ' ';
}
}
return $buffer;
}
/**
* Resolve all content-objects
* Resolve all content objects.
*
* @param array $content_ref
* @param array $contentRef
* @return array
*/
function _getPageContent($content_ref) {
protected function _getPageContent($contentRef)
{
$contents = array();
if ($content_ref[0] == PDF_TYPE_OBJREF) {
$content = $this->pdf_resolve_object($this->c, $content_ref);
if ($content[1][0] == PDF_TYPE_ARRAY) {
if ($contentRef[0] == pdf_parser::TYPE_OBJREF) {
$content = $this->resolveObject($contentRef);
if ($content[1][0] == pdf_parser::TYPE_ARRAY) {
$contents = $this->_getPageContent($content[1]);
} else {
$contents[] = $content;
}
} else if ($content_ref[0] == PDF_TYPE_ARRAY) {
foreach ($content_ref[1] AS $tmp_content_ref) {
$contents = array_merge($contents,$this->_getPageContent($tmp_content_ref));
} else if ($contentRef[0] == pdf_parser::TYPE_ARRAY) {
foreach ($contentRef[1] AS $tmp_content_ref) {
$contents = array_merge($contents, $this->_getPageContent($tmp_content_ref));
}
}
return $contents;
}
/**
* Rebuild content-streams
* Get a boundary box from a page
*
* @param array $obj
* @return string
*/
function _rebuildContentStream($obj) {
$filters = array();
if (isset($obj[1][1]['/Filter'])) {
$_filter = $obj[1][1]['/Filter'];
if ($_filter[0] == PDF_TYPE_OBJREF) {
$tmpFilter = $this->pdf_resolve_object($this->c, $_filter);
$_filter = $tmpFilter[1];
}
if ($_filter[0] == PDF_TYPE_TOKEN) {
$filters[] = $_filter;
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
$filters = $_filter[1];
}
}
$stream = $obj[2][1];
foreach ($filters AS $_filter) {
switch ($_filter[1]) {
case '/FlateDecode':
case '/Fl':
// $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work
// $stream .= "\x0A";
// $stream .= "\x0D";
if (function_exists('gzuncompress')) {
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
} else {
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
}
if ($stream === false) {
$this->error('Error while decompressing stream.');
}
break;
case '/LZWDecode':
include_once('filters/FilterLZW_FPDI.php');
$decoder = new FilterLZW_FPDI($this->fpdi);
$stream = $decoder->decode($stream);
break;
case '/ASCII85Decode':
include_once('filters/FilterASCII85_FPDI.php');
$decoder = new FilterASCII85_FPDI($this->fpdi);
$stream = $decoder->decode($stream);
break;
case null:
$stream = $stream;
break;
default:
$this->error(sprintf('Unsupported Filter: %s',$_filter[1]));
}
}
return $stream;
}
/**
* Get a Box from a page
* Arrayformat is same as used by fpdf_tpl
* Array format is same as used by FPDF_TPL.
*
* @param array $page a /Page
* @param string $box_index Type of Box @see $availableBoxes
* @param array $page a /Page dictionary
* @param string $boxIndex Type of box {see {@link $availableBoxes})
* @param float Scale factor from user space units to points
* @return array
*
* @return array|boolean
*/
function getPageBox($page, $box_index, $k) {
$page = $this->pdf_resolve_object($this->c, $page);
protected function _getPageBox($page, $boxIndex, $k)
{
$page = $this->resolveObject($page);
$box = null;
if (isset($page[1][1][$box_index]))
$box =& $page[1][1][$box_index];
if (isset($page[1][1][$boxIndex])) {
$box = $page[1][1][$boxIndex];
}
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
$tmp_box = $this->pdf_resolve_object($this->c, $box);
if (!is_null($box) && $box[0] == pdf_parser::TYPE_OBJREF) {
$tmp_box = $this->resolveObject($box);
$box = $tmp_box[1];
}
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
$b =& $box[1];
return array('x' => $b[0][1] / $k,
'y' => $b[1][1] / $k,
'w' => abs($b[0][1] - $b[2][1]) / $k,
'h' => abs($b[1][1] - $b[3][1]) / $k,
'llx' => min($b[0][1], $b[2][1]) / $k,
'lly' => min($b[1][1], $b[3][1]) / $k,
'urx' => max($b[0][1], $b[2][1]) / $k,
'ury' => max($b[1][1], $b[3][1]) / $k,
);
} else if (!isset ($page[1][1]['/Parent'])) {
if (!is_null($box) && $box[0] == pdf_parser::TYPE_ARRAY) {
$b = $box[1];
return array(
'x' => $b[0][1] / $k,
'y' => $b[1][1] / $k,
'w' => abs($b[0][1] - $b[2][1]) / $k,
'h' => abs($b[1][1] - $b[3][1]) / $k,
'llx' => min($b[0][1], $b[2][1]) / $k,
'lly' => min($b[1][1], $b[3][1]) / $k,
'urx' => max($b[0][1], $b[2][1]) / $k,
'ury' => max($b[1][1], $b[3][1]) / $k,
);
} else if (!isset($page[1][1]['/Parent'])) {
return false;
} else {
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index, $k);
return $this->_getPageBox($this->resolveObject($page[1][1]['/Parent']), $boxIndex, $k);
}
}
/**
* Get all page boxes by page no
* Get all page boundary boxes by page number
*
* @param int The page number
* @param float Scale factor from user space units to points
* @param int $pageNo The page number
* @param float $k Scale factor from user space units to points
* @return array
* @throws InvalidArgumentException
*/
function getPageBoxes($pageno, $k) {
return $this->_getPageBoxes($this->pages[$pageno - 1], $k);
public function getPageBoxes($pageNo, $k)
{
if (!isset($this->_pages[$pageNo - 1])) {
throw new InvalidArgumentException('Page ' . $pageNo . ' does not exists.');
}
return $this->_getPageBoxes($this->_pages[$pageNo - 1], $k);
}
/**
* Get all boxes from /Page
* Get all boxes from /Page dictionary
*
* @param array a /Page
* @param array $page A /Page dictionary
* @param float $k Scale factor from user space units to points
* @return array
*/
function _getPageBoxes($page, $k) {
protected function _getPageBoxes($page, $k)
{
$boxes = array();
foreach($this->availableBoxes AS $box) {
if ($_box = $this->getPageBox($page, $box, $k)) {
if ($_box = $this->_getPageBox($page, $box, $k)) {
$boxes[$box] = $_box;
}
}
@ -334,75 +276,79 @@ class fpdi_pdf_parser extends pdf_parser {
}
/**
* Get the page rotation by pageno
* Get the page rotation by page number
*
* @param integer $pageno
* @param integer $pageNo
* @throws InvalidArgumentException
* @return array
*/
function getPageRotation($pageno) {
return $this->_getPageRotation($this->pages[$pageno - 1]);
public function getPageRotation($pageNo)
{
if (!isset($this->_pages[$pageNo - 1])) {
throw new InvalidArgumentException('Page ' . $pageNo . ' does not exists.');
}
return $this->_getPageRotation($this->_pages[$pageNo - 1]);
}
function _getPageRotation($obj) { // $obj = /Page
$obj = $this->pdf_resolve_object($this->c, $obj);
if (isset ($obj[1][1]['/Rotate'])) {
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']);
if ($res[0] == PDF_TYPE_OBJECT)
/**
* Get the rotation value of a page
*
* @param array $obj A /Page dictionary
* @return array|bool
*/
protected function _getPageRotation($obj)
{
$obj = $this->resolveObject($obj);
if (isset($obj[1][1]['/Rotate'])) {
$res = $this->resolveObject($obj[1][1]['/Rotate']);
if ($res[0] == pdf_parser::TYPE_OBJECT)
return $res[1];
return $res;
} else {
if (!isset ($obj[1][1]['/Parent'])) {
return false;
} else {
$res = $this->_getPageRotation($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
}
}
/**
* Read all /Page(es)
*
* @param object pdf_context
* @param array /Pages
* @param array the result-array
*/
function read_pages(&$c, &$pages, &$result) {
// Get the kids dictionary
$_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
if (!is_array($_kids))
$this->error('Cannot find /Kids in current /Page-Dictionary');
if ($_kids[1][0] == PDF_TYPE_ARRAY) {
$kids = $_kids[1][1];
} else {
$kids = $_kids[1];
if (!isset($obj[1][1]['/Parent'])) {
return false;
}
$res = $this->_getPageRotation($obj[1][1]['/Parent']);
if ($res[0] == pdf_parser::TYPE_OBJECT)
return $res[1];
return $res;
}
/**
* Read all pages
*
* @param array $pages /Pages dictionary
* @param array $result The result array
* @throws Exception
*/
protected function _readPages(&$pages, &$result)
{
// Get the kids dictionary
$_kids = $this->resolveObject($pages[1][1]['/Kids']);
if (!is_array($_kids)) {
throw new Exception('Cannot find /Kids in current /Page-Dictionary');
}
if ($_kids[0] === self::TYPE_OBJECT) {
$_kids = $_kids[1];
}
$kids = $_kids[1];
foreach ($kids as $v) {
$pg = $this->pdf_resolve_object ($c, $v);
$pg = $this->resolveObject($v);
if ($pg[1][1]['/Type'][1] === '/Pages') {
// If one of the kids is an embedded
// /Pages array, resolve it as well.
$this->read_pages($c, $pg, $result);
$this->_readPages($pg, $result);
} else {
$result[] = $pg;
}
}
}
/**
* Get PDF-Version
*
* And reset the PDF Version used in FPDI if needed
*/
function getPDFVersion() {
parent::getPDFVersion();
$this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion));
}
}

View File

@ -1,8 +1,8 @@
<?php
//
// FPDI - Version 1.4.2
// FPDI - Version 1.5.1
//
// Copyright 2004-2011 Setasign - Jan Slabon
// Copyright 2004-2014 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,88 +17,137 @@
// limitations under the License.
//
if (!class_exists('pdf_context', false)) {
class pdf_context {
/**
* Modi
*
* @var integer 0 = file | 1 = string
*/
var $_mode = 0;
var $file;
var $buffer;
var $offset;
var $length;
var $stack;
// Constructor
function pdf_context(&$f) {
$this->file =& $f;
if (is_string($this->file))
$this->_mode = 1;
$this->reset();
}
// Optionally move the file
// pointer to a new location
// and reset the buffered data
function reset($pos = null, $l = 100) {
if ($this->_mode == 0) {
if (!is_null ($pos)) {
fseek ($this->file, $pos);
}
$this->buffer = $l > 0 ? fread($this->file, $l) : '';
$this->length = strlen($this->buffer);
if ($this->length < $l)
$this->increase_length($l - $this->length);
} else {
$this->buffer = $this->file;
$this->length = strlen($this->buffer);
}
$this->offset = 0;
$this->stack = array();
}
// Make sure that there is at least one
// character beyond the current offset in
// the buffer to prevent the tokenizer
// from attempting to access data that does
// not exist
function ensure_content() {
if ($this->offset >= $this->length - 1) {
return $this->increase_length();
} else {
return true;
}
}
// Forcefully read more data into the buffer
function increase_length($l = 100) {
if ($this->_mode == 0 && feof($this->file)) {
return false;
} else if ($this->_mode == 0) {
$totalLength = $this->length + $l;
do {
$toRead = $totalLength - $this->length;
if ($toRead < 1)
break;
$this->buffer .= fread($this->file, $toRead);
} while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
return true;
} else {
return false;
}
}
/**
* Class pdf_context
*/
class pdf_context
{
/**
* Mode
*
* @var integer 0 = file | 1 = string
*/
protected $_mode = 0;
/**
* @var resource|string
*/
public $file;
/**
* @var string
*/
public $buffer;
/**
* @var integer
*/
public $offset;
/**
* @var integer
*/
public $length;
/**
* @var array
*/
public $stack;
/**
* The constructor
*
* @param resource $f
*/
public function __construct(&$f)
{
$this->file =& $f;
if (is_string($this->file))
$this->_mode = 1;
$this->reset();
}
/**
* Get the position in the file stream
*
* @return int
*/
public function getPos()
{
if ($this->_mode == 0) {
return ftell($this->file);
} else {
return 0;
}
}
/**
* Reset the position in the file stream.
*
* Optionally move the file pointer to a new location and reset the buffered data.
*
* @param null $pos
* @param int $l
*/
public function reset($pos = null, $l = 100)
{
if ($this->_mode == 0) {
if (!is_null($pos)) {
fseek ($this->file, $pos);
}
$this->buffer = $l > 0 ? fread($this->file, $l) : '';
$this->length = strlen($this->buffer);
if ($this->length < $l)
$this->increaseLength($l - $this->length);
} else {
$this->buffer = $this->file;
$this->length = strlen($this->buffer);
}
$this->offset = 0;
$this->stack = array();
}
/**
* Make sure that there is at least one character beyond the current offset in the buffer.
*
* To prevent the tokenizer from attempting to access data that does not exist.
*
* @return bool
*/
public function ensureContent()
{
if ($this->offset >= $this->length - 1) {
return $this->increaseLength();
} else {
return true;
}
}
/**
* Forcefully read more data into the buffer
*
* @param int $l
* @return bool
*/
public function increaseLength($l = 100)
{
if ($this->_mode == 0 && feof($this->file)) {
return false;
} else if ($this->_mode == 0) {
$totalLength = $this->length + $l;
do {
$toRead = $totalLength - $this->length;
if ($toRead < 1)
break;
$this->buffer .= fread($this->file, $toRead);
} while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
return true;
} else {
return false;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,9 @@ ini_set('error_log','/tmp/wsn.log');
}
}
} else {
$sql_user = "SELECT distinct uid,site,variable,starttime,endtime from users_pm_down where starttime is not null and result=-1 and type='down' and uid=$uid";
$sql_user = "SELECT distinct u.uid,u.site,u.starttime,u.endtime ,s.fld_name,case when (u.variable=-1) then '-1' else '1' end as variable
from users_pm_down u left join tbl_site_info s on u.site=s.fld_site_id
where starttime is not null and result=-1 and type='down' and uid=$uid";
$sth_user = $db->query($sql_user);
$rows_user = $sth_user->fetchAll();
@ -84,10 +86,7 @@ ini_set('error_log','/tmp/wsn.log');
$days=round((strtotime($end)-strtotime($start))/3600/24)+1;
//获取观测点的名称
$sql_site= "SELECT fld_name from tbl_site_info where fld_site_id=$site";
$sth_site = $db->query($sql_site);
$rows_site = $sth_site->fetch();
$sitename= $rows_site['fld_name'];
$sitename= $v['fld_name'];
//先为该用户创建一个文件夹
$aimDir_user=$basepath.'wsn_'.$uid;
@ -103,84 +102,77 @@ ini_set('error_log','/tmp/wsn.log');
$result = mkdir($aimDir_site);
}
//选择全部变量
if($variable==-1)
//获取变量名称
$sql="select distinct va.fld_name from tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id
WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$end'";
if ($variable==1)
{
//获取数据
$sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<'$end' ORDER BY time ";
$sth2 = $db->query($sql2);
//$rows2 = $sth2->fetchAll();
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$head = "Time,Variable,Value, \n";
$html="";
while ($v=$sth2->fetch())
{
//组装数据
if ($v['time']>=$start && $v['time']<$endtime)
{
$html.=$v['time'].",".$v['variablename'].",".$v['value']."\n";
} elseif ($v['time']>=$endtime) {
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_all_".$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
$start=$endtime;
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$html=$v['time'].",".$v['variablename'].",".$v['value']."\n";
}
}
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_all_".$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
print $sitename."\r\n";
$sql_up= "update users_pm_down set result=0 WHERE site=$site and variable=-1 and uid=$uid and result=-1 and type='down'";
$db->query($sql_up);
} else {
//获取观测变量的名称
$sql3= "SELECT fld_name from tbl_variable_info where fld_variable_id=$variable";
$sth3 = $db->query($sql3);
$rows3 = $sth3->fetch();
$varname=$rows3['fld_name'];
//获取数据
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$sql2= "SELECT v.fld_time as time,v.fld_value as value,va.fld_name as variablename FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id WHERE v.fld_variable_id=$variable and v.fld_site_id=$site AND v.fld_time>='$start' AND v.fld_time<='$end' ORDER BY time ";
$sth2 = $db->query($sql2);
//$rows2 = $sth2->fetchAll();
$head = "Time,Variable,Value, \n";
$html="";
while ($v = $sth2->fetch())
{
//组装数据
if ($v['time']>=$start && $v['time']<$endtime)
{
$html.=$v['time'].",".$v['variablename'].",".$v['value']."\n";
} elseif ($v['time']>=$endtime) {
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_".$varname."_".$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
$start=$endtime;
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$html=$v['time'].",".$v['variablename'].",".$v['value']."\n";
}
}
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename."_".$varname."_".$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
print $sitename.'--'.$varname."\r\n";
//给处理的数据做个标记result=0
$sql_up= "update users_pm_down set result=0 WHERE site=$site and variable=$variable and uid=$uid and result=-1 and type='down'";
$db->query($sql_up);
$sql.=" and va.fld_variable_id in (select distinct variable from users_pm_down where starttime is not null and result=-1 and type='down' and uid=$uid) ";
}
$sql.=" order by va.fld_name";
$sth=$db->query($sql);
$rs=$sth->fetchAll();
$head = "Time";
$sql2= "select * from crosstab('SELECT v.fld_time as time,va.fld_name as variablename,v.fld_value as value
FROM tbl_value v left join tbl_variable_info va on v.fld_variable_id=va.fld_variable_id
WHERE v.fld_site_id=$site AND v.fld_time>=''$start'' AND v.fld_time<''$end'' ";
if ($variable==1)
{
$sql2.=" and va.fld_variable_id in (select distinct variable from users_pm_down where starttime is not null and result=-1 and type=''down'' and uid=$uid) ";
}
$sql2.=" ORDER BY time',
'select distinct va.fld_name from tbl_variable_info va left join tbl_value v on v.fld_variable_id=va.fld_variable_id
WHERE v.fld_site_id=$site AND v.fld_time>=''$start'' AND v.fld_time<''$end''";
if ($variable==1)
{
$sql2.=" and va.fld_variable_id in (select distinct variable from users_pm_down where starttime is not null and result=-1 and type=''down'' and uid=$uid) ";
}
$sql2.=" order by va.fld_name')
as ct(time timestamp without time zone";
foreach($rs as $k=>$var)
{
$head.=", ".$var['fld_name'];
$sql2.=",v".$k." real";
}
$head.="\n";
$sql2.=")";
//获取数据
$sth2 = $db->query($sql2);
//$rows2 = $sth2->fetchAll();
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$html="";
while ($v=$sth2->fetch())
{
//组装数据
if ($v['time']>=$start && $v['time']<$endtime)
{
$html.=$v['time'];
foreach ($rs as $k=>$var)
$html.=",".$v['v'.$k];
$html.="\n";
} elseif ($v['time']>=$endtime) {
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename.(($variable==-1)?"_all_":"_selected_").$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
$start=$endtime;
$endtime=date("Y-m-d",strtotime($start)+24*3600);
$html=$v['time'];
foreach ($rs as $k=>$var)
$html.=",".$v['v'.$k];
$html.="\n";
}
}
//写入文件
$resulttime=date("Ymd",strtotime($start));
$fp = fopen($aimDir_site.DIRECTORY_SEPARATOR.$sitename.(($variable==-1)?"_all_":"_selected_").$resulttime.".CSV","w+");
fwrite($fp,$head.$html); //写入数据
fclose($fp); //关闭文件句柄
print $sitename."\r\n";
$sql_up= "update users_pm_down set result=0 WHERE site=$site and uid=$uid and result=-1 and type='down'";
$db->query($sql_up);
}
}
}
}