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