Example usage for com.liferay.portal.kernel.theme ThemeDisplay isShowStagingIcon

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay isShowStagingIcon

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay isShowStagingIcon.

Prototype

public boolean isShowStagingIcon() 

Source Link

Usage

From source file:com.liferay.staging.bar.web.internal.product.navigation.control.menu.StagingProductNavigationControlMenuEntry.java

License:Open Source License

@Override
public boolean isShow(HttpServletRequest request) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    if (layout.isTypeControlPanel()) {
        return false;
    }//from   w ww  .j a  va  2s.  c o m

    if (!themeDisplay.isShowStagingIcon()) {
        return false;
    }

    return true;
}

From source file:com.liferay.staging.bar.web.internal.theme.contributor.StagingBarTemplateContextContributor.java

License:Open Source License

@Override
public void prepare(Map<String, Object> contextObjects, HttpServletRequest request) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    try {/*from ww w.  ja va2s .  c  o  m*/
        if (_stagingProductNavigationControlMenuEntry.isShow(request)) {
            StringBuilder sb = new StringBuilder();

            sb.append(GetterUtil.getString(contextObjects.get("bodyCssClass")));
            sb.append(StringPool.SPACE);
            sb.append("has-staging-bar");

            Group group = themeDisplay.getScopeGroup();

            if (group.isStagingGroup()) {
                sb.append(StringPool.SPACE);
                sb.append("staging local-staging");
            } else if (themeDisplay.isShowStagingIcon() && group.hasStagingGroup()) {

                sb.append(StringPool.SPACE);
                sb.append("live-view");
            } else if (themeDisplay.isShowStagingIcon() && group.isStagedRemotely()) {

                sb.append(StringPool.SPACE);
                sb.append("staging remote-staging");
            }

            contextObjects.put("bodyCssClass", sb.toString());
        }
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }

    contextObjects.put("show_staging", themeDisplay.isShowStagingIcon());

    if (themeDisplay.isShowStagingIcon()) {
        contextObjects.put("staging_text", LanguageUtil.get(request, "staging"));
    }
}