===============================
声明:3.0出来了,本插件不再提供技术支持,望谅解.
2005.11.26 by beecheung
===============================
作者:beecheung
最后更新:2005/09/09 8:15 修正浏览贴子中用户组图例显示错误
名称:仿D4折叠论坛列表中的在线显示,折叠贴子内在线浏览显示,折叠本版规则
演示:http://libr.hunau.net/forum
说明:
1,三者之间不会有冲突,比如收了这个,那个也跟着收,缩了这个,另一个也跟着缩;
2,无需先安装其他折叠,比如折叠首页论坛,在线用户和联盟,如果需要,到这里查看方法;
3,采用cookies缓存,折叠后刷新不影响折叠,在d2.5sp1和园园美化版上测试有效.
1 收缩论坛列表中的在线显示
../include/common.js
在适当地方加入如下代码(如果有了,不必再加了):
- function toggle_collapse(objname) {
- obj = findobj(objname);
- img = findobj(objname+"_img");
- collapsed = getcookie("discuz_collapse");
- cookie_start = collapsed ? collapsed.indexOf(objname) : -1;
- cookie_end = cookie_start + objname.length + 1;
- if(obj.style.display == "none") {
- obj.style.display = "";
- img_re = new RegExp("_yes\\.gif$");
- img.src = img.src.replace(img_re, '_no.gif');
- if(cookie_start != -1) collapsed = collapsed.substring(0, cookie_start) + collapsed.substring(cookie_end, collapsed.length);
- } else {
- obj.style.display = "none";
- img_re = new RegExp("_no\\.gif$");
- img.src = img.src.replace(img_re, '_yes.gif');
- if(cookie_start == -1) collapsed = collapsed + objname + " ";
- }
- expires = new Date();
- expires.setTime(expires.getTime() + (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));
- document.cookie = "discuz_collapse=" + escape(collapsed) + "; expires=" + expires.toGMTString() + "; path=/";
- }
- function imgzoom(o){
- if(event.ctrlKey) {
- var zoom = parseInt(o.style.zoom, 10) || 100;
- zoom -= event.wheelDelta / 12;
- if(zoom > 0) {
- o.style.zoom = zoom + '%';
- }
- return false;
- } else {
- return true;
- }
- }
- function getcookie(name) {
- var cookie_start = document.cookie.indexOf(name);
- var cookie_end = document.cookie.indexOf(";", cookie_start);
- return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
- }
复制代码
forumdisplay.php
查找:
- if($forum['viewperm'] && !strstr($forum['viewperm'], "\t$groupid\t") && !$forum['allowview']) {
复制代码
在上面加:
- if($whosonlinestatus) {
- if(empty($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'online_'.$forum['fid'].' ') === FALSE) {
- $onlinecollapseimg = 'collapsed_no.gif';
- $collapseonline = '';
- } else {
- $onlinecollapseimg = 'collapsed_yes.gif';
- $collapseonline = 'display: none';
- }
- $whosonlinestatus = nl2br($whosonlinestatus);
- }
复制代码
forumdisplay.htm
查找:
- <!--{if $whosonlinestatus}-->
- <table border="0" cellspacing="0" cellpadding="0" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr><td>
- <table border="0" cellspacing="{BORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%">
- <tr class="header"><td width="80%">{lang forum_activeusers}</td>
- <td align="center" nowrap><a href="javascript:this.location.reload();" style="color: {HEADERTEXT}; font-weight: normal">{lang refresh}</a></td>
- <td align="center" nowrap><a href="forumdisplay.php?fid=$fid&page=$page&showoldetails=no" style="color: {HEADERTEXT}; font-weight: normal">{lang index_hideonlinedetails}</a></td>
- </tr>
- <tr><td bgcolor="{ALTBG2}" colspan="3" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
- <table cellspacing="0" cellpadding="0" border="0" width="98%" align="center">
- <tr><td nowrap>
- <!--{loop $whosonline $key $online}-->
- <!--{if $key % 7 == 0}--></td></tr><tr><td width="15%" nowrap><!--{else}--></td><td width="15%" nowrap><!--{/if}-->
- <img src="images/common/$online[icon]" align="absmiddle">
- <a href="viewpro.php?uid=$online[uid]" title="{lang time}: $online[lastactivity]{LF}
- {lang action}: $online[action]{LF}
- {lang forum}: $forumname">$online[username]</a>
- <!--{/loop}-->
- </td></tr></table></td></tr>
- </table></td></tr></table>
- <br>
- <!--{/if}-->
复制代码
替换为:(如果要像现在的D4官方那样,就把这段放到快速回复的下面)
- <!--{if $whosonlinestatus}-->
- <table border="0" cellspacing="0" cellpadding="0" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr><td>
- <table border="0" cellspacing="{BORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%">
- <tr class="header"><td><a href="###" onclick="toggle_collapse('online_$fid');"><img id="online_{$fid}_img" src="{IMGDIR}/$onlinecollapseimg" align="right" border="0"></a>{lang forum_activeusers}</td></tr>
- <tbody id="online_$fid" style="$collapseonline">
- <tr><td bgcolor="{ALTBG2}" colspan="2" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
- <table cellspacing="0" cellpadding="0" border="0" width="98%" align="center">
- <tr><td nowrap>
- <!--{loop $whosonline $key $online}-->
- <!--{if $key % 7 == 0}--></td></tr><tr><td width="15%" nowrap><!--{else}--></td><td width="15%" nowrap><!--{/if}-->
- <img src="images/common/$online[icon]" align="absmiddle">
- <a href="viewpro.php?uid=$online[uid]" title="{lang time}: $online[lastactivity]{LF}
- {lang action}: $online[action]{LF}
- {lang forum}: $forumname">$online[username]</a>
- <!--{/loop}-->
- </td></tr></table></td></tr>
- </table></td></tr></table>
- <br>
- <!--{/if}-->
复制代码
2 收缩贴子内在线浏览显示
前提:安装了oytktk(靖飒)
的贴子里显示正在阅读此贴的会员[后台控制] For D2.5
我在这里加入了会员动作、时间显示,并显示用户组图例。
viewthread.php
查找:
- $query = $db->query("SELECT username FROM $table_sessions WHERE tid='$tid' AND invisible='0' AND uid>'0'");
- if($db->num_rows($query)) {
- $whosonlinestatus = 1;
- while($online = $db->fetch_array($query)) {
- $readsome=1;
- $whosonline[] = $online;
- }
- }
复制代码
替换为:
- $query = $db->query("SELECT uid, groupid, username, invisible, lastactivity, action FROM $table_sessions WHERE tid='$tid' AND invisible='0' AND uid>'0'");
- if($db->num_rows($query)) {
- $whosonlinestatus = 1;
- while($online = $db->fetch_array($query)) {
- $online['icon'] = isset($_DCACHE['onlinelist'][$online['groupid']]) ? $_DCACHE['onlinelist'][$online['groupid']] : $_DCACHE['onlinelist'][0];
- if ($online['groupid'] == 1 ){
- $online['icon'] = 'online_admin.gif';
- } elseif ($online['groupid'] == 2 ) {
- $online['icon'] = 'online_supermod.gif';
- } elseif ($online['groupid'] == 3 ) {
- $online['icon'] = 'online_moderator.gif';
- }
- //如果自建了特殊用户组,加入下面这一段,16是我建的VIP组的组ID,这个数字可在phpmyadmin中查到
- elseif ($online['groupid'] == 16 ) {
- $online['icon'] = 'online_vip.gif';
- }
- //如果自建了特殊用户组,加入上面这一段,16是我建的VIP组的组ID,这个数字可在phpmyadmin中查到
- else {
- $online['icon'] = 'online_member.gif';
- }
- $online['action'] = $actioncode[$online['action']];
- $online['lastactivity'] = gmdate($timeformat, $online['lastactivity'] + ($timeoffset * 3600));
- $readsome=1;
- $whosonline[] = $online;
- }
- }
复制代码
再查找:
在上面加:
- if($readuseron) {
- if(empty($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'read_'.$forum['fid'].' ') === FALSE) {
- $readcollapseimg = 'collapsed_no.gif';
- $collapseread = '';
- } else {
- $readcollapseimg = 'collapsed_yes.gif';
- $collapseread = 'display: none';
- }
- $readuseron = nl2br($readuseron);
- }
复制代码
viewthread.htm
查找:
- <!--{if $readuseron}-->
- ...
- <!--{/if}-->
复制代码
将这段替换为:
- <!--{if $readuseron}-->
- <table border="0" cellspacing="{BORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder" bgcolor="{BORDERCOLOR}">
- <tr class="header"><td><a href="###" onclick="toggle_collapse('read_$fid');"><img id="read_{$fid}_img" src="{IMGDIR}/$readcollapseimg" align="right" border="0"></a>正在浏览此贴的会员</td></tr>
- <tbody id="read_$fid" style="$collapseread">
- <tr><td bgcolor="{ALTBG2}" colspan="2" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
- <table cellspacing="0" cellpadding="0" border="0" width="98%" align="center">
- <tr><td nowrap>
- <!--{if $readsome }-->
- <!--{loop $whosonline $key $online}-->
- <!--{if $key % 7 == 0}--></td></tr><tr><td width="15%" nowrap><!--{else}--></td><td width="15%" nowrap><!--{/if}-->
- <img src="images/common/$online[icon]" align="absmiddle">
- <a href="viewpro.php?uid=$online[uid]" title="{lang time}: $online[lastactivity]{LF}
- {lang action}: $online[action]{LF}
- {lang forum}: $forumname">$online[username]</a>
- <!--{/loop}-->
- <!--{else}-->
- 只有游客或隐身会员正在浏览本贴!
- <!--{/if}-->
- </td></tr></table>
- </td></tr></td></tr>
- </td></tr></tbody></table>
- <br>
- <!--{/if}-->
复制代码
3 收缩本版规则
前提:安装了本版规则插件
forumdisplay.php
查找:
- if($forum['password'] && $action == 'pwverify') {
- if($pw != $forum['password']) {
- showmessage('forum_passwd_incorrect', NULL, 'HALTED');
- } else {
- setcookie("fidpw$fid", $pw, 0, $cookiepath, $cookiedomain);
- showmessage('forum_passwd_correct', "forumdisplay.php?fid=$fid");
- }
- }
复制代码
在下面加入(如果有了就不用加了):
- if($forum['cntwrules']) {
- if(empty($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'rules_'.$forum['fid'].' ') === FALSE) {
- $rulescollapseimg = 'collapsed_no.gif';
- $collapserules = '';
- } else {
- $rulescollapseimg = 'collapsed_yes.gif';
- $collapserules = 'display: none';
- }
- $forum['cntwrules'] = nl2br($forum['cntwrules']);
- }
复制代码
forumdisplay.htm
- <!--{if !empty($forum[cntwrules])}-->
- ...
- <!--{/if}-->
复制代码
将这一段替换为:
- <!--{if !empty($forum[cntwrules])}-->
- <table border="0" cellspacing="{BORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder" bgcolor="{BORDERCOLOR}">
- <tr class="header"><td><a href="###" onclick="toggle_collapse('rules_$fid');"><img id="rules_{$fid}_img" src="{IMGDIR}/$rulescollapseimg" align="right" border="0"></a>{lang forum_rules}</td></tr>
- <tbody id="rules_$fid" style="$collapserules">
- <tr><td bgcolor="{ALTBG2}" colspan="2" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">$forum[cntwrules]</td></tr>
- </tbody></table><br>
- <!--{/if}-->
复制代码
最后,把这两张小图标放入.\images\模版名\ 下.
这两个收缩和展开的按纽,根据风格不同,可以自己换换,我这里还有两组,看大家喜不喜欢.
[ 本帖最后由 beecheung 于 2005-11-26 09:54 编辑 ] |