List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java
License:Open Source License
public Set<Long> getAvailableClassNameIds() { if (_availableClassNameIdsSet != null) { return _availableClassNameIdsSet; }/*from w ww . j av a 2s .c om*/ ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long[] availableClassNameIds = AssetRendererFactoryRegistryUtil.getClassNameIds(themeDisplay.getCompanyId(), true); _availableClassNameIdsSet = SetUtil.fromArray(availableClassNameIds); return _availableClassNameIdsSet; }
From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java
License:Open Source License
public SearchContainer getSearchContainer() throws PortalException { if (_searchContainer != null) { return _searchContainer; }//from www .j a v a 2 s . com ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); SearchContainer searchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(), null, "there-are-no-asset-display-templates"); if (!isSearch()) { if (isShowAddButton()) { searchContainer.setEmptyResultsMessage("there-are-no-asset-display-templates-you-can-add-an-" + "asset-display-template-by-clicking-plus-button-on-" + "the-bottom-right-corner"); searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { searchContainer.setSearch(true); } searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse)); searchContainer.setOrderByCol(getOrderByCol()); OrderByComparator<AssetDisplayTemplate> orderByComparator = _getOrderByComparator(getOrderByCol(), getOrderByType()); searchContainer.setOrderByComparator(orderByComparator); searchContainer.setOrderByType(getOrderByType()); int assetDisplayTemplatesCount = 0; List<AssetDisplayTemplate> assetDisplayTemplates = null; if (isSearch()) { assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId(), getKeywords()); assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates( themeDisplay.getScopeGroupId(), getKeywords(), searchContainer.getStart(), searchContainer.getEnd(), orderByComparator); } else { assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId()); assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates( themeDisplay.getScopeGroupId(), searchContainer.getStart(), searchContainer.getEnd(), orderByComparator); } searchContainer.setTotal(assetDisplayTemplatesCount); searchContainer.setResults(assetDisplayTemplates); _searchContainer = searchContainer; return _searchContainer; }
From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java
License:Open Source License
public boolean isShowAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (AssetDisplayPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getSiteGroupId(), AssetDisplayTemplateActionKeys.ADD_ASSET_DISPLAY_TEMPLATE)) { return true; }/* w w w .j a v a 2s. c o m*/ return false; }
From source file:com.liferay.asset.display.template.web.internal.portlet.action.EditAssetDisplayTemplateMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long assetDisplayTemplateId = ParamUtil.getLong(actionRequest, "assetDisplayTemplateId"); String name = ParamUtil.getString(actionRequest, "name"); long classNameId = ParamUtil.getLong(actionRequest, "classNameId"); String language = ParamUtil.getString(actionRequest, "language"); String scriptContent = ParamUtil.getString(actionRequest, "scriptContent"); boolean main = ParamUtil.getBoolean(actionRequest, "main"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (assetDisplayTemplateId <= 0) { _assetDisplayTemplateService.addAssetDisplayTemplate(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), name, classNameId, language, scriptContent, main, serviceContext); } else {//w w w. ja v a2s. c om _assetDisplayTemplateService.updateAssetDisplayTemplate(assetDisplayTemplateId, name, classNameId, language, scriptContent, main, serviceContext); } }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
@Override public PortletURL getAddPortletURL(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long groupId, String className, long classTypeId, long[] allAssetCategoryIds, String[] allAssetTagNames, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); if ((assetRendererFactory == null) || !assetRendererFactory .hasAddPermission(themeDisplay.getPermissionChecker(), groupId, classTypeId)) { return null; }/* w w w . ja v a 2 s . co m*/ if (groupId > 0) { Group group = _groupLocalService.fetchGroup(groupId); liferayPortletRequest.setAttribute(WebKeys.ASSET_RENDERER_FACTORY_GROUP, group); } PortletURL addPortletURL = assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId); if (addPortletURL == null) { return null; } if (redirect != null) { addPortletURL.setParameter("redirect", redirect); } String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource"); if (Validator.isNotNull(referringPortletResource)) { addPortletURL.setParameter("referringPortletResource", referringPortletResource); } else { PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); addPortletURL.setParameter("referringPortletResource", portletDisplay.getId()); if (allAssetCategoryIds != null) { Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>(); for (long assetCategoryId : allAssetCategoryIds) { AssetCategory assetCategory = _assetCategoryLocalService.fetchAssetCategory(assetCategoryId); if (assetCategory == null) { continue; } long assetVocabularyId = assetCategory.getVocabularyId(); if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) { String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId); assetVocabularyAssetCategoryIds.put(assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId); } else { assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId)); } } for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) { long assetVocabularyId = entry.getKey(); String assetCategoryIds = entry.getValue(); addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds); } } if (allAssetTagNames != null) { addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames)); } } addPortletURL.setPortletMode(PortletMode.VIEW); addPortletURL.setWindowState(LiferayWindowState.POP_UP); return addPortletURL; }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
@Override public List<AssetPublisherAddItemHolder> getAssetPublisherAddItemHolders( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long groupId, long[] classNameIds, long[] classTypeIds, long[] allAssetCategoryIds, String[] allAssetTagNames, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); Locale locale = themeDisplay.getLocale(); List<AssetPublisherAddItemHolder> assetPublisherAddItemHolders = new ArrayList<>(); for (long classNameId : classNameIds) { String className = _portal.getClassName(classNameId); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); if (Validator.isNull(assetRendererFactory.getPortletId())) { continue; }/*from w w w . j ava2 s. c o m*/ Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), assetRendererFactory.getPortletId()); if (!portlet.isActive()) { continue; } PortletBag portletBag = PortletBagPool.get(portlet.getRootPortletId()); if (portletBag == null) { continue; } ResourceBundle resourceBundle = portletBag.getResourceBundle(locale); ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader(); List<ClassType> classTypes = Collections.emptyList(); if (!(classTypeReader instanceof NullClassTypeReader)) { classTypes = classTypeReader.getAvailableClassTypes( _portal.getCurrentAndAncestorSiteGroupIds(groupId), themeDisplay.getLocale()); } if (classTypes.isEmpty()) { PortletURL addPortletURL = getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, className, 0, allAssetCategoryIds, allAssetTagNames, redirect); if (addPortletURL != null) { assetPublisherAddItemHolders.add(new AssetPublisherAddItemHolder(portlet.getPortletId(), className, resourceBundle, locale, addPortletURL)); } } for (ClassType classType : classTypes) { long classTypeId = classType.getClassTypeId(); if (ArrayUtil.contains(classTypeIds, classTypeId) || (classTypeIds.length == 0)) { PortletURL addPortletURL = getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, className, classTypeId, allAssetCategoryIds, allAssetTagNames, redirect); if (addPortletURL != null) { assetPublisherAddItemHolders.add(new AssetPublisherAddItemHolder(portlet.getPortletId(), classType.getName(), resourceBundle, locale, addPortletURL)); } } } } if (assetPublisherAddItemHolders.size() <= 1) { return assetPublisherAddItemHolders; } assetPublisherAddItemHolders.sort(null); return assetPublisherAddItemHolders; }
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
@Override public String getAssetViewURL(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, AssetRenderer<?> assetRenderer, AssetEntry assetEntry, boolean viewInContext) { PortletURL viewFullContentURL = liferayPortletResponse.createRenderURL(); viewFullContentURL.setParameter("mvcPath", "/view_content.jsp"); viewFullContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); PortletURL redirectURL = liferayPortletResponse.createRenderURL(); int cur = ParamUtil.getInteger(liferayPortletRequest, "cur"); int delta = ParamUtil.getInteger(liferayPortletRequest, "delta"); boolean resetCur = ParamUtil.getBoolean(liferayPortletRequest, "resetCur"); redirectURL.setParameter("cur", String.valueOf(cur)); if (delta > 0) { redirectURL.setParameter("delta", String.valueOf(delta)); }//ww w .jav a 2s . c om redirectURL.setParameter("resetCur", String.valueOf(resetCur)); redirectURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); viewFullContentURL.setParameter("redirect", redirectURL.toString()); AssetRendererFactory<?> assetRendererFactory = assetRenderer.getAssetRendererFactory(); viewFullContentURL.setParameter("type", assetRendererFactory.getType()); ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (Validator.isNotNull(assetRenderer.getUrlTitle())) { if (assetRenderer.getGroupId() != themeDisplay.getScopeGroupId()) { viewFullContentURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId())); } viewFullContentURL.setParameter("urlTitle", assetRenderer.getUrlTitle()); } String viewURL = null; if (viewInContext) { try { String noSuchEntryRedirect = viewFullContentURL.toString(); viewURL = assetRenderer.getURLViewInContext(liferayPortletRequest, liferayPortletResponse, noSuchEntryRedirect); if (Validator.isNotNull(viewURL) && !Objects.equals(viewURL, noSuchEntryRedirect)) { viewURL = _http.setParameter(viewURL, "redirect", _portal.getCurrentURL(liferayPortletRequest)); } } catch (Exception e) { } } if (Validator.isNull(viewURL)) { viewURL = viewFullContentURL.toString(); } return viewURL; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public AssetEntryQuery getAssetEntryQuery() throws Exception { if (_assetEntryQuery != null) { return _assetEntryQuery; }//w ww . jav a 2 s . c om ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); _assetEntryQuery = AssetPublisherUtil.getAssetEntryQuery(_portletPreferences, themeDisplay.getScopeGroupId(), themeDisplay.getLayout(), getAllAssetCategoryIds(), getAllAssetTagNames()); _assetEntryQuery.setEnablePermissions(isEnablePermissions()); configureSubtypeFieldFilter(_assetEntryQuery, themeDisplay.getLocale()); _assetEntryQuery.setPaginationType(getPaginationType()); _assetPublisherWebUtil.processAssetEntryQuery(themeDisplay.getUser(), _portletPreferences, _assetEntryQuery); _assetPublisherCustomizer.setAssetEntryQueryOptions(_assetEntryQuery, _request); return _assetEntryQuery; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public JSONArray getAutoFieldRulesJSONArray() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); String queryLogicIndexesParam = ParamUtil.getString(_request, "queryLogicIndexes"); int[] queryLogicIndexes = null; if (Validator.isNotNull(queryLogicIndexesParam)) { queryLogicIndexes = StringUtil.split(queryLogicIndexesParam, 0); } else {/*from w w w . j a va 2s . co m*/ queryLogicIndexes = new int[0]; for (int i = 0; true; i++) { String queryValues = PrefsParamUtil.getString(_portletPreferences, _request, "queryValues" + i); if (Validator.isNull(queryValues)) { break; } queryLogicIndexes = ArrayUtil.append(queryLogicIndexes, i); } if (queryLogicIndexes.length == 0) { queryLogicIndexes = ArrayUtil.append(queryLogicIndexes, -1); } } JSONArray rulesJSONArray = JSONFactoryUtil.createJSONArray(); for (int queryLogicIndex : queryLogicIndexes) { JSONObject ruleJSONObject = JSONFactoryUtil.createJSONObject(); boolean queryAndOperator = PrefsParamUtil.getBoolean(_portletPreferences, _request, "queryAndOperator" + queryLogicIndex); ruleJSONObject.put("queryAndOperator", queryAndOperator); boolean queryContains = PrefsParamUtil.getBoolean(_portletPreferences, _request, "queryContains" + queryLogicIndex, true); ruleJSONObject.put("queryContains", queryContains); String queryValues = StringUtil .merge(_portletPreferences.getValues("queryValues" + queryLogicIndex, new String[0])); String queryName = PrefsParamUtil.getString(_portletPreferences, _request, "queryName" + queryLogicIndex, "assetTags"); if (Objects.equals(queryName, "assetTags")) { queryValues = ParamUtil.getString(_request, "queryTagNames" + queryLogicIndex, queryValues); queryValues = _assetPublisherWebUtil.filterAssetTagNames(themeDisplay.getScopeGroupId(), queryValues); } else { queryValues = ParamUtil.getString(_request, "queryCategoryIds" + queryLogicIndex, queryValues); JSONArray categoryIdsTitles = JSONFactoryUtil.createJSONArray(); long[] categoryIds = GetterUtil.getLongValues(queryValues.split(",")); for (long categoryId : categoryIds) { AssetCategory category = AssetCategoryLocalServiceUtil.fetchAssetCategory(categoryId); categoryIdsTitles.put(category.getTitle(themeDisplay.getLocale())); } ruleJSONObject.put("categoryIdsTitles", categoryIdsTitles); } ruleJSONObject.put("queryValues", queryValues); ruleJSONObject.put("type", queryName); rulesJSONArray.put(ruleJSONObject); } return rulesJSONArray; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public long[] getAvailableClassNameIds() { if (_availableClassNameIds != null) { return _availableClassNameIds; }/* ww w. j a va 2 s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); _availableClassNameIds = AssetRendererFactoryRegistryUtil.getClassNameIds(themeDisplay.getCompanyId(), true); return _availableClassNameIds; }