#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

@ -256,6 +256,7 @@ echo '</li>';
<?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; ?>
@ -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; ?>));