Ticket #148 添加了提交下载用途的功能

This commit is contained in:
Li Jianxuan 2011-09-08 03:12:41 +00:00
parent 1ed52e92e9
commit 0f7925594b
2 changed files with 187 additions and 29 deletions

View File

@ -670,6 +670,142 @@ class DataController extends Zend_Controller_Action
}
}//else echo "<li>No comments.</li>";
}
function creatform($datas) {
return '
<div class="downloadtip">温馨提示:您需要填写以下信息才可以下载该数据</div>
<form id="todownloadform" name="todownloadform" action="/data/todownload/">
<table>
<tr><td>真实姓名</td><td><input type="text" name="username" value="'.$datas['username'].'" /></td></tr>
<tr><td>单位名称</td><td><input type="text" name="unit" value="'.$datas['unit'].'"/></td></tr>
<tr><td>联系电话</td><td><input type="text" name="phone" value="'.$datas['phone'].'"/></td></tr>
<tr><td>联系地址</td><td><input type="text" name="address" value="'.$datas['address'].'"/></td></tr>
<tr><td>邮政编码</td><td><input type="text" name="postcode" value="'.$datas['postcode'].'"/></td></tr>
<tr><td>电子邮箱</td><td><input type="text" name="email" value="'.$datas['email'].'"/></td></tr>
<tr><td>项目说明</td><td><textarea name="project">'.$datas['project'].'</textarea></td></tr>
</table>
请您填写完整的数据用途信息,包括项目类型、编号、题目、负责人等信息;若仅用于论文写作,请告知研究题目或主要内容,并注明导师姓名;其他用途如实注明即可。清晰明确的数据用途有助于我们更快得审核和通过申请,也会使您更快获得数据!<br />
例一:<br />
项目类型973<br />
项目名称:飞行终端区复杂场景建模的理论与方法子课题:基于多源遥感影像的目标和场景三维重建研究<br />
项目编号2010CB731801<br />
项目负责人:邵振峰<br />
使用目的:用于模拟基于多源遥感影像的目标和场景<br />
<br />
例二:<br />
硕士毕业论文:《全波形激光雷达数据处理研究》,导师:李传荣研究员。<br />
<input type="button" value="提交" onclick="todownload(0)" class="btn" />
<input type="hidden" name="submited" value="1" />
</form>';
}
/*
* 判断用户是否填写了申请信息
* @param string $uuid
* @param int $userid
*/
function todownloadAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_request->getParam('uuid');
$ft = $this->_request->getParam('ft');
if (empty($uuid)) $this->_redirect('/data');
$datas = array();
$submited = $this->_request->getParam('submited');
$datas['username'] = $this->_request->getParam('username');
$datas['unit'] = $this->_request->getParam('unit');
$datas['phone'] = $this->_request->getParam('phone');
$datas['address'] = $this->_request->getParam('address');
$datas['postcode'] = $this->_request->getParam('postcode');
$datas['email'] = $this->_request->getParam('email');
$datas['project'] = $this->_request->getParam('project');
$userid=Zend_Auth::getInstance()->getIdentity()->id;
$form=$this->creatform($datas);
if (!empty($submited) && $ft==0){
foreach($datas as $k=>$v)
{
if(empty($v))
{
echo $form.'<script>alert("每一项内容都需要填写")</script>';
exit();
}
$datas[$k]=preg_replace("/\"/i","'",$v);
}
if(!is_numeric($datas['postcode']))
{
echo $form.'<script>alert("联系电话和邮政编码请填写数字")</script>';
exit();
}
if(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$datas['email']))
{
echo $form.'<script>alert("请填写正确的email地址")</script>';
exit();
}
$sql="insert into onlineapp (userid,username,unit,phone,address,postcode,project,uuid,email)
values ('$userid','{$datas['username']}','{$datas['unit']}','{$datas['phone']}','{$datas['address']}','{$datas['postcode']}','{$datas['project']}','$uuid','{$datas['email']}')
";
if($this->db->exec($sql))
{
echo "您的信息已经提交成功,可以进行下载。<br />
如果页面没有自动跳转,<a href='/data/download/uuid/$uuid'>请点击这里进入下载页面</a>
<script>self.location='/data/download/uuid/$uuid'</script>";
exit();
}
else {
echo $form.'<script>alert("服务器忙,请重试")</script>';
exit();
}
}else if( $ft==1 )
{
$testsql="select * from onlineapp where userid='$userid' and uuid='$uuid' order by id desc";
$result=$this->db->query($testsql);
$rows = $result->fetch();
if (empty($rows['id']))
{
$sql="select * from users where id='$userid'";
$result=$this->db->query($sql);
$rows = $result->fetch();
$datas['username'] = $rows['realname'];
$datas['unit'] = $rows['unit'];
$datas['phone'] = $rows['phone'];
$datas['address'] = $rows['address'];
//$datas['postcode'] = $rows['postcode'];
$datas['email'] = $rows['email'];
$datas['project'] = $rows['project'];
echo $this->creatform($datas);
exit();
}
else
{
$datas['username'] = $rows['username'];
$datas['unit'] = $rows['unit'];
$datas['phone'] = $rows['phone'];
$datas['address'] = $rows['address'];
$datas['postcode'] = $rows['postcode'];
$datas['email'] = $rows['email'];
$datas['project'] = $rows['project'];
echo $this->creatform($datas);
exit();
}
}
}
/*
* 数据下载根据UUID进行判断
* 一次只下载一个数据(一个元数据项)
@ -679,6 +815,18 @@ class DataController extends Zend_Controller_Action
$uuid=$this->_request->getParam('uuid');
if (empty($uuid)) $this->_redirect('/data');
$userid=Zend_Auth::getInstance()->getIdentity()->id;
/*
* 判断用户是否浑水摸鱼的去下载
$testsql="select id from onlineapp where userid='$userid' and uuid='$uuid'";
$result=$this->db->query($sql,$id);
$rows = $result->fetch();
if (empty($rows['id']))
{
$this->_redirect('/data/'.$uuid);
}
*/
// block end!
$this->view->username='westdc'.Zend_Auth::getInstance()->getIdentity()->id;
$sql=$this->db->quoteInto("select o.* from onlineresource o left join metadata m on o.uuid=m.uuid where m.datatype=0 and m.uuid=?",$uuid);
$rows=$this->db->fetchAll($sql);

View File

@ -97,7 +97,7 @@ else
</ul>
<div id="linkurl">
<?php if (!$md->datatype) : ?>
<a href="/data/download/uuid/<?php echo $md->uuid; ?>"><img src="/images/download.png" title="直接下载" /></a>
<a href="javascript:$('todownload').show();todownload(1);"><img src="/images/download.png" title="直接下载" /></a>
<?php endif; ?>
<a href="/data/order/uuid/<?php echo $md->uuid; ?>"><img src="/images/order.png" title="免费!离线申请此数据(在线数据和离线数据都可申请)"/></a>
</div>
@ -252,30 +252,6 @@ echo '</li>';
<h2>数据评论</h2>
<div id="allcomments">
</div>
<script type="text/javascript">
function loading()
{
$('loading').style.display = 'block';
}
function done()
{
$('loading').style.display = 'none';
}
function reportError(request)
{
alert('Sorry. There was an error.');
}
var request_pars = ''; //请求参数
var myAjax = new Ajax.Updater('allcomments', '/data/comment/uuid/<?= $md->uuid; ?>',{
method : 'get', // http 请求方法,get or post
parameters : request_pars, // 请求参数
onFailure : reportError, // 失败的时候调用 reportError 函数处理
onLoading : loading, // 加载时
onComplete : done // 读取完毕
});
</script>
<?php echo $this->commentForm; ?>
</div>
@ -290,8 +266,42 @@ function reportError(request)
</div>
</div>
</div>
<div id="todownload" style="display:none;">
<div class="closeox"><a href="javascript:void(0);" onclick="$('todownload').hide()">[关闭]</a></div>
<div id="returninfo">
</div>
</div>
<script type="text/javascript" charset="utf-8">
//ajax download
function todownload(ft)
{
var request_url = "/data/todownload/uuid/<?php echo $md->uuid;?>/ft/"+ft;
if($('todownloadform')) {var request_pars = $('todownloadform').serialize();}else{var request_pars = '';}
var myAjax = new Ajax.Updater('returninfo', request_url,{
method : 'get',
parameters : request_pars,
onFailure : reportError,
onLoading : loading,
onComplete : done,
evalScripts: true
});
}
//ajax comment
function loading(){$('loading').style.display = 'block';}
function done(){$('loading').style.display = 'none';}
function reportError(request){alert('Sorry. There was an error.');}
var request_pars = ''; //请求参数
var myAjax = new Ajax.Updater('allcomments', '/data/comment/uuid/<?= $md->uuid; ?>',{
method : 'get', // http 请求方法,get or post
parameters : request_pars, // 请求参数
onFailure : reportError, // 失败的时候调用 reportError 函数处理
onLoading : loading, // 加载时
onComplete : done // 读取完毕
});
//google map
var map = new GMap2(document.getElementById("watermap"));
var plotbounds=new GLatLngBounds(new GLatLng(<?= $md->south; ?>,<?= $md->west; ?>),new GLatLng(<?= $md->north; ?>,<?= $md->east; ?>));
var zoomlevel=map.getBoundsZoomLevel(plotbounds);