List of usage examples for com.liferay.portal.kernel.util WebKeys THEME
String THEME
To view the source code for com.liferay.portal.kernel.util WebKeys THEME.
Click Source Link
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 {//from ww w . j a v a 2 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.liferay.mobile.device.rules.rule.group.action.ThemeModificationActionHandler.java
License:Open Source License
@Override public void applyAction(MDRAction mdrAction, HttpServletRequest request, HttpServletResponse response) { long companyId = _portal.getCompanyId(request); UnicodeProperties typeSettingsProperties = mdrAction.getTypeSettingsProperties(); String themeId = GetterUtil.getString(typeSettingsProperties.getProperty("themeId")); Theme theme = _themeLocalService.fetchTheme(companyId, themeId); if (theme == null) { theme = _themeLocalService.getTheme(companyId, themeId); }// w w w. j a va 2 s .c o m if (theme == null) { return; } request.setAttribute(WebKeys.THEME, theme); String colorSchemeId = GetterUtil.getString(typeSettingsProperties.getProperty("colorSchemeId")); ColorScheme colorScheme = _themeLocalService.fetchColorScheme(companyId, themeId, colorSchemeId); if (colorScheme == null) { colorScheme = _themeLocalService.getColorScheme(companyId, themeId, colorSchemeId); } request.setAttribute(WebKeys.COLOR_SCHEME, colorScheme); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); themeDisplay.setLookAndFeel(theme, colorScheme); }
From source file:com.liferay.taglib.theme.IncludeTag.java
License:Open Source License
@Override public int doEndTag() throws JspException { try {//from www .j ava 2 s . co m ServletContext servletContext = getServletContext(); HttpServletRequest request = getServletRequest(); Theme theme = (Theme) request.getAttribute(WebKeys.THEME); ThemeUtil.include(servletContext, request, new PipingServletResponse(pageContext), pageContext, getPage(), theme); return EVAL_PAGE; } catch (Exception e) { throw new JspException(e); } }
From source file:com.liferay.taglib.util.IncludeTag.java
License:Open Source License
protected boolean themeResourceExists(String page) throws Exception { if ((page == null) || !_THEME_JSP_OVERRIDE_ENABLED || _strict) { return false; }/*w w w .j ava2 s .c om*/ ServletContext servletContext = getServletContext(); HttpServletRequest request = getServletRequest(); Theme theme = (Theme) request.getAttribute(WebKeys.THEME); String portletId = ThemeUtil.getPortletId(request); boolean exists = theme.resourceExists(servletContext, portletId, page); if (_log.isDebugEnabled() && exists) { String resourcePath = theme.getResourcePath(servletContext, null, page); _log.debug(resourcePath); } return exists; }
From source file:com.liferay.taglib.util.IncludeTag.java
License:Open Source License
private void _doIncludeTheme(String page) throws Exception { ServletContext servletContext = getServletContext(); HttpServletRequest request = getServletRequest(); HttpServletResponse response = getServletResponse(); Theme theme = (Theme) request.getAttribute(WebKeys.THEME); ThemeUtil.include(servletContext, request, response, pageContext, page, theme); }
From source file:com.slemarchand.pagecomposer.hook.events.ThemeParameterServicePreAction.java
License:Open Source License
private void switchThemeForRequest(String themeId, String colorSchemeId, ThemeDisplay themeDisplay) throws SystemException { HttpServletRequest request = themeDisplay.getRequest(); boolean wapTheme = BrowserSnifferUtil.isWap(request); long companyId = themeDisplay.getCompanyId(); Theme theme = ThemeLocalServiceUtil.getTheme(companyId, themeId, wapTheme); ColorScheme colorScheme = null;/* w w w .j a v a2s.c om*/ if (colorSchemeId != null) { colorScheme = ThemeLocalServiceUtil.getColorScheme(companyId, themeId, colorSchemeId, wapTheme); } else if (theme.hasColorSchemes()) { Iterator<ColorScheme> it = theme.getColorSchemes().iterator(); do { colorScheme = it.next(); } while (!colorScheme.isDefaultCs() && it.hasNext()); } // Override current theme request.setAttribute(WebKeys.THEME, theme); request.setAttribute("COLOR_SCHEME", colorScheme); // Can't use constant located un portal-impl.jar themeDisplay.setLookAndFeel(theme, colorScheme); // Inject Javascript into page bottom String javascriptSrc = themeDisplay.getPortalURL() + _JAVASCRIPT_PATH + "?t=" + _getJavascriptTimestamp(request); StringBundler sb = new StringBundler(); sb.append("<script src=\"" + javascriptSrc + "\" type=\"text/javascript\"></script>"); OutputData outputData = _getOutputData(request); String outputKey = this.getClass().getName(); outputData.addData(outputKey, WebKeys.PAGE_BODY_BOTTOM, sb); }