當前位置: 首頁>>代碼示例>>Java>>正文


Java BrowserSnifferUtil類代碼示例

本文整理匯總了Java中com.liferay.portal.kernel.servlet.BrowserSnifferUtil的典型用法代碼示例。如果您正苦於以下問題:Java BrowserSnifferUtil類的具體用法?Java BrowserSnifferUtil怎麽用?Java BrowserSnifferUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BrowserSnifferUtil類屬於com.liferay.portal.kernel.servlet包,在下文中一共展示了BrowserSnifferUtil類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: needsInternetExplorerSupport

import com.liferay.portal.kernel.servlet.BrowserSnifferUtil; //導入依賴的package包/類
/**
 * Returns true if the browser that sent the request needs support for older
 * internet explorer browsers.
 *
 * @param request RenderRequest
 * @return true if the browser needs internet explorer support
 */
public static boolean needsInternetExplorerSupport(RenderRequest request) {
    // Cast to http servlet request
    HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request);

    // Check the availability of Internet Explorer
    boolean isIE = BrowserSnifferUtil.isIe(httpServletRequest);
    float majorVersion = BrowserSnifferUtil.getMajorVersion(httpServletRequest);

    return isIE && majorVersion <= 8;
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:18,代碼來源:BrowserDetector.java

示例2: validateInternetExplorer

import com.liferay.portal.kernel.servlet.BrowserSnifferUtil; //導入依賴的package包/類
/**
 * Returns false if the browser that sent the request is internet explorer in a version
 * that is not supported.
 *
 * @param request HttpServletRequest
 * @return true if the request is valid
 */
private static boolean validateInternetExplorer(HttpServletRequest request) {

    // Check the availability of Internet Explorer
    boolean isIE = BrowserSnifferUtil.isIe(request);
    float majorVersion = BrowserSnifferUtil.getMajorVersion(request);

    // If it's not IE we stop validation
    return !isIE || majorVersion >= MIN_SUPPORTED_VERSION_IE;
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:17,代碼來源:BrowserDetector.java

示例3: run

import com.liferay.portal.kernel.servlet.BrowserSnifferUtil; //導入依賴的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

示例4: switchThemeForRequest

import com.liferay.portal.kernel.servlet.BrowserSnifferUtil; //導入依賴的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.kernel.servlet.BrowserSnifferUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。