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.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;//w ww. j ava 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 boolean _isVisible(AssetPublisherDisplayContext assetPublisherDisplayContext, PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!assetPublisherDisplayContext.isShowAddContentButton()) { return false; }/* w ww.j av a2 s. co 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 void addAndStoreSelection(PortletRequest portletRequest, String className, long classPK, int assetEntryOrder) throws Exception { String portletId = _portal.getPortletId(portletRequest); String rootPortletId = PortletIdCodec.decodePortletName(portletId); if (!rootPortletId.equals(AssetPublisherPortletKeys.ASSET_PUBLISHER)) { return;/*from www. j a va 2s .c o m*/ } ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = _layoutLocalService.fetchLayout(themeDisplay.getPlid()); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout, portletId); if (portletPreferences instanceof StrictPortletPreferencesImpl) { return; } String selectionStyle = portletPreferences.getValue("selectionStyle", "dynamic"); if (selectionStyle.equals("dynamic")) { return; } AssetEntry assetEntry = _assetEntryLocalService.getEntry(className, classPK); addSelection(portletPreferences, assetEntry.getEntryId(), assetEntryOrder, className); portletPreferences.store(); }
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 ww w . j ava 2 s .com 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
protected void addScope(ActionRequest actionRequest, PortletPreferences preferences) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] scopeIds = preferences.getValues("scopeIds", new String[] { AssetPublisherUtil.SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT }); long groupId = ParamUtil.getLong(actionRequest, "groupId"); Group selectedGroup = groupLocalService.fetchGroup(groupId); String scopeId = AssetPublisherUtil.getScopeId(selectedGroup, themeDisplay.getScopeGroupId()); checkPermission(actionRequest, scopeId); if (!ArrayUtil.contains(scopeIds, scopeId)) { scopeIds = ArrayUtil.append(scopeIds, scopeId); }//from w ww .j a va 2 s . c o m preferences.setValues("scopeIds", scopeIds); }
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
protected void checkPermission(ActionRequest actionRequest, String scopeId) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (!assetPublisherWebUtil.isScopeIdSelectable(themeDisplay.getPermissionChecker(), scopeId, themeDisplay.getCompanyGroupId(), layout, true)) { throw new PrincipalException(); }/*from w w w . j a v a 2 s . co m*/ }
From source file:com.liferay.asset.publisher.web.portlet.action.AssetPublisherConfigurationAction.java
License:Open Source License
protected void updateQueryLogic(ActionRequest actionRequest, PortletPreferences preferences) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = themeDisplay.getUserId(); long groupId = themeDisplay.getSiteGroupId(); int[] queryRulesIndexes = StringUtil.split(ParamUtil.getString(actionRequest, "queryLogicIndexes"), 0); int i = 0;//from w w w . ja v a 2s .c om List<AssetQueryRule> queryRules = new ArrayList<>(); for (int queryRulesIndex : queryRulesIndexes) { AssetQueryRule queryRule = getQueryRule(actionRequest, queryRulesIndex); validateQueryRule(userId, groupId, queryRules, queryRule); queryRules.add(queryRule); setPreference(actionRequest, "queryContains" + i, String.valueOf(queryRule.isContains())); setPreference(actionRequest, "queryAndOperator" + i, String.valueOf(queryRule.isAndOperator())); setPreference(actionRequest, "queryName" + i, queryRule.getName()); setPreference(actionRequest, "queryValues" + i, queryRule.getValues()); i++; } // Clear previous preferences that are now blank String[] values = preferences.getValues("queryValues" + i, new String[0]); while (values.length > 0) { setPreference(actionRequest, "queryContains" + i, StringPool.BLANK); setPreference(actionRequest, "queryAndOperator" + i, StringPool.BLANK); setPreference(actionRequest, "queryName" + i, StringPool.BLANK); setPreference(actionRequest, "queryValues" + i, new String[0]); i++; values = preferences.getValues("queryValues" + i, new String[0]); } }
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
public void getFieldValue(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); try {/*ww w. j av a 2 s . c o m*/ ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); long structureId = ParamUtil.getLong(resourceRequest, "structureId"); Fields fields = (Fields) serviceContext.getAttribute(Fields.class.getName() + structureId); if (fields == null) { String fieldsNamespace = ParamUtil.getString(resourceRequest, "fieldsNamespace"); fields = DDMUtil.getFields(structureId, fieldsNamespace, serviceContext); } String fieldName = ParamUtil.getString(resourceRequest, "name"); Field field = fields.get(fieldName); Serializable fieldValue = field.getValue(themeDisplay.getLocale(), 0); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); if (fieldValue != null) { jsonObject.put("success", true); } else { jsonObject.put("success", false); writeJSON(resourceRequest, resourceResponse, jsonObject); return; } DDMStructure ddmStructure = field.getDDMStructure(); String type = ddmStructure.getFieldType(fieldName); Serializable displayValue = DDMUtil.getDisplayFieldValue(themeDisplay, fieldValue, type); jsonObject.put("displayValue", String.valueOf(displayValue)); if (fieldValue instanceof Boolean) { jsonObject.put("value", (Boolean) fieldValue); } else if (fieldValue instanceof Date) { DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMM ddHHmmss"); jsonObject.put("value", dateFormat.format(fieldValue)); } else if (fieldValue instanceof Double) { jsonObject.put("value", (Double) fieldValue); } else if (fieldValue instanceof Float) { jsonObject.put("value", (Float) fieldValue); } else if (fieldValue instanceof Integer) { jsonObject.put("value", (Integer) fieldValue); } else if (fieldValue instanceof Number) { jsonObject.put("value", String.valueOf(fieldValue)); } else { jsonObject.put("value", (String) fieldValue); } writeJSON(resourceRequest, resourceResponse, jsonObject); } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.asset.publisher.web.portlet.AssetPublisherPortlet.java
License:Open Source License
public void subscribe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); assetPublisherWebUtil.subscribe(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), themeDisplay.getPlid(), themeDisplay.getPpid()); }