List of usage examples for com.liferay.portal.kernel.servlet BrowserSnifferUtil isIe
public static boolean isIe(HttpServletRequest httpServletRequest)
From source file:com.liferay.adaptive.media.image.web.internal.servlet.taglib.AMPictureDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { if (BrowserSnifferUtil.isIe(request)) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); StringBundler sb = new StringBundler(7); sb.append("<script src=\""); sb.append(themeDisplay.getPortalURL()); sb.append(_portal.getPathProxy()); sb.append(_servletContext.getContextPath()); sb.append("/picturefill.min.js\" "); sb.append("type= \"text/javascript\">"); sb.append("</script>"); printWriter.println(sb.toString()); }/* w ww. ja v a 2 s . co m*/ }
From source file:com.liferay.adaptive.media.image.web.servlet.taglib.AdaptiveMediaPictureDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { if (BrowserSnifferUtil.isIe(request)) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); StringBundler sb = new StringBundler(7); sb.append("<script src=\""); sb.append(themeDisplay.getPortalURL()); sb.append(_portal.getPathProxy()); sb.append(_servletContext.getContextPath()); sb.append("/picturefill.js\" "); sb.append("type= \"text/javascript\">"); sb.append("</script>"); printWriter.println(sb.toString()); }// w ww.j a v a2 s. c o m }
From source file:com.liferay.content.targeting.rule.browser.BrowserRule.java
License:Open Source License
@Override public boolean evaluate(HttpServletRequest request, RuleInstance ruleInstance, AnonymousUser anonymousUser) throws Exception { String browser = ruleInstance.getTypeSettings(); if (browser.equals(CHROME) && BrowserSnifferUtil.isChrome(request)) { return true; } else if (browser.equals(FIREFOX) && BrowserSnifferUtil.isFirefox(request)) { return true; } else if (browser.equals(IE) && BrowserSnifferUtil.isIe(request)) { return true; } else if (browser.equals(OPERA) && BrowserSnifferUtil.isOpera(request)) { return true; } else if (browser.equals(SAFARI) && BrowserSnifferUtil.isSafari(request)) { return true; }//from w w w.ja va 2 s. c o m return false; }
From source file:com.liferay.content.targeting.rule.browser.BrowserRuleTest.java
License:Open Source License
@Test public void testIE() throws Exception { when(_ruleInstance.getTypeSettings()).thenReturn(BrowserRule.IE); when(BrowserSnifferUtil.isIe(_request)).thenReturn(true); Assert.assertTrue(_browserRule.evaluate(_request, _ruleInstance, _anonymousUser)); }
From source file:com.liferay.taglib.aui.ScriptTag.java
License:Open Source License
protected void processEndTag(ScriptData scriptData) throws Exception { JspWriter jspWriter = pageContext.getOut(); jspWriter.write("<script type=\"text/javascript\">\n// <![CDATA[\n"); StringBundler rawSB = scriptData.getRawSB(); rawSB.writeTo(jspWriter);/*from w ww . j a v a 2 s . c o m*/ StringBundler callbackSB = scriptData.getCallbackSB(); if (callbackSB.index() > 0) { String loadMethod = "use"; HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) < 8)) { loadMethod = "ready"; } jspWriter.write("AUI()."); jspWriter.write(loadMethod); jspWriter.write("("); Set<String> useSet = scriptData.getUseSet(); for (String use : useSet) { jspWriter.write(StringPool.APOSTROPHE); jspWriter.write(use); jspWriter.write(StringPool.APOSTROPHE); jspWriter.write(StringPool.COMMA_AND_SPACE); } jspWriter.write("function(A) {"); callbackSB.writeTo(jspWriter); jspWriter.write("});"); } jspWriter.write("\n// ]]>\n</script>"); }
From source file:com.marcelmika.lims.portal.portlet.BrowserDetector.java
License:Open Source License
/** * Returns true if the browser that sent the request needs support for older * internet explorer browsers.//from w w w. ja va 2 s .c om * * @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; }
From source file:com.marcelmika.lims.portal.portlet.BrowserDetector.java
License:Open Source License
/** * Returns false if the browser that sent the request is internet explorer in a version * that is not supported.// w ww. j a va 2 s .com * * @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; }
From source file:org.apache.jsp.html.taglib.ui.input_005feditor.page_jsp.java
License:Open Source License
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;/*from ww w . j av a 2s. c om*/ HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); // liferay-theme:defineObjects com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .get(com.liferay.taglib.theme.DefineObjectsTag.class); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null); int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doStartTag(); if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); com.liferay.portal.theme.ThemeDisplay themeDisplay = null; com.liferay.portal.model.Company company = null; com.liferay.portal.model.Account account = null; com.liferay.portal.model.User user = null; com.liferay.portal.model.User realUser = null; com.liferay.portal.model.Contact contact = null; com.liferay.portal.model.Layout layout = null; java.util.List layouts = null; java.lang.Long plid = null; com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null; java.lang.Long scopeGroupId = null; com.liferay.portal.security.permission.PermissionChecker permissionChecker = null; java.util.Locale locale = null; java.util.TimeZone timeZone = null; com.liferay.portal.model.Theme theme = null; com.liferay.portal.model.ColorScheme colorScheme = null; com.liferay.portal.theme.PortletDisplay portletDisplay = null; java.lang.Long portletGroupId = null; themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay"); company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company"); account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account"); user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user"); realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser"); contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact"); layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout"); layouts = (java.util.List) _jspx_page_context.findAttribute("layouts"); plid = (java.lang.Long) _jspx_page_context.findAttribute("plid"); layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context .findAttribute("layoutTypePortlet"); scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId"); permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context .findAttribute("permissionChecker"); locale = (java.util.Locale) _jspx_page_context.findAttribute("locale"); timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone"); theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme"); colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme"); portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context .findAttribute("portletDisplay"); portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId"); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); PortletRequest portletRequest = (PortletRequest) request .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); PortletResponse portletResponse = (PortletResponse) request .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); String namespace = StringPool.BLANK; boolean useNamespace = GetterUtil.getBoolean((String) request.getAttribute("aui:form:useNamespace"), true); if ((portletResponse != null) && useNamespace) { namespace = portletResponse.getNamespace(); } String currentURL = PortalUtil.getCurrentURL(request); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); out.write('\n'); out.write('\n'); String cssClass = GetterUtil .getString((String) request.getAttribute("liferay-ui:input-editor:cssClass")); String name = GetterUtil.getString((String) request.getAttribute("liferay-ui:input-editor:name"), namespace + "editor"); String editorImpl = (String) request.getAttribute("liferay-ui:input-editor:editorImpl"); if (Validator.isNull(editorImpl)) { editorImpl = PropsValues.EDITOR_WYSIWYG_DEFAULT; } else { editorImpl = PropsUtil.get(editorImpl); } String toolbarSet = (String) request.getAttribute("liferay-ui:input-editor:toolbarSet"); String initMethod = GetterUtil.getString( (String) request.getAttribute("liferay-ui:input-editor:initMethod"), namespace + "initEditor"); String onChangeMethod = (String) request.getAttribute("liferay-ui:input-editor:onChangeMethod"); String height = GetterUtil.getString((String) request.getAttribute("liferay-ui:input-editor:height"), "450"); String width = GetterUtil.getString((String) request.getAttribute("liferay-ui:input-editor:width"), "640"); StringBundler sb = new StringBundler(); sb.append(themeDisplay.getPathContext()); sb.append("/html/js/editor/editor.jsp?p_l_id="); sb.append(plid); sb.append("&p_main_path="); sb.append(HttpUtil.encodeURL(themeDisplay.getPathMain())); sb.append("&doAsUserId="); String doAsUserId = themeDisplay.getDoAsUserId(); if (Validator.isNull(doAsUserId)) { doAsUserId = Encryptor.encrypt(company.getKeyObj(), String.valueOf(themeDisplay.getUserId())); } sb.append(HttpUtil.encodeURL(doAsUserId)); sb.append("&editorImpl="); sb.append(editorImpl); if (Validator.isNotNull(toolbarSet)) { sb.append("&toolbarSet="); sb.append(toolbarSet); } if (Validator.isNotNull(initMethod)) { sb.append("&initMethod="); sb.append(initMethod); } if (Validator.isNotNull(onChangeMethod)) { sb.append("&onChangeMethod="); sb.append(onChangeMethod); } sb.append("&cssPath="); sb.append(HttpUtil.encodeURL(themeDisplay.getPathThemeCss())); String cssClasses = "portlet "; Portlet portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET); if (portlet != null) { cssClasses += portlet.getCssClassWrapper(); } sb.append("&cssClasses="); sb.append(HttpUtil.encodeURL(cssClasses)); String editorURL = sb.toString(); out.write("\n"); out.write("\n"); out.write("<iframe "); out.print(Validator.isNotNull(cssClass) ? "class=\"" + cssClass + "\"" : StringPool.BLANK); out.write(' '); out.print(BrowserSnifferUtil.isIe(request) && (BrowserSnifferUtil.getMajorVersion(request) <= 8) ? "frameborder=\"0\"" : StringPool.BLANK); out.write(" height=\""); out.print(height); out.write("\" id=\""); out.print(name); out.write("\" name=\""); out.print(name); out.write("\" src=\""); out.print(editorURL); out.write("\" style=\"border: none;\" width=\""); out.print(width); out.write("\"></iframe>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }