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 class
CmsTransformerTemplateProvider.Configuration
Contains the configuration data for the provider, usually read from a configuration file.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COOKIE_PREFIX
The cookie prefix.static java.lang.String
PARAM_CONFIG
Parameter for the configuration file in the template provider string.static java.lang.String
TEMPLATE_KEY_SOURCE
The template context key for the source template.static java.lang.String
TEMPLATE_KEY_TARGET
The 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.Configuration
getConfiguration()
Gets the configuration data that was read from the config file.java.lang.String
getDefaultLabel(java.util.Locale locale)
Customizes the label for the default template context option.java.lang.String
getEditorStyleSheet(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.String
getMenuLabel(java.util.Locale locale)
Gets the label to use for the menu entry in the given locale.int
getMenuPosition()
Special integer that indicates the position for the template context selection in the context menu.java.lang.String
getOverrideCookieName()
Gets the name of the cookie which should be used for overriding the template context.java.lang.String
getTemplateCompatibility(java.lang.String currentContext)
Gets the template compatibility for the given template context key.CmsTemplateContext
getTemplateContext(CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
Determines the template context from the current CMS context, request, and resource.void
initialize(CmsObject cms, java.lang.String config)
Initializes the context provider using a CMS object.boolean
isHiddenContext(java.lang.String key)
Checks if the template context should be hidden in the GUI.boolean
isIgnoreTemplateContextsSetting()
Checks if the 'templateContexts' setting should be ignored when rendering container elements (i.e.protected CmsTransformerTemplateProvider.Configuration
loadConfiguration()
Helper method for loading the configuration from the VFS.java.lang.String
readCommonProperty(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.boolean
shouldShowContextMenuOption(CmsObject cms)
Checks if the context menu option for switching the template should be shown for the given user context.boolean
shouldShowElementTemplateContextSelection(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_CmsTemplateContextProvider
Gets a map of all template contexts, with the template context names as keys.- Specified by:
getAllContexts
in 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_CmsTemplateContextProvider
Customizes 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:
getDefaultLabel
in 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_CmsTemplateContextProvider
Returns the style sheet to be used for the editor.- Specified by:
getEditorStyleSheet
in 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_CmsTemplateContextProvider
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.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:
getFunctionsForGallery
in 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_CmsTemplateContextProvider
Gets 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:
getMenuLabel
in 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_CmsTemplateContextProvider
Special integer that indicates the position for the template context selection in the context menu.Currently can only return 0 or 1.
- Specified by:
getMenuPosition
in interfaceI_CmsTemplateContextProvider
- Returns:
- the context menu position
- See Also:
I_CmsTemplateContextProvider.getMenuPosition()
-
getOverrideCookieName
public java.lang.String getOverrideCookieName()
Description copied from interface:I_CmsTemplateContextProvider
Gets the name of the cookie which should be used for overriding the template context.- Specified by:
getOverrideCookieName
in 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_CmsTemplateContextProvider
Gets 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:
getTemplateCompatibility
in 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_CmsTemplateContextProvider
Determines the template context from the current CMS context, request, and resource.- Specified by:
getTemplateContext
in 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_CmsTemplateContextProvider
Initializes the context provider using a CMS object.Initialization always happens in the Online project.
- Specified by:
initialize
in 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_CmsTemplateContextProvider
Checks if the template context should be hidden in the GUI.- Specified by:
isHiddenContext
in 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)
-
isIgnoreTemplateContextsSetting
public boolean isIgnoreTemplateContextsSetting()
Description copied from interface:I_CmsTemplateContextProvider
Checks if the 'templateContexts' setting should be ignored when rendering container elements (i.e. they will be rendered by default, regardless of the setting value).- Specified by:
isIgnoreTemplateContextsSetting
in interfaceI_CmsTemplateContextProvider
- Returns:
- true if the templateContexts setting should be ignored by the cms:container tag
- See Also:
I_CmsTemplateContextProvider.isIgnoreTemplateContextsSetting()
-
readCommonProperty
public java.lang.String readCommonProperty(CmsObject cms, java.lang.String propertyName, java.lang.String fallbackValue)
Description copied from interface:I_CmsTemplateContextProvider
Gets 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:
readCommonProperty
in 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_CmsTemplateContextProvider
Checks if the context menu option for switching the template should be shown for the given user context.- Specified by:
shouldShowContextMenuOption
in 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_CmsTemplateContextProvider
Controls whether template context select options should be shown in the element settings dialog.- Specified by:
shouldShowElementTemplateContextSelection
in 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
-
-