⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leaf.java

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package com.redmoon.forum;

import java.io.File;
import java.io.Serializable;
import java.sql.*;
import java.sql.Date;
import java.util.Iterator;
import java.util.Vector;

import javax.servlet.ServletContext;

import cn.js.fan.base.ITagSupport;
import cn.js.fan.cache.jcs.RMCache;
import cn.js.fan.db.*;
import cn.js.fan.security.SecurityUtil;
import cn.js.fan.util.*;
import cn.js.fan.web.Global;
import com.redmoon.forum.person.UserDb;
import com.redmoon.forum.plugin.EntranceMgr;
import com.redmoon.forum.plugin.EntranceUnit;
import org.apache.log4j.Logger;
import com.redmoon.forum.plugin2.Plugin2Mgr;
import com.redmoon.forum.plugin2.Plugin2Unit;

/**
 *
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Leaf implements Serializable,ITagSupport {
    public static String CODE_BLOG = "blog";

    public static String CODE_ROOT = "root";

    public static final int TYPE_DOMAIN = 0;
    public static final int TYPE_BOARD = 1;

    public static final int WEBEDIT_ALLOW_TYPE_UBB = 1;                // 只能用UBB方式,暂时放弃
    public static final int WEBEDIT_ALLOW_TYPE_UBB_NORMAL = 2;         // 能用UBB及NORMAL
    public static final int WEBEDIT_ALLOW_TYPE_UBB_NORMAL_REDMOON = 3; // 三种方式都可以
    public static final int WEBEDIT_ALLOW_TYPE_REDMOON_FIRST = 4;            // 以高级方式优先

    transient RMCache rmCache = RMCache.getInstance();
    String connname = "";
    public transient Logger logger = Logger.getLogger(Leaf.class.getName());

    long addId;

    private String code = "", name = "", description = "", parent_code = "-1",
            root_code = "", add_date = "";
    private int orders = 1, layer = 1, child_count = 0;

    final String LOAD = "select code,name,description,parent_code,root_code,orders,layer,child_count,add_date,islocked,type,isHome,add_id,logo,today_count,today_date,topic_count,post_count,theme,skin,boardRule,color,webeditAllowType,plugin2Code from sq_board where code=?";
    boolean isHome = false;
    final String dirCache = "BOARD_";

    public void renew() {
        if (logger==null) {
            logger = Logger.getLogger(Leaf.class.getName());
        }
        if (rmCache==null) {
            rmCache = RMCache.getInstance();
        }
    }

    public String get(String field) {
        if (field.equals("code"))
            return getCode();
        else if (field.equals("name"))
            return getName();
        else if (field.equals("desc"))
            return getDescription();
        else if (field.equals("parent_code"))
            return getParentCode();
        else if (field.equals("root_code"))
            return getRootCode();
        else if (field.equals("layer"))
            return "" + getLayer();
        else
            return "";
    }

    public Leaf() {
        connname = Global.defaultDB;
        if (connname.equals(""))
            logger.info("Leaf:connname is empty");
    }

    public Leaf(String code) {
        connname = Global.defaultDB;
        if (connname.equals(""))
            logger.info("Leaf:connname is empty");
        this.code = code;
        loadFromDb();
    }

    public void loadFromDb() {
        ResultSet rs = null;
        Conn conn = new Conn(connname);
        PreparedStatement ps = null;
        try {
            ps = conn.prepareStatement(LOAD);
            ps.setString(1, code);
            rs = conn.executePreQuery();
            if (rs != null && rs.next()) {
                this.code = rs.getString(1);
                name = rs.getString(2);
                description = rs.getString(3);
                parent_code = rs.getString(4);
                root_code = rs.getString(5);
                orders = rs.getInt(6);
                layer = rs.getInt(7);
                child_count = rs.getInt(8);
                add_date = DateUtil.format(DateUtil.parse(rs.getString(9)), "yyyy-MM-dd HH:mm:ss");
                locked = rs.getInt(10)==1?true:false;
                type = rs.getInt(11);
                isHome = rs.getInt(12) > 0 ? true : false;
                addId = rs.getInt(13);
                logo = rs.getString(14);

                todayCount = rs.getInt(15);
                todayDate = DateUtil.parse(rs.getString(16));
                topicCount = rs.getInt(17);
                postCount = rs.getInt(18);
                theme = StrUtil.getNullStr(rs.getString(19));
                skin = StrUtil.getNullStr(rs.getString(20));
                boardRule = StrUtil.getNullString(rs.getString(21));
                color = StrUtil.getNullString(rs.getString(22));
                webeditAllowType = rs.getInt(23);
                plugin2Code = StrUtil.getNullStr(rs.getString(24));
                loaded = true;
            }
        } catch (SQLException e) {
            logger.error("load: code= " + code + " " + e.getMessage());
        } finally {
            if (rs!=null) {
                try { rs.close(); } catch (Exception e) {}
                rs = null;
            }
            if (ps!=null) {
                try { ps.close(); } catch (Exception e) {}
                ps = null;
            }
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
    }

    public long getAddId() {
        return addId;
    }

    public void setAddId(long d) {
        this.addId = d;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setRootCode(String c) {
        this.root_code = c;
    }

    public void setType(int t) {
        this.type = t;
    }

    public void setName(String n) {
        this.name = n;
    }

    public void setDescription(String desc) {
        this.description = desc;
    }

    public int getOrders() {
        return orders;
    }

    public boolean getIsHome() {
        return isHome;
    }

    public void setParentCode(String p) {
        this.parent_code = p;
    }

    public String getParentCode() {
        return this.parent_code;
    }

    public void setIsHome(boolean b) {
        this.isHome = b;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public void setTodayCount(int todayCount) {
        this.todayCount = todayCount;
    }

    public void setTodayDate(Date todayDate) {
        this.todayDate = todayDate;
    }

    public void setTopicCount(int topicCount) {
        this.topicCount = topicCount;
    }

    public void setPostCount(int postCount) {
        this.postCount = postCount;
    }

    public void setTheme(String theme) {
        this.theme = theme;
    }

    public void setSkin(String skin) {
        this.skin = skin;
    }

    public void setLoaded(boolean loaded) {
        this.loaded = loaded;
    }

    public String getRootCode() {
        return root_code;
    }

    public int getLayer() {
        return layer;
    }

    public String getDescription() {
        return description;
    }

    public int getType() {
        return type;
    }

    public String getLogo() {
        return logo;
    }

    public int getTodayCount() {
        if (todayCount!=0) {
            // 如果today_date字段中不为当前日期,则today_count为0
            if (!DateUtil.isSameDay(todayDate, new java.util.Date())) {
                todayCount = 0;
                todayDate = new java.util.Date();
                update();
            }
        }
        return todayCount;
    }

    public java.util.Date getTodayDate() {
        return todayDate;
    }

    public int getTopicCount() {
        return topicCount;
    }

    public int getPostCount() {
        return postCount;
    }

    public String getTheme() {
        return theme;
    }

    public String getSkin() {
        return skin;
    }

    public boolean isLoaded() {
        return loaded;
    }

    public boolean isLocked() {
        return locked;
    }

    public String getBoardRule() {
        return boardRule;
    }

    public String getColor() {
        return color;
    }

    public int getWebeditAllowType() {
        return webeditAllowType;
    }

    public String getPlugin2Code() {
        return plugin2Code;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -