PHPWIND[民间论坛]数据搬迁导致丢失严重,用户数据基本全部损坏,十分遗憾来自phpwind.me的远古记忆
官方楼中楼修改
需要修改的文件比较多,大家先看看页末的效果再决定是否修改
主要修改功能:
1.楼中楼回复的排序,默认为按时间降序,现在改为升序
2.重写帖子的楼层数
3.修改楼中楼回复帖子页面显示
4.解决修改后出现的分页问题
效果图在最下方
楼中楼回复的排序,默认为按时间降序,现在改为升序
src/service/forum/dao/PwPostsReplyDao.php 修改
$sql = $this->_bindSql('SELECT b.* FROM %s a LEFT JOIN %s b ON a.pid=b.pid WHERE a.rpid=? AND b.disabled=0 ORDER BY a.pid DESC %s', $this->getTable(), $this->getTable($this->_mergeTable), $this->sqlLimit($limit, $offset));
改成:
$sql = $this->_bindSql('SELECT b.* FROM %s a LEFT JOIN %s b ON a.pid=b.pid WHERE a.rpid=? AND b.disabled=0 ORDER BY a.pid ASC %s', $this->getTable(), $this->getTable($this->_mergeTable), $this->sqlLimit($limit, $offset));
重写帖子的楼层数
src/service/forum/PwThread.php
countPostByTidUnderPid($tid, $pid)统计帖子(A)中的ID小于回复(B)的回复个数
src/service/dao/PwPostsDao.php
countPostByTidUnderPid($tid, $pid) 修改
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0');
改成:
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0 AND rpid=0');
修改帖子页面显示
src/service/forum/PwThread.php
function getPostByTid($tid, $limit = 20, $offset = 0, $asc = true)获取一个帖子的回复列表
src/service/dao/PwPostsDao.php
public function countPostByTidUnderPid($tid, $pid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid, $pid));
}
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
改成:
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 AND rpid=0 ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
src/service/dao/PwPostsDao.php
统计用户(A)在帖子(B)中的回复数
public function countPostByTidAndUid($tid, $uid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND created_userid=? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid, $uid));
}
public function getPostByTidAndUid($tid, $uid, $limit, $offset, $asc) {
$orderby = $asc ? 'ASC' : 'DESC';
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 AND rpid=0 AND created_userid=? ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
$smt = $this->getConnection()->createStatement($sql);
return $smt->queryAll(array($tid, $uid), 'pid');
}
$this->thread->info['replies'] + $this->thread->info['reply_topped'] + 1;
replies得减去楼中楼的回复数、
效果:
楼中楼回复
帖子列表,没有了楼中楼回复:
样式大家可以去适应自己的版本,我下载的官方直接改的,所以是官方版,要改成百度贴吧那种,只需要在风格上改改就OK了。
主要修改功能:
1.楼中楼回复的排序,默认为按时间降序,现在改为升序
2.重写帖子的楼层数
3.修改楼中楼回复帖子页面显示
4.解决修改后出现的分页问题
效果图在最下方
楼中楼回复的排序,默认为按时间降序,现在改为升序
src/service/forum/dao/PwPostsReplyDao.php 修改
$sql = $this->_bindSql('SELECT b.* FROM %s a LEFT JOIN %s b ON a.pid=b.pid WHERE a.rpid=? AND b.disabled=0 ORDER BY a.pid DESC %s', $this->getTable(), $this->getTable($this->_mergeTable), $this->sqlLimit($limit, $offset));
改成:
$sql = $this->_bindSql('SELECT b.* FROM %s a LEFT JOIN %s b ON a.pid=b.pid WHERE a.rpid=? AND b.disabled=0 ORDER BY a.pid ASC %s', $this->getTable(), $this->getTable($this->_mergeTable), $this->sqlLimit($limit, $offset));
重写帖子的楼层数
src/service/forum/PwThread.php
countPostByTidUnderPid($tid, $pid)统计帖子(A)中的ID小于回复(B)的回复个数
src/service/dao/PwPostsDao.php
countPostByTidUnderPid($tid, $pid) 修改
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0');
改成:
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0 AND rpid=0');
修改帖子页面显示
src/service/forum/PwThread.php
function getPostByTid($tid, $limit = 20, $offset = 0, $asc = true)获取一个帖子的回复列表
src/service/dao/PwPostsDao.php
public function countPostByTidUnderPid($tid, $pid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND pid<? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid, $pid));
}
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
改成:
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 AND rpid=0 ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
src/service/dao/PwPostsDao.php
统计用户(A)在帖子(B)中的回复数
public function countPostByTidAndUid($tid, $uid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND created_userid=? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid, $uid));
}
public function getPostByTidAndUid($tid, $uid, $limit, $offset, $asc) {
$orderby = $asc ? 'ASC' : 'DESC';
$sql = $this->_bindSql('SELECT * FROM %s WHERE tid=? AND disabled=0 AND rpid=0 AND created_userid=? ORDER BY created_time %s %s', $this->getTable(), $orderby , $this->sqlLimit($limit, $offset));
$smt = $this->getConnection()->createStatement($sql);
return $smt->queryAll(array($tid, $uid), 'pid');
}
$this->thread->info['replies'] + $this->thread->info['reply_topped'] + 1;
replies得减去楼中楼的回复数、
效果:
楼中楼回复
图片:效果.jpg
帖子列表,没有了楼中楼回复:
图片:效果2.jpg
样式大家可以去适应自己的版本,我下载的官方直接改的,所以是官方版,要改成百度贴吧那种,只需要在风格上改改就OK了。
+3
游客
⌘+回车发表评论
咪
zrj766
11年前
山西省太原市
0
好复杂啊
咪
risingsun
分页问题解决方案:
src/service/forum/srv/threadDisplay/PwCommonRead.php
修改:
public function execute() {
$this->total = $this->thread->info['pagereplies'] + $this->thread->info['reply_topped'] + 1;
$this->initPage($this->total);
list($start, $limit) = Pw::page2limit($this->page, $this->perpage);
if ($start == 0) {
$this->info['pid'] = 0;
$this->data[] =& $this->info; //地址引用,便于bulidRead同步修改
$this->info['aids'] && $this->_aids[] = 0;
$this->_uids[] = $this->info['created_userid'];
}
if ($this->info['pagereplies'] > 0) {
$offset = $start;
$offset == 0 ? $limit-- : $offset--;
$replies = array();
if ($this->thread->info['reply_topped']) {
if ($offset < $this->thread->info['reply_topped']) {
$replies = $this->_getToppedReply($limit, $offset);
$limit -= count($replies);
$offset = 0;
} else {
$offset -= $this->thread->info['reply_topped'];
}
}
if ($limit > 0) {
$replies = array_merge($replies, $this->thread->getReplies($limit, $offset, $this->asc));
}
foreach ($replies as $value) {
$this->data[] = $value;
$value['aids'] && $this->_aids[] = $value['pid'];
$this->_uids[] = $value['created_userid'];
}
}
$this->firstFloor = $start;
}
src/service/forum/bo/PwThreadBo.php
在function __construct($tid)添加:
//修改replies,让replies数量中不包含楼中楼回复数
$this->info['pagereplies'] = $this->_getThreadService()->countPostByTid($tid);
src/service/forum/PwThread.php
添加函数
/**
* 获取一个帖子的回复数量(新增)
*
* @param int $tid 帖子id
* @return int
*/
public function countPostByTid($tid) {
if (empty($tid)) return 0;
return $this->_getPostDao()->countPostByTid($tid);
}
src/service/forum/dao/PwPostsDao.php
添加函数:
/**
* 获取一个帖子的回复数量(新增)
*
* @param int $tid 帖子id
* @param int $limit
* @param int $offset
* @return int
*/
public function countPostByTid($tid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid));
}
楼主
12年前
内蒙古呼和浩特市
分页问题解决方案:
src/service/forum/srv/threadDisplay/PwCommonRead.php
修改:
public function execute() {
$this->total = $this->thread->info['pagereplies'] + $this->thread->info['reply_topped'] + 1;
$this->initPage($this->total);
list($start, $limit) = Pw::page2limit($this->page, $this->perpage);
if ($start == 0) {
$this->info['pid'] = 0;
$this->data[] =& $this->info; //地址引用,便于bulidRead同步修改
$this->info['aids'] && $this->_aids[] = 0;
$this->_uids[] = $this->info['created_userid'];
}
if ($this->info['pagereplies'] > 0) {
$offset = $start;
$offset == 0 ? $limit-- : $offset--;
$replies = array();
if ($this->thread->info['reply_topped']) {
if ($offset < $this->thread->info['reply_topped']) {
$replies = $this->_getToppedReply($limit, $offset);
$limit -= count($replies);
$offset = 0;
} else {
$offset -= $this->thread->info['reply_topped'];
}
}
if ($limit > 0) {
$replies = array_merge($replies, $this->thread->getReplies($limit, $offset, $this->asc));
}
foreach ($replies as $value) {
$this->data[] = $value;
$value['aids'] && $this->_aids[] = $value['pid'];
$this->_uids[] = $value['created_userid'];
}
}
$this->firstFloor = $start;
}
src/service/forum/bo/PwThreadBo.php
在function __construct($tid)添加:
//修改replies,让replies数量中不包含楼中楼回复数
$this->info['pagereplies'] = $this->_getThreadService()->countPostByTid($tid);
src/service/forum/PwThread.php
添加函数
/**
* 获取一个帖子的回复数量(新增)
*
* @param int $tid 帖子id
* @return int
*/
public function countPostByTid($tid) {
if (empty($tid)) return 0;
return $this->_getPostDao()->countPostByTid($tid);
}
src/service/forum/dao/PwPostsDao.php
添加函数:
/**
* 获取一个帖子的回复数量(新增)
*
* @param int $tid 帖子id
* @param int $limit
* @param int $offset
* @return int
*/
public function countPostByTid($tid) {
$sql = $this->_bindTable('SELECT COUNT(*) FROM %s WHERE tid=? AND disabled=0 AND rpid=0');
$smt = $this->getConnection()->createStatement($sql);
return $smt->getValue(array($tid));
}
求懒人包,看楼主的代码需要改好长时间。。