001
014
015 package com.liferay.portlet.assetcategoriesnavigation.template;
016
017 import com.liferay.portal.kernel.language.LanguageUtil;
018 import com.liferay.portal.kernel.portletdisplaytemplate.BasePortletDisplayTemplateHandler;
019 import com.liferay.portal.kernel.template.TemplateVariableGroup;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.util.PortalUtil;
022 import com.liferay.portal.util.PortletKeys;
023 import com.liferay.portal.util.PropsValues;
024 import com.liferay.portlet.asset.model.AssetCategory;
025 import com.liferay.portlet.asset.model.AssetVocabulary;
026 import com.liferay.portlet.asset.service.AssetCategoryLocalService;
027 import com.liferay.portlet.asset.service.AssetCategoryService;
028 import com.liferay.portlet.asset.service.AssetVocabularyLocalService;
029 import com.liferay.portlet.asset.service.AssetVocabularyService;
030 import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplateConstants;
031
032 import java.util.List;
033 import java.util.Locale;
034 import java.util.Map;
035
036
039 public class AssetCategoriesNavigationPortletDisplayTemplateHandler
040 extends BasePortletDisplayTemplateHandler {
041
042 @Override
043 public String getClassName() {
044 return AssetCategory.class.getName();
045 }
046
047 @Override
048 public String getName(Locale locale) {
049 String portletTitle = PortalUtil.getPortletTitle(
050 PortletKeys.ASSET_CATEGORIES_NAVIGATION, locale);
051
052 return portletTitle.concat(StringPool.SPACE).concat(
053 LanguageUtil.get(locale, "template"));
054 }
055
056 @Override
057 public String getResourceName() {
058 return PortletKeys.ASSET_CATEGORIES_NAVIGATION;
059 }
060
061 @Override
062 public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
063 long classPK, String language, Locale locale)
064 throws Exception {
065
066 Map<String, TemplateVariableGroup> templateVariableGroups =
067 super.getTemplateVariableGroups(classPK, language, locale);
068
069 TemplateVariableGroup templateVariableGroup =
070 templateVariableGroups.get("fields");
071
072 templateVariableGroup.empty();
073
074 templateVariableGroup.addCollectionVariable(
075 "vocabularies", List.class, PortletDisplayTemplateConstants.ENTRIES,
076 "vocabulary", AssetVocabulary.class, "curVocabulary", "name");
077
078 String[] restrictedVariables = getRestrictedVariables(language);
079
080 TemplateVariableGroup categoriesServicesTemplateVariableGroup =
081 new TemplateVariableGroup("category-services", restrictedVariables);
082
083 categoriesServicesTemplateVariableGroup.setAutocompleteEnabled(false);
084
085 categoriesServicesTemplateVariableGroup.addServiceLocatorVariables(
086 AssetVocabularyLocalService.class, AssetVocabularyService.class,
087 AssetCategoryLocalService.class, AssetCategoryService.class);
088
089 templateVariableGroups.put(
090 categoriesServicesTemplateVariableGroup.getLabel(),
091 categoriesServicesTemplateVariableGroup);
092
093 return templateVariableGroups;
094 }
095
096 @Override
097 protected String getTemplatesConfigPath() {
098 return PropsValues.ASSET_CATEGORIES_NAVIGATION_DISPLAY_TEMPLATES_CONFIG;
099 }
100
101 }