PHPWIND[民间论坛]数据搬迁导致丢失严重,用户数据基本全部损坏,十分遗憾来自phpwind.me的远古记忆

官方楼中楼修改

risingsun 离线 10K阅读 14回复 于 2014-01-05 16:59 发布在 技术文献 分类
需要修改的文件比较多,大家先看看页末的效果再决定是否修改
主要修改功能:
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了。

评论

14 最热 最新
游客
zrj766
zrj766
11年前 山西省太原市
0
好复杂啊
bink1224
bink1224
11年前 山东省
0
优秀分享,奖励~~!
董宝中
董宝中
11年前 中国
0
这个,有懒人包么
sfczs
sfczs
11年前 墨西哥
0
phpwind爱好者:没这么复杂,我已经测试好了,到时候发懒人包上来回到原帖
大神你的懒人包啥时候分享啊?
littleyang
littleyang
11年前 山东省
0
求懒人包,看楼主的代码需要改好长时间。。
响水论坛
响水论坛
11年前 江苏省
0
phpwind爱好者:没这么复杂,我已经测试好了,到时候发懒人包上来回到原帖
大神,懒人包呢?最好也有手动修改方法
celebrity99
celebrity99
11年前 广东省广州市番禺区
0
phpwind爱好者:没这么复杂,我已经测试好了,到时候发懒人包上来回到原帖
大神,等你好久了
phpwind爱好者
phpwind爱好者
11年前 Unknown
0
没这么复杂,我已经测试好了,到时候发懒人包上来



图片:QQ图片20140709230616.jpg

MEDZ
MEDZ
11年前 广东省深圳市
0
其实根本没有楼主说的那么复杂。。。。还有楼主的教程真心叫人看不懂!
t7367388
t7367388
11年前 福建省漳州市
0
测试过,改到第三个,网站出错。
t7367388
t7367388
11年前 福建省漳州市
0
细看以后,真心看不懂。
t7367388
t7367388
11年前 福建省漳州市
0
回复要点开,才能看吗?
admin
admin
12年前 Unknown
0
感谢首发!
稍后我测试一下!
risingsun
risingsun
楼主
12年前 内蒙古呼和浩特市
0


分页问题解决方案:
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));
 }
s_footer