当前位置: 首页>>代码示例>>Java>>正文


Java ThemeLocalServiceUtil.getColorScheme方法代码示例

本文整理汇总了Java中com.liferay.portal.service.ThemeLocalServiceUtil.getColorScheme方法的典型用法代码示例。如果您正苦于以下问题:Java ThemeLocalServiceUtil.getColorScheme方法的具体用法?Java ThemeLocalServiceUtil.getColorScheme怎么用?Java ThemeLocalServiceUtil.getColorScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.service.ThemeLocalServiceUtil的用法示例。


在下文中一共展示了ThemeLocalServiceUtil.getColorScheme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.liferay.portal.service.ThemeLocalServiceUtil; //导入方法依赖的package包/类
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 {

			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);
		}

	}

}
 
开发者ID:knowarth-technologies,项目名称:theme-personalizer,代码行数:49,代码来源:ThemePersonalizerServicePreAction.java

示例2: switchThemeForRequest

import com.liferay.portal.service.ThemeLocalServiceUtil; //导入方法依赖的package包/类
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;
	
	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);
	
	// Add warning message 
	
	Locale locale = themeDisplay.getLocale();
	
	String message = LanguageUtil.format(locale, "this-page-is-displayed-with-x-theme-just-for-your-session", theme.getName())
			+ " <a id=\"clearThemeSwitchLink\" href=\"#\">" 
			+ LanguageUtil.get(locale, "display-the-page-with-original-theme") + "</a>";
	
	PortalMessages.add(request, PortalMessages.KEY_ANIMATION, false);
	PortalMessages.add(request, PortalMessages.KEY_MESSAGE, message);
	PortalMessages.add(request, PortalMessages.KEY_TIMEOUT, -1);
	PortalMessages.add(request, PortalMessages.KEY_CSS_CLASS, "alert-warn");
	
	// 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);
}
 
开发者ID:slemarchand,项目名称:page-composer-hook,代码行数:56,代码来源:ThemeSwitchServicePreAction.java


注:本文中的com.liferay.portal.service.ThemeLocalServiceUtil.getColorScheme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。