merge heihedata branch r3812 to r3821 for trunk

This commit is contained in:
wlx 2013-07-22 11:27:11 +00:00
parent 3bfb53767a
commit ccdb4f2fbc
17 changed files with 2927 additions and 2152 deletions

View File

@ -56,12 +56,12 @@ table thead tr th {background:#EBF2F6;}
<td><a href="/data/<?= $item['uuid'] ?>"><?= $item['title'] ?></a></td>
<td><?= $item['doi'] ?></td>
<td>
<?php if(empty($item['ts_submitted'])) {?>
<a href="/admin/data/doi/ac/edit/uuid/<?= $item['uuid']?>">编辑</a>
<a href="/admin/data/doi/ac/convert/uuid/<?= $item['uuid']?>">导出</a>
<?php } ?>
<a href="javascript:void(0);" rel="/admin/data/doi/ac/verified/uuid/<?= $item['uuid']?>" class="verified_btn">验证</a>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<a href="javascript:void(0);" rel="/admin/data/doi/ac/verified/uuid/<?= $item['uuid']?>" class="verified_btn">验证</a>
<?php if(empty($item['ts_published'])) {?>
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
<?php } ?>
</td>
</tr>
<?php endforeach; ?>

View File

@ -53,7 +53,8 @@ ftp.user=newwestdc
ftp.password=westdcforsmall
download.max=5 //最多同时申请下载个数
page.max=10 //每页显示条目数
offline.template=../data/offline.pdf
offline.template=../data/offline.pdf
offline.heihetemplate=../data/heihe.pdf
offline.security=../data/security.pdf
offline.water_template=../data/water_offline.pdf
offline.font=../data/simhei.ttf

View File

@ -2805,7 +2805,7 @@ class AuthorController extends Zend_Controller_Action
$this->jsonexit($data);
return true;
}
$author = new Author($this->db);
if(!$author->checkAuthor($uuid))
{
@ -2828,7 +2828,7 @@ class AuthorController extends Zend_Controller_Action
$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));

File diff suppressed because it is too large Load Diff

View File

@ -6,11 +6,11 @@
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
$this->breadcrumb('离线申请');
$this->breadcrumb()->setSeparator(' > ');
$this->breadcrumb()->setSeparator(' > ');
$this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
?>
<?= $this->render('breadcrumbs.phtml') ?>
<div class="row">
<?= $this->render('breadcrumbs.phtml') ?>
<div class="row">
<div class="span3">
<div class="well sidebar-nav">
@ -18,13 +18,13 @@ $this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
</div><!--/.well -->
</div><!--/span-->
<div class="span9">
<h3>数据篮</h3>
<h3>数据篮</h3>
<hr />
<?php
if(!empty($this->msg))
{
echo $this->msg;
}
<?php
if(!empty($this->msg))
{
echo $this->msg;
}
?>
<ul class="nav nav-tabs">
@ -32,55 +32,55 @@ $this->nav[] = array('link'=>"/data/order",'title'=>'数据蓝');
<li id="Nav-order-offline2"><a href="/data/order/ac/offline2">正在提交的数据</a></li>
<li id="Nav-order-offline3"><a href="/data/order/ac/offline3">等待通过的申请</a></li>
<li id="Nav-order-offline4"><a href="/data/order/ac/offline4">已通过的申请</a></li>
<li id="Nav-order-online"><a href="/data/order/ac/online">在线数据</a></li>
<li id="Nav-order-online"><a href="/data/order/ac/online">在线数据</a></li>
</ul>
<!-- content -->
<!-- content -->
<?php if (!empty($this->paginator)) : ?>
<div class="pagenavi"><?= $this->paginator; ?></div>
<table class="table table-bordered table-striped">
<thead>
<th>时间</th>
<th>标题</th>
<th>
<?php if ($this->tabID=='order-offline1') {
echo '<a class="btn btn-primary" href="/data/order/apply/all">提交所有数据</a>一次最多5条';
} elseif ($this->tabID=='order-offline2') {
echo '<a class="btn btn-primary" href="/data/order/pdf/1">提交离线申请</a>';
} elseif ($this->tabID=='order-offline3') {
echo '申请状态';
} elseif ($this->tabID=='order-offline4') {
echo '通过时间';
}
?>
<th>标题</th>
<th>
<?php if ($this->tabID=='order-offline1') {
echo '<a class="btn btn-primary" href="/data/order/apply/all">提交所有数据</a>一次最多5条';
} elseif ($this->tabID=='order-offline2') {
echo '<a class="btn btn-primary" href="/data/order/pdf/1">提交离线申请</a>';
} elseif ($this->tabID=='order-offline3') {
echo '申请状态';
} elseif ($this->tabID=='order-offline4') {
echo '通过时间';
}
?>
</th>
</thead>
<tbody>
<?php foreach($this->paginator as $order) : ?>
<?php foreach($this->paginator as $order) : ?>
<tr>
<td><?php echo date('Y-m-d H:i:s',strtotime($order['ts_created'])); ?></td>
<td><a href="<?php echo $order['uuid']; ?>"><?php echo $order['title']; ?></a></td>
<td>
<?php
if ($this->tabID=='order-offline1') {
<td><a href="/data/<?php echo $order['uuid']; ?>"><?php echo $order['title']; ?></a></td>
<td>
<?php
if ($this->tabID=='order-offline1') {
echo '<a href="/data/order/apply/'.$order['id'].'" class="btn btn-primary">提交</a>
<a href="/data/order/cancel/'.$order['id'].'" class="btn">取消</a>';
} elseif ($this->tabID=='order-offline2') {
<a href="/data/order/cancel/'.$order['id'].'" class="btn">取消</a>';
} elseif ($this->tabID=='order-offline2') {
switch($order['status']) {
case 2:
echo "请生成PDF申请表";
echo ' <a class="btn" href="/data/order/cancel/'.$order['id'].'">取消</a>';
break;
case 3:
echo "请打印签字然后扫描或拍照申请表并email或邮寄";
echo "请打印签字扫描为pdf并email或邮寄";
break;
default:
break;
}
} elseif ($this->tabID=='order-offline3') {
}
} elseif ($this->tabID=='order-offline3') {
switch($order['status']) {
case 3:
echo "请打印签字然后扫描或拍照申请表并email或邮寄";
echo "请打印签字扫描为pdf并email或邮寄";
break;
case 4:
echo "已收到申请,请等待审批。日期:";echo date('Y-m-d',strtotime($order['ts_received']));
@ -90,18 +90,18 @@ if ($this->tabID=='order-offline1') {
break;
default:
break;
}
} elseif ($this->tabID=='order-offline4') {
echo date('Y-m-d',strtotime($order['ts_approved']));
}
?>
}
} elseif ($this->tabID=='order-offline4') {
echo date('Y-m-d',strtotime($order['ts_approved']));
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</table>
<?php endif; ?>
<!-- /content -->
</div><!--/span-->
</div><!--/row-->
</div><!--/row-->
<script>$('#Nav-<?= $this->tabID?>').addClass("active");</script>

View File

@ -17,25 +17,106 @@
</div><!--/span-->
<div class="span9">
<h3>离线申请提交</h3>
<h4>数据清单</h4>
<h4>数据清单</h4>
<blockquote>
<ul class="unstyled">
<?php foreach ($this->data2 as $i=>$md) : ?>
<li><?php echo ($i+1).". ".$md['title']; ?></li>
<?php endforeach; ?>
</ul></blockquote>
<hr />
<h4>申请表填写说明</h4>
<hr />
<h4>申请表填写说明</h4>
<blockquote>
<p class="text-info">其中用途部分,请填写您的详细使用目的;项目类型请从列表中选择,若无对应的项目支持,请选择其他项目工程;如项目无编号信息,则填写“无”;硕博论文请在用途中注明。</p>
<p class="text-info">其中用途部分,请填写您的详细使用目的;项目类型请从列表中选择,若无对应的项目支持,请选择其他项目工程;如项目无编号信息,则填写“无”;硕博论文请在用途中注明。</p>
<p class="text-success">详细准确的信息能使您更快通过申请。(数据提供者会根据您提供的信息来进行决策判断)</p></blockquote>
<h4>申请表(请务必填写真实信息以便审核通过)</h4>
<?php if ($this->messages): foreach($this->messages as $msg): ?>
<div class="alert"><?php echo $msg; ?></div>
<?php endforeach;endif; ?>
<?php if ($this->msg) : ?>
<div class="alert"><p><?php echo $this->msg; ?></div>
<?php echo $this->msg; ?>
<?php endif; ?>
<?php echo $this->form;?>
<?php if ($this->error) : ?>
<?php echo $this->error; ?>
<?php endif; ?>
<form id="OfflinePdf" enctype="application/x-www-form-urlencoded" class="form-horizontal" action="" method="post">
<div class="control-group">
<label class="control-label" name="realname">真实姓名</label>
<div class="controls">
<input type="text" name="realname" id="realname" value="<?= empty($this->formData['realname']) ? "":$this->formData['realname']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="email">E-Mail</label>
<div class="controls">
<input type="text" name="email" id="email" value="<?= empty($this->formData['email']) ? "":$this->formData['email']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="phone">电话</label>
<div class="controls">
<input type="text" name="phone" id="phone" value="<?= empty($this->formData['phone']) ? "":$this->formData['phone']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="unit">单位</label>
<div class="controls">
<input type="text" name="unit" id="unit" value="<?= empty($this->formData['unit']) ? "":$this->formData['unit']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="address">联系地址</label>
<div class="controls">
<input type="text" name="address" id="address" value="<?= empty($this->formData['address']) ? "":$this->formData['address']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="postcode">邮编</label>
<div class="controls">
<input type="text" name="postcode" id="postcode" value="<?= empty($this->formData['postcode']) ? "":$this->formData['postcode']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project_id">项目编号</label>
<div class="controls">
<input type="text" name="project_id" id="project_id" value="<?= empty($this->formData['project_id']) ? "":$this->formData['project_id']?>" helper="formText"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project_type">项目类型</label>
<div class="controls">
<select name="project_type" id="project_type" helper="formSelect">
<option value="" label="请选择项目类型" <?= empty($this->formData['project_type']) ? 'selected="selected"':"" ?>>请选择项目类型</option>
<?php foreach($this->projectType as $k=>$v) {?>
<option value="<?= $v ?>" <?= $this->formData['project_type'] == $v ? 'selected="selected"':"" ?>><?= $k ?></option>
<?php }?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" name="project_title">项目名称</label>
<div class="controls">
<input type="text" name="project_title" id="project_title" value="<?= empty($this->formData['project_title']) ? "":$this->formData['project_title']?>" helper="formText" class="input-block-level"> </div>
</div>
<div class="control-group">
<label class="control-label" name="project">用途<br/>(请详细描述使用目的)</label>
<div class="controls">
<textarea name="project" id="project" helper="formTextarea" rows="3" class="input-block-level" cols="80">
<?= empty($this->formData['project']) ? "":$this->formData['project']?>
</textarea> </div>
</div>
<div class="control-group">
<div class="controls">
<input type="hidden" name="id" value="8018" helper="formHidden" id="id">
<input type="submit" name="save" id="savebutton" value="预览PDF" class="btn">
<input type="submit" name="submit" id="submitbutton" value="提交申请到数据中心" class="btn btn-primary">
</div>
</div>
</form>
</div><!--/span-->
</div>

View File

@ -21,7 +21,7 @@ $this->nav[] = array('link'=>"/heihe/offline",'title'=>'离线数据浏览');
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<h4 class="media-heading"><a href="/heihe/view/uuid/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>

View File

@ -21,7 +21,7 @@ $this->nav[] = array('link'=>"/heihe/offline",'title'=>'在线数据浏览');
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<h4 class="media-heading"><a href="/heihe/view/uuid/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>

View File

@ -5,36 +5,70 @@ require_once('fpdi/fpdi.php');
class ApplicantPDF extends FPDI
{
public $template;//模板文件的路径
public $heihetemplate;//模板文件的路径
public $data;//包含具体的数据,数组
public $fontsize=10;
function __construct()
{
parent::__construct();
$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
}
function drawWestdc()
{
$pagecount = $this->setSourceFile($this->template);
$tplidx = $this->importPage(1);
$this->addPage();
$this->useTemplate($tplidx);
$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
$this->useTemplate($tplidx);
$this->SetFont('ugb','',$this->fontsize);
$this->setXY(71,44);
$this->setXY(74,43);
$this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['datalist']));
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['westdclist']));
$this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,225);
$this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,225);
$this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,225);
$this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,231);
$this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,231);
$this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d");
$this->setXY(174,231);
$this->setXY(174,230);
$this->Write($this->fontsize,$t);
}
function drawHeihe()
{
$pagecount = $this->setSourceFile($this->heihetemplate);
$tplidx = $this->importPage(1);
$this->addPage();
$this->useTemplate($tplidx);
$this->SetFont('ugb','',$this->fontsize);
$this->setXY(88,43);
$this->Write($this->fontsize,$this->data['realname']);
$this->SetXY(34,55);
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['heihelist']));
$this->setXY(30,100);
$this->MultiCell(166,4,trim($this->data['project']));
//$this->setXY(34,239);
//$this->Write($this->fontsize,$this->data['realname']);
$this->setXY(32,223);
$this->Write($this->fontsize,$this->data['unit']);
$this->setXY(112,223);
$this->Write($this->fontsize,$this->data['email']);
$this->setXY(174,223);
$this->Write($this->fontsize,$this->data['postcode']);
$this->setXY(32,230);
$this->Write($this->fontsize,$this->data['address']);
$this->setXY(112,230);
$this->Write($this->fontsize,$this->data['phone']);
$t=date("Y-m-d");
$this->setXY(174,230);
$this->Write($this->fontsize,$t);
}
function addRef($mds)

View File

@ -0,0 +1,94 @@
<?php
namespace data;
class Favorite extends Zend_Controller_Plugin_Abstract
{
public $db; //传入PDO对象.
private $auth = NULL; //Zend_Auth 对象
//使用到的公共变量
public $tbl_metadata = "metadata"; //元数据
public $tbl_favorite = "favorite"; //用户收藏表
public $fav_max;
function __construct($db)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->fav_max = empty($this->config->favorite->limit) ? 50 : $this->config->favorite->limit ;
}
function like($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
if(!is_numeric($uid))
{
$uid = \view::User('id');
}
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
{
return "参数错误";
}
if($this->checkUserFavNum($uid))
{
if($this->checkAlreadyLike($uuid,$uid))
{
$sql = "INSERT INTO {$this->tbl_favorite} (uid,uuid) VALUES ($uid,'$uuid')";
if($this->db->exec($sql))
{
return true;
}else{
return "收藏失败,请重试";
}
}else{
return "您已经收藏过此数据";
}
}else{
return "您的收藏量已达到系统允许的上限";
}
}
//检查是否达到允许的收藏上限
public function checkUserFavNum($uid)
{
$sql = "SELECT count(id) as c FROM {$this->tbl_favorite} WHERE uid=$uid";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if($row['c'] >= $this->fav_max)
{
return false;
}else{
return true;
}
}
//检查是否已经搜藏过
public function checkAlreadyLike($uuid,$uid)
{
$sql = "SELECT * FROM {$this->tbl_favorite} WHERE uid=$uid AND uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['uuid']) && !empty($row['uuid']))
{
return false;
}else{
return true;
}
}
}

View File

@ -0,0 +1,293 @@
<?php
namespace order;
include_once("helper/view.php");
class Order
{
private $db;
private $config;
protected $events = NULL;
public $projectType = array(
"国家973计划项目课题" => "国家973计划项目课题",
"国家863计划课题"=>"国家863计划课题",
"国家级科技支撑课题" => "国家级科技支撑课题",
"国家级科技重大专项" => "国家级科技重大专项",
"国家级国家重大工程" => "国家级国家重大工程",
"国家级国家自然科学基金" => "国家级国家自然科学基金",
"国际合作项目"=>"国际合作项目",
"省部级项目" => "省部级项目",
"其他项目工程" => "其他项目工程",
); //申请中的项目类型
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
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;
}
/*************
status:
1 开始进入离线申请申请程序中
2 填写并提交离线申请表
3 邮寄离线申请表
4 收到离线申请表
5 处理离线申请表
10:离线申请完成?
-1: 取消了在线下载进程
**************/
//添加到数据篮
public function addOrder($uuid,$uid = 0){
if(empty($uid))
{
$uid = \view::User('id');
}
if(!is_numeric($uid))
{
$uid = \view::User('id');
}
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
{
return "参数错误";
}
$results = $this->events()->trigger('submit', $this, compact('uuid','uid'));
$data = $results->bottom();
if($data !== true)
{
return $data;
}
$results = $this->events()->trigger('checksource', $this, compact('uuid'));
$data = $results->bottom();
if($data !== true)
{
return array("datetype"=>$data,"uuid"=>$uuid);
}
if($this->pushToDataorder($uuid,$uid) === true)
{
return true;
}else{
return "操作中出现错误,请重试";
}
}//addOrder
//放到数据篮中
public function pushToDataorder($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql="insert into dataorder (uuid,ts_created,userid,status) values(?,now(),?,?)";
$rs = $this->db->query($sql,array($uuid,$uid,1));
if($rs)
{
return true;
}else{
return false;
}
}//pushToDataorder
//提交
public function apply($id,$uid = 0)
{
if(!is_numeric($id) || !is_numeric($uid))
{
return "参数错误";
}
if(empty($uid))
{
$uid = \view::User('id');
}
if($id == -1)
{
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$uid);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到问题,请重试";
}
}
if($id > 0)
{
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=$uid and id=?",$id);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到问题,请重试";
}
}
return "参数错误";
}//apply()
//删除
public function del($id,$uid = 0)
{
if(!is_numeric($id) || !is_numeric($uid))
{
return "参数错误";
}
if(empty($uid))
{
$uid = \view::User('id');
}
if($id > 0)
{
$sql = $this->db->quoteInto("delete from dataorder where userid=$uid and status in (1,2) and id=?",$id);
if($this->db->exec($sql))
{
return true;
}else{
return "处理中遇到错误,请重试";
}
}
return "参数错误";
}
//发送邮件
public function SendEmail(){
}
//生成pdf
public function pdf($uid = 0)
{
}
//获得要生成pdf的信息
public function getOrderItemForPdf($uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select m.title||'('||m.filesize::text||'MB)' as title,m.ts_published,date_part('year',doi.ts_published) as publish_year,m.citation,m.suppinfo,
array_to_string(ARRAY(
select r.reference from mdref mr left join reference r on mr.refid=r.id
where mr.reftype=3 and mr.uuid=d.uuid order by mr.place),'\n'::text) as reference,
array_to_string(array(
select fund.fund_type||':'||fund.title||'(编号:'||fund.fund_id||')'
from fund left join mdfund on fund.id=mdfund.fid where mdfund.uuid=d.uuid order by mdfund.place),'\n'::text) as fund,
doi.doi as datadoi,doi.authors,doi.publisher,doi.title as doititle,doi.author_en,doi.publisher_en,doi.title_en
from dataorder d left join metadata m on d.uuid=m.uuid left join datadoi doi on doi.uuid=d.uuid
where d.status=2 and d.userid=? order by d.ts_created desc
";
$rows = $this->db->fetchAll($sql,array($uid));
return $rows;
}
public function makePdf($formData,$userid = 0)
{
}
public function PdfOrderSave($formData,$uid = 0)
{
}
//checkPdfOrderField 检查PDF申请表的信息
public function checkPdfOrderField($formData)
{
if(empty($formData['realname']))
{
return "请输入真实姓名";
}
if(empty($formData['email']))
{
return "请输入Email";
}
if (!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$formData['email']))
{
return "请输入正确的电子邮件地址";
}
if(empty($formData['phone']))
{
return "请输入联系电话";
}
if(empty($formData['unit']))
{
return "请输入单位";
}
if(empty($formData['address']))
{
return "请输入地址";
}
if(empty($formData['postcode']) || !is_numeric($formData['postcode']))
{
return "请输入邮政编码";
}
if(empty($formData['project_id']))
{
return "请输入项目编号";
}
if(empty($formData['project_type']))
{
return "请选择项目类型";
}
if(empty($formData['project_title']))
{
return "请填写项目标题";
}
if(empty($formData['project']))
{
return "请填写用途";
}
return true;
}//checkPdfOrderField
}

View File

@ -0,0 +1,14 @@
<?php
namespace order\listener;
//接口 需要实现的Listener中的方法
interface OrderEvents
{
//申请提交事件
public function submit(\Zend_EventManager_Event $e);
//检查数据来源事件
//区别是直接下载的数据或是wsn来源的数据
//wsn来源的数据需要用户在提交申请的时候选择要下载的内容
public function checksource(\Zend_EventManager_Event $e);
}

View File

@ -0,0 +1,37 @@
<?php
namespace order\listener;
//侦听
class OrderListener implements \Zend_EventManager_ListenerAggregate
{
private $db;
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
public function attach(\Zend_EventManager_EventCollection $events)
{
$this->attachOnOrder($events);
}
public function detach(\Zend_EventManager_EventCollection $events)
{
}
public function attachOnOrder(\Zend_EventManager_EventCollection $events)
{
$mountedClass = new \order\mount\OrderOperate();
$events->attach('submit', array($mountedClass, 'submit'), 100);
$events->attach('checksource',array($mountedClass,'checksource'),100);
}
}

View File

@ -0,0 +1,134 @@
<?php
namespace order\mount;
include_once("helper/view.php");
//事件中存在的操作
class OrderOperate implements \order\listener\OrderEvents
{
private $db;
private $config;
//!!!!!!important!!!!!
//不同项目使用时是否要修改此项??
public $tbl_metadata = "normalmetadata";
public $tbl_dataorder = "dataorder";
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
}
//提交申请
public function submit(\Zend_EventManager_Event $e)
{
$uuid = $e->getParam('uuid');
$uid = $e->getParam('uid');
try{
if($this->checkOrderUUID($uuid) !== false)
{
return "此数据尚未正式发布,还不能申请";
}
if($this->checkOrderNum(true,$uid) === false)
{
return "您的数据篮中存放的数据已达到可申请的数量";
}
if($this->checkOrderHas($uuid,$uid))
{
return "此数据已经在数据篮中";
}
}catch(Exception $e)
{
\view::Dump($e->getMessage());
}
return true;
}
//检查元数据是否已发布(存在于metadata表中)
public function checkOrderUUID($uuid)
{
$sql = "select count(*) as mdcount from {$this->tbl_metadata} where uuid=?";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid));
if($rs['mdcount'] == 0)
{
return true;
}else{
return false;
}
}
//检查用户是否已经提交了该数据的申请
public function checkOrderHas($uuid,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=$uid and uuid=? and status in (1,2,3,4)";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uuid));
if($rs['datacount']>=1)
{
return true;
}else{
return false;
}
}//CheckOrderHas()
//检查用户已经在数据篮中的申请的数量
// 已经超过返回 true
public function checkOrderNum($bool = true,$uid = 0)
{
if(empty($uid))
{
$uid = \view::User('id');
}
$sql = "select count(*) as datacount from {$this->tbl_dataorder} where (ts_approved is null) and userid=? and status>0 and status<3";
$rs = $this->db->fetchRow($this->db->quoteInto($sql,$uid));
if($bool === true)
{
if($rs['datacount'] <= $this->config->download->max - 1)
{
return true;
}else{
return false;
}
}else{
return $rs['datacount'];
}
}//checkOrderNum
//检查数据来源
public function checksource(\Zend_EventManager_Event $e)
{
$uuid = $e->getParam('uuid');
$sql = "SELECT * FROM wsn_metadata WHERE uuid='$uuid'";
$rs = $this->db->query($sql);
$row = $rs->fetch();
if(isset($row['uuid']) && !empty($row['uuid']))
{
return "wsn";
}else{
return true;
}
}
}

BIN
data/heihe.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,43 @@
var method = {};
//收藏数据
method.like = function(uuid,btn){
text = $(btn).text();
current_event = $(btn).attr('onclick');
$.ajax({
type:"GET",
url:"/data/like/",
data:'uuid=' + uuid,
success:function(data){
if (typeof(data)=='object')
{
if(typeof(data.error) !== 'undefined')
{
Alert(data.error);return false;
}else{
Alert("收藏成功!");
}
}
else{
Alert('出现错误,请稍后再试');
}
},
beforeSend:function(){
$(btn).removeAttr('onclick');
$(btn).html('<img src="/images/ajax-load-small.gif" />');
},
timeout: 15000,
error: function(){
Alert('处理中出现错误,请刷新页面后重试');
},
complete:function(){
$(btn).attr('onclick',current_event);
$(btn).html(text);
}
});
}
//文件列表
method.filelist = {
get : function(uuid){
html ='<div id="window-outter">'
@ -279,7 +317,7 @@ function setRectangle(east,west,south,north){
editable: false
});
rectangle.setMap(map);
rectangle.setMap(map);
}else{