#222 增加了watermdview中评论的ajax分页功能

This commit is contained in:
Li Jianxuan 2011-10-28 03:18:44 +00:00
parent 8b31b302f8
commit 179e757ea3
3 changed files with 51 additions and 13 deletions

View File

@ -645,7 +645,7 @@ class DataController extends Zend_Controller_Action
$mail=new WestdcMailer($this->view->config->smtp); $mail=new WestdcMailer($this->view->config->smtp);
$mail->setBodyText($mailtp->getBody()); $mail->setBodyText($mailtp->getBody());
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
$mail->addTo($this->view->config->service->email); $mail->addTo('la5c@qq.com');
$mail->setSubject($mailtp->getSubject()); $mail->setSubject($mailtp->getSubject());
$mail->send(); $mail->send();
$formdata['content']=''; $formdata['content']='';
@ -671,16 +671,24 @@ class DataController extends Zend_Controller_Action
if (empty($uuid)) die(); if (empty($uuid)) die();
$sql="select * from comments where uuid=? order by id desc"; $sql="select * from comments where uuid=? order by id desc";
$comments=$this->db->fetchAll($sql,array($uuid)); $comments=$this->db->fetchAll($sql,array($uuid));
if ($comments)
$paginator = Zend_Paginator::factory($comments);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(5);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('data/pagination_ajax.phtml');
if ($paginator)
{ {
foreach($comments as $c) foreach($paginator as $c)
{ {
//$author=$this->view->escape($c['author']); //$author=$this->view->escape($c['author']);
$author=$c['author']; $author=$c['author'];
$author=($c['userid'])?"<strong>".$author."</strong>":$author; $author=($c['userid'])?"<strong>".$author."</strong>":$author;
$author=($c['url'])?'<a href="'.$c['url'].'">'.$author.'</a>':$author; $author=($c['url'])?'<a href="'.$c['url'].'">'.$author.'</a>':$author;
print "<div class='comment-content'><span>".$author." 发表于".date('Y-m-d H:i:s',strtotime($c['ts_created']))."</span><p>".($c['content'])."</p></div>"; print "<div class='comment-content'><span class='title'>".$author." 发表于".date('Y-m-d H:i:s',strtotime($c['ts_created']))."</span><p>".($c['content'])."</p></div>";
} }
echo '<div class="paginator">'.$paginator.'</div>';
}//else echo "<li>No comments.</li>"; }//else echo "<li>No comments.</li>";
} }

View File

@ -0,0 +1,26 @@
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="javascript:void(0);" onclick="ajaxpage(<?php echo $this->previous;?>)">&lt; Previous</a>
<?php else: ?>
<span class="disabled">&lt; Previous</span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="javascript:void(0);" onclick="ajaxpage(<?php echo $page;?>)"><?= $page; ?></a>
<?php else: ?>
<span class="current"><?= $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="javascript:void(0);" onclick="ajaxpage(<?php echo $this->next;?>)">Next &gt;</a>
<?php else: ?>
<span class="disabled">Next &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>

View File

@ -94,14 +94,14 @@ else
<?php endif; ?> <?php endif; ?>
<li id="datatype">数据共享方式:<?php if ($md->datatype) print "离线"; else print "在线(可直接下载)";?> <a href="#" id="show-list" rel="<?php echo $md->uuid;?>">文件列表</a></li> <li id="datatype">数据共享方式:<?php if ($md->datatype) print "离线"; else print "在线(可直接下载)";?> <a href="#" id="show-list" rel="<?php echo $md->uuid;?>">文件列表</a></li>
</ul> </ul>
<div id="linkurl"> <div id="linkurl">
<?php if ($md->status>0 and $md->status<5) : ?> <?php if ($md->status>0 and $md->status<5) : ?>
<a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a> <a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a>
<?php else : if (!$md->datatype) : ?> <?php else : if (!$md->datatype) : ?>
<a href="javascript:$('todownload').show();todownload(1);"><img src="/images/download.png" title="直接下载" /></a> <a href="javascript:$('todownload').show();todownload(1);"><img src="/images/download.png" title="直接下载" /></a>
<?php endif; ?> <?php endif; ?>
<a href="/data/order/uuid/<?php echo $md->uuid; ?>"><img src="/images/order.png" title="免费!离线申请此数据(在线数据和离线数据都可申请)"/></a> <a href="/data/order/uuid/<?php echo $md->uuid; ?>"><img src="/images/order.png" title="免费!离线申请此数据(在线数据和离线数据都可申请)"/></a>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>
@ -250,14 +250,15 @@ echo '</li>';
</div> </div>
<?php endif; ?> <?php endif; ?>
<hr /> <hr />
<div id="comments"> <div id="comments">
<?php if ($md->status>0 and $md->status<5) : ?> <?php if ($md->status>0 and $md->status<5) : ?>
<p class="strong">此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!<a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a></p> <p class="strong">此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!<a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a></p>
<?php else : ?> <?php else : ?>
<h2>数据评论</h2> <h2>数据评论</h2>
<div id="allcomments"> <div id="allcomments">
<div id="loading"><img src="/images/loading.gif" />评论加载中</div>
</div> </div>
<?php echo $this->commentForm; ?> <?php echo $this->commentForm; ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -298,7 +299,8 @@ function todownload(ft)
function loading(){$('loading').style.display = 'block';} function loading(){$('loading').style.display = 'block';}
function done(){$('loading').style.display = 'none';} function done(){$('loading').style.display = 'none';}
function reportError(request){alert('Sorry. There was an error.');} function reportError(request){alert('Sorry. There was an error.');}
var request_pars = ''; //请求参数 function ajaxpage(page){
var request_pars = 'page='+page; //请求参数
var myAjax = new Ajax.Updater('allcomments', '/data/comment/uuid/<?= $md->uuid; ?>',{ var myAjax = new Ajax.Updater('allcomments', '/data/comment/uuid/<?= $md->uuid; ?>',{
method : 'get', // http 请求方法,get or post method : 'get', // http 请求方法,get or post
parameters : request_pars, // 请求参数 parameters : request_pars, // 请求参数
@ -306,6 +308,8 @@ function reportError(request){alert('Sorry. There was an error.');}
onLoading : loading, // 加载时 onLoading : loading, // 加载时
onComplete : done // 读取完毕 onComplete : done // 读取完毕
}); });
}
ajaxpage(0);
//google map //google map
var map = new GMap2(document.getElementById("watermap")); var map = new GMap2(document.getElementById("watermap"));
var plotbounds=new GLatLngBounds(new GLatLng(<?= $md->south; ?>,<?= $md->west; ?>),new GLatLng(<?= $md->north; ?>,<?= $md->east; ?>)); var plotbounds=new GLatLngBounds(new GLatLng(<?= $md->south; ?>,<?= $md->west; ?>),new GLatLng(<?= $md->north; ?>,<?= $md->east; ?>));