forked from fanruan/design
vito
7 years ago
7 changed files with 168 additions and 153 deletions
@ -1,59 +1,69 @@
|
||||
/** |
||||
* |
||||
* |
||||
*/ |
||||
package com.fr.design.mainframe.bbs; |
||||
|
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* @author neil |
||||
* |
||||
* @date: 2015-3-10-上午9:50:13 |
||||
*/ |
||||
public class BBSConstants { |
||||
|
||||
//判断是否更新的关键字
|
||||
public static final String UPDATE_KEY = loadAttribute("UPDATE_KEY", "newIsPopup"); |
||||
|
||||
|
||||
private static final String GUEST_KEY = "USER"; |
||||
private static final String LINK_KEY = "LINK"; |
||||
private static final int GUEST_NUM = 5; |
||||
|
||||
//用户名信息数组
|
||||
public static final String[] ALL_GUEST = loadAllGuestsInfo(GUEST_KEY); |
||||
//用户论坛链接信息
|
||||
public static final String[] ALL_LINK = loadAllGuestsInfo(LINK_KEY); |
||||
|
||||
private static Properties PROP = null; |
||||
|
||||
//加载所有用户的信息, 用户名, 论坛连接
|
||||
private static String[] loadAllGuestsInfo(String key){ |
||||
String[] allGuests = new String[GUEST_NUM]; |
||||
for (int i = 0; i < GUEST_NUM; i++) { |
||||
allGuests[i] = loadAttribute(key + i, StringUtils.EMPTY); |
||||
} |
||||
|
||||
return allGuests; |
||||
} |
||||
//如果要定制, 直接改bbs.properties就行了
|
||||
private static String loadAttribute(String key, String defaultValue) { |
||||
if (PROP == null) { |
||||
PROP = new Properties(); |
||||
try { |
||||
PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); |
||||
} catch (Exception e) { |
||||
} |
||||
} |
||||
|
||||
String p = PROP.getProperty(key); |
||||
if (StringUtils.isEmpty(p)) { |
||||
p = defaultValue; |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
|
||||
|
||||
private static final String GUEST_KEY = "USER"; |
||||
private static final String GUEST_KEY_ONLINE = "guest.user"; |
||||
private static final String LINK_KEY = "LINK"; |
||||
private static final String LINK_KEY_ONLINE = "guest.link"; |
||||
|
||||
private static Properties PROP = null; |
||||
|
||||
public static String[] getAllGuest() { |
||||
return loadAllGuestsInfoOnline(GUEST_KEY_ONLINE, loadAllGuestsInfo(GUEST_KEY)); |
||||
} |
||||
|
||||
public static String[] getAllLink() { |
||||
return loadAllGuestsInfoOnline(LINK_KEY_ONLINE, loadAllGuestsInfo(LINK_KEY)); |
||||
} |
||||
|
||||
//加载所有用户的信息, 用户名, 论坛连接
|
||||
private static String loadAllGuestsInfo(String key) { |
||||
return loadAttribute(key, StringUtils.EMPTY); |
||||
} |
||||
|
||||
//加载所有用户的信息, 用户名, 论坛连接
|
||||
private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) { |
||||
String[] allGuests = new String[0]; |
||||
String guest = SiteCenter.getInstance().acquireUrlByKind(key, defaultValue); |
||||
if (StringUtils.isNotEmpty(guest)) { |
||||
allGuests = guest.split("\\|"); |
||||
} |
||||
return allGuests; |
||||
} |
||||
|
||||
//如果要定制, 直接改bbs.properties就行了
|
||||
private static String loadAttribute(String key, String defaultValue) { |
||||
if (PROP == null) { |
||||
PROP = new Properties(); |
||||
try { |
||||
PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); |
||||
} catch (Exception e) { |
||||
} |
||||
} |
||||
|
||||
String p = PROP.getProperty(key); |
||||
if (StringUtils.isEmpty(p)) { |
||||
p = defaultValue; |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue