leaf.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 1,053 行 · 第 1/3 页

JAVA
1,053
字号
            removeAllFromCache();        } catch (SQLException e) {            conn.rollback();            logger.error("delsingle:" + e.getMessage());            return false;        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public synchronized void del(ServletContext application, Leaf leaf) {        delsingle(application, leaf);        Iterator children = leaf.getChildren().iterator();        while (children.hasNext()) {            Leaf lf = (Leaf) children.next();            del(application, lf);        }    }    public Leaf getBrother(String direction) {        String sql;        RMConn rmconn = new RMConn(connname);        Leaf bleaf = null;        try {            if (direction.equals("down")) {                sql = "select code from sq_board where parent_code=" +                      StrUtil.sqlstr(parent_code) +                      " and orders=" + (orders + 1);            } else {                sql = "select code from sq_board where parent_code=" +                      StrUtil.sqlstr(parent_code) +                      " and orders=" + (orders - 1);            }            ResultIterator ri = rmconn.executeQuery(sql);            if (ri != null && ri.hasNext()) {                ResultRecord rr = (ResultRecord) ri.next();                bleaf = getLeaf(rr.getString(1));            }        } catch (SQLException e) {            logger.error("getBrother: " + e.getMessage());        }        return bleaf;    }    public boolean move(String direction) {        String sql = "";                boolean isexist = false;        Leaf bleaf = getBrother(direction);        if (bleaf != null) {            isexist = true;        }                if (isexist) {            Conn conn = new Conn(connname);            try {                conn.beginTrans();                if (direction.equals("down")) {                    sql = "update sq_board set orders=orders+1" +                          " where code=" + StrUtil.sqlstr(code);                    conn.executeUpdate(sql);                    sql = "update sq_board set orders=orders-1" +                          " where code=" + StrUtil.sqlstr(bleaf.getCode());                    conn.executeUpdate(sql);                }                if (direction.equals("up")) {                    sql = "update sq_board set orders=orders-1" +                          " where code=" + StrUtil.sqlstr(code);                    conn.executeUpdate(sql);                    sql = "update sq_board set orders=orders+1" +                          " where code=" + StrUtil.sqlstr(bleaf.getCode());                    conn.executeUpdate(sql);                }                conn.commit();            } catch (Exception e) {                conn.rollback();                logger.error("move: " + e.getMessage());                return false;            } finally {                removeAllFromCache();                if (conn != null) {                    conn.close();                    conn = null;                }            }        }        return true;    }    public void setChildCount(int childCount) {        this.child_count = childCount;    }    public void setOrders(int orders) {        this.orders = orders;    }    public void setLayer(int layer) {        this.layer = layer;    }    public void setLocked(boolean locked) {        this.locked = locked;    }    public void setBoardRule(String boardRule) {        this.boardRule = boardRule;    }    public void setColor(String color) {        this.color = color;    }    public void setWebeditAllowType(int webeditAllowType) {        this.webeditAllowType = webeditAllowType;    }    public void setPlugin2Code(String plugin2Code) {        this.plugin2Code = plugin2Code;    }    public void setCheckMsg(int checkMsg) {        this.checkMsg = checkMsg;    }    public void setDelMode(int delMode) {        this.delMode = delMode;    }    public void setDisplayStyle(int displayStyle) {        this.displayStyle = displayStyle;    }    public void setBold(boolean bold) {        this.bold = bold;    }    public Vector getAllPlugin2() {        Vector v = new Vector();        String[] ary = StrUtil.split(plugin2Code, ",");        if (ary != null) {            Plugin2Mgr pm = new Plugin2Mgr();            Plugin2Unit pu = null;            int len = ary.length;            for (int i = 0; i < len; i++) {                pu = pm.getPlugin2Unit(ary[i]);                if (pu != null)                    v.addElement(pu);            }        }        return v;    }    public boolean isUsePlugin2(String code) {        String[] ary = StrUtil.split(plugin2Code, ",");        if (ary != null) {            int len = ary.length;            Plugin2Mgr pm = new Plugin2Mgr();            Plugin2Unit pu = null;            for (int i = 0; i < len; i++) {                if (ary[i].equals(code))                    return true;            }        }        return false;    }    public String getMenuString(HttpServletRequest request, Leaf lf) throws            ErrMsgException {        if (lf.getChildCount() == 0)            return "";        String str = "";        try {            str = (String) rmCache.getFromGroup("menu_" + lf.getCode(),                                                dirCache);        } catch (Exception e) {            logger.error("getMenuString: " + e.getMessage());        }        if (str == null) {            StringBuffer sb = new StringBuffer(200);            sb.append("one");            ShowBoardsToString(request, sb, lf, lf.getLayer());            str = sb.toString();            try {                rmCache.putInGroup("menu_" + lf.getCode(), dirCache, str);            } catch (Exception e) {                logger.error("getMenuString2:" + e.getMessage());            }        }        return str;    }        public void ShowBoardsToString(HttpServletRequest request, StringBuffer sb,                                   Leaf leaf, int rootlayer) throws            ErrMsgException {                if (sb.toString().equals("one")) {            sb.delete(0, sb.length());        } else            ShowLeafToString(request, sb, leaf, rootlayer);        Directory dir = new Directory();        Vector children = dir.getChildren(leaf.getCode());        int size = children.size();        if (size == 0)            return;        int i = 0;        Iterator ri = children.iterator();        while (ri.hasNext()) {            Leaf childlf = (Leaf) ri.next();            if (childlf.getIsHome())                ShowBoardsToString(request, sb, childlf, rootlayer);        }    }        public void ShowLeafToString(HttpServletRequest request, StringBuffer sb,                                 Leaf leaf, int rootlayer) {        String code = leaf.getCode();        String name = leaf.getName();        int layer = leaf.getLayer();        String blank = "";        int d = layer - rootlayer;        for (int i = 0; i < d; i++) {            blank += "&nbsp;&nbsp;";        }        if (leaf.getIsHome()) {            if (leaf.getChildCount() > 0) {                if (leaf.getType() == leaf.TYPE_DOMAIN)                    sb.append("<a>" + blank + "╋ " + name + "</option><BR>");                else if (leaf.getType() == leaf.TYPE_BOARD) {                    String sName = name;                    if (!leaf.getColor().equals(""))                        sName = "<font color='" + leaf.getColor() + "'>" + name + "</font>";                    if (leaf.isBold())                        sName = "<strong>" + sName + "</strong>";                    sb.append("<a href='" +                              ForumPage.getListTopicPage(request, code) + "'>" +                              blank + "├『" +                              sName + "』</option><BR>");                }            } else {                if (leaf.getType() == leaf.TYPE_DOMAIN)                    sb.append("<a>" + blank + "╋ " + name + "</option><BR>");                else if (leaf.getType() == leaf.TYPE_BOARD) {                    String sName = name;                    if (!leaf.getColor().equals(""))                        sName = "<font color='" + leaf.getColor() + "'>" + name + "</font>";                    if (leaf.isBold())                        sName = "<strong>" + sName + "</strong>";                    sb.append("<a href='" +                              ForumPage.getListTopicPage(request, code) + "'>" +                              blank + "├『" +                              sName +                              "』</option><BR>");                }            }        }    }        public boolean isDisplay(HttpServletRequest request, Privilege privilege) {        if (isHome) {            if (!Config.getInstance().getBooleanProperty(                    "forum.isBoardCannotEnterShow")) {                if (privilege.canUserDo(request, code, "enter_board")) {                    return true;                } else                    return false;            } else                return true;        } else            return false;    }            public Vector getBoardsByTodayPost(int count) {        Vector v = new Vector();        String sql = "select code from sq_board order by today_count desc";        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        ResultSet rs = null;        try {            pstmt = conn.prepareStatement(sql);            conn.setMaxRows(count);            rs = conn.executePreQuery();            conn.setFetchSize(count);            Directory dir = new Directory();            while (rs.next()) {                Leaf lf = dir.getLeaf(rs.getString(1));                if (lf != null)                    v.addElement(lf);            }        } catch (SQLException e) {            logger.error("getBoardsByTodayPost:" + e.getMessage());        } finally {            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}                rs = null;            }            if (pstmt != null) {                try {                    pstmt.close();                } catch (Exception e) {}                pstmt = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }        return v;    }    private String logo;    private int todayCount = 0;    private java.util.Date todayDate;    private int topicCount = 0;    private int postCount = 0;    private String theme = "default";    private String skin = "default";    private boolean loaded = false;    private boolean locked;    private String boardRule;    private String color = "";    private int webeditAllowType = WEBEDIT_ALLOW_TYPE_UBB_NORMAL;    private String plugin2Code;    private int checkMsg = 0;    private int delMode = 0;    private int displayStyle;    private boolean bold = false;}

⌨️ 快捷键说明

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