001
014
015 package com.liferay.portlet.assetpublisher.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.AssetEntry;
025 import com.liferay.portlet.asset.service.AssetCategoryLocalService;
026 import com.liferay.portlet.asset.service.AssetCategoryService;
027 import com.liferay.portlet.asset.service.AssetEntryLocalService;
028 import com.liferay.portlet.asset.service.AssetEntryService;
029 import com.liferay.portlet.asset.service.AssetTagLocalService;
030 import com.liferay.portlet.asset.service.AssetTagService;
031 import com.liferay.portlet.asset.service.AssetTagStatsLocalService;
032 import com.liferay.portlet.asset.service.AssetVocabularyLocalService;
033 import com.liferay.portlet.asset.service.AssetVocabularyService;
034 import com.liferay.portlet.assetpublisher.util.AssetPublisherHelper;
035 import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplateConstants;
036
037 import java.util.List;
038 import java.util.Locale;
039 import java.util.Map;
040
041
044 public class AssetPublisherPortletDisplayTemplateHandler
045 extends BasePortletDisplayTemplateHandler {
046
047 @Override
048 public String getClassName() {
049 return AssetEntry.class.getName();
050 }
051
052 @Override
053 public String getName(Locale locale) {
054 String portletTitle = PortalUtil.getPortletTitle(
055 PortletKeys.ASSET_PUBLISHER, locale);
056
057 return portletTitle.concat(StringPool.SPACE).concat(
058 LanguageUtil.get(locale, "template"));
059 }
060
061 @Override
062 public String getResourceName() {
063 return PortletKeys.ASSET_PUBLISHER;
064 }
065
066 @Override
067 public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
068 long classPK, String language, Locale locale)
069 throws Exception {
070
071 Map<String, TemplateVariableGroup> templateVariableGroups =
072 super.getTemplateVariableGroups(classPK, language, locale);
073
074 TemplateVariableGroup assetPublisherUtilTemplateVariableGroup =
075 new TemplateVariableGroup("asset-publisher-util");
076
077 assetPublisherUtilTemplateVariableGroup.addVariable(
078 "asset-publisher-helper", AssetPublisherHelper.class,
079 PortletDisplayTemplateConstants.ASSET_PUBLISHER_HELPER);
080
081 templateVariableGroups.put(
082 "asset-publisher-util", assetPublisherUtilTemplateVariableGroup);
083
084 TemplateVariableGroup fieldsTemplateVariableGroup =
085 templateVariableGroups.get("fields");
086
087 fieldsTemplateVariableGroup.empty();
088
089 fieldsTemplateVariableGroup.addCollectionVariable(
090 "asset-entries", List.class,
091 PortletDisplayTemplateConstants.ENTRIES, "asset-entry",
092 AssetEntry.class, "curEntry", "getTitle(locale)");
093 fieldsTemplateVariableGroup.addVariable(
094 "asset-entry", AssetEntry.class,
095 PortletDisplayTemplateConstants.ENTRY, "getTitle(locale)");
096
097 TemplateVariableGroup assetServicesTemplateVariableGroup =
098 new TemplateVariableGroup("asset-services");
099
100 assetServicesTemplateVariableGroup.setAutocompleteEnabled(false);
101
102 assetServicesTemplateVariableGroup.addServiceLocatorVariables(
103 AssetEntryLocalService.class, AssetEntryService.class,
104 AssetVocabularyLocalService.class, AssetVocabularyService.class,
105 AssetCategoryLocalService.class, AssetCategoryService.class,
106 AssetTagLocalService.class, AssetTagService.class,
107 AssetTagStatsLocalService.class);
108
109 templateVariableGroups.put(
110 assetServicesTemplateVariableGroup.getLabel(),
111 assetServicesTemplateVariableGroup);
112
113 return templateVariableGroups;
114 }
115
116 @Override
117 protected String getTemplatesConfigPath() {
118 return PropsValues.ASSET_PUBLISHER_DISPLAY_TEMPLATES_CONFIG;
119 }
120
121 }