原作者主题:https://discuz.dismall.com/viewthread.php?tid=610581
感谢他为大家提供这么好的插件!
有几点他没有做好,最大的问题就是出现的<br><font>等现象。
在此我做一修改,美化一下。
俺只提供5.5的修改方法和修改后的文件。
俺是菜鸟,请不要问我高深的问题。
欢迎大家光临我的小站:http://bbs.hongse.net.cn
==============================================================
名称:鼠标指向主题表格时显示最后回复等内容[修正版置顶、区置顶、总置顶帖无法预览的问题]
功能:与权限挂钩,扩大鼠标反应区域至表格
修改:forumdisplay.php、forumdisplay.htm
美化:枫
版权:归原作者所有
1.修改forumdisplay.php
查找:
- isset($ascdesc) && $ascdesc == 'ASC' ? $forumdisplayadd .= '&ascdesc=ASC' : $ascdesc = 'DESC';
复制代码
在其下添加:
- //----鼠标指向主题表格时显示最后回复等内容--------开始
- $dotadd1 = $dotadd2 = '';
- if($dotfolders && $discuz_uid) {
- $dotadd1 = "DISTINCT p.authorid AS dotauthor, p.subject AS re_subject, p.message, ";
- $dotadd2 = "LEFT JOIN {$tablepre}posts p ON (t.tid=p.tid AND p.authorid='$discuz_uid')";
- }else {
- $dotadd1 = "p.subject AS re_subject, p.message, ";
- $dotadd2 = "LEFT JOIN {$tablepre}posts p ON (t.tid=p.tid AND t.lastpost=p.dateline)";
- }
- //----鼠标指向主题表格时显示最后回复等内容--------结束
复制代码
查找:
- $thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
复制代码
在其下添加:(此为关键步骤,与原作者不同)
- //----鼠标指向主题表格时显示最后回复等内容--------开始
- if($forum['viewperm'] && !forumperm($forum['viewperm']) && !$forum['allowview']) {
- $thread['message'] = "谢谢您的访问!由于权限不够,您仅可浏览本版主题标题。";
- } elseif($thread['creditsrequire'] && $thread['creditsrequire'] > $credit && !$ismoderator) {
- include language('messages');
- eval("\$show_message = "".$language[thread_nopermission]."";");
- $thread['message'] = $show_message;
- } else {
- $thread['message'] = preg_replace("/\[hide=?\d*\](.+?)\[\/hide\]/is", "**** 回复后才可查看信息 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[sell=?\d*\](.+?)\[\/sell\]/is", "**** 付費信息,已經隱藏 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[php](.+?)\[\/php\]/is", "**** 内容为PHP代码 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[code](.+?)\[\/code\]/is", "**** 内容为普通代码 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[quote](.+?)\[\/quote\]/is", "**** 内容为引用信息 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[url=?(.+?)\](.+?)\[\/url\]/is", "**** 此处为超级链接 *****", $thread['message'] );
- $thread['message'] = preg_replace("/\[img](.+?)\[\/img\]/is", "**** 此处为图片链接 *****", $thread['message'] );
- $thread['message'] = str_replace('"', '"', $thread['message']);
- $thread['message'] = str_replace('<', '<', $thread['message']);
- $thread['message'] = str_replace('>', '>', $thread['message']);
- $thread['message'] = str_replace("\r\n", " ", $thread['message']); //去掉回车换成了空格,紧凑显示
- $thread['message'] = cutstr($thread['message'],240); //内容截断
- }
- if($thread[replies]) {
- $thread['shortmsg'] = '主题作者: '.$thread[author].'
- 主题日期: '.$thread[dateline].'
- 最新回复: '.$thread[lastpost].'
- 回复数量: '.$thread[replies].' | 查看数量: '.$thread[views].'
- 回复内容: '.$thread[re_subject].''.$thread[message].''.'';
- } else {
- $thread['shortmsg'] = '主题作者:'.$thread[author].'
- 主题日期: '.$thread[dateline].'
- 最新回复: '.$thread[lastpost].'
- 回复数量: '.$thread[replies].' | 查看数量: '.$thread[views].'
- 主题内容: '.$thread[message].''.'';
- }
- //----鼠标指向主题表格时显示最后回复等内容--------结束
复制代码
如果您安装过全论坛置顶HACK直接进行第二步
如果没有请查找:
- $query = $db->query("SELECT t.* FROM {$tablepre}threads t
复制代码
把第一个上述代码替换为:
- /*$query = $db->query("SELECT t.* FROM {$tablepre}threads t*/
- $query = $db->query("SELECT $dotadd1 t.* FROM {$tablepre}threads t $dotadd2
复制代码
2.修改templates\default\forumdisplay.htm
查找:
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" class="row" onMouseOver="this.style.backgroundColor='{ALTBG1}'" onMouseOut="this.style.backgroundColor='{ALTBG2}'"
复制代码
在='{ALTBG2}'"后面空一格后添加:
- title="$thread[shortmsg]"
复制代码
3.修改include\javascript\common.js
在最底加入:
- document.write("<style type='text/css'>");
- document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #DDEEFF; border: 1px #8899AA dashed; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80); opacity: 0.8;}");
- document.write("</style>");
- document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>")
- function showPopupText(event) {
- if(event.srcElement) o = event.srcElement; else o = event.target;
- if(!o) {
- return;
- }
- MouseX = event.clientX;
- MouseY = event.clientY;
- if(o.alt != null && o.alt != '') {
- o.pop = o.alt;
- o.alt = '';
- }
- if(o.title != null && o.title != '') {
- o.pop = o.title;
- o.title = '';
- }
- if(o.pop != sPop) {
- sPop = o.pop;
- if(sPop == null || sPop == '') {
- $('popLayer').style.visibility = "hidden";
- } else {
- popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
- $('popLayer').style.visibility = "visible";
- showIt();
- }
- }
- }
- function showIt() {
- $('popLayer').className = popStyle;
- $('popLayer').innerHTML = sPop.replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>");
- var bodySL, bodyST;
- if(window.pageXOffset){
- bodySL=window.pageXOffset;
- }else if(document.documentElement&&document.documentElement.scrollLeft){
- bodySL=document.documentElement.scrollLeft;
- }else if(document.body){
- bodySL=document.body.scrollLeft; //author: meizz
- }
- if(window.pageYOffset){
- bodyST=window.pageYOffset;
- }else if(document.documentElement&&document.documentElement.scrollTop){
- bodyST=document.documentElement.scrollTop;
- }else if(document.body){
- bodyST=document.body.scrollTop;
- }
- var bodyCW, bodyCH;
- if(window.innerWidth){
- bodyCW=window.innerWidth;
- }else if(document.documentElement&&document.documentElement.clientWidth){
- bodyCW=document.documentElement.clientWidth;
- }else if(document.body){
- bodyCW=document.body.clientWidth; //author: meizz
- }
- if(window.innerHeight){
- bodyCH=window.innerHeight;
- }else if(document.documentElement&&document.documentElement.clientHeight){
- bodyCH=document.documentElement.clientHeight;
- }else if(document.body){
- bodyCH=document.body.clientHeight;
- }
- if($('popLayer').clientWidth>300){
- var popWidth = 300;
- }else{
- var popWidth = $('popLayer').clientWidth;
- }
- var popWidth = $('popLayer').clientWidth;
- var popHeight = $('popLayer').clientHeight;
- var popLeftAdjust = MouseX + 12 + popWidth > bodyCW ? -popWidth - 24 : 0;
- var popTopAdjust = MouseY + 12 + popHeight > bodyCH ? -popHeight - 24 : 0;
- $('popLayer').style.left = (MouseX + 12 + bodySL + popLeftAdjust) + 'px';
- $('popLayer').style.top = (MouseY + 12 + bodyST + popTopAdjust) + 'px';
- }
- if(!document.onmouseover) {
- document.onmouseover = function(e) {
- var event = e ? e : window.event;
- showPopupText(event);
- };
- }
复制代码
======================================================================
6月9日增加解决办法:
当你按照上面的方法修改以后,出现下列情况的:
1、在论坛的第一页出现不了最后回复预览,而在第二页就可以出现了;
2、版置顶、区置顶、总置顶的帖子都出现不了最后回复内容预览。
那么请把forumdisplay.php里面的:- $db->query("SELECT t.* FROM {$tablepre}threads t
复制代码 全部替换为- $db->query("SELECT $dotadd1 t.* FROM {$tablepre}threads t $dotadd2
复制代码
======================================================================
如果你没有更改过上述的三个文件,建议你下载我的压缩包的文件直接覆盖。
附件文件已经更新。
[ 本帖最后由 枫之白衣 于 2007-6-9 18:25 编辑 ] |