/** * Check if the user can delete the current node * * @return true, if current mode is edit mode * @throws RepositoryException * @throws AccessControlException */ public static boolean isShowDelete(Node content) throws AccessControlException, RepositoryException { boolean isEditMode = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode())) isEditMode = true; ((ExtendedNode) content).checkPermission(PermissionType.SET_PROPERTY); ((ExtendedNode) content).checkPermission(PermissionType.ADD_NODE); ((ExtendedNode) content).checkPermission(PermissionType.REMOVE); return isEditMode; }
/** * Check if the current mode of the site is edit mode * * @return true, if current mode is edit mode */ public static boolean isShowQuickEdit() { try { boolean isEditMode = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode())) isEditMode = true; return isEditMode; } catch (Exception e) { return false; } }
/* * (non-Javadoc) * @see * org.exoplatform.webui.core.UIPortletApplication#processRender(org.exoplatform * .webui.application.WebuiApplication, * org.exoplatform.webui.application.WebuiRequestContext) */ public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception { PortletRequestContext pContext = (PortletRequestContext) context; PortletMode newMode = pContext.getApplicationMode(); PortletPreferences preferences = pContext.getRequest().getPreferences(); Boolean sharedCache = "true".equals(preferences.getValue(ENABLE_CACHE, "true")); if (context.getRemoteUser() == null || (Utils.isLiveMode() && sharedCache && !Utils.isPortalEditMode() && Utils.isPortletViewMode(pContext))) { WCMService wcmService = getApplicationComponent(WCMService.class); pContext .getResponse() .setProperty(MimeResponse.EXPIRATION_CACHE, "" + wcmService.getPortletExpirationCache()); if (log.isTraceEnabled()) log.trace("SCV rendering : cache set to " + wcmService.getPortletExpirationCache()); } if (!newMode.equals(mode)) { activateMode(newMode); mode = newMode; } Node nodeView = null; if (uiPresentation != null) { nodeView = uiPresentation.getNodeView(); if (nodeView != null) { TemplateService templateService = getApplicationComponent(TemplateService.class); uiPresentation .getChild(UIPresentation.class) .setTemplatePath(templateService.getTemplatePath(nodeView, false)); } } if (uiPresentation != null && uiPresentation.isContextual() && nodeView != null) { RenderResponse response = context.getResponse(); Element title = response.createElement("title"); title.setTextContent(uiPresentation.getTitle(nodeView)); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title); } if (context.getRemoteUser() != null && WCMComposer.MODE_EDIT.equals(Utils.getCurrentMode())) { pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "content-selector"); pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "quick-edit"); } setId(UISingleContentViewerPortlet.class.getSimpleName() + pContext.getWindowId()); super.processRender(app, context); }
/** * Check if the content is editable and current mode of the site is edit mode * * @param content the content node * @return true if there is no content if the content is editable and current mode is edit mode */ public static boolean isShowQuickEdit(Node content) { if (content == null) return true; try { boolean isEditMode = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode()) || Util.getUIPortalApplication().getModeState() != UIPortalApplication.NORMAL_MODE) isEditMode = true; ((ExtendedNode) content).checkPermission(PermissionType.SET_PROPERTY); ((ExtendedNode) content).checkPermission(PermissionType.ADD_NODE); ((ExtendedNode) content).checkPermission(PermissionType.REMOVE); return isEditMode; } catch (Exception e) { return false; } }
/** * Check if the content is draft and current mode of the site is edit mode * * @param content the content node. * @return true, the content is draft and current mode is edit mode, otherwise return false. */ public static boolean isShowDraft(Node content) { if (content == null) return false; try { if (content.isNodeType("nt:frozenNode")) return false; WCMPublicationService wcmPublicationService = WCMCoreUtils.getService(WCMPublicationService.class); String contentState = wcmPublicationService.getContentState(content); boolean isDraftContent = false; if (PublicationDefaultStates.DRAFT.equals(contentState)) isDraftContent = true; boolean isShowDraft = false; if (WCMComposer.MODE_EDIT.equals(getCurrentMode())) isShowDraft = true; return isDraftContent && isShowDraft; } catch (Exception e) { return false; } }