Class CmsTransformerTemplateProvider
- All Implemented Interfaces:
I_CmsTemplateContextProvider
Note: The template provider by itself does not transform anything, the feature is just named like that.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Contains the configuration data for the provider, usually read from a configuration file. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The cookie prefix.static final String
Parameter for the configuration file in the template provider string.static final String
The template context key for the source template.static final String
The template context key for the target template. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets a map of all template contexts, with the template context names as keys.Gets the configuration data that was read from the config file.getDefaultLabel
(Locale locale) Customizes the label for the default template context option.getEditorStyleSheet
(CmsObject cms, String editedResourcePath) Returns the style sheet to be used for the editor.getFunctionsForGallery
(CmsObject cms, 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.getMenuLabel
(Locale locale) Gets the label to use for the menu entry in the given locale.int
Special integer that indicates the position for the template context selection in the context menu.Gets the name of the cookie which should be used for overriding the template context.getTemplateCompatibility
(String currentContext) Gets the template compatibility for the given template context key.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, String config) Initializes the context provider using a CMS object.boolean
isHiddenContext
(String key) Checks if the template context should be hidden in the GUI.boolean
Checks if the 'templateContexts' setting should be ignored when rendering container elements (i.e.Helper method for loading the configuration from the VFS.readCommonProperty
(CmsObject cms, String propertyName, String fallbackValue) Gets the value which should be used instead of a property which was read from the template resource.boolean
Checks if the context menu option for switching the template should be shown for the given user context.boolean
Controls whether template context select options should be shown in the element settings dialog.
-
Field Details
-
COOKIE_PREFIX
The cookie prefix.- See Also:
-
PARAM_CONFIG
Parameter for the configuration file in the template provider string.- See Also:
-
TEMPLATE_KEY_SOURCE
The template context key for the source template.- See Also:
-
TEMPLATE_KEY_TARGET
The template context key for the target template.- See Also:
-
-
Constructor Details
-
CmsTransformerTemplateProvider
public CmsTransformerTemplateProvider()
-
-
Method Details
-
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:
-
getConfiguration
Gets the configuration data that was read from the config file.- Returns:
- the configuration data from the config file
-
getDefaultLabel
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:
-
getEditorStyleSheet
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:
-
getFunctionsForGallery
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:
-
getMenuLabel
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:
-
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:
-
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:
-
getTemplateCompatibility
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:
-
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:
-
initialize
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:
-
isHiddenContext
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:
-
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:
-
readCommonProperty
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:
-
shouldShowContextMenuOption
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:
-
shouldShowElementTemplateContextSelection
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:
-
loadConfiguration
Helper method for loading the configuration from the VFS.- Returns:
- the provider configuration
- Throws:
Exception
- if something goes wrong
-