001
014
015 package com.liferay.portlet.blogs.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.blogs.model.BlogsEntry;
025 import com.liferay.portlet.blogs.service.BlogsEntryLocalService;
026 import com.liferay.portlet.blogs.service.BlogsEntryService;
027 import com.liferay.portlet.portletdisplaytemplate.util.PortletDisplayTemplateConstants;
028
029 import java.util.List;
030 import java.util.Locale;
031 import java.util.Map;
032
033
036 public class BlogsPortletDisplayTemplateHandler
037 extends BasePortletDisplayTemplateHandler {
038
039 @Override
040 public String getClassName() {
041 return BlogsEntry.class.getName();
042 }
043
044 @Override
045 public String getName(Locale locale) {
046 String portletTitle = PortalUtil.getPortletTitle(
047 PortletKeys.BLOGS, locale);
048
049 return portletTitle.concat(StringPool.SPACE).concat(
050 LanguageUtil.get(locale, "template"));
051 }
052
053 @Override
054 public String getResourceName() {
055 return PortletKeys.BLOGS;
056 }
057
058 @Override
059 public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
060 long classPK, String language, Locale locale)
061 throws Exception {
062
063 Map<String, TemplateVariableGroup> templateVariableGroups =
064 super.getTemplateVariableGroups(classPK, language, locale);
065
066 TemplateVariableGroup templateVariableGroup =
067 templateVariableGroups.get("fields");
068
069 templateVariableGroup.empty();
070
071 templateVariableGroup.addCollectionVariable(
072 "blog-entries", List.class, PortletDisplayTemplateConstants.ENTRIES,
073 "blog-entry", BlogsEntry.class, "curBlogEntry", "title");
074
075 String[] restrictedVariables = getRestrictedVariables(language);
076
077 TemplateVariableGroup blogServicesTemplateVariableGroup =
078 new TemplateVariableGroup("blog-services", restrictedVariables);
079
080 blogServicesTemplateVariableGroup.setAutocompleteEnabled(false);
081
082 blogServicesTemplateVariableGroup.addServiceLocatorVariables(
083 BlogsEntryLocalService.class, BlogsEntryService.class);
084
085 templateVariableGroups.put(
086 blogServicesTemplateVariableGroup.getLabel(),
087 blogServicesTemplateVariableGroup);
088
089 return templateVariableGroups;
090 }
091
092 @Override
093 protected String getTemplatesConfigPath() {
094 return PropsValues.BLOGS_DISPLAY_TEMPLATES_CONFIG;
095 }
096
097 }