List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPortletDisplay
@JSON(include = false)
public PortletDisplay getPortletDisplay()
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 w w . j ava 2 s . c om ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); _assetCategoriesNavigationPortletInstanceConfiguration = portletDisplay .getPortletInstanceConfiguration(AssetCategoriesNavigationPortletInstanceConfiguration.class); }
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; }//from w w w . jav a2 s .c om 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.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public String getRSSName() { if (_rssName != null) { return _rssName; }// w ww. j ava 2s . co m ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); _rssName = _portletPreferences.getValue("rssName", portletDisplay.getTitle()); return _rssName; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public boolean isDefaultAssetPublisher() { if (_defaultAssetPublisher != null) { return _defaultAssetPublisher; }// w w w . j a v a2s . co m ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); _defaultAssetPublisher = _assetPublisherWebUtil.isDefaultAssetPublisher(themeDisplay.getLayout(), portletDisplay.getId(), getPortletResource()); return _defaultAssetPublisher; }
From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddAssetEntryMenuItems(List<MenuItem> menuItems, PortletRequest portletRequest, PortletResponse portletResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); AssetPublisherCustomizer assetPublisherCustomizer = (AssetPublisherCustomizer) portletRequest .getAttribute(AssetPublisherWebKeys.ASSET_PUBLISHER_CUSTOMIZER); AssetPublisherDisplayContext assetPublisherDisplayContext = new AssetPublisherDisplayContext( assetPublisherCustomizer, portletRequest, portletResponse, portletRequest.getPreferences()); if (!_isVisible(assetPublisherDisplayContext, portletRequest)) { return;/* ww w. j av a 2 s. co m*/ } Map<Long, List<AssetPublisherAddItemHolder>> scopeAssetPublisherAddItemHolders = assetPublisherDisplayContext .getScopeAssetPublisherAddItemHolders(1); if (MapUtil.isEmpty(scopeAssetPublisherAddItemHolders)) { return; } if (scopeAssetPublisherAddItemHolders.size() == 1) { Set<Map.Entry<Long, List<AssetPublisherAddItemHolder>>> entrySet = scopeAssetPublisherAddItemHolders .entrySet(); Iterator<Map.Entry<Long, List<AssetPublisherAddItemHolder>>> iterator = entrySet.iterator(); Map.Entry<Long, List<AssetPublisherAddItemHolder>> scopeAddPortletURL = iterator.next(); long groupId = scopeAddPortletURL.getKey(); List<AssetPublisherAddItemHolder> assetPublisherAddItemHolders = scopeAddPortletURL.getValue(); for (AssetPublisherAddItemHolder assetPublisherAddItemHolder : assetPublisherAddItemHolders) { URLMenuItem urlMenuItem = _getPortletTitleAddAssetEntryMenuItem(themeDisplay, assetPublisherDisplayContext, groupId, assetPublisherAddItemHolder); menuItems.add(urlMenuItem); } return; } URLMenuItem urlMenuItem = new URLMenuItem(); Map<String, Object> data = new HashMap<>(); data.put("id", HtmlUtil.escape(portletDisplay.getNamespace()) + "editAsset"); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", themeDisplay.getLocale(), getClass()); String title = LanguageUtil.get(resourceBundle, "add-content-select-scope-and-type"); data.put("title", title); urlMenuItem.setData(data); urlMenuItem.setLabel(title); LiferayPortletResponse liferayPortletResponse = _portal.getLiferayPortletResponse(portletResponse); PortletURL portletURL = liferayPortletResponse.createRenderURL(); portletURL.setParameter("mvcPath", "/add_asset_selector.jsp"); portletURL.setParameter("redirect", themeDisplay.getURLCurrent()); portletURL.setWindowState(LiferayWindowState.POP_UP); urlMenuItem.setURL(portletURL.toString()); urlMenuItem.setUseDialog(true); menuItems.add(urlMenuItem); }
From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java
License:Open Source License
private URLMenuItem _getPortletTitleAddAssetEntryMenuItem(ThemeDisplay themeDisplay, AssetPublisherDisplayContext assetPublisherDisplayContext, long groupId, AssetPublisherAddItemHolder assetPublisherAddItemHolder) { URLMenuItem urlMenuItem = new URLMenuItem(); Map<String, Object> data = new HashMap<>(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); data.put("id", HtmlUtil.escape(portletDisplay.getNamespace()) + "editAsset"); String message = assetPublisherAddItemHolder.getModelResource(); String title = LanguageUtil.format(themeDisplay.getLocale(), "new-x", message, false); data.put("title", title); urlMenuItem.setData(data);// w w w . j ava 2 s. c om urlMenuItem.setLabel(HtmlUtil.escape(message)); long curGroupId = groupId; Group group = _groupLocalService.fetchGroup(groupId); if (!group.isStagedPortlet(assetPublisherAddItemHolder.getPortletId()) && !group.isStagedRemotely()) { curGroupId = group.getLiveGroupId(); } boolean addDisplayPageParameter = _assetPublisherWebUtil.isDefaultAssetPublisher(themeDisplay.getLayout(), portletDisplay.getId(), assetPublisherDisplayContext.getPortletResource()); String url = _assetHelper.getAddURLPopUp(curGroupId, themeDisplay.getPlid(), assetPublisherAddItemHolder.getPortletURL(), addDisplayPageParameter, themeDisplay.getLayout()); urlMenuItem.setURL(url); urlMenuItem.setUseDialog(true); return urlMenuItem; }
From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java
License:Open Source License
private boolean _isVisible(AssetPublisherDisplayContext assetPublisherDisplayContext, PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!assetPublisherDisplayContext.isShowAddContentButton()) { return false; }/*from w w w . ja v a 2 s . c o m*/ Group scopeGroup = themeDisplay.getScopeGroup(); if (scopeGroup.hasStagingGroup() && !scopeGroup.isStagingGroup() && PropsValues.STAGING_LIVE_GROUP_LOCKING_ENABLED) { return false; } Layout layout = themeDisplay.getLayout(); if (layout.isLayoutPrototypeLinkActive() && assetPublisherDisplayContext.isSelectionStyleManual()) { return false; } PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletName = portletDisplay.getPortletName(); if (portletName.equals(AssetPublisherPortletKeys.HIGHEST_RATED_ASSETS)) { return false; } if (portletName.equals(AssetPublisherPortletKeys.MOST_VIEWED_ASSETS)) { return false; } if (portletName.equals(AssetPublisherPortletKeys.RELATED_ASSETS)) { return false; } return true; }
From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java
License:Open Source License
public Map<String, String> getEmailDefinitionTerms(PortletRequest portletRequest, String emailFromAddress, String emailFromName) {/*from w w w. j av a2 s.c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Map<String, String> definitionTerms = new LinkedHashMap<>(); definitionTerms.put("[$ASSET_ENTRIES$]", LanguageUtil.get(themeDisplay.getLocale(), "the-list-of-assets")); definitionTerms.put("[$COMPANY_ID$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-id-associated-with-the-assets")); definitionTerms.put("[$COMPANY_MX$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-mx-associated-with-the-assets")); definitionTerms.put("[$COMPANY_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-company-name-associated-with-the-assets")); definitionTerms.put("[$FROM_ADDRESS$]", HtmlUtil.escape(emailFromAddress)); definitionTerms.put("[$FROM_NAME$]", HtmlUtil.escape(emailFromName)); Company company = themeDisplay.getCompany(); definitionTerms.put("[$PORTAL_URL$]", company.getVirtualHostname()); definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape( _portal.getPortletTitle(AssetPublisherPortletKeys.ASSET_PUBLISHER, themeDisplay.getLocale()))); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); definitionTerms.put("[$PORTLET_TITLE$]", HtmlUtil.escape(portletDisplay.getTitle())); definitionTerms.put("[$SITE_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-site-name-associated-with-the-assets")); definitionTerms.put("[$TO_ADDRESS$]", LanguageUtil.get(themeDisplay.getLocale(), "the-address-of-the-email-recipient")); definitionTerms.put("[$TO_NAME$]", LanguageUtil.get(themeDisplay.getLocale(), "the-name-of-the-email-recipient")); return definitionTerms; }
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
private AssetPublisherPortletInstanceConfiguration _getAssetPublisherPortletInstanceConfiguration( HttpServletRequest request) throws ConfigurationException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); return portletDisplay.getPortletInstanceConfiguration(AssetPublisherPortletInstanceConfiguration.class); }
From source file:com.liferay.asset.publisher.web.portlet.AssetPublisherPortlet.java
License:Open Source License
@Override protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {/*from w w w.j a va 2 s . c o m*/ renderRequest.setAttribute(AssetPublisherWebKeys.ASSET_ENTRY_ACTION_REGISTRY, assetEntryActionRegistry); renderRequest.setAttribute(AssetWebKeys.ASSET_HELPER, assetHelper); String rootPortletId = PortletIdCodec.decodePortletName(portal.getPortletId(renderRequest)); AssetPublisherCustomizer assetPublisherCustomizer = assetPublisherCustomizerRegistry .getAssetPublisherCustomizer(rootPortletId); renderRequest.setAttribute(AssetPublisherWebKeys.ASSET_PUBLISHER_CUSTOMIZER, assetPublisherCustomizer); renderRequest.setAttribute(AssetPublisherWebKeys.ASSET_PUBLISHER_WEB_CONFIGURATION, assetPublisherWebConfiguration); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); AssetPublisherPortletInstanceConfiguration assetPublisherPortletInstanceConfiguration = portletDisplay .getPortletInstanceConfiguration(AssetPublisherPortletInstanceConfiguration.class); renderRequest.setAttribute(AssetPublisherWebKeys.ASSET_PUBLISHER_PORTLET_INSTANCE_CONFIGURATION, assetPublisherPortletInstanceConfiguration); renderRequest.setAttribute(WebKeys.SINGLE_PAGE_APPLICATION_CLEAR_CACHE, Boolean.TRUE); } catch (Exception e) { _log.error("Unable to get asset publisher customizer", e); } if (SessionErrors.contains(renderRequest, NoSuchGroupException.class.getName()) || SessionErrors.contains(renderRequest, PrincipalException.getNestedClasses())) { include("/error.jsp", renderRequest, renderResponse); } else { super.doDispatch(renderRequest, renderResponse); } }