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 public String getClassName() {
043 return AssetCategory.class.getName();
044 }
045
046 public String getName(Locale locale) {
047 String portletTitle = PortalUtil.getPortletTitle(
048 PortletKeys.TAGS_CATEGORIES_NAVIGATION, locale);
049
050 return portletTitle.concat(StringPool.SPACE).concat(
051 LanguageUtil.get(locale, "template"));
052 }
053
054 public String getResourceName() {
055 return "com.liferay.portlet.assetcategoriesnavigation";
056 }
057
058 @Override
059 public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
060 long classPK, Locale locale)
061 throws Exception {
062
063 Map<String, TemplateVariableGroup> templateVariableGroups =
064 super.getTemplateVariableGroups(classPK, locale);
065
066 TemplateVariableGroup templateVariableGroup =
067 templateVariableGroups.get("fields");
068
069 templateVariableGroup.empty();
070
071 templateVariableGroup.addCollectionVariable(
072 "vocabularies", List.class, PortletDisplayTemplateConstants.ENTRIES,
073 "vocabulary", AssetVocabulary.class, "curVocabulary");
074
075 TemplateVariableGroup categoriesServicesTemplateVariableGroup =
076 new TemplateVariableGroup("category-services");
077
078 categoriesServicesTemplateVariableGroup.setAutocompleteEnabled(false);
079
080 categoriesServicesTemplateVariableGroup.addServiceLocatorVariables(
081 AssetVocabularyLocalService.class, AssetVocabularyService.class,
082 AssetCategoryLocalService.class, AssetCategoryService.class);
083
084 templateVariableGroups.put(
085 categoriesServicesTemplateVariableGroup.getLabel(),
086 categoriesServicesTemplateVariableGroup);
087
088 return templateVariableGroups;
089 }
090
091 @Override
092 protected String getTemplatesConfigPath() {
093 return PropsValues.ASSET_CATEGORIES_NAVIGATION_DISPLAY_TEMPLATES_CONFIG;
094 }
095
096 }