List of usage examples for com.liferay.portal.kernel.util LocalizationUtil getPreferencesValues
public static String[] getPreferencesValues(PortletPreferences preferences, String key, String languageId)
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static String[] getThreadPriority(PortletPreferences preferences, String languageId, double value, ThemeDisplay themeDisplay) throws Exception { String[] priorities = LocalizationUtil.getPreferencesValues(preferences, "priorities", languageId); String[] priorityPair = _findThreadPriority(value, themeDisplay, priorities); if (priorityPair == null) { String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getSiteDefault()); priorities = LocalizationUtil.getPreferencesValues(preferences, "priorities", defaultLanguageId); priorityPair = _findThreadPriority(value, themeDisplay, priorities); }//from w w w .j a va 2 s.c o m return priorityPair; }
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static String getUserRank(PortletPreferences preferences, String languageId, int posts) throws Exception { String rank = StringPool.BLANK; String[] ranks = LocalizationUtil.getPreferencesValues(preferences, "ranks", languageId); for (int i = 0; i < ranks.length; i++) { String[] kvp = StringUtil.split(ranks[i], CharPool.EQUAL); String kvpName = kvp[0];/* w w w . j a v a 2s .c om*/ int kvpPosts = GetterUtil.getInteger(kvp[1]); if (posts >= kvpPosts) { rank = kvpName; } else { break; } } return rank; }
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static String[] getUserRank(PortletPreferences preferences, String languageId, MBStatsUser statsUser) throws Exception { String[] rank = { StringPool.BLANK, StringPool.BLANK }; int maxPosts = 0; Group group = GroupLocalServiceUtil.getGroup(statsUser.getGroupId()); long companyId = group.getCompanyId(); String[] ranks = LocalizationUtil.getPreferencesValues(preferences, "ranks", languageId); for (int i = 0; i < ranks.length; i++) { String[] kvp = StringUtil.split(ranks[i], CharPool.EQUAL); String curRank = kvp[0];/*from ww w .j a va 2s. c om*/ String curRankValue = kvp[1]; String[] curRankValueKvp = StringUtil.split(curRankValue, CharPool.COLON); if (curRankValueKvp.length <= 1) { int posts = GetterUtil.getInteger(curRankValue); if ((posts <= statsUser.getMessageCount()) && (posts >= maxPosts)) { rank[0] = curRank; maxPosts = posts; } } else { String entityType = curRankValueKvp[0]; String entityValue = curRankValueKvp[1]; try { if (_isEntityRank(companyId, statsUser, entityType, entityValue)) { rank[1] = curRank; break; } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e); } } } } return rank; }
From source file:com.liferay.portlet.messageboards.util.MBUtil.java
License:Open Source License
public static String[] getThreadPriority(PortletPreferences preferences, String languageId, double value, ThemeDisplay themeDisplay) throws Exception { String[] priorities = LocalizationUtil.getPreferencesValues(preferences, "priorities", languageId); String[] priorityPair = _findThreadPriority(value, themeDisplay, priorities); if (priorityPair == null) { String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault()); priorities = LocalizationUtil.getPreferencesValues(preferences, "priorities", defaultLanguageId); priorityPair = _findThreadPriority(value, themeDisplay, priorities); }/* w w w . j a v a 2 s .c om*/ return priorityPair; }
From source file:com.liferay.portlet.messageboards.util.MBUtil.java
License:Open Source License
public static String[] getUserRank(PortletPreferences preferences, String languageId, MBStatsUser statsUser) throws Exception { String[] rank = { StringPool.BLANK, StringPool.BLANK }; int maxPosts = 0; Group group = GroupLocalServiceUtil.getGroup(statsUser.getGroupId()); long companyId = group.getCompanyId(); String[] ranks = LocalizationUtil.getPreferencesValues(preferences, "ranks", languageId); for (int i = 0; i < ranks.length; i++) { String[] kvp = StringUtil.split(ranks[i], CharPool.EQUAL); String curRank = kvp[0];//from w w w. j a v a 2 s . co m String curRankValue = kvp[1]; String[] curRankValueKvp = StringUtil.split(curRankValue, CharPool.COLON); if (curRankValueKvp.length <= 1) { int posts = GetterUtil.getInteger(curRankValue); if ((posts <= statsUser.getMessageCount()) && (posts >= maxPosts)) { rank[0] = curRank; maxPosts = posts; } } else { String entityType = curRankValueKvp[0]; String entityValue = curRankValueKvp[1]; try { if (_isEntityRank(companyId, statsUser, entityType, entityValue)) { rank[1] = curRank; break; } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e); } } } } return rank; }