Example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Prototype

String THEME_DISPLAY

To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Click Source Link

Usage

From source file:com.liferay.asset.categories.admin.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    String url = StringPool.BLANK;

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

    try {// w  w w.  ja va  2 s. co  m
        url = PermissionsURLTag.doTag(StringPool.BLANK, "com.liferay.asset.categories",
                themeDisplay.getScopeGroupName(), null, String.valueOf(themeDisplay.getSiteGroupId()),
                LiferayWindowState.POP_UP.toString(), null, themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();// w  w w .j  av  a 2 s. c  o m

    if (user.isDefaultUser()) {
        return false;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    try {
        if (!AssetCategoriesPermission.contains(permissionChecker, themeDisplay.getSiteGroupId(),
                ActionKeys.PERMISSIONS)
                || !GroupPermissionUtil.contains(permissionChecker, themeDisplay.getSiteGroupId(),
                        ActionKeys.PERMISSIONS)) {

            return false;
        }
    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:com.liferay.asset.categories.admin.web.internal.util.AssetCategoryUtil.java

License:Open Source License

public static void addPortletBreadcrumbEntry(AssetVocabulary vocabulary, AssetCategory category,
        HttpServletRequest request, RenderResponse renderResponse) throws PortalException {

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

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "/view.jsp");

    PortalUtil.addPortletBreadcrumbEntry(request, LanguageUtil.get(request, "vocabularies"),
            portletURL.toString());//from  ww w  .  j ava  2  s  .c o m

    if (category == null) {
        PortalUtil.addPortletBreadcrumbEntry(request, vocabulary.getTitle(themeDisplay.getLocale()), null);

        return;
    }

    portletURL.setParameter("mvcPath", "/view_categories.jsp");

    String navigation = ParamUtil.getString(request, "navigation");

    if (Validator.isNotNull(navigation)) {
        portletURL.setParameter("navigation", navigation);
    }

    portletURL.setParameter("vocabularyId", String.valueOf(vocabulary.getVocabularyId()));

    PortalUtil.addPortletBreadcrumbEntry(request, vocabulary.getTitle(themeDisplay.getLocale()),
            portletURL.toString());

    List<AssetCategory> ancestorsCategories = category.getAncestors();

    Collections.reverse(ancestorsCategories);

    for (AssetCategory curCategory : ancestorsCategories) {
        portletURL.setParameter("categoryId", String.valueOf(curCategory.getCategoryId()));

        PortalUtil.addPortletBreadcrumbEntry(request, curCategory.getTitle(themeDisplay.getLocale()),
                portletURL.toString());
    }

    PortalUtil.addPortletBreadcrumbEntry(request, category.getTitle(themeDisplay.getLocale()), null);
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

public AssetCategoriesNavigationDisplayContext(HttpServletRequest request) throws ConfigurationException {

    _request = request;/*from  w  ww  .  j a va2s . c  o  m*/

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _assetCategoriesNavigationPortletInstanceConfiguration = portletDisplay
            .getPortletInstanceConfiguration(AssetCategoriesNavigationPortletInstanceConfiguration.class);
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

public List<AssetVocabulary> getAssetVocabularies() {
    if (_assetVocabularies != null) {
        return _assetVocabularies;
    }//w  ww  . j a  v a2  s.  c  om

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

    long[] groupIds = new long[0];

    try {
        groupIds = PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId());
    } catch (PortalException pe) {
        groupIds = new long[] { themeDisplay.getScopeGroupId() };

        _log.error(pe, pe);
    }

    _assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(groupIds);

    return _assetVocabularies;
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

public long getDisplayStyleGroupId() {
    if (_displayStyleGroupId != 0) {
        return _displayStyleGroupId;
    }/*from  w w  w. j ava 2  s  .c  om*/

    _displayStyleGroupId = _assetCategoriesNavigationPortletInstanceConfiguration.displayStyleGroupId();

    if (_displayStyleGroupId <= 0) {
        ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

        _displayStyleGroupId = themeDisplay.getScopeGroupId();
    }

    return _displayStyleGroupId;
}

From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java

License:Open Source License

protected String getTitle(AssetVocabulary assetVocabulary) {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    String title = HtmlUtil.escape(assetVocabulary.getTitle(themeDisplay.getLanguageId()));

    if (assetVocabulary.getGroupId() == themeDisplay.getCompanyGroupId()) {
        title += " (" + LanguageUtil.get(_request, "global") + ")";
    }/*from   w  ww .ja v  a  2 s .c o m*/

    return title;
}

From source file:com.liferay.asset.categories.selector.web.display.context.AssetCategoriesSelectorDisplayContext.java

License:Open Source License

public JSONArray getCategoriesJSONArray() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    JSONArray jsonArray = _getCategoriesJSONArray();

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    jsonObject.put("children", jsonArray);
    jsonObject.put("disabled", true);
    jsonObject.put("expanded", true);
    jsonObject.put("icon", "folder");
    jsonObject.put("id", "0");
    jsonObject.put("name", LanguageUtil.get(themeDisplay.getLocale(), "vocabularies"));

    JSONArray rootJSONArray = JSONFactoryUtil.createJSONArray();

    rootJSONArray.put(jsonObject);//from   ww  w  .  j a  v  a2  s .c  o m

    return rootJSONArray;
}

From source file:com.liferay.asset.categories.selector.web.display.context.AssetCategoriesSelectorDisplayContext.java

License:Open Source License

public String getVocabularyTitle(long vocabularyId) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil.fetchAssetVocabulary(vocabularyId);

    StringBundler sb = new StringBundler(4);

    String title = assetVocabulary.getTitle(themeDisplay.getLocale());

    sb.append(HtmlUtil.escape(title));/*  w  w w  .j a  v  a  2  s .co m*/

    sb.append(StringPool.OPEN_PARENTHESIS);

    if (assetVocabulary.getGroupId() == themeDisplay.getCompanyGroupId()) {
        sb.append(LanguageUtil.get(_request, "global"));
    } else {
        Group group = GroupLocalServiceUtil.fetchGroup(assetVocabulary.getGroupId());

        sb.append(group.getDescriptiveName(themeDisplay.getLocale()));
    }

    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}

From source file:com.liferay.asset.categories.selector.web.display.context.AssetCategoriesSelectorDisplayContext.java

License:Open Source License

private JSONArray _getCategoriesJSONArray(long vocabularyId, long categoryId) throws Exception {

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

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

    List<AssetCategory> categories = AssetCategoryServiceUtil.getVocabularyCategories(categoryId, vocabularyId,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    for (AssetCategory category : categories) {
        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

        JSONArray children = _getCategoriesJSONArray(vocabularyId, category.getCategoryId());

        if (children.length() > 0) {
            jsonObject.put("children", children);
        }/*from w w  w.jav  a2s.com*/

        jsonObject.put("icon", "page");
        jsonObject.put("id", category.getCategoryId());
        jsonObject.put("name", category.getTitle(themeDisplay.getLocale()));

        if (getSelectedCategories().contains(String.valueOf(category.getCategoryId()))) {

            jsonObject.put("selected", true);
        }

        jsonArray.put(jsonObject);
    }

    return jsonArray;
}