Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[美化] [原创]主题分类以图片格式显示!(普通会员不能使用《公告》分类Hack)Dz5.0 Gbk

[复制链接]
badfox 发表于 2006-12-6 21:21:25 | 显示全部楼层 |阅读模式
#############################################
插件名称:主题分类MEI化
适用版本:Dz5.0 GBK
作  者:badfox
修  改:
forumdisplay.php
viewthread.php
include\global.func.php
templates\default\post_editpost.htm
templates\default\post_newthread.htm

数据升级:无
安装难度:易
最后更新:2006/12/06
演  示:见楼下图片

功能说明:
将主题分类显示改为图片,可以文字与图片混合使用!


备  注:
本来以为不用更改模板,由于图片不能用下拉框显示,所以只有更改了发帖和编辑帖子的模板,将主题分类改为横排显示!



安装插件有风险,安装前注意备份文件!
#############################################

全新安装开始:
1、

forumdisplay.php

查找

  1. $thread['typeid'] = $thread['typeid'] && !empty($forum['threadtypes']['prefix']) && isset($forum['threadtypes']['types'][$thread['typeid']]) ?
  2.                 '['.$forum['threadtypes']['types'][$thread['typeid']].'] ' : '';
复制代码

替换为

  1. if($thread['typeid'] && !empty($forum['threadtypes']['prefix']) && isset($forum['threadtypes']['types'][$thread['typeid']])){
  2.         if(preg_match("/^[\w_.-]*$/", $forum['threadtypes']['types'][$thread['typeid']])){
  3.                 $thread['typeid']= '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['types'][$thread['typeid']].'.gif'.'" border="0" alt="" />' ;
  4.         }else{
  5.                 $thread['typeid']= '['.$forum['threadtypes']['types'][$thread['typeid']].'] ' ;

  6.         }
  7. }else{
  8.         $thread['typeid'] = '';
  9.         }
复制代码


查找

  1. $ppp = $forum['threadcaches'] ? $_DCACHE['settings']['postperpage'] : $ppp;
复制代码


上面添加
  1. if($forum['threadtypes'] && $forum['threadtypes']['listable']) {
  2.         if($forum['threadtypes']['flat']) {
  3.                 foreach($forum['threadtypes']['flat'] as $id => $name){

  4.                                         $forum['threadtypes']['flat'][$id] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['flat'][$id]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['flat'][$id].'.gif'.'" border="0" alt="" />' : $forum['threadtypes']['flat'][$id];
  5.                         }
  6.         }

  7.         if($forum['threadtypes']['selectbox']) {
  8.                 foreach($forum['threadtypes']['selectbox'] as $id => $name){

  9.                                         $forum['threadtypes']['selectbox'][$id] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['selectbox'][$id]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['selectbox'][$id].'.gif'.'" border="0" alt="" />' : $forum['threadtypes']['selectbox'][$id];

  10.                        
  11.                         }
  12.         }

  13. }
复制代码

2、

viewthread.php

查找



  1. if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
  2.         $thread['subject'] = ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">['.$forum['threadtypes']['types'][$thread['typeid']].']</a>' : '['.$forum['threadtypes']['types'][$thread['typeid']].']').' '.$thread['subject'];
  3. }
复制代码


替换为


  1. if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
  2.         $forum['threadtypes']['types'][$thread['typeid']] = preg_match("/^[\w_.-]*$/", $forum['threadtypes']['types'][$thread['typeid']]) ? '<img src="'.IMGDIR.'/types/'.$forum['threadtypes']['types'][$thread['typeid']].'.gif'.'" border="0" alt="" />' : '['.$forum['threadtypes']['types'][$thread['typeid']].'] ';
  3.         $thread['subject'] = ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">'.$forum['threadtypes']['types'][$thread['typeid']].'</a>' : $forum['threadtypes']['types'][$thread['typeid']]).' '.$thread['subject'];

  4. }
复制代码

3、
include\global.func.php
查找
  1. function typeselect($curtypeid = 0) {
  2.         if($threadtypes = $GLOBALS['forum']['threadtypes']) {
  3.                 $html = '<select name="typeid"><option value="0">&nbsp;</option>';
  4.                 foreach($threadtypes['types'] as $typeid => $name) {
  5.                         $html .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>';
  6.                 }
  7.                 $html .= '</select>';
  8.                 return $html;
  9.         } else {
  10.                 return '';
  11.         }
  12. }
复制代码

替换为
  1. function typeselect($curtypeid = 0) {
  2.         $i = 1;
  3.         $br = '';
  4.         $typemark = '';
  5.         if($threadtypes = $GLOBALS['forum']['threadtypes']) {
  6.                 $html[1] = '';
  7.                 $html[2] = '<select name="typeid"><option value="0">&nbsp;</option>';
  8.                 foreach($threadtypes['types'] as $typeid => $name) {
  9.                 if(preg_match("/^[\w_.-]*$/", $name)) {
  10.                                         if($i==8) {
  11.                                                 $br= '<br />';
  12.                                                 $i = 0;
  13.                                         }  else {
  14.                                                 $br= '';
  15.                                         }
  16.                                         $i++;
  17.                                         $html[1] .= '<input class="radio" type="radio" name="typeid" value="'.$typeid.'"'.($curtypeid == $typeid ? 'selected' : '').'>'.'<img src="'.IMGDIR.'/types/'.$name.'.gif'.'" border="0" alt="" />&nbsp;&nbsp;'.$br;
  18.                                         $typemark = '1';
  19.                                 }else{
  20.                                         if($i==8) {
  21.                                                 $br= '<br />';
  22.                                                 $i = 0;
  23.                                         }  else {
  24.                                                 $br= '';
  25.                                         }
  26.                                         $i++;
  27.                                         $html[1] .= '<input class="radio" type="radio" name="typeid" value="'.$typeid.'"'.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'&nbsp;&nbsp;'.$br;

  28.                                         $html[2] .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>';
  29.                                 }
  30.                 }
  31.                 $html[2] .= '</select>';
  32.                 if($typemark) {
  33.                         $html[2] = '';
  34.                 }else {
  35.                         $html[1] = '';
  36.                 }
  37.                 return $html;
  38.         } else {
  39.                 return '';
  40.         }
  41. }
复制代码
4、

templates\default\post_newthread.htm

查找
  1. <tr>
  2. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  3. <td class="altbg2">$typeselect <input type="text" name="subject" id="subject" size="45" value="$subject" tabindex="3"></td>
  4. </tr>
复制代码


替换为

  1. <!--{if $typeselect[1]}-->
  2. <tr>
  3. <td class="altbg1" width="20%"><span class="bold">主题分类</span></td>
  4. <td class="altbg2"> $typeselect[1]</td>
  5. </tr>
  6. <!--{/if}-->
  7. <tr>
  8. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  9. <td class="altbg2"> $typeselect[2] <input type="text" name="subject" id="subject" size="45" value="$subject" tabindex="3"></td>
  10. </tr>
复制代码


5、
templates\default\post_editpost.htm

查找

  1. <tr>
  2. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  3. <td class="altbg2">
  4. <!--{if $isfirstpost}-->$typeselect<!--{/if}-->
复制代码




替换为

  1. <!--{if $isfirstpost}-->
  2. <!--{if $typeselect[1]}-->
  3. <tr>
  4. <td class="altbg1" width="20%"><span class="bold">主题分类</span></td>
  5. <td class="altbg2"> $typeselect[1]</td>
  6. </tr>
  7. <!--{/if}-->
  8. <!--{/if}-->
  9. <tr>
  10. <td class="altbg1" width="20%"><span class="bold"><!--{if isset($activity) && $allowpostactivity}-->{lang activity_name}<!--{else}-->{lang subject}<!--{/if}--></span></td>
  11. <td class="altbg2">
  12. <!--{if $isfirstpost}-->$typeselect[2]<!--{/if}-->
复制代码


6、
将主题分类的图片上传到images\default\types目录下,即主题分类图片的目录是images\default\types

附件中提供部分分类图片,做的很粗糙,仅供测试!

7、
进后台,添加主题分类,将主题分类图片名称添加为主题分类,注意图片名称不能为中文和特殊字符,建议只用字母和数字!
编辑论坛,设置显示主题分类!

注意,图片为gif格式。
也可以汉字的主题分类,混合使用,互不影响!
如果全部为汉字的主题分类,则编辑帖子和发新帖界面主题分类变为下拉框显示!


详见楼下图片!

全新安装结束。


#############################################
有人问如何控制普通会员不能使用“公告”分类,我想到一个办法能实现!

添加WAN主题分类后,查到“公告”分类的id,假设为'1'
则打开
include\newthread.inc.php

查找

        if(!$typeid && $forum['threadtypes']['required']) {
                showmessage('post_type_isnull');
        }

下面添加

        if($typeid == '1' && !$forum['ismoderator']) {
                showmessage('您不属于管理组,不能使用此主题分类!');
        }


#############################################

[ 本帖最后由 badfox 于 2006-12-7 09:17 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
 楼主| badfox 发表于 2006-12-6 21:21:42 | 显示全部楼层
沙发...........

[ 本帖最后由 badfox 于 2006-12-6 21:25 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

 楼主| badfox 发表于 2006-12-6 21:22:06 | 显示全部楼层
板凳........................
回复

使用道具 举报

紫云杉 发表于 2006-12-6 21:25:46 | 显示全部楼层
回复

使用道具 举报

jianquan 发表于 2006-12-6 21:52:17 | 显示全部楼层
看上去好象不错啊 呵呵
回复

使用道具 举报

 楼主| badfox 发表于 2006-12-6 22:54:08 | 显示全部楼层
自己顶...............
回复

使用道具 举报

binbin85129 发表于 2006-12-6 23:03:04 | 显示全部楼层
:) :) :) :)
回复

使用道具 举报

H5N1 发表于 2006-12-6 23:26:32 | 显示全部楼层
不错哦                              .
回复

使用道具 举报

5025488.net 发表于 2006-12-6 23:36:45 | 显示全部楼层
回复

使用道具 举报

开心一生 发表于 2006-12-7 00:24:02 | 显示全部楼层
:) 图片美化起来效果一定很好
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-4-25 02:42 , Processed in 0.113684 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表