Class CmsTransformerTemplateProvider
- java.lang.Object
-
- org.opencms.loader.CmsTransformerTemplateProvider
-
- All Implemented Interfaces:
I_CmsTemplateContextProvider
public class CmsTransformerTemplateProvider extends java.lang.Object implements I_CmsTemplateContextProvider
Template context provider that can be used to migrate from one template to another.Note: The template provider by itself does not transform anything, the feature is just named like that.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCmsTransformerTemplateProvider.ConfigurationContains the configuration data for the provider, usually read from a configuration file.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOOKIE_PREFIXThe cookie prefix.static java.lang.StringPARAM_CONFIGParameter for the configuration file in the template provider string.static java.lang.StringTEMPLATE_KEY_SOURCEThe template context key for the source template.static java.lang.StringTEMPLATE_KEY_TARGETThe template context key for the target template.
-
Constructor Summary
Constructors Constructor Description CmsTransformerTemplateProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,CmsTemplateContext>getAllContexts()Gets a map of all template contexts, with the template context names as keys.CmsTransformerTemplateProvider.ConfigurationgetConfiguration()Gets the configuration data that was read from the config file.java.lang.StringgetDefaultLabel(java.util.Locale locale)Customizes the label for the default template context option.java.lang.StringgetEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)Returns the style sheet to be used for the editor.java.util.Set<CmsUUID>getFunctionsForGallery(CmsObject cms, java.lang.String templateContext)Returns a set of structure ids of dynamic functions that are allowed to appear in the gallery dialog search results, or null if the dynamic function results should not be restricted.java.lang.StringgetMenuLabel(java.util.Locale locale)Gets the label to use for the menu entry in the given locale.intgetMenuPosition()Special integer that indicates the position for the template context selection in the context menu.java.lang.StringgetOverrideCookieName()Gets the name of the cookie which should be used for overriding the template context.java.lang.StringgetTemplateCompatibility(java.lang.String currentContext)Gets the template compatibility for the given template context key.CmsTemplateContextgetTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)Determines the template context from the current CMS context, request, and resource.voidinitialize(CmsObject cms, java.lang.String config)Initializes the context provider using a CMS object.booleanisHiddenContext(java.lang.String key)Checks if the template context should be hidden in the GUI.protected CmsTransformerTemplateProvider.ConfigurationloadConfiguration()Helper method for loading the configuration from the VFS.java.lang.StringreadCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue)Gets the value which should be used instead of a property which was read from the template resource.booleanshouldShowContextMenuOption(CmsObject cms)Checks if the context menu option for switching the template should be shown for the given user context.booleanshouldShowElementTemplateContextSelection(CmsObject cms)Controls whether template context select options should be shown in the element settings dialog.
-
-
-
Field Detail
-
COOKIE_PREFIX
public static final java.lang.String COOKIE_PREFIX
The cookie prefix.- See Also:
- Constant Field Values
-
PARAM_CONFIG
public static final java.lang.String PARAM_CONFIG
Parameter for the configuration file in the template provider string.- See Also:
- Constant Field Values
-
TEMPLATE_KEY_SOURCE
public static final java.lang.String TEMPLATE_KEY_SOURCE
The template context key for the source template.- See Also:
- Constant Field Values
-
TEMPLATE_KEY_TARGET
public static final java.lang.String TEMPLATE_KEY_TARGET
The template context key for the target template.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsTransformerTemplateProvider
public CmsTransformerTemplateProvider()
-
-
Method Detail
-
getAllContexts
public java.util.Map<java.lang.String,CmsTemplateContext> getAllContexts()
Description copied from interface:I_CmsTemplateContextProviderGets a map of all template contexts, with the template context names as keys.- Specified by:
getAllContextsin interfaceI_CmsTemplateContextProvider- Returns:
- the map of template context providers
- See Also:
I_CmsTemplateContextProvider.getAllContexts()
-
getConfiguration
public CmsTransformerTemplateProvider.Configuration getConfiguration()
Gets the configuration data that was read from the config file.- Returns:
- the configuration data from the config file
-
getDefaultLabel
public java.lang.String getDefaultLabel(java.util.Locale locale)
Description copied from interface:I_CmsTemplateContextProviderCustomizes the label for the default template context option.If null is returned, the default label for the default template will be used. If null is returned, a default
- Specified by:
getDefaultLabelin interfaceI_CmsTemplateContextProvider- Parameters:
locale- the locale for i18n- Returns:
- the label for the default template context option
- See Also:
I_CmsTemplateContextProvider.getDefaultLabel(java.util.Locale)
-
getEditorStyleSheet
public java.lang.String getEditorStyleSheet(CmsObject cms, java.lang.String editedResourcePath)
Description copied from interface:I_CmsTemplateContextProviderReturns the style sheet to be used for the editor.- Specified by:
getEditorStyleSheetin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the current CMS contexteditedResourcePath- the path of the edited resource- Returns:
- the path of the style sheet to be used for the resource
- See Also:
I_CmsTemplateContextProvider.getEditorStyleSheet(org.opencms.file.CmsObject, java.lang.String)
-
getFunctionsForGallery
public java.util.Set<CmsUUID> getFunctionsForGallery(CmsObject cms, java.lang.String templateContext)
Description copied from interface:I_CmsTemplateContextProviderReturns a set of structure ids of dynamic functions that are allowed to appear in the gallery dialog search results, or null if the dynamic function results should not be restricted.Note: Functions may be excluded from the gallery dialog search results for other reasons even if they appear in the set returned by this method.
- Specified by:
getFunctionsForGalleryin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the current CMS contexttemplateContext- the current template context key- Returns:
- the set of ids of dynamic functions to allow in the gallery search results, or null if function results shouldn't be restricted
- See Also:
I_CmsTemplateContextProvider.getFunctionsForGallery(org.opencms.file.CmsObject, java.lang.String)
-
getMenuLabel
public java.lang.String getMenuLabel(java.util.Locale locale)
Description copied from interface:I_CmsTemplateContextProviderGets the label to use for the menu entry in the given locale.If this returns null, the default menu entry label is used.
- Specified by:
getMenuLabelin interfaceI_CmsTemplateContextProvider- Parameters:
locale- the locale for which we want the menu entry label- Returns:
- the menu entry label
- See Also:
I_CmsTemplateContextProvider.getMenuLabel(java.util.Locale)
-
getMenuPosition
public int getMenuPosition()
Description copied from interface:I_CmsTemplateContextProviderSpecial integer that indicates the position for the template context selection in the context menu.Currently can only return 0 or 1.
- Specified by:
getMenuPositionin interfaceI_CmsTemplateContextProvider- Returns:
- the context menu position
- See Also:
I_CmsTemplateContextProvider.getMenuPosition()
-
getOverrideCookieName
public java.lang.String getOverrideCookieName()
Description copied from interface:I_CmsTemplateContextProviderGets the name of the cookie which should be used for overriding the template context.- Specified by:
getOverrideCookieNamein interfaceI_CmsTemplateContextProvider- Returns:
- the name of the cookie used for overriding the template context
- See Also:
I_CmsTemplateContextProvider.getOverrideCookieName()
-
getTemplateCompatibility
public java.lang.String getTemplateCompatibility(java.lang.String currentContext)
Description copied from interface:I_CmsTemplateContextProviderGets the template compatibility for the given template context key.The template compatibility controls which elements are visible as gallery search results when the template with the given key is active. If the template.compatibility property on a resource is set (possibly inherited from a parent folder), but does not contain the compatibility value returned by this method, it will not show up in gallery search results when the template referenced by templateContextKey is active.
- Specified by:
getTemplateCompatibilityin interfaceI_CmsTemplateContextProvider- Parameters:
currentContext- the key for a template context- Returns:
- a template compatibility string (should not contain whitespace or punctuation)
- See Also:
I_CmsTemplateContextProvider.getTemplateCompatibility(java.lang.String)
-
getTemplateContext
public CmsTemplateContext getTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
Description copied from interface:I_CmsTemplateContextProviderDetermines the template context from the current CMS context, request, and resource.- Specified by:
getTemplateContextin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the CMS contextrequest- the current requestresource- the resource being rendered- Returns:
- the current template context
- See Also:
I_CmsTemplateContextProvider.getTemplateContext(org.opencms.file.CmsObject, javax.servlet.http.HttpServletRequest, org.opencms.file.CmsResource)
-
initialize
public void initialize(CmsObject cms, java.lang.String config)
Description copied from interface:I_CmsTemplateContextProviderInitializes the context provider using a CMS object.Initialization always happens in the Online project.
- Specified by:
initializein interfaceI_CmsTemplateContextProvider- Parameters:
cms- the current CMS contextconfig- the template context provider configuration- See Also:
I_CmsTemplateContextProvider.initialize(org.opencms.file.CmsObject, java.lang.String)
-
isHiddenContext
public boolean isHiddenContext(java.lang.String key)
Description copied from interface:I_CmsTemplateContextProviderChecks if the template context should be hidden in the GUI.- Specified by:
isHiddenContextin interfaceI_CmsTemplateContextProvider- Parameters:
key- the key of a template context- Returns:
- true if the template context should be hidden in the GUI
- See Also:
I_CmsTemplateContextProvider.isHiddenContext(java.lang.String)
-
readCommonProperty
public java.lang.String readCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue)
Description copied from interface:I_CmsTemplateContextProviderGets the value which should be used instead of a property which was read from the template resource.This is needed because before template context providers, it was common to store template-specific configuration in a property on the template JSP. Since template context providers make the result ambiguous, this method is intended as a replacement.
- Specified by:
readCommonPropertyin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the CMS context to usepropertyName- the name of the propertyfallbackValue- the value to return if no value is found or an error occurs- Returns:
- the common property value
- See Also:
I_CmsTemplateContextProvider.readCommonProperty(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
shouldShowContextMenuOption
public boolean shouldShowContextMenuOption(CmsObject cms)
Description copied from interface:I_CmsTemplateContextProviderChecks if the context menu option for switching the template should be shown for the given user context.- Specified by:
shouldShowContextMenuOptionin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the CmsObject to check- Returns:
- true if the context menu option should be visible
- See Also:
I_CmsTemplateContextProvider.shouldShowContextMenuOption(org.opencms.file.CmsObject)
-
shouldShowElementTemplateContextSelection
public boolean shouldShowElementTemplateContextSelection(CmsObject cms)
Description copied from interface:I_CmsTemplateContextProviderControls whether template context select options should be shown in the element settings dialog.- Specified by:
shouldShowElementTemplateContextSelectionin interfaceI_CmsTemplateContextProvider- Parameters:
cms- the CmsObject for the current user- Returns:
- true if the template context select options should be shown in the element settings dialog
- See Also:
I_CmsTemplateContextProvider.shouldShowElementTemplateContextSelection(org.opencms.file.CmsObject)
-
loadConfiguration
protected CmsTransformerTemplateProvider.Configuration loadConfiguration() throws java.lang.Exception
Helper method for loading the configuration from the VFS.- Returns:
- the provider configuration
- Throws:
java.lang.Exception- if something goes wrong
-
-