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 TemplateVariableGroup categoriesServicesTemplateVariableGroup =
079 new TemplateVariableGroup("category-services");
080
081 categoriesServicesTemplateVariableGroup.setAutocompleteEnabled(false);
082
083 categoriesServicesTemplateVariableGroup.addServiceLocatorVariables(
084 AssetVocabularyLocalService.class, AssetVocabularyService.class,
085 AssetCategoryLocalService.class, AssetCategoryService.class);
086
087 templateVariableGroups.put(
088 categoriesServicesTemplateVariableGroup.getLabel(),
089 categoriesServicesTemplateVariableGroup);
090
091 return templateVariableGroups;
092 }
093
094 @Override
095 protected String getTemplatesConfigPath() {
096 return PropsValues.ASSET_CATEGORIES_NAVIGATION_DISPLAY_TEMPLATES_CONFIG;
097 }
098
099 }