jforum论坛二次开发--小修小改汇总贴

lynx286原创, 首发www.mydwbi.com
http://www.mydwbi.com/posts/list/0/103.page
欢迎转贴, 但转贴请不要删除此段版权说明.
将会员列表改成按id排序(新注册用户排前面)
web-inf\config\database\generic\generic_queries.sql
将58-59行 "order by username" 改成 "order by user_id desc"
添加网站地图
-生成sitemap.xml
jforum 的url后缀是.page不是常规的.htm .html .asp .jsp 所以很多sitemap.xml builder不能识别jforum中的链接,所以自动生成不了sitemap.xml(本人猜想是这个原因),后来找半天找到一个工具叫SOFTplus GSiteCrawler的可以自定义页面后缀,从而自动生成sitemap.xml.

-添加国际化属性
zh_CN.properties中最后添加:mydwbi.sitemap=\u7f51\u7ad9\u5730\u56fe

-添加入口链接
在forum_list.htm中第181行下添加:
<td>  </td>   
<td align="center" width="20"><img   /></td>   
<td><span class="gensmall"><a href="${contextPath}/sitemap.xml">${I18n.getMessage("mydwbi.sitemap")}</a></span></td>  

修改版权信息
修改bottom.htm 11行.



将发贴时"pool","attachments","options"改成中文
-添加国际化属性
mydwbi.Options=\u9009\u9879 
mydwbi.Pool=\u6295\u7968 
mydwbi.Attach=\u9644\u4ef6 

修改模板
将post_form.htm中第369,372,375行"pool","attachments","options"改成:
${I18n.getMessage("mydwbi.Options")} 
${I18n.getMessage("mydwbi.Pool")} 
${I18n.getMessage("mydwbi.Attach")} 


让发贴的表情符号列表多显示几个表情
修改post_form.htm261行,改成:<#if (count < 32)>
特定用户显示ip
post_show_user_inc.htm36,37行改成:
<#if (post.userIp?exists && isModerator) || (post.userIp?exists && session.username = "lynx286")>   
${I18n.getMessage("PostShow.userIP")}: <a href="http://whois.domaintools.com/${post.userIp}"  target="_blank">${post.userIp}</a>  


即如果当前登陆用户为该版版主或用户名为lynx286,就显示发贴人ip地址



进入板块后显示主题列表页面发表人栏显示帖子发表时间
进入板块后显示主题列表页面指: /forums/show/xxxx.page 页面
forum_show.htm页面224行改成:
<span class="postdetails">${topic.firstPostTime}<br /><a >  

176行改成:width=140



bmp图片也显示缩略图
用户经常用print screen键拷贝屏幕图片,并发到帖子上,是bmp格式,不能显示缩略图,要下载才能看,不太方便。这里改一下可显示缩略图 。
AttachmentCommon.java 254行添加:
"bmp".equals(extension) || 

将整个论坛页面宽度由满屏改为固定宽度
header.htm 31行:
<table width="950" border="0" ALIGN="center"> 

将论坛跳转下拉框放到上面
post_show.htm 等页面 90 行,加上下面代码:
<td align="left">   
                    <span class="gensmall">${I18n.getMessage("ForumIndex.goTo")}: </span>   
                    <select onchange="if(this.options[this.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ this.options[this.selectedIndex].value +'${extension}'; }" name="select">   
                        <option value="-1" selected="selected">${I18n.getMessage("ForumIndex.goToSelectAForum")}</option>                  
                           
                        <#list allCategories as category>   
                            <optgroup label="${category.name}">   
           
                            <#list category.getForums() as forum>   
                                <option value="${forum.id}">${forum.name}</option>   
                            </#list>   
                            </optgroup>   
                        </#list>   
                    </select>   
                        
                    <input class="liteoption" type="button" value="${I18n.getMessage("ForumIndex.goToGo")}" onclick="if(document.f.select.options[document.f.select.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ document.f.select.options[document.f.select.selectedIndex].value +'${extension}'; }" />   
                  </td>

此段代码可以从 macros\presentaion.ftl 中 <#macro forumsComboTable> 里面拷贝。
让附件图片支持gif动画:
AttachmentCommon.java:
private boolean shouldCreateThumb(Attachment a) {   
        if (SystemGlobals   
                .getBoolValue(ConfigKeys.ATTACHMENTS_IMAGES_CREATE_THUMB)) {   
            String extension = a.getInfo().getExtension().getExtension()   
                    .toLowerCase();   
            if (Attachment.isPicture(extension)) {   
                String path = SystemGlobals   
                        .getValue(ConfigKeys.ATTACHMENTS_STORE_DIR)   
                        + "/" + a.getInfo().getPhysicalFilename();   
                File fileOriginal = new File(path);   
                Image imageOriginal = null;   
                try {   
                    imageOriginal = ImageIO.read(fileOriginal);   
                } catch (IOException e) {   
                    e.printStackTrace();   
                }   
                int widthOriginal = imageOriginal.getWidth(null);   
                int heightOriginal = imageOriginal.getHeight(null);   
                if (widthOriginal > 800 || heightOriginal > 600)   
                    return true;   
                else  
                    return false;   
            } else  
                return false;   
        } else  
            return false;   
    }   


Attachment.java:
public boolean hasThumb() {   
        String pName = this.info.getPhysicalFilename();   
        String extension = pName.substring(pName.lastIndexOf('.') + 1, pName   
                .length() - 1);   
        if (isPicture(extension)   
                && SystemGlobals   
                        .getBoolValue(ConfigKeys.ATTACHMENTS_IMAGES_CREATE_THUMB))   
            return true;   
        else  
            return false;   
    }   
  
    public String thumbPath() {   
        String fileDir = SystemGlobals   
                .getValue(ConfigKeys.ATTACHMENTS_UPLOAD_DIR)   
                + '/' + this.info.getPhysicalFilename();   
        String path = SystemGlobals.getValue(ConfigKeys.ATTACHMENTS_STORE_DIR)   
                + "/" + this.info.getPhysicalFilename();   
        if (new File(path + "_thumb").exists()) {   
            return fileDir + "_thumb";   
        } else {   
            return fileDir;   
        }   
    }   
  
    public static boolean isPicture(String extension) {   
        if ("bmp".equals(extension) || "jpg".equals(extension)   
                || "jpeg".equals(extension) || "gif".equals(extension)   
                || "png".equals(extension))   
            return true;   
        else  
            return false;   
    }   


让头像也支持gif动画:
UserCommon.java: 
private static void handleAvatar(User u) {   
        String fileName = MD5.crypt(Integer.toString(u.getId()));   
        FileItem item = (FileItem) JForumExecutionContext.getRequest()   
                .getObjectParameter("avatar");   
        UploadUtils uploadUtils = new UploadUtils(item);   
  
        // Gets file extension   
        String extension = uploadUtils.getExtension().toLowerCase();   
        int type = ImageUtils.IMAGE_UNKNOWN;   
        if (extension.equals("jpg") || extension.equals("jpeg")) {   
            type = ImageUtils.IMAGE_JPEG;   
        } else if (extension.equals("gif")) {   
            type = ImageUtils.IMAGE_GIF;   
        } else if (extension.equals("png")) {   
            type = ImageUtils.IMAGE_PNG;   
        }   
  
        if (type != ImageUtils.IMAGE_UNKNOWN) {   
            String avatarFinalFileName = SystemGlobals.getApplicationPath()   
                    + "/images/avatar/" + fileName + "." + extension;   
            uploadUtils.saveUploadedFile(avatarFinalFileName);   
            File avatar = new File(avatarFinalFileName);   
            Image imageOriginal = null;   
            try {   
                imageOriginal = ImageIO.read(avatar);   
            } catch (IOException e) {   
                e.printStackTrace();   
            }   
            int widthOriginal = imageOriginal.getWidth(null);   
            int heightOriginal = imageOriginal.getHeight(null);   
            if (widthOriginal <= 130 && heightOriginal <= 130) {   
                u.setAvatar(fileName + "." + extension);   
            }else{   
                avatar.delete();   
            }   
        }   
    }   

你可能感兴趣的:(java,sql,jsp,xml,asp)