List of usage examples for com.liferay.portal.kernel.servlet BrowserSnifferUtil isMobile
public static boolean isMobile(HttpServletRequest httpServletRequest)
From source file:com.liferay.content.targeting.rule.os.OSRule.java
License:Open Source License
@Override public boolean evaluate(HttpServletRequest request, RuleInstance ruleInstance, AnonymousUser anonymousUser) throws Exception { String os = ruleInstance.getTypeSettings(); if (os.equals(ANDROID) && BrowserSnifferUtil.isAndroid(request)) { return true; } else if (os.equals(IOS) && BrowserSnifferUtil.isMac(request) && BrowserSnifferUtil.isMobile(request)) { return true; } else if (os.equals(LINUX) && BrowserSnifferUtil.isLinux(request)) { return true; } else if (os.equals(MAC) && BrowserSnifferUtil.isMac(request) && !BrowserSnifferUtil.isMobile(request)) { return true; } else if (os.equals(WINDOWS) && BrowserSnifferUtil.isWindows(request)) { return true; }/*from ww w .j a va2 s . co m*/ return false; }
From source file:com.liferay.content.targeting.rule.os.OSRuleTest.java
License:Open Source License
@Test public void testIOS() throws Exception { when(_ruleInstance.getTypeSettings()).thenReturn(OSRule.IOS); when(BrowserSnifferUtil.isMac(_request)).thenReturn(true); when(BrowserSnifferUtil.isMobile(_request)).thenReturn(true); Assert.assertTrue(_osRule.evaluate(_request, _ruleInstance, _anonymousUser)); }
From source file:com.liferay.content.targeting.rule.os.OSRuleTest.java
License:Open Source License
@Test public void testMac() throws Exception { when(_ruleInstance.getTypeSettings()).thenReturn(OSRule.MAC); when(BrowserSnifferUtil.isMac(_request)).thenReturn(true); when(BrowserSnifferUtil.isMobile(_request)).thenReturn(false); Assert.assertTrue(_osRule.evaluate(_request, _ruleInstance, _anonymousUser)); }
From source file:com.liferay.frontend.editor.tinymce.web.editor.configuration.TinyMCEEditorConfigContributor.java
License:Open Source License
protected JSONArray getToolbarJSONArray(Map<String, Object> inputEditorTaglibAttributes, ThemeDisplay themeDisplay) {/* w ww.jav a 2 s .c o m*/ JSONObject toolbarsJSONObject = getToolbarsJSONObject(inputEditorTaglibAttributes); String toolbarSet = (String) inputEditorTaglibAttributes.get("liferay-ui:input-editor:toolbarSet"); String currentToolbarSet = TextFormatter.format(HtmlUtil.escapeJS(toolbarSet), TextFormatter.M); if (BrowserSnifferUtil.isMobile(themeDisplay.getRequest())) { currentToolbarSet = "phone"; } JSONArray toolbarJSONArray = toolbarsJSONObject.getJSONArray(currentToolbarSet); if (toolbarJSONArray == null) { toolbarJSONArray = toolbarsJSONObject.getJSONArray("liferay"); } return toolbarJSONArray; }
From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private JSONObject _toJSONObject(HttpServletRequest request, long groupId, LayoutTreeNodes layoutTreeNodes, LayoutSetBranch layoutSetBranch) throws Exception { if (_log.isDebugEnabled()) { StringBundler sb = new StringBundler(5); sb.append("_toJSON(groupId="); sb.append(groupId);// w ww. j av a 2s .c om sb.append(", layoutTreeNodes="); sb.append(layoutTreeNodes); sb.append(StringPool.CLOSE_PARENTHESIS); _log.debug(sb.toString()); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); boolean hasManageLayoutsPermission = GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), groupId, ActionKeys.MANAGE_LAYOUTS); boolean mobile = BrowserSnifferUtil.isMobile(request); for (LayoutTreeNode layoutTreeNode : layoutTreeNodes) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject childrenJSONObject = _toJSONObject(request, groupId, layoutTreeNode.getChildLayoutTreeNodes(), layoutSetBranch); jsonObject.put("children", childrenJSONObject); Layout layout = layoutTreeNode.getLayout(); jsonObject.put("contentDisplayPage", layout.isContentDisplayPage()); jsonObject.put("deleteable", _isDeleteable(layout, themeDisplay, layoutSetBranch)); jsonObject.put("friendlyURL", layout.getFriendlyURL()); if (layout instanceof VirtualLayout) { VirtualLayout virtualLayout = (VirtualLayout) layout; jsonObject.put("groupId", virtualLayout.getSourceGroupId()); } else { jsonObject.put("groupId", layout.getGroupId()); } jsonObject.put("hasChildren", layout.hasChildren()); jsonObject.put("layoutId", layout.getLayoutId()); jsonObject.put("name", layout.getName(themeDisplay.getLocale())); jsonObject.put("parentable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.ADD_LAYOUT)); jsonObject.put("parentLayoutId", layout.getParentLayoutId()); jsonObject.put("plid", layout.getPlid()); jsonObject.put("priority", layout.getPriority()); jsonObject.put("privateLayout", layout.isPrivateLayout()); jsonObject.put("regularURL", layout.getRegularURL(request)); jsonObject.put("sortable", hasManageLayoutsPermission && !mobile && SitesUtil.isLayoutSortable(layout)); jsonObject.put("type", layout.getType()); jsonObject.put("updateable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)); jsonObject.put("uuid", layout.getUuid()); LayoutRevision layoutRevision = LayoutStagingUtil.getLayoutRevision(layout); if (layoutRevision != null) { long layoutSetBranchId = layoutRevision.getLayoutSetBranchId(); if (_staging.isIncomplete(layout, layoutSetBranchId)) { jsonObject.put("incomplete", true); } LayoutSetBranch boundLayoutSetBranch = _layoutSetBranchLocalService .getLayoutSetBranch(layoutSetBranchId); LayoutBranch layoutBranch = layoutRevision.getLayoutBranch(); if (!layoutBranch.isMaster()) { jsonObject.put("layoutBranchId", layoutBranch.getLayoutBranchId()); jsonObject.put("layoutBranchName", layoutBranch.getName()); } if (layoutRevision.isHead()) { jsonObject.put("layoutRevisionHead", true); } jsonObject.put("layoutRevisionId", layoutRevision.getLayoutRevisionId()); jsonObject.put("layoutSetBranchId", layoutSetBranchId); jsonObject.put("layoutSetBranchName", boundLayoutSetBranch.getName()); } jsonArray.put(jsonObject); } JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(); responseJSONObject.put("layouts", jsonArray); responseJSONObject.put("total", layoutTreeNodes.getTotal()); return responseJSONObject; }
From source file:org.apache.jsp.html.js.editor.editor_jsp.java
License:Open Source License
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;//from w w w . ja v a 2 s .com 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"); 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"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); String editorImpl = ParamUtil.getString(request, "editorImpl", PropsValues.EDITOR_WYSIWYG_DEFAULT); if (!BrowserSnifferUtil.isRtf(request)) { if (BrowserSnifferUtil.isSafari(request) && BrowserSnifferUtil.isMobile(request)) { editorImpl = "simple"; } else if (BrowserSnifferUtil.isSafari(request) && (editorImpl.indexOf("simple") == -1)) { editorImpl = "tinymcesimple"; } else { editorImpl = "simple"; } } //editorImpl = "fckeditor"; //editorImpl = "liferay"; //editorImpl = "simple"; //editorImpl = "tinymce"; //editorImpl = "tinymcesimple"; // Resin won't allow dynamic content inside the jsp:include tag RequestDispatcher rd = application .getRequestDispatcher(StrutsUtil.TEXT_HTML_DIR + "/js/editor/" + editorImpl + ".jsp"); rd.include(request, response); out.write('\n'); out.write('\n'); } 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); } }