List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:com.inkwell.internet.slogan.util.ActionUtil.java
License:Open Source License
/** * Given an ActionRequest, grabs the field values from the form and * populates an Slogan object with them. This object can then be validated * and then stored.//from w ww. jav a2 s . c o m * * @param request * @return */ public static Slogan sloganFromRequest(ActionRequest request) { SloganImpl slogan = new SloganImpl(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); slogan.setCompanyId(themeDisplay.getCompanyId()); slogan.setGroupId(themeDisplay.getScopeGroupId()); slogan.setUserId(themeDisplay.getUserId()); slogan.setSloganIdString(ParamUtil.getString(request, "sloganPrimKey")); slogan.setSloganText(ParamUtil.getString(request, "sloganText")); if (slogan.getSloganIdString() != "") { slogan.setSloganId(Long.parseLong(ParamUtil.getString(request, "sloganPrimKey"))); } int sloganDateMonth = ParamUtil.getInteger(request, "sloganDateMonth"); int sloganDateDay = ParamUtil.getInteger(request, "sloganDateDay"); int sloganDateYear = ParamUtil.getInteger(request, "sloganDateYear"); try { slogan.setSloganDate( PortalUtil.getDate(sloganDateMonth, sloganDateDay, sloganDateYear, new PortalException())); } catch (PortalException ex) { slogan.setSloganDate(new Date()); } return slogan; }
From source file:com.jhu.cvrg.guid.utility.ResourceUtility.java
License:Apache License
public static long getCurrentGroupId() { PortletRequest request = (PortletRequest) liferayFacesContext.getExternalContext().getRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); return themeDisplay.getLayout().getGroupId(); }
From source file:com.jhu.cvrg.portal.survey.utility.ResourceUtility.java
License:Apache License
public static String getPortletId() { PortletRequest request = (PortletRequest) liferayFacesContext.getExternalContext().getRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); return String.valueOf(themeDisplay.getPlid()); }
From source file:com.jhu.cvrg.portal.videodisplay.utility.ResourceUtility.java
License:Apache License
public static long getCurrentGroupId() { LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance(); PortletRequest request = (PortletRequest) liferayFacesContext.getExternalContext().getRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); return themeDisplay.getLayout().getGroupId(); }
From source file:com.knowarth.portlets.themepersonalizer.hook.ThemePersonalizerServicePreAction.java
License:Open Source License
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isSignedIn()) { Layout layout = themeDisplay.getLayout(); try {//www . ja v a2 s. c o m boolean wapTheme = BrowserSnifferUtil.isWap(request); if (layout != null && !layout.isTypeControlPanel() && !wapTheme) { long userId = themeDisplay.getUserId(); Theme theme = themeDisplay.getTheme(); ColorScheme colorScheme = themeDisplay.getColorScheme(); UserPersonalizedTheme userPersonalTheme; userPersonalTheme = UserPersonalizedThemeLocalServiceUtil .findByUserIDAndLayoutId(themeDisplay.getCompanyId(), userId, layout.getLayoutId()); if (Validator.isNotNull(userPersonalTheme)) { theme = ThemeLocalServiceUtil.fetchTheme(themeDisplay.getCompanyId(), userPersonalTheme.getThemeId()); if (Validator.isNotNull(theme)) { colorScheme = ThemeLocalServiceUtil.getColorScheme(themeDisplay.getCompanyId(), theme.getThemeId(), userPersonalTheme.getColorSchemeId(), wapTheme); request.setAttribute(WebKeys.THEME, theme); request.setAttribute("COLOR_SCHEME", colorScheme); themeDisplay.setLookAndFeel(theme, colorScheme); } } } } catch (SystemException e) { _log.error("Error setting personalized theme information", e); } } }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerAdminPortlet.java
License:Open Source License
@Override protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { try {// w ww .ja va 2 s . c o m ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); List selectedThemeIdList = new ArrayList(); List<AvailablePersonalizedTheme> selectedPersonalizedThemes = AvailablePersonalizedThemeLocalServiceUtil .findAllByCompanyId(themeDisplay.getCompanyId()); List<String> selectedThemeIds = new ArrayList<String>(); for (AvailablePersonalizedTheme selectedPersonalizedTheme : selectedPersonalizedThemes) { Theme themeObject = ThemeLocalServiceUtil.fetchTheme(themeDisplay.getCompanyId(), selectedPersonalizedTheme.getThemeId()); if (Validator.isNotNull(themeObject)) { selectedThemeIdList.add(new KeyValuePair(themeObject.getThemeId(), themeObject.getName())); selectedThemeIds.add(themeObject.getThemeId()); } } List availableThemeIdsList = new ArrayList(); List<Theme> themes = ThemeLocalServiceUtil.getThemes(themeDisplay.getCompanyId()); for (Theme themeObject : themes) { if (!selectedThemeIds.contains(themeObject.getThemeId()) && !themeObject.isWapTheme()) { availableThemeIdsList.add(new KeyValuePair(themeObject.getThemeId(), themeObject.getName())); } } availableThemeIdsList = ListUtil.sort(availableThemeIdsList, new KeyValuePairComparator(false, true)); renderRequest.setAttribute("selectedThemeIdList", selectedThemeIdList); renderRequest.setAttribute("availableThemeIdsList", availableThemeIdsList); } catch (SystemException e) { SessionErrors.add(renderRequest, "system-error-please-contact-adminstrator"); _log.error("Error retriving available theme information", e); } include(viewJSP, renderRequest, renderResponse); }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerAdminPortlet.java
License:Open Source License
@ProcessAction(name = "saveAvailableThemes") public void saveAction(ActionRequest request, ActionResponse response) { try {/*from www. j a v a2 s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String themesIdsString = ParamUtil.getString(request, "selectedThemeIds"); AvailablePersonalizedThemeLocalServiceUtil.removeAllByCompanyId(themeDisplay.getCompanyId()); if (Validator.isNotNull(themesIdsString)) { String[] themeIds = themesIdsString.split(","); for (String themeId : themeIds) { AvailablePersonalizedThemeLocalServiceUtil .addAvailablePersonalizedTheme(themeDisplay.getCompanyId(), themeId); } } SessionMessages.add(request, "available-theme-changes-saved-successfully"); } catch (SystemException e) { SessionErrors.add(request, "system-error-please-contact-adminstrator"); _log.error("Error persisting available theme information", e); } }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@Override protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { try {/* w w w. j ava 2s. c om*/ ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE); } else { Map<String, String> availableThemesMap = retrieveAvailableThemesMap(themeDisplay.getCompanyId()); Layout layout = themeDisplay.getLayout(); UserPersonalizedTheme userPersonalTheme = UserPersonalizedThemeLocalServiceUtil .findByUserIDAndLayoutId(themeDisplay.getCompanyId(), themeDisplay.getUserId(), layout.getLayoutId()); if (Validator.isNotNull(userPersonalTheme)) { setPersonalizedThemeParams(renderRequest, themeDisplay.getCompanyId(), availableThemesMap, userPersonalTheme); } else { setDefaults(renderRequest, themeDisplay.getCompanyId(), availableThemesMap); } } } catch (SystemException e) { SessionErrors.add(renderRequest, "system-error-please-contact-adminstrator"); _log.error("Error retrieving personalized theme information", e); } include(viewJSP, renderRequest, renderResponse); }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@ProcessAction(name = "savePersonalizedTheme") public void saveAction(ActionRequest request, ActionResponse response) throws IOException { try {/*from www .j av a 2 s . co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String selectedThemeId = ParamUtil.getString(request, PARAM_SELECTED_THEME_ID); String selectedColorSchemeId = ParamUtil.getString(request, PARAM_SELECTED_COLOR_SCHEME_ID); boolean applyForAllPages = ParamUtil.getBoolean(request, PARAM_APPLY_FOR_ALL_PAGES); UserPersonalizedThemeLocalServiceUtil.addUserPersonalizedTheme(themeDisplay.getUserId(), themeDisplay.getLayout().getLayoutId(), selectedThemeId, selectedColorSchemeId, applyForAllPages); SessionMessages.add(request, "theme-personalization-changes-saved-scucessfully"); sendRedirect(request, response); } catch (SystemException e) { SessionErrors.add(request, "system-error-please-contact-adminstrator"); _log.error("Error persisting personalized theme information", e); } }
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@ProcessAction(name = "resetPersonalizedTheme") public void resetAction(ActionRequest request, ActionResponse response) throws IOException { try {/*from w ww.j av a 2s .c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); UserPersonalizedTheme userPersonalizedTheme = UserPersonalizedThemeLocalServiceUtil .findByUserIDAndLayoutId(themeDisplay.getCompanyId(), themeDisplay.getUserId(), themeDisplay.getLayout().getLayoutId()); UserPersonalizedThemeLocalServiceUtil.deleteUserPersonalizedTheme(userPersonalizedTheme); SessionMessages.add(request, "theme-personalization-restored-to-default"); sendRedirect(request, response); } catch (SystemException e) { SessionErrors.add(request, "system-error-please-contact-adminstrator"); _log.error("Error removing personalized theme information", e); } }