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.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public SearchContainer getCategoriesSearchContainer() throws PortalException {

    if (_categoriesSearchContainer != null) {
        return _categoriesSearchContainer;
    }/* w ww.  j av a2s  .co m*/

    SearchContainer categoriesSearchContainer = new SearchContainer(_renderRequest, getIteratorURL(), null,
            "there-are-no-categories");

    if (Validator.isNull(getKeywords())) {
        if (isShowCategoriesAddButton()) {
            categoriesSearchContainer
                    .setEmptyResultsMessageCssClass("there-are-no-categories.-you-can-add-a-category-by-"
                            + "clicking-the-plus-button-on-the-bottom-right-corner");
            categoriesSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        categoriesSearchContainer.setSearch(true);
    }

    categoriesSearchContainer.setOrderByCol(getOrderByCol());

    boolean orderByAsc = false;

    String orderByType = getOrderByType();

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<AssetCategory> orderByComparator = new AssetCategoryCreateDateComparator(orderByAsc);

    categoriesSearchContainer.setOrderByComparator(orderByComparator);

    categoriesSearchContainer.setOrderByType(orderByType);

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse);

    StringBundler sb = new StringBundler(7);

    sb.append("^(?!.*");
    sb.append(_renderResponse.getNamespace());
    sb.append("redirect).*(/vocabulary/");
    sb.append(getVocabularyId());
    sb.append("/category/");
    sb.append(getCategoryId());
    sb.append(")");

    emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString());

    categoriesSearchContainer.setRowChecker(emptyOnClickRowChecker);

    List<AssetCategory> categories = null;
    int categoriesCount = 0;

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

    long scopeGroupId = themeDisplay.getScopeGroupId();

    if (Validator.isNotNull(getKeywords())) {
        AssetCategoryDisplay assetCategoryDisplay = null;

        Sort sort = null;

        if (isFlattenedNavigationAllowed()) {
            sort = new Sort("leftCategoryId", Sort.INT_TYPE, orderByAsc);
        } else {
            sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc);
        }

        assetCategoryDisplay = AssetCategoryServiceUtil.searchCategoriesDisplay(new long[] { scopeGroupId },
                getKeywords(), new long[] { getVocabularyId() }, new long[0],
                categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), sort);

        categoriesCount = assetCategoryDisplay.getTotal();

        categoriesSearchContainer.setTotal(categoriesCount);

        categories = assetCategoryDisplay.getCategories();
    } else if (isFlattenedNavigationAllowed()) {
        AssetCategory category = getCategory();

        if (Validator.isNull(category)) {
            categoriesCount = AssetCategoryServiceUtil
                    .getVocabularyCategoriesCount(themeDisplay.getScopeGroupId(), getVocabularyId());

            categories = AssetCategoryServiceUtil.getVocabularyCategories(getVocabularyId(),
                    categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                    new AssetCategoryLeftCategoryIdComparator(orderByAsc));
        } else {
            categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(
                    themeDisplay.getScopeGroupId(), category.getCategoryId(), getVocabularyId());

            categories = AssetCategoryServiceUtil.getVocabularyCategories(category.getCategoryId(),
                    getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                    new AssetCategoryLeftCategoryIdComparator(orderByAsc));
        }

        categoriesSearchContainer.setTotal(categoriesCount);
    } else {
        categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(scopeGroupId, getCategoryId(),
                getVocabularyId());

        categoriesSearchContainer.setTotal(categoriesCount);

        categories = AssetCategoryServiceUtil.getVocabularyCategories(scopeGroupId, getCategoryId(),
                getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                categoriesSearchContainer.getOrderByComparator());
    }

    categoriesSearchContainer.setResults(categories);

    _categoriesSearchContainer = categoriesSearchContainer;

    return _categoriesSearchContainer;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public String getCategoryTitle() throws PortalException {
    AssetCategory category = getCategory();

    AssetVocabulary vocabulary = getVocabulary();

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

    Locale locale = themeDisplay.getLocale();

    if (category != null) {
        return category.getTitle(locale);
    }//from  w  ww.j a v a  2  s .  c  o m

    return vocabulary.getTitle(locale);
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public String getSelectCategoryURL() throws Exception {
    if (_selectCategoryURL != null) {
        return _selectCategoryURL;
    }/*from w  ww  .  j  ava  2 s  . c  o  m*/

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

    List<AssetVocabulary> vocabularies = AssetVocabularyServiceUtil
            .getGroupVocabularies(themeDisplay.getScopeGroupId());

    PortletURL selectCategoryURL = PortletProviderUtil.getPortletURL(_request, AssetCategory.class.getName(),
            PortletProvider.Action.BROWSE);

    selectCategoryURL.setParameter("allowedSelectVocabularies", Boolean.TRUE.toString());
    selectCategoryURL.setParameter("eventName", _renderResponse.getNamespace() + "selectCategory");
    selectCategoryURL.setParameter("singleSelect", Boolean.TRUE.toString());
    selectCategoryURL.setParameter("vocabularyIds",
            ListUtil.toString(vocabularies, AssetVocabulary.VOCABULARY_ID_ACCESSOR));
    selectCategoryURL.setWindowState(LiferayWindowState.POP_UP);

    _selectCategoryURL = selectCategoryURL.toString();

    return _selectCategoryURL;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public SearchContainer getVocabulariesSearchContainer() throws PortalException {

    if (_vocabulariesSearchContainer != null) {
        return _vocabulariesSearchContainer;
    }/*from ww w.j  ava2s .  co  m*/

    SearchContainer vocabulariesSearchContainer = new SearchContainer(_renderRequest,
            _renderResponse.createRenderURL(), null, "there-are-no-vocabularies");

    String keywords = getKeywords();

    if (Validator.isNull(keywords)) {
        if (isShowVocabulariesAddButton()) {
            vocabulariesSearchContainer
                    .setEmptyResultsMessage("there-are-no-vocabularies.-you-can-add-a-vocabulary-by-"
                            + "clicking-the-plus-button-on-the-bottom-right-corner");
            vocabulariesSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        vocabulariesSearchContainer.setSearch(true);
    }

    vocabulariesSearchContainer.setOrderByCol(getOrderByCol());

    String orderByType = getOrderByType();

    boolean orderByAsc = false;

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<AssetVocabulary> orderByComparator = new AssetVocabularyCreateDateComparator(orderByAsc);

    vocabulariesSearchContainer.setOrderByComparator(orderByComparator);

    vocabulariesSearchContainer.setOrderByType(orderByType);

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse);

    StringBundler sb = new StringBundler(5);

    sb.append("^(?!.*");
    sb.append(_renderResponse.getNamespace());
    sb.append("redirect).*(/vocabulary/");
    sb.append(getVocabularyId());
    sb.append(")");

    emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString());

    vocabulariesSearchContainer.setRowChecker(emptyOnClickRowChecker);

    List<AssetVocabulary> vocabularies = null;
    int vocabulariesCount = 0;

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

    long scopeGroupId = themeDisplay.getScopeGroupId();

    if (Validator.isNotNull(keywords)) {
        Sort sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc);

        AssetVocabularyDisplay assetVocabularyDisplay = AssetVocabularyServiceUtil.searchVocabulariesDisplay(
                scopeGroupId, keywords, true, vocabulariesSearchContainer.getStart(),
                vocabulariesSearchContainer.getEnd(), sort);

        vocabulariesCount = assetVocabularyDisplay.getTotal();

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = assetVocabularyDisplay.getVocabularies();
    } else {
        vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(scopeGroupId, true,
                vocabulariesSearchContainer.getStart(), vocabulariesSearchContainer.getEnd(),
                vocabulariesSearchContainer.getOrderByComparator());

        if (vocabulariesCount == 0) {
            vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

            vocabulariesSearchContainer.setTotal(vocabulariesCount);
        }
    }

    vocabulariesSearchContainer.setResults(vocabularies);

    _vocabulariesSearchContainer = vocabulariesSearchContainer;

    return _vocabulariesSearchContainer;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean hasPermission(AssetCategory category, String actionId) throws PortalException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker,
            themeDisplay.getScopeGroupId(), AssetCategory.class.getName(), category.getCategoryId(),
            AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }/*w  w  w. j a  v a2  s .  co m*/

    return AssetCategoryPermission.contains(permissionChecker, category, actionId);
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean hasPermission(AssetVocabulary vocabulary, String actionId) throws PortalException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker,
            themeDisplay.getScopeGroupId(), AssetVocabulary.class.getName(), vocabulary.getVocabularyId(),
            AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }/*from w w  w .j a  va2s  . c  o  m*/

    return AssetVocabularyPermission.contains(permissionChecker, vocabulary, actionId);
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean isShowCategoriesAddButton() {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (AssetCategoriesPermission.contains(themeDisplay.getPermissionChecker(),
            AssetCategoriesPermission.RESOURCE_NAME, AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN,
            themeDisplay.getSiteGroupId(), ActionKeys.ADD_CATEGORY)) {

        return true;
    }//  w  ww. jav a  2s .co  m

    return false;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public boolean isShowVocabulariesAddButton() {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (AssetCategoriesPermission.contains(themeDisplay.getPermissionChecker(),
            AssetCategoriesPermission.RESOURCE_NAME, AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN,
            themeDisplay.getSiteGroupId(), ActionKeys.ADD_VOCABULARY)) {

        return true;
    }//from  w w w .  j  a v  a2 s. c o  m

    return false;
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.AssetCategoryAdminPortlet.java

License:Open Source License

protected String getSettings(ActionRequest actionRequest) throws PortalException {

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

    AssetVocabularySettingsHelper vocabularySettingsHelper = new AssetVocabularySettingsHelper();

    int[] indexes = StringUtil.split(ParamUtil.getString(actionRequest, "indexes"), 0);

    long[] classNameIds = new long[indexes.length];
    long[] classTypePKs = new long[indexes.length];
    boolean[] requireds = new boolean[indexes.length];

    for (int i = 0; i < indexes.length; i++) {
        int index = indexes[i];

        classNameIds[i] = ParamUtil.getLong(actionRequest, "classNameId" + index);

        classTypePKs[i] = ParamUtil//from w ww.  j  ava 2  s. c om
                .getLong(
                        actionRequest, StringBundler.concat("subtype", String.valueOf(classNameIds[i]),
                                "-classNameId", String.valueOf(index)),
                        AssetCategoryConstants.ALL_CLASS_TYPE_PK);

        if (classTypePKs[i] != -1) {
            AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil
                    .getAssetRendererFactoryByClassNameId(classNameIds[i]);

            ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

            try {
                classTypeReader.getClassType(classTypePKs[i], themeDisplay.getLocale());
            } catch (NoSuchModelException nsme) {
                throw new NoSuchClassTypeException(nsme);
            }
        }

        requireds[i] = ParamUtil.getBoolean(actionRequest, "required" + index);
    }

    vocabularySettingsHelper.setClassNameIdsAndClassTypePKs(classNameIds, classTypePKs, requireds);

    boolean multiValued = ParamUtil.getBoolean(actionRequest, "multiValued");

    vocabularySettingsHelper.setMultiValued(multiValued);

    return vocabularySettingsHelper.toString();
}

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

License:Open Source License

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

    long categoryId = ParamUtil.getLong(portletRequest, "categoryId", 0);

    if (categoryId <= 0) {
        return StringPool.BLANK;
    }// w  w w .jav a  2s .c  om

    String url = StringPool.BLANK;

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

    AssetCategory assetCategory = _assetCategoryLocalService.fetchCategory(categoryId);

    try {
        url = PermissionsURLTag.doTag(StringPool.BLANK, AssetCategory.class.getName(),
                assetCategory.getTitle(themeDisplay.getLocale()), null,
                String.valueOf(assetCategory.getCategoryId()), LiferayWindowState.POP_UP.toString(), null,
                themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
}